his_api_controller.go 1.7MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/base64"
  6. //"github.com/jung-kurt/gofpdf"
  7. "encoding/json"
  8. "fmt"
  9. "gdyb/controllers"
  10. "gdyb/enums"
  11. "gdyb/models"
  12. "gdyb/service"
  13. "gdyb/utils"
  14. "github.com/astaxie/beego"
  15. "github.com/axgle/mahonia"
  16. "github.com/go-ole/go-ole/oleutil"
  17. "github.com/gorilla/websocket"
  18. "github.com/jinzhu/gorm"
  19. "github.com/shopspring/decimal"
  20. "io"
  21. "io/ioutil"
  22. "math"
  23. "math/rand"
  24. "net/http"
  25. "net/url"
  26. "os"
  27. "path/filepath"
  28. "regexp"
  29. "strconv"
  30. "strings"
  31. "syscall"
  32. "time"
  33. "unsafe"
  34. "github.com/go-ole/go-ole"
  35. )
  36. type HisApiController struct {
  37. controllers.BaseAuthAPIController
  38. }
  39. func HisManagerApiRegistRouters() {
  40. //挂号
  41. beego.Router("/test/net", &HisApiController{}, "get:TestNet")
  42. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  43. //上传就诊信息-上传明细-结算
  44. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  45. //查询
  46. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  47. //对总账
  48. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  49. //对明细
  50. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  51. //退费,退明细
  52. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  53. //退号
  54. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  55. //退明细
  56. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  57. //上传就诊信息-上传明细-预结算
  58. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  59. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  60. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  61. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  62. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  63. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  64. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  65. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  66. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  67. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  68. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  69. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  70. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  71. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  72. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  73. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  74. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  75. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  76. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  77. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  78. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  79. beego.Router("/api/check", &HisApiController{}, "get:Check")
  80. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  81. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  82. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  83. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  84. beego.Router("/api/3204a", &HisApiController{}, "get:Post3204a")
  85. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  86. beego.Router("/api/8404", &HisApiController{}, "get:Post8404")
  87. beego.Router("/api/3204", &HisApiController{}, "get:Post3204")
  88. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  89. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  90. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  91. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  92. //beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  93. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  94. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  95. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  96. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  97. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  98. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  99. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  100. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  101. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  102. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  103. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  104. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  105. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  106. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  107. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  108. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  109. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  110. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  111. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  112. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  113. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  114. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  115. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  116. beego.Router("/api/CFYLJG012", &HisApiController{}, "get:GetCFYLJG12")
  117. beego.Router("/api/CFYLJG013", &HisApiController{}, "get:GetCFYLJG13")
  118. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  119. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  120. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  121. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  122. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  123. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  124. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  125. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  126. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  127. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  128. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  129. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  130. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  131. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  132. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  133. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  134. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  135. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  136. beego.Router("/api/3103", &HisApiController{}, "get:Get3103")
  137. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  138. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  139. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  140. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  141. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  142. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  143. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  144. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  145. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  146. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  147. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  148. //beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  149. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  150. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  151. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  152. //库盘和变更
  153. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  154. //删除库盘和变更
  155. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  156. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  157. //药品变更
  158. //beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  159. //beego.Router("/api/changedrug/two", &HisApiController{}, "get:ChangeDrugtwo")
  160. //beego.Router("/api/changedrug/three", &HisApiController{}, "get:ChangeDrugthree")
  161. //beego.Router("/api/changedrug/ten", &HisApiController{}, "get:ChangeDrugTen")
  162. beego.Router("/api/3508", &HisApiController{}, "get:Get3508")
  163. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  164. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  165. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  166. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  167. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  168. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  169. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  170. beego.Router("/api/changedrug/four", &HisApiController{}, "get:ChangeDrugfour")
  171. beego.Router("/api/changedrug/five", &HisApiController{}, "get:ChangeDrugFive")
  172. beego.Router("/api/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  173. //beego.Router("/api/delete_xs_bg_three", &HisApiController{}, "get:DeleteXSandBGThree")
  174. beego.Router("/api/3201", &HisApiController{}, "get:Get3201")
  175. beego.Router("/api/5101", &HisApiController{}, "get:Get5101")
  176. beego.Router("/api/5102", &HisApiController{}, "get:Get5102")
  177. }
  178. func (c *HisApiController) Get5101() {
  179. adminUser := c.GetAdminUserInfo()
  180. admin_user_id, _ := c.GetInt64("admin_user_id")
  181. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  182. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  183. if miConfig.MdtrtareaAdmvs == "341203" {
  184. fmt.Println(miConfig.SecretKey)
  185. var res models.Result9001Two
  186. api := miConfig.SecretKey + "ahyb/5101?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  187. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  188. resp, requestErr := http.Get(api)
  189. if requestErr != nil {
  190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  191. return
  192. }
  193. body, ioErr := ioutil.ReadAll(resp.Body)
  194. if ioErr != nil {
  195. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  197. return
  198. }
  199. var respJSON map[string]interface{}
  200. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  201. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  203. return
  204. }
  205. status := respJSON["data"].(map[string]interface{})["status"].(string)
  206. if status == "0" {
  207. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  208. c.ServeSuccessJSON(map[string]interface{}{
  209. "failed_code": -10,
  210. "msg": err_msg,
  211. })
  212. return
  213. }
  214. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  215. result, _ := json.Marshal(respJSON)
  216. fmt.Println("log")
  217. fmt.Println(string(result))
  218. if err := json.Unmarshal([]byte(result), &res); err != nil {
  219. utils.ErrorLog("解析失败:%v", err)
  220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  221. return
  222. }
  223. if res.Infcode == 0 {
  224. sign := models.HisSignIn{
  225. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  226. SignNo: res.Output.Signinoutb.SignNo,
  227. SignTime: "",
  228. Ctime: time.Now().Unix(),
  229. Mtime: time.Now().Unix(),
  230. Status: 1,
  231. InputLog: "",
  232. OutputLog: "",
  233. FixmedinsCode: miConfig.Code,
  234. }
  235. err := service.CreateSignIn(&sign)
  236. if err == nil {
  237. c.ServeSuccessJSON(map[string]interface{}{
  238. "msg": "签到成功",
  239. })
  240. }
  241. } else {
  242. c.ServeSuccessJSON(map[string]interface{}{
  243. "failed_code": -10,
  244. "msg": res.ErrMsg,
  245. })
  246. return
  247. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  248. //return
  249. }
  250. } else if miConfig.MdtrtareaAdmvs == "340699" {
  251. fmt.Println(miConfig.SecretKey)
  252. var res models.Result9001Two
  253. api := miConfig.SecretKey + "ahyb/5101?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  254. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  255. resp, requestErr := http.Get(api)
  256. if requestErr != nil {
  257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  258. return
  259. }
  260. body, ioErr := ioutil.ReadAll(resp.Body)
  261. if ioErr != nil {
  262. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  264. return
  265. }
  266. var respJSON map[string]interface{}
  267. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  270. return
  271. }
  272. status := respJSON["data"].(map[string]interface{})["status"].(string)
  273. if status == "0" {
  274. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  275. c.ServeSuccessJSON(map[string]interface{}{
  276. "failed_code": -10,
  277. "msg": err_msg,
  278. })
  279. return
  280. }
  281. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  282. result, _ := json.Marshal(respJSON)
  283. fmt.Println("log")
  284. fmt.Println(string(result))
  285. if err := json.Unmarshal([]byte(result), &res); err != nil {
  286. utils.ErrorLog("解析失败:%v", err)
  287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  288. return
  289. }
  290. if res.Infcode == 0 {
  291. sign := models.HisSignIn{
  292. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  293. SignNo: res.Output.Signinoutb.SignNo,
  294. SignTime: "",
  295. Ctime: time.Now().Unix(),
  296. Mtime: time.Now().Unix(),
  297. Status: 1,
  298. InputLog: "",
  299. OutputLog: "",
  300. FixmedinsCode: miConfig.Code,
  301. }
  302. err := service.CreateSignIn(&sign)
  303. if err == nil {
  304. c.ServeSuccessJSON(map[string]interface{}{
  305. "msg": "查询成功",
  306. })
  307. }
  308. } else {
  309. c.ServeSuccessJSON(map[string]interface{}{
  310. "failed_code": -10,
  311. "msg": res.ErrMsg,
  312. })
  313. return
  314. }
  315. }
  316. }
  317. func (c *HisApiController) Get5102() {
  318. adminUser := c.GetAdminUserInfo()
  319. admin_user_id, _ := c.GetInt64("admin_user_id")
  320. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  321. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  322. if miConfig.MdtrtareaAdmvs == "341203" {
  323. fmt.Println(miConfig.SecretKey)
  324. var res models.Result9001Two
  325. api := miConfig.SecretKey + "ahyb/5102?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  326. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  327. resp, requestErr := http.Get(api)
  328. if requestErr != nil {
  329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  330. return
  331. }
  332. body, ioErr := ioutil.ReadAll(resp.Body)
  333. if ioErr != nil {
  334. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  336. return
  337. }
  338. var respJSON map[string]interface{}
  339. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  340. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  342. return
  343. }
  344. status := respJSON["data"].(map[string]interface{})["status"].(string)
  345. if status == "0" {
  346. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  347. c.ServeSuccessJSON(map[string]interface{}{
  348. "failed_code": -10,
  349. "msg": err_msg,
  350. })
  351. return
  352. }
  353. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  354. result, _ := json.Marshal(respJSON)
  355. fmt.Println("log")
  356. fmt.Println(string(result))
  357. if err := json.Unmarshal([]byte(result), &res); err != nil {
  358. utils.ErrorLog("解析失败:%v", err)
  359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  360. return
  361. }
  362. if res.Infcode == 0 {
  363. sign := models.HisSignIn{
  364. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  365. SignNo: res.Output.Signinoutb.SignNo,
  366. SignTime: "",
  367. Ctime: time.Now().Unix(),
  368. Mtime: time.Now().Unix(),
  369. Status: 1,
  370. InputLog: "",
  371. OutputLog: "",
  372. FixmedinsCode: miConfig.Code,
  373. }
  374. err := service.CreateSignIn(&sign)
  375. if err == nil {
  376. c.ServeSuccessJSON(map[string]interface{}{
  377. "msg": "签到成功",
  378. })
  379. }
  380. } else {
  381. c.ServeSuccessJSON(map[string]interface{}{
  382. "failed_code": -10,
  383. "msg": res.ErrMsg,
  384. })
  385. return
  386. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  387. //return
  388. }
  389. } else if miConfig.MdtrtareaAdmvs == "340699" {
  390. fmt.Println(miConfig.SecretKey)
  391. var res models.Result9001Two
  392. api := miConfig.SecretKey + "ahyb/5102?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  393. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  394. resp, requestErr := http.Get(api)
  395. if requestErr != nil {
  396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  397. return
  398. }
  399. body, ioErr := ioutil.ReadAll(resp.Body)
  400. if ioErr != nil {
  401. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  403. return
  404. }
  405. var respJSON map[string]interface{}
  406. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  407. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  409. return
  410. }
  411. status := respJSON["data"].(map[string]interface{})["status"].(string)
  412. if status == "0" {
  413. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  414. c.ServeSuccessJSON(map[string]interface{}{
  415. "failed_code": -10,
  416. "msg": err_msg,
  417. })
  418. return
  419. }
  420. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  421. result, _ := json.Marshal(respJSON)
  422. fmt.Println("log")
  423. fmt.Println(string(result))
  424. if err := json.Unmarshal([]byte(result), &res); err != nil {
  425. utils.ErrorLog("解析失败:%v", err)
  426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  427. return
  428. }
  429. if res.Infcode == 0 {
  430. sign := models.HisSignIn{
  431. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  432. SignNo: res.Output.Signinoutb.SignNo,
  433. SignTime: "",
  434. Ctime: time.Now().Unix(),
  435. Mtime: time.Now().Unix(),
  436. Status: 1,
  437. InputLog: "",
  438. OutputLog: "",
  439. FixmedinsCode: miConfig.Code,
  440. }
  441. err := service.CreateSignIn(&sign)
  442. if err == nil {
  443. c.ServeSuccessJSON(map[string]interface{}{
  444. "msg": "查询成功",
  445. })
  446. }
  447. } else {
  448. c.ServeSuccessJSON(map[string]interface{}{
  449. "failed_code": -10,
  450. "msg": res.ErrMsg,
  451. })
  452. return
  453. }
  454. }
  455. }
  456. func (c *HisApiController) Get3201() {
  457. adminUser := c.GetAdminUserInfo()
  458. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  459. result, _ := service.AHyb3201(932, 0, 571536.19, 543283.9, "2024-10-01", "2024-10-31", "340699", "11", "390", miConfig.OrgName, "王幸子", miConfig.Code, "340399", "340399", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey, miConfig.Cainfo)
  460. var response Response
  461. if err := json.Unmarshal([]byte(result), &response); err != nil {
  462. fmt.Println("Error decoding JSON:", err)
  463. return
  464. }
  465. }
  466. func (c *HisApiController) TestNet() {
  467. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  468. //return
  469. c.ServeSuccessJSON(map[string]interface{}{
  470. "msg": "成功",
  471. })
  472. }
  473. func (c *HisApiController) Get3508() {
  474. admin_user_id, _ := c.GetInt64("admin_user_id")
  475. drug_id, _ := c.GetInt64("id")
  476. start_time := c.GetString("start_time")
  477. end_time := c.GetString("end_time")
  478. adminUser := c.GetAdminUserInfo()
  479. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  480. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  481. drug, _ := service.GetDrugByID(drug_id)
  482. var struct3508 models.Struct3508
  483. struct3508.OrgName = miConfig.OrgName
  484. struct3508.FixmedinsCode = miConfig.Code
  485. struct3508.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  486. struct3508.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  487. struct3508.AccessKey = miConfig.AccessKey
  488. struct3508.Opter = curRoles.UserName
  489. struct3508.RequestUrl = miConfig.Url
  490. struct3508.Url = miConfig.Url
  491. struct3508.AppId = miConfig.Cainfo
  492. struct3508.AppSecret = miConfig.AppSecret
  493. struct3508.Enckey = miConfig.EncKey
  494. struct3508.SignKey = miConfig.SignKey
  495. struct3508.SecretKey = miConfig.SecretKey
  496. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  497. struct3508.Begndate = start_time
  498. struct3508.Enddate = end_time
  499. struct3508.Enddate = end_time
  500. struct3508.Enddate = end_time
  501. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  502. result1, result2 := service.Gdyb3508(struct3508, struct3508.SecretKey)
  503. saveLog(result1, result2, "3508", "3508")
  504. var res models.Result3508
  505. var respJSON2 map[string]interface{}
  506. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  507. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  509. return
  510. }
  511. userJSONBytes2, _ := json.Marshal(respJSON2)
  512. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  513. utils.ErrorLog("解析失败:%v", err)
  514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  515. return
  516. }
  517. if res.Infcode == -1 {
  518. c.ServeSuccessJSON(map[string]interface{}{
  519. "failed_code": -10,
  520. "msg": res.ErrMsg,
  521. })
  522. } else {
  523. c.ServeSuccessJSON(map[string]interface{}{
  524. "info": res.Output,
  525. })
  526. }
  527. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  528. result1, result2, _ := service.FJyb3508(struct3508)
  529. saveLog(result1, result2, "3508", "3508")
  530. var res models.Result3508
  531. var respJSON2 map[string]interface{}
  532. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  533. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  535. return
  536. }
  537. userJSONBytes2, _ := json.Marshal(respJSON2)
  538. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  539. utils.ErrorLog("解析失败:%v", err)
  540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  541. return
  542. }
  543. if res.Infcode == -1 {
  544. c.ServeSuccessJSON(map[string]interface{}{
  545. "failed_code": -10,
  546. "msg": res.ErrMsg,
  547. })
  548. } else {
  549. c.ServeSuccessJSON(map[string]interface{}{
  550. "info": res.Output,
  551. })
  552. }
  553. }
  554. }
  555. func (c *HisApiController) Get3509() {
  556. admin_user_id, _ := c.GetInt64("admin_user_id")
  557. drug_id, _ := c.GetInt64("id")
  558. start_time := c.GetString("start_time")
  559. end_time := c.GetString("end_time")
  560. adminUser := c.GetAdminUserInfo()
  561. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  562. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  563. drug, _ := service.GetDrugByID(drug_id)
  564. var struct3508 models.Struct3509
  565. struct3508.OrgName = miConfig.OrgName
  566. struct3508.FixmedinsCode = miConfig.Code
  567. struct3508.AccessKey = miConfig.AccessKey
  568. struct3508.Opter = curRoles.UserName
  569. struct3508.RequestUrl = miConfig.Url
  570. struct3508.Url = miConfig.Url
  571. struct3508.AppId = miConfig.Cainfo
  572. struct3508.AppSecret = miConfig.AppSecret
  573. struct3508.Enckey = miConfig.EncKey
  574. struct3508.SignKey = miConfig.SignKey
  575. struct3508.SecretKey = miConfig.SecretKey
  576. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  577. struct3508.Begndate = start_time
  578. struct3508.Enddate = end_time
  579. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  580. result1, result2 := service.Gdyb3509(struct3508, struct3508.SecretKey)
  581. saveLog(result1, result2, "3509", "3509")
  582. var res models.Result3508
  583. var respJSON2 map[string]interface{}
  584. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  585. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  587. return
  588. }
  589. userJSONBytes2, _ := json.Marshal(respJSON2)
  590. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  591. utils.ErrorLog("解析失败:%v", err)
  592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  593. return
  594. }
  595. if res.Infcode == -1 {
  596. c.ServeSuccessJSON(map[string]interface{}{
  597. "failed_code": -10,
  598. "msg": res.ErrMsg,
  599. })
  600. } else {
  601. c.ServeSuccessJSON(map[string]interface{}{
  602. "info": res.Output,
  603. })
  604. }
  605. } else {
  606. result1, result2, _ := service.FJyb3509(struct3508)
  607. saveLog(result1, result2, "3509", "3509")
  608. var res models.Result3509
  609. var respJSON2 map[string]interface{}
  610. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  611. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  613. return
  614. }
  615. userJSONBytes2, _ := json.Marshal(respJSON2)
  616. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  617. utils.ErrorLog("解析失败:%v", err)
  618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  619. return
  620. }
  621. if res.Infcode == -1 {
  622. c.ServeSuccessJSON(map[string]interface{}{
  623. "failed_code": -10,
  624. "msg": res.ErrMsg,
  625. })
  626. } else {
  627. c.ServeSuccessJSON(map[string]interface{}{
  628. "info": res.Output,
  629. })
  630. }
  631. }
  632. }
  633. func (c *HisApiController) Get3510() {
  634. admin_user_id, _ := c.GetInt64("admin_user_id")
  635. drug_id, _ := c.GetInt64("id")
  636. start_time := c.GetString("start_time")
  637. end_time := c.GetString("end_time")
  638. adminUser := c.GetAdminUserInfo()
  639. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  640. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  641. drug, _ := service.GetDrugByID(drug_id)
  642. var struct3508 models.Struct3510
  643. struct3508.FixmedinsCode = miConfig.Code
  644. struct3508.OrgName = miConfig.OrgName
  645. struct3508.AccessKey = miConfig.AccessKey
  646. struct3508.Opter = curRoles.UserName
  647. struct3508.RequestUrl = miConfig.Url
  648. struct3508.Url = miConfig.Url
  649. struct3508.AppId = miConfig.Cainfo
  650. struct3508.AppSecret = miConfig.AppSecret
  651. struct3508.Enckey = miConfig.EncKey
  652. struct3508.SignKey = miConfig.SignKey
  653. struct3508.SecretKey = miConfig.SecretKey
  654. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  655. struct3508.Begndate = start_time
  656. struct3508.Enddate = end_time
  657. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  658. result1, result2 := service.Gdyb3510(struct3508, struct3508.SecretKey)
  659. saveLog(result1, result2, "3510", "3510")
  660. var res models.Result3510
  661. var respJSON2 map[string]interface{}
  662. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  663. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  665. return
  666. }
  667. userJSONBytes2, _ := json.Marshal(respJSON2)
  668. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  669. utils.ErrorLog("解析失败:%v", err)
  670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  671. return
  672. }
  673. if res.Infcode == -1 {
  674. c.ServeSuccessJSON(map[string]interface{}{
  675. "failed_code": -10,
  676. "msg": res.ErrMsg,
  677. })
  678. } else {
  679. c.ServeSuccessJSON(map[string]interface{}{
  680. "info": res.Output,
  681. })
  682. }
  683. } else {
  684. result1, result2, _ := service.FJyb3510(struct3508)
  685. saveLog(result1, result2, "3510", "3510")
  686. var res models.Result3510
  687. var respJSON2 map[string]interface{}
  688. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  689. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  691. return
  692. }
  693. userJSONBytes2, _ := json.Marshal(respJSON2)
  694. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  695. utils.ErrorLog("解析失败:%v", err)
  696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  697. return
  698. }
  699. if res.Infcode == -1 {
  700. c.ServeSuccessJSON(map[string]interface{}{
  701. "failed_code": -10,
  702. "msg": res.ErrMsg,
  703. })
  704. } else {
  705. c.ServeSuccessJSON(map[string]interface{}{
  706. "info": res.Output,
  707. })
  708. }
  709. }
  710. }
  711. func (c *HisApiController) Get3511() {
  712. admin_user_id, _ := c.GetInt64("admin_user_id")
  713. drug_id, _ := c.GetInt64("id")
  714. start_time := c.GetString("start_time")
  715. end_time := c.GetString("end_time")
  716. adminUser := c.GetAdminUserInfo()
  717. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  718. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  719. drug, _ := service.GetDrugByID(drug_id)
  720. var struct3508 models.Struct3511
  721. struct3508.FixmedinsCode = miConfig.Code
  722. struct3508.OrgName = miConfig.OrgName
  723. struct3508.AccessKey = miConfig.AccessKey
  724. struct3508.Opter = curRoles.UserName
  725. struct3508.RequestUrl = miConfig.Url
  726. struct3508.Url = miConfig.Url
  727. struct3508.AppId = miConfig.Cainfo
  728. struct3508.AppSecret = miConfig.AppSecret
  729. struct3508.Enckey = miConfig.EncKey
  730. struct3508.SignKey = miConfig.SignKey
  731. struct3508.SecretKey = miConfig.SecretKey
  732. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  733. struct3508.Begndate = start_time
  734. struct3508.Enddate = end_time
  735. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  736. result1, result2 := service.Gdyb3511(struct3508, struct3508.SecretKey)
  737. saveLog(result1, result2, "3511", "3511")
  738. var res models.Result3511
  739. var respJSON2 map[string]interface{}
  740. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  741. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  743. return
  744. }
  745. userJSONBytes2, _ := json.Marshal(respJSON2)
  746. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  747. utils.ErrorLog("解析失败:%v", err)
  748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  749. return
  750. }
  751. if res.Infcode == -1 {
  752. c.ServeSuccessJSON(map[string]interface{}{
  753. "failed_code": -10,
  754. "msg": res.ErrMsg,
  755. })
  756. } else {
  757. c.ServeSuccessJSON(map[string]interface{}{
  758. "info": res.Output,
  759. })
  760. }
  761. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  762. var res models.Result3511
  763. //安徽
  764. data := make(map[string]interface{})
  765. data["struct_3511s"] = struct3508
  766. client := &http.Client{}
  767. bytesData, _ := json.Marshal(data)
  768. var req *http.Request
  769. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3511", bytes.NewReader(bytesData))
  770. resp, _ := client.Do(req)
  771. defer resp.Body.Close()
  772. body, ioErr := ioutil.ReadAll(resp.Body)
  773. if ioErr != nil {
  774. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  775. }
  776. var respJSON map[string]interface{}
  777. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  778. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  780. return
  781. }
  782. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  783. result, _ := json.Marshal(respJSON)
  784. if err := json.Unmarshal([]byte(result), &res); err != nil {
  785. //utils.ErrorLog("解析失败:%v", err)
  786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  787. return
  788. }
  789. if res.Infcode == -1 {
  790. c.ServeSuccessJSON(map[string]interface{}{
  791. "failed_code": -10,
  792. "msg": res.ErrMsg,
  793. })
  794. } else {
  795. c.ServeSuccessJSON(map[string]interface{}{
  796. "info": res.Output,
  797. })
  798. }
  799. }else {
  800. result1, result2, _ := service.FJyb3511(struct3508)
  801. saveLog(result1, result2, "3511", "3511")
  802. var res models.Result3511
  803. var respJSON2 map[string]interface{}
  804. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  805. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  807. return
  808. }
  809. userJSONBytes2, _ := json.Marshal(respJSON2)
  810. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  811. utils.ErrorLog("解析失败:%v", err)
  812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  813. return
  814. }
  815. if res.Infcode == -1 {
  816. c.ServeSuccessJSON(map[string]interface{}{
  817. "failed_code": -10,
  818. "msg": res.ErrMsg,
  819. })
  820. } else {
  821. c.ServeSuccessJSON(map[string]interface{}{
  822. "info": res.Output,
  823. })
  824. }
  825. }
  826. }
  827. func (c *HisApiController) Get3512() {
  828. admin_user_id, _ := c.GetInt64("admin_user_id")
  829. drug_id, _ := c.GetInt64("id")
  830. start_time := c.GetString("start_time")
  831. end_time := c.GetString("end_time")
  832. adminUser := c.GetAdminUserInfo()
  833. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  834. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  835. drug, _ := service.GetDrugByIDTwo(drug_id,adminUser.CurrentOrgId)
  836. var infos models.Output2
  837. for _, item := range drug{
  838. var struct3508 models.Struct3512
  839. struct3508.FixmedinsCode = miConfig.Code
  840. struct3508.OrgName = miConfig.OrgName
  841. struct3508.AccessKey = miConfig.AccessKey
  842. struct3508.Opter = curRoles.UserName
  843. struct3508.RequestUrl = miConfig.Url
  844. struct3508.Url = miConfig.Url
  845. struct3508.AppId = miConfig.Cainfo
  846. struct3508.AppSecret = miConfig.AppSecret
  847. struct3508.Enckey = miConfig.EncKey
  848. struct3508.SignKey = miConfig.SignKey
  849. struct3508.SecretKey = miConfig.SecretKey
  850. struct3508.MedListCodg = item.MedicalInsuranceNumber
  851. struct3508.Begndate = start_time
  852. struct3508.Enddate = end_time
  853. struct3508.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  854. struct3508.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  855. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  856. result1, result2 := service.Gdyb3512(struct3508, struct3508.SecretKey)
  857. saveLog(result1, result2, "3512", "3512")
  858. var res models.Result3512
  859. var respJSON2 map[string]interface{}
  860. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  861. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  863. return
  864. }
  865. userJSONBytes2, _ := json.Marshal(respJSON2)
  866. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  867. utils.ErrorLog("解析失败:%v", err)
  868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  869. return
  870. }
  871. for _, item := range res.Output{
  872. if item.ValiFlag == "1"{
  873. infos = append(infos, item)
  874. }
  875. }
  876. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  877. result1, result2, _ := service.FJyb3512(struct3508)
  878. saveLog(result1, result2, "3512", "3512")
  879. var res models.Result3512
  880. var respJSON2 map[string]interface{}
  881. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  882. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  884. return
  885. }
  886. userJSONBytes2, _ := json.Marshal(respJSON2)
  887. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  888. utils.ErrorLog("解析失败:%v", err)
  889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  890. return
  891. }
  892. for _, item := range res.Output{
  893. if item.ValiFlag == "1"{
  894. infos = append(infos, item)
  895. }
  896. }
  897. }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  898. var res models.Result3512
  899. //安徽
  900. data := make(map[string]interface{})
  901. data["struct_3512s"] = struct3508
  902. client := &http.Client{}
  903. bytesData, _ := json.Marshal(data)
  904. var req *http.Request
  905. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3512", bytes.NewReader(bytesData))
  906. resp, _ := client.Do(req)
  907. defer resp.Body.Close()
  908. body, ioErr := ioutil.ReadAll(resp.Body)
  909. if ioErr != nil {
  910. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  911. }
  912. var respJSON map[string]interface{}
  913. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  914. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  916. return
  917. }
  918. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  919. result, _ := json.Marshal(respJSON)
  920. if err := json.Unmarshal([]byte(result), &res); err != nil {
  921. //utils.ErrorLog("解析失败:%v", err)
  922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  923. return
  924. }
  925. for _, item := range res.Output{
  926. if item.ValiFlag == "1"{
  927. infos = append(infos, item)
  928. }
  929. }
  930. }
  931. }
  932. c.ServeSuccessJSON(map[string]interface{}{
  933. "info": infos,
  934. })
  935. }
  936. func (c *HisApiController) Get3513() {
  937. admin_user_id, _ := c.GetInt64("admin_user_id")
  938. drug_id, _ := c.GetInt64("id")
  939. start_time := c.GetString("start_time")
  940. end_time := c.GetString("end_time")
  941. adminUser := c.GetAdminUserInfo()
  942. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  943. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  944. //drug, _ := service.GetDrugByID(drug_id)
  945. drug, _ := service.GetDrugByIDTwo(drug_id,adminUser.CurrentOrgId)
  946. var infos models.Output3
  947. for _, item := range drug {
  948. var struct3508 models.Struct3513
  949. struct3508.FixmedinsCode = miConfig.Code
  950. struct3508.OrgName = miConfig.OrgName
  951. struct3508.AccessKey = miConfig.AccessKey
  952. struct3508.Opter = curRoles.UserName
  953. struct3508.RequestUrl = miConfig.Url
  954. struct3508.Url = miConfig.Url
  955. struct3508.AppId = miConfig.Cainfo
  956. struct3508.AppSecret = miConfig.AppSecret
  957. struct3508.Enckey = miConfig.EncKey
  958. struct3508.SignKey = miConfig.SignKey
  959. struct3508.SecretKey = miConfig.SecretKey
  960. struct3508.MedListCodg = item.MedicalInsuranceNumber
  961. struct3508.Begndate = start_time
  962. struct3508.Enddate = end_time
  963. struct3508.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  964. struct3508.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  965. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  966. result1, result2 := service.Gdyb3513(struct3508, struct3508.SecretKey)
  967. saveLog(result1, result2, "3513", "3513")
  968. var res models.Result3513
  969. var respJSON2 map[string]interface{}
  970. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  971. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  973. return
  974. }
  975. userJSONBytes2, _ := json.Marshal(respJSON2)
  976. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  977. utils.ErrorLog("解析失败:%v", err)
  978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  979. return
  980. }
  981. infos = append(infos, res.Output...)
  982. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  983. result1, result2, _ := service.FJyb3513(struct3508)
  984. saveLog(result1, result2, "3513", "3513")
  985. var res models.Result3513
  986. var respJSON2 map[string]interface{}
  987. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  988. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  990. return
  991. }
  992. userJSONBytes2, _ := json.Marshal(respJSON2)
  993. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  994. utils.ErrorLog("解析失败:%v", err)
  995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  996. return
  997. }
  998. infos = append(infos, res.Output...)
  999. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  1000. var res models.Result3513
  1001. //安徽
  1002. data := make(map[string]interface{})
  1003. data["struct_3513s"] = struct3508
  1004. client := &http.Client{}
  1005. bytesData, _ := json.Marshal(data)
  1006. var req *http.Request
  1007. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3513", bytes.NewReader(bytesData))
  1008. resp, _ := client.Do(req)
  1009. defer resp.Body.Close()
  1010. body, ioErr := ioutil.ReadAll(resp.Body)
  1011. if ioErr != nil {
  1012. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1013. }
  1014. var respJSON map[string]interface{}
  1015. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1016. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1018. return
  1019. }
  1020. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1021. result, _ := json.Marshal(respJSON)
  1022. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1023. //utils.ErrorLog("解析失败:%v", err)
  1024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1025. return
  1026. }
  1027. infos = append(infos, res.Output...)
  1028. }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") { //
  1029. result1, result2 := service.JXyb3513(struct3508, struct3508.SecretKey, struct3508.AccessKey, struct3508.RequestUrl)
  1030. saveLog(result1, result2, "3513", "3513")
  1031. var res models.Result3513
  1032. var respJSON2 map[string]interface{}
  1033. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1034. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1036. return
  1037. }
  1038. userJSONBytes2, _ := json.Marshal(respJSON2)
  1039. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1040. utils.ErrorLog("解析失败:%v", err)
  1041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1042. return
  1043. }
  1044. infos = append(infos, res.Output...)
  1045. }
  1046. }
  1047. type Newinfo struct {
  1048. FixmedinsCode string
  1049. MedListCodg string
  1050. MedinsListCodg string
  1051. MedinsListName string
  1052. FixmedinsBchno string
  1053. MdtrtId string
  1054. MdtrtSetlType string
  1055. BkkpSn string
  1056. DrugTracCodg string
  1057. PsnNo string
  1058. PsnCertType string
  1059. Certno string
  1060. PsnName string
  1061. Memo string
  1062. TrdnFlag string
  1063. UpdtTime string
  1064. OpterName string
  1065. Rid string
  1066. CrteTime string
  1067. OptTime string
  1068. OpterId string
  1069. CrterName string
  1070. CrterId string
  1071. OptinsNo string
  1072. }
  1073. var Newinfos []Newinfo
  1074. for _, item := range infos {
  1075. var ni Newinfo
  1076. patient, _ := service.GetPatientByIDCard(item.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1077. //patient, _ := service.GetPatientByIDCard(item.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1078. numbers := strings.Split(item.FixmedinsBchno,"-")
  1079. flow := service.GetSaleDate(numbers[1])
  1080. ni.MdtrtId = item.MdtrtId
  1081. ni.UpdtTime = flow.SaleDate
  1082. ni.PsnName = patient.Name
  1083. ni.Certno = item.Certno
  1084. ni.MedinsListName = item.MedinsListName
  1085. ni.FixmedinsBchno = item.FixmedinsBchno
  1086. ni.DrugTracCodg = item.DrugTracCodg
  1087. ni.MedListCodg = patient.Name
  1088. Newinfos = append(Newinfos, ni)
  1089. }
  1090. c.ServeSuccessJSON(map[string]interface{}{
  1091. "info": Newinfos,
  1092. })
  1093. }
  1094. func (c *HisApiController) Get35081() {
  1095. admin_user_id, _ := c.GetInt64("admin_user_id")
  1096. drug_id, _ := c.GetInt64("id")
  1097. //start_time := c.GetString("start_time")
  1098. //end_time := c.GetString("end_time")
  1099. page, _ := c.GetInt("page")
  1100. adminUser := c.GetAdminUserInfo()
  1101. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1102. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1103. drug, _ := service.GetDrugByID(drug_id)
  1104. var struct3508 models.Struct35081
  1105. struct3508.FixmedinsCode = miConfig.Code
  1106. struct3508.OrgName = miConfig.OrgName
  1107. struct3508.AccessKey = miConfig.AccessKey
  1108. struct3508.Opter = curRoles.UserName
  1109. struct3508.RequestUrl = miConfig.Url
  1110. struct3508.Url = miConfig.Url
  1111. struct3508.AppId = miConfig.Cainfo
  1112. struct3508.AppSecret = miConfig.AppSecret
  1113. struct3508.Enckey = miConfig.EncKey
  1114. struct3508.SignKey = miConfig.SignKey
  1115. struct3508.SecretKey = miConfig.SecretKey
  1116. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  1117. struct3508.PageNum = page
  1118. struct3508.PageSize = 10
  1119. result1, result2, _ := service.FJyb35081(struct3508)
  1120. saveLog(result1, result2, "35081", "35081")
  1121. var res models.Result35081
  1122. var respJSON2 map[string]interface{}
  1123. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1124. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1126. return
  1127. }
  1128. userJSONBytes2, _ := json.Marshal(respJSON2)
  1129. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1130. utils.ErrorLog("解析失败:%v", err)
  1131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1132. return
  1133. }
  1134. if res.Infcode == -1 {
  1135. c.ServeSuccessJSON(map[string]interface{}{
  1136. "failed_code": -10,
  1137. "msg": res.ErrMsg,
  1138. })
  1139. } else {
  1140. c.ServeSuccessJSON(map[string]interface{}{
  1141. "info": res.Output,
  1142. })
  1143. }
  1144. }
  1145. func (c *HisApiController) Get35082() {
  1146. admin_user_id, _ := c.GetInt64("admin_user_id")
  1147. drug_id, _ := c.GetInt64("id")
  1148. //start_time := c.GetString("start_time")
  1149. //end_time := c.GetString("end_time")
  1150. page, _ := c.GetInt("page")
  1151. adminUser := c.GetAdminUserInfo()
  1152. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1153. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1154. drug, _ := service.GetDrugByID(drug_id)
  1155. var struct3508 models.Struct35082
  1156. struct3508.FixmedinsCode = miConfig.Code
  1157. struct3508.OrgName = miConfig.OrgName
  1158. struct3508.AccessKey = miConfig.AccessKey
  1159. struct3508.Opter = curRoles.UserName
  1160. struct3508.RequestUrl = miConfig.Url
  1161. struct3508.Url = miConfig.Url
  1162. struct3508.AppId = miConfig.Cainfo
  1163. struct3508.AppSecret = miConfig.AppSecret
  1164. struct3508.Enckey = miConfig.EncKey
  1165. struct3508.SignKey = miConfig.SignKey
  1166. struct3508.SecretKey = miConfig.SecretKey
  1167. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  1168. struct3508.PageNum = page
  1169. struct3508.PageSize = 10
  1170. result1, result2, _ := service.FJyb35082(struct3508)
  1171. saveLog(result1, result2, "35082", "35082")
  1172. var res models.Result35082
  1173. var respJSON2 map[string]interface{}
  1174. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1175. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1177. return
  1178. }
  1179. userJSONBytes2, _ := json.Marshal(respJSON2)
  1180. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1181. utils.ErrorLog("解析失败:%v", err)
  1182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1183. return
  1184. }
  1185. if res.Infcode == -1 {
  1186. c.ServeSuccessJSON(map[string]interface{}{
  1187. "failed_code": -10,
  1188. "msg": res.ErrMsg,
  1189. })
  1190. } else {
  1191. c.ServeSuccessJSON(map[string]interface{}{
  1192. "info": res.Output,
  1193. })
  1194. }
  1195. }
  1196. func IsDigit(s string) bool {
  1197. re := regexp.MustCompile("^[0-9]+$")
  1198. return re.MatchString(s)
  1199. }
  1200. func (c *HisApiController) FJ3501AND3502() {
  1201. ids := c.GetString("ids")
  1202. admin_user_id, _ := c.GetInt64("admin_user_id")
  1203. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1204. id_arr := strings.Split(ids, ",")
  1205. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1206. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1207. //规则判断
  1208. var errs []string
  1209. for _, drug := range drugs {
  1210. if drug.IsPc == 0 {
  1211. if len(drug.DrugCode) > 0 {
  1212. codes := strings.Split(drug.DrugCode, ",")
  1213. for _, code := range codes {
  1214. if len(code) > 0 {
  1215. if len(code) != 20 {
  1216. errs = append(errs, drug.BaseDrugLib.DrugName+" 溯源码"+code+"位数不是20位")
  1217. }
  1218. if IsDigit(code) == false {
  1219. errs = append(errs, drug.BaseDrugLib.DrugName+" 溯源码"+code+"不是纯数字")
  1220. }
  1221. }
  1222. }
  1223. }
  1224. }
  1225. }
  1226. if len(errs) > 0 {
  1227. c.ServeSuccessJSON(map[string]interface{}{
  1228. "failed_code": -10,
  1229. "msg": errs,
  1230. })
  1231. return
  1232. }
  1233. //库盘
  1234. for _, drug := range drugs {
  1235. if drug.IsPc == 0 {
  1236. var res2 ResultSix
  1237. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  1238. var struct3501 models.Struct3501
  1239. struct3501.Code = miConfig.Code
  1240. struct3501.OrgName = miConfig.OrgName
  1241. struct3501.AccessKey = miConfig.AccessKey
  1242. struct3501.Opter = roles.UserName
  1243. struct3501.RequestUrl = miConfig.Url
  1244. struct3501.Url = miConfig.Url
  1245. struct3501.AppId = miConfig.Cainfo
  1246. struct3501.AppSecret = miConfig.AppSecret
  1247. struct3501.Enckey = miConfig.EncKey
  1248. struct3501.SignKey = miConfig.SignKey
  1249. struct3501.SecretKey = miConfig.SecretKey
  1250. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  1251. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  1252. struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  1253. struct3501.RxFlag = "1"
  1254. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  1255. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  1256. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1257. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1258. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  1259. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  1260. struct3501.FixmedinsBchno = number
  1261. struct3501.DrugTracCodg = drug.DrugCode
  1262. memo := make(map[string]interface{})
  1263. memo["pric"] = drug.Price
  1264. bytesData, _ := json.Marshal(memo)
  1265. struct3501.Memo = string(bytesData)
  1266. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  1267. result1, result2, _ := service.FJyb3501(struct3501)
  1268. saveLog(result1, result2, "3501", "3501")
  1269. //saveLog(result, requestLog, "2201", "挂号")
  1270. var respJSON2 map[string]interface{}
  1271. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1272. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1274. return
  1275. }
  1276. userJSONBytes2, _ := json.Marshal(respJSON2)
  1277. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1278. utils.ErrorLog("解析失败:%v", err)
  1279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1280. return
  1281. }
  1282. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  1283. data := make(map[string]interface{})
  1284. data["struct_3501s"] = struct3501
  1285. client := &http.Client{}
  1286. bytesData, _ := json.Marshal(data)
  1287. var req *http.Request
  1288. if miConfig.MdtrtareaAdmvs == "320830" {
  1289. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3501", bytes.NewReader(bytesData))
  1290. } else {
  1291. if miConfig.MdtrtareaAdmvs == "320921" {
  1292. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  1293. } else {
  1294. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  1295. }
  1296. }
  1297. resp, _ := client.Do(req)
  1298. defer resp.Body.Close()
  1299. body, ioErr := ioutil.ReadAll(resp.Body)
  1300. if ioErr != nil {
  1301. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1302. }
  1303. var respJSON map[string]interface{}
  1304. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1305. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1307. return
  1308. }
  1309. var resSix10265 ResultSix10265 //1101结果
  1310. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1311. result, _ := json.Marshal(respJSON)
  1312. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1313. utils.ErrorLog("解析失败:%v", err)
  1314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1315. return
  1316. }
  1317. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1318. res2.Output = resSix10265.Output
  1319. res2.ErrMsg = resSix10265.ErrMsg
  1320. res2.Cainfo = resSix10265.Cainfo
  1321. res2.WarnMsg = resSix10265.WarnMsg
  1322. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1323. res2.Infcode = infocode
  1324. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  1325. data := make(map[string]interface{})
  1326. data["struct_3501s"] = struct3501
  1327. client := &http.Client{}
  1328. bytesData, _ := json.Marshal(data)
  1329. var req *http.Request
  1330. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  1331. resp, _ := client.Do(req)
  1332. defer resp.Body.Close()
  1333. body, ioErr := ioutil.ReadAll(resp.Body)
  1334. if ioErr != nil {
  1335. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1336. }
  1337. var respJSON map[string]interface{}
  1338. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1339. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1341. return
  1342. }
  1343. var resSix10265 ResultSix10265 //1101结果
  1344. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1345. result, _ := json.Marshal(respJSON)
  1346. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1347. utils.ErrorLog("解析失败:%v", err)
  1348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1349. return
  1350. }
  1351. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1352. res2.Output = resSix10265.Output
  1353. res2.ErrMsg = resSix10265.ErrMsg
  1354. res2.Cainfo = resSix10265.Cainfo
  1355. res2.WarnMsg = resSix10265.WarnMsg
  1356. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1357. res2.Infcode = infocode
  1358. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  1359. data := make(map[string]interface{})
  1360. data["struct_3501s"] = struct3501
  1361. client := &http.Client{}
  1362. bytesData, _ := json.Marshal(data)
  1363. var req *http.Request
  1364. req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  1365. resp, _ := client.Do(req)
  1366. defer resp.Body.Close()
  1367. body, ioErr := ioutil.ReadAll(resp.Body)
  1368. if ioErr != nil {
  1369. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1370. }
  1371. var respJSON map[string]interface{}
  1372. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1373. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1375. return
  1376. }
  1377. var resSix10265 ResultSix10265 //1101结果
  1378. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1379. result, _ := json.Marshal(respJSON)
  1380. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1381. utils.ErrorLog("解析失败:%v", err)
  1382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1383. return
  1384. }
  1385. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1386. res2.Output = resSix10265.Output
  1387. res2.ErrMsg = resSix10265.ErrMsg
  1388. res2.Cainfo = resSix10265.Cainfo
  1389. res2.WarnMsg = resSix10265.WarnMsg
  1390. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1391. res2.Infcode = infocode
  1392. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  1393. result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  1394. saveLog(result1, result2, "3501", "3501")
  1395. //saveLog(result, requestLog, "2201", "挂号")
  1396. var respJSON2 map[string]interface{}
  1397. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1398. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1400. return
  1401. }
  1402. userJSONBytes2, _ := json.Marshal(respJSON2)
  1403. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1404. utils.ErrorLog("解析失败:%v", err)
  1405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1406. return
  1407. }
  1408. }
  1409. utils.ErrorLog("解析失败:%v", res2.Infcode)
  1410. if res2.Infcode != -1 {
  1411. drug.IsPc = 1
  1412. drug.Bchno = number
  1413. drug.PcDate = time.Now().Unix()
  1414. service.SaveW(drug)
  1415. //if err == nil {
  1416. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  1417. // var struct3502 models.Struct3502
  1418. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  1419. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  1420. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  1421. // struct3502.FixmedinsCode = miConfig.Code
  1422. // struct3502.Code = miConfig.Code
  1423. //
  1424. // struct3502.RxFlag = "0"
  1425. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  1426. // struct3502.OrgName = miConfig.OrgName
  1427. // struct3502.Opter = roles.UserName
  1428. // struct3502.AccessKey = miConfig.AccessKey
  1429. // struct3502.RequestUrl = miConfig.Url
  1430. // struct3502.SecretKey = miConfig.SecretKey
  1431. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1432. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1433. // struct3502.Url = miConfig.Url
  1434. // struct3502.AppId = miConfig.Cainfo
  1435. // struct3502.AppSecret = miConfig.AppSecret
  1436. // struct3502.Enckey = miConfig.EncKey
  1437. // struct3502.SignKey = miConfig.SignKey
  1438. // struct3502.SecretKey = miConfig.SecretKey
  1439. // struct3502.DrugTracCodg = drug.DrugCode
  1440. //
  1441. // struct3502.Memo = ""
  1442. // struct3502.InvChgType = "108"
  1443. // struct3502.FixmedinsBchno = bg_number
  1444. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  1445. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  1446. //
  1447. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  1448. // result11, result22, _ := service.FJyb3502(struct3502)
  1449. // saveLog(result11, result22, "3502", "3502")
  1450. //
  1451. // var respJSON3 map[string]interface{}
  1452. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1453. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1454. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1455. // return
  1456. // }
  1457. // userJSONBytes3, _ := json.Marshal(respJSON3)
  1458. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1459. // utils.ErrorLog("解析失败:%v", err)
  1460. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1461. // return
  1462. // }
  1463. //
  1464. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  1465. // data := make(map[string]interface{})
  1466. // data["struct_3502s"] = struct3502
  1467. // client := &http.Client{}
  1468. // bytesData, _ := json.Marshal(data)
  1469. // var req *http.Request
  1470. // if miConfig.MdtrtareaAdmvs == "320830" {
  1471. // req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3502", bytes.NewReader(bytesData))
  1472. // } else if miConfig.MdtrtareaAdmvs == "320921" {
  1473. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1474. // } else {
  1475. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1476. // }
  1477. //
  1478. // resp, _ := client.Do(req)
  1479. // defer resp.Body.Close()
  1480. // body, ioErr := ioutil.ReadAll(resp.Body)
  1481. // if ioErr != nil {
  1482. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1483. // }
  1484. // var respJSON map[string]interface{}
  1485. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1486. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1487. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1488. // return
  1489. // }
  1490. // var resSix10265 ResultSix10265 //1101结果
  1491. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1492. // result, _ := json.Marshal(respJSON)
  1493. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1494. // utils.ErrorLog("解析失败:%v", err)
  1495. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1496. // return
  1497. // }
  1498. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  1499. // res3.Output = resSix10265.Output
  1500. // res3.ErrMsg = resSix10265.ErrMsg
  1501. // res3.Cainfo = resSix10265.Cainfo
  1502. // res3.WarnMsg = resSix10265.WarnMsg
  1503. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1504. // res3.Infcode = infocode
  1505. //
  1506. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  1507. //
  1508. // data := make(map[string]interface{})
  1509. // data["struct_3502s"] = struct3502
  1510. // client := &http.Client{}
  1511. // bytesData, _ := json.Marshal(data)
  1512. // var req *http.Request
  1513. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  1514. // resp, _ := client.Do(req)
  1515. // defer resp.Body.Close()
  1516. // body, ioErr := ioutil.ReadAll(resp.Body)
  1517. // if ioErr != nil {
  1518. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1519. // }
  1520. // var respJSON map[string]interface{}
  1521. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1522. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1523. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1524. // return
  1525. // }
  1526. // var resSix10265 ResultSix10265 //1101结果
  1527. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1528. // result, _ := json.Marshal(respJSON)
  1529. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1530. // utils.ErrorLog("解析失败:%v", err)
  1531. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1532. // return
  1533. // }
  1534. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  1535. // res3.Output = resSix10265.Output
  1536. // res3.ErrMsg = resSix10265.ErrMsg
  1537. // res3.Cainfo = resSix10265.Cainfo
  1538. // res3.WarnMsg = resSix10265.WarnMsg
  1539. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1540. // res3.Infcode = infocode
  1541. //
  1542. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  1543. //
  1544. // data := make(map[string]interface{})
  1545. // data["struct_3501s"] = struct3501
  1546. // client := &http.Client{}
  1547. // bytesData, _ := json.Marshal(data)
  1548. // var req *http.Request
  1549. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  1550. // resp, _ := client.Do(req)
  1551. // defer resp.Body.Close()
  1552. // body, ioErr := ioutil.ReadAll(resp.Body)
  1553. // if ioErr != nil {
  1554. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1555. // }
  1556. // var respJSON map[string]interface{}
  1557. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1558. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1559. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1560. // return
  1561. // }
  1562. // var resSix10265 ResultSix10265 //1101结果
  1563. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1564. // result, _ := json.Marshal(respJSON)
  1565. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1566. // utils.ErrorLog("解析失败:%v", err)
  1567. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1568. // return
  1569. // }
  1570. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  1571. // res2.Output = resSix10265.Output
  1572. // res2.ErrMsg = resSix10265.ErrMsg
  1573. // res2.Cainfo = resSix10265.Cainfo
  1574. // res2.WarnMsg = resSix10265.WarnMsg
  1575. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1576. // res2.Infcode = infocode
  1577. //
  1578. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  1579. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  1580. // saveLog(result11, result22, "3502", "3502")
  1581. //
  1582. // var respJSON3 map[string]interface{}
  1583. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1584. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1585. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1586. // return
  1587. // }
  1588. // userJSONBytes3, _ := json.Marshal(respJSON3)
  1589. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1590. // utils.ErrorLog("解析失败:%v", err)
  1591. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1592. // return
  1593. // }
  1594. // }
  1595. // if res3.Infcode == -1 {
  1596. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  1597. // c.ServeSuccessJSON(map[string]interface{}{
  1598. // "failed_code": -10,
  1599. // "msg": res3.ErrMsg,
  1600. // })
  1601. // } else {
  1602. // drug.IsBg = 1
  1603. // drug.BgBchno = bg_number
  1604. // service.SaveW(drug)
  1605. // }
  1606. //}
  1607. //} else {
  1608. } else {
  1609. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  1610. }
  1611. }
  1612. //变更
  1613. }
  1614. if len(errs) == 0 {
  1615. c.ServeSuccessJSON(map[string]interface{}{
  1616. "msg": "盘存变更成功",
  1617. })
  1618. } else {
  1619. c.ServeSuccessJSON(map[string]interface{}{
  1620. "failed_code": -10,
  1621. "msg": errs,
  1622. })
  1623. }
  1624. }
  1625. func (c *HisApiController) DeletePCandBG() {
  1626. ids := c.GetString("ids")
  1627. id_arr := strings.Split(ids, ",")
  1628. admin_user_id, _ := c.GetInt64("admin_user_id")
  1629. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1630. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1631. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1632. var err []string
  1633. for _, item := range drugs {
  1634. if item.IsPc == 1 {
  1635. var res FJ3507Result
  1636. var struct3507 models.Struct3507
  1637. struct3507.FixmedinsBchno = item.Bchno
  1638. struct3507.InvDataType = "1"
  1639. struct3507.Opter = roles.UserName
  1640. struct3507.OrgName = miConfig.OrgName
  1641. struct3507.AccessKey = miConfig.AccessKey
  1642. struct3507.RequestUrl = miConfig.Url
  1643. struct3507.FixmedinsCode = miConfig.Code
  1644. struct3507.Code = miConfig.Code
  1645. struct3507.SecretKey = miConfig.SecretKey
  1646. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1647. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1648. struct3507.Url = miConfig.Url
  1649. struct3507.AppId = miConfig.Cainfo
  1650. struct3507.AppSecret = miConfig.AppSecret
  1651. struct3507.Enckey = miConfig.EncKey
  1652. struct3507.SignKey = miConfig.SignKey
  1653. struct3507.SecretKey = miConfig.SecretKey
  1654. if miConfig.MdtrtareaAdmvs == "350500" {
  1655. result, result1, _ := service.FJyb3507(struct3507)
  1656. saveLog(result, result1, "3507", "3507")
  1657. var respJSON2 map[string]interface{}
  1658. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1659. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1661. return
  1662. }
  1663. userJSONBytes2, _ := json.Marshal(respJSON2)
  1664. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1665. utils.ErrorLog("解析失败:%v", err)
  1666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1667. return
  1668. }
  1669. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  1670. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  1671. saveLog(result2, result1, "3507", "3507")
  1672. var respJSON2 map[string]interface{}
  1673. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1674. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1676. return
  1677. }
  1678. userJSONBytes2, _ := json.Marshal(respJSON2)
  1679. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1680. utils.ErrorLog("解析失败:%v", err)
  1681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1682. return
  1683. }
  1684. } else {
  1685. data := make(map[string]interface{})
  1686. data["struct_3507s"] = struct3507
  1687. client := &http.Client{}
  1688. bytesData, _ := json.Marshal(data)
  1689. var req *http.Request
  1690. if miConfig.MdtrtareaAdmvs == "320830" {
  1691. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1692. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1693. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1694. } else {
  1695. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1696. }
  1697. resp, _ := client.Do(req)
  1698. defer resp.Body.Close()
  1699. body, ioErr := ioutil.ReadAll(resp.Body)
  1700. if ioErr != nil {
  1701. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1702. }
  1703. var respJSON map[string]interface{}
  1704. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1705. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1707. return
  1708. }
  1709. var resSix10265 ResultSix10265 //1101结果
  1710. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1711. result, _ := json.Marshal(respJSON)
  1712. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1713. utils.ErrorLog("解析失败:%v", err)
  1714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1715. return
  1716. }
  1717. res.InfRefmsgid = resSix10265.InfRefmsgid
  1718. //res.Output = resSix10265.Output
  1719. res.ErrMsg = resSix10265.ErrMsg
  1720. res.Cainfo = resSix10265.Cainfo
  1721. res.WarnMsg = resSix10265.WarnMsg
  1722. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1723. res.Infcode = infocode
  1724. }
  1725. if res.Infcode == 0 {
  1726. item.IsPc = 0
  1727. service.SaveW(item)
  1728. } else {
  1729. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1730. }
  1731. }
  1732. }
  1733. if len(err) == 0 {
  1734. c.ServeSuccessJSON(map[string]interface{}{
  1735. "msg": "删除盘存变更成功",
  1736. })
  1737. } else {
  1738. c.ServeSuccessJSON(map[string]interface{}{
  1739. "failed_code": -10,
  1740. "msg": err,
  1741. })
  1742. }
  1743. }
  1744. func (c *HisApiController) DeleteXSandBG() {
  1745. ids := c.GetString("ids")
  1746. id_arr := strings.Split(ids, ",")
  1747. admin_user_id, _ := c.GetInt64("admin_user_id")
  1748. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1749. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1750. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1751. var err []string
  1752. for _, item := range flows {
  1753. if item.IsSale == 1 && item.IsChange == 1 {
  1754. var res FJ3507Result
  1755. var res2 FJ3507Result
  1756. var struct3507 models.Struct3507
  1757. struct3507.FixmedinsBchno = item.Bchno
  1758. struct3507.InvDataType = "4"
  1759. struct3507.Opter = roles.UserName
  1760. struct3507.OrgName = miConfig.OrgName
  1761. struct3507.AccessKey = miConfig.AccessKey
  1762. struct3507.RequestUrl = miConfig.Url
  1763. struct3507.FixmedinsCode = miConfig.Code
  1764. struct3507.SecretKey = miConfig.SecretKey
  1765. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1766. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1767. struct3507.Url = miConfig.Url
  1768. struct3507.AppId = miConfig.Cainfo
  1769. struct3507.AppSecret = miConfig.AppSecret
  1770. struct3507.Enckey = miConfig.EncKey
  1771. struct3507.SignKey = miConfig.SignKey
  1772. struct3507.SecretKey = miConfig.SecretKey
  1773. //result, result1, _ := service.FJyb3507(struct3507)
  1774. //saveLog(result, result1, "3507", "3507")
  1775. if miConfig.MdtrtareaAdmvs == "350500" {
  1776. result, result1, _ := service.FJyb3507(struct3507)
  1777. saveLog(result, result1, "3507", "3507")
  1778. var respJSON2 map[string]interface{}
  1779. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1780. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1782. return
  1783. }
  1784. userJSONBytes2, _ := json.Marshal(respJSON2)
  1785. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1786. utils.ErrorLog("解析失败:%v", err)
  1787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1788. return
  1789. }
  1790. } else {
  1791. data := make(map[string]interface{})
  1792. data["struct_3507s"] = struct3507
  1793. client := &http.Client{}
  1794. bytesData, _ := json.Marshal(data)
  1795. var req *http.Request
  1796. if miConfig.MdtrtareaAdmvs == "320830" {
  1797. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1798. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1799. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1800. } else {
  1801. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1802. }
  1803. resp, _ := client.Do(req)
  1804. defer resp.Body.Close()
  1805. body, ioErr := ioutil.ReadAll(resp.Body)
  1806. if ioErr != nil {
  1807. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1808. }
  1809. var respJSON map[string]interface{}
  1810. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1811. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1813. return
  1814. }
  1815. var resSix10265 ResultSix10265 //1101结果
  1816. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1817. result, _ := json.Marshal(respJSON)
  1818. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1819. utils.ErrorLog("解析失败:%v", err)
  1820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1821. return
  1822. }
  1823. res.InfRefmsgid = resSix10265.InfRefmsgid
  1824. //res.Output = resSix10265.Output
  1825. res.ErrMsg = resSix10265.ErrMsg
  1826. res.Cainfo = resSix10265.Cainfo
  1827. res.WarnMsg = resSix10265.WarnMsg
  1828. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1829. res.Infcode = infocode
  1830. }
  1831. if res.Infcode == 0 {
  1832. item.IsSale = 0
  1833. item.SaleDate = ""
  1834. item.Bchno = ""
  1835. err2 := service.SaveDF(item)
  1836. if err2 == nil {
  1837. var struct3507_2 models.Struct3507
  1838. struct3507_2.OrgName = miConfig.OrgName
  1839. struct3507_2.AccessKey = miConfig.AccessKey
  1840. struct3507_2.RequestUrl = miConfig.Url
  1841. struct3507_2.Opter = roles.UserName
  1842. struct3507_2.FixmedinsCode = miConfig.Code
  1843. struct3507_2.Code = miConfig.Code
  1844. struct3507_2.SecretKey = miConfig.SecretKey
  1845. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1846. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1847. struct3507_2.Url = miConfig.Url
  1848. struct3507_2.AppId = miConfig.Cainfo
  1849. struct3507_2.AppSecret = miConfig.AppSecret
  1850. struct3507_2.Enckey = miConfig.EncKey
  1851. struct3507_2.SignKey = miConfig.SignKey
  1852. struct3507_2.SecretKey = miConfig.SecretKey
  1853. struct3507_2.FixmedinsBchno = item.BgBchno
  1854. struct3507_2.InvDataType = "2"
  1855. if miConfig.MdtrtareaAdmvs == "350500" {
  1856. result11, result22, _ := service.FJyb3507(struct3507_2)
  1857. saveLog(result11, result22, "3507", "3507")
  1858. var respJSON3 map[string]interface{}
  1859. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1860. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1862. return
  1863. }
  1864. userJSONBytes3, _ := json.Marshal(respJSON3)
  1865. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1866. utils.ErrorLog("解析失败:%v", err)
  1867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1868. return
  1869. }
  1870. } else {
  1871. data := make(map[string]interface{})
  1872. data["struct_3507s"] = struct3507_2
  1873. client := &http.Client{}
  1874. bytesData, _ := json.Marshal(data)
  1875. var req *http.Request
  1876. if miConfig.MdtrtareaAdmvs == "320830" {
  1877. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1878. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1879. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1880. } else {
  1881. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1882. }
  1883. resp, _ := client.Do(req)
  1884. defer resp.Body.Close()
  1885. body, ioErr := ioutil.ReadAll(resp.Body)
  1886. if ioErr != nil {
  1887. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1888. }
  1889. var respJSON map[string]interface{}
  1890. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1891. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1893. return
  1894. }
  1895. var resSix10265 ResultSix10265 //1101结果
  1896. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1897. result, _ := json.Marshal(respJSON)
  1898. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1899. utils.ErrorLog("解析失败:%v", err)
  1900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1901. return
  1902. }
  1903. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1904. //res.Output = resSix10265.Output
  1905. res2.ErrMsg = resSix10265.ErrMsg
  1906. res2.Cainfo = resSix10265.Cainfo
  1907. res2.WarnMsg = resSix10265.WarnMsg
  1908. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1909. res2.Infcode = infocode
  1910. }
  1911. if res2.Infcode == 0 {
  1912. item.IsChange = 0
  1913. item.BgBchno = ""
  1914. service.SaveDF2(item)
  1915. } else {
  1916. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1917. }
  1918. }
  1919. } else {
  1920. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1921. }
  1922. }
  1923. if item.IsSale == 2 && item.IsChange == 1 {
  1924. var res FJ3507Result
  1925. var res2 FJ3507Result
  1926. var struct3507 models.Struct3507
  1927. struct3507.FixmedinsBchno = item.Bchno
  1928. struct3507.InvDataType = "4"
  1929. struct3507.Opter = roles.UserName
  1930. struct3507.OrgName = miConfig.OrgName
  1931. struct3507.AccessKey = miConfig.AccessKey
  1932. struct3507.RequestUrl = miConfig.Url
  1933. struct3507.FixmedinsCode = miConfig.Code
  1934. struct3507.Code = miConfig.Code
  1935. struct3507.SecretKey = miConfig.SecretKey
  1936. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1937. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1938. struct3507.Url = miConfig.Url
  1939. struct3507.AppId = miConfig.Cainfo
  1940. struct3507.AppSecret = miConfig.AppSecret
  1941. struct3507.Enckey = miConfig.EncKey
  1942. struct3507.SignKey = miConfig.SignKey
  1943. struct3507.SecretKey = miConfig.SecretKey
  1944. //result, result1, _ := service.FJyb3507(struct3507)
  1945. //saveLog(result, result1, "3507", "3507")
  1946. //
  1947. //var respJSON2 map[string]interface{}
  1948. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1949. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1950. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1951. // return
  1952. //}
  1953. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1954. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1955. // utils.ErrorLog("解析失败:%v", err)
  1956. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1957. // return
  1958. //}
  1959. if miConfig.MdtrtareaAdmvs == "350500" {
  1960. result, result1, _ := service.FJyb3507(struct3507)
  1961. saveLog(result, result1, "3507", "3507")
  1962. var respJSON2 map[string]interface{}
  1963. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1964. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1966. return
  1967. }
  1968. userJSONBytes2, _ := json.Marshal(respJSON2)
  1969. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1970. utils.ErrorLog("解析失败:%v", err)
  1971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1972. return
  1973. }
  1974. } else {
  1975. data := make(map[string]interface{})
  1976. data["struct_3507s"] = struct3507
  1977. client := &http.Client{}
  1978. bytesData, _ := json.Marshal(data)
  1979. var req *http.Request
  1980. if miConfig.MdtrtareaAdmvs == "320830" {
  1981. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1982. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1983. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1984. } else {
  1985. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1986. }
  1987. resp, _ := client.Do(req)
  1988. defer resp.Body.Close()
  1989. body, ioErr := ioutil.ReadAll(resp.Body)
  1990. if ioErr != nil {
  1991. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1992. }
  1993. var respJSON map[string]interface{}
  1994. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1995. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1997. return
  1998. }
  1999. var resSix10265 ResultSix10265 //1101结果
  2000. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2001. result, _ := json.Marshal(respJSON)
  2002. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2003. utils.ErrorLog("解析失败:%v", err)
  2004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2005. return
  2006. }
  2007. res.InfRefmsgid = resSix10265.InfRefmsgid
  2008. //res.Output = resSix10265.Output
  2009. res.ErrMsg = resSix10265.ErrMsg
  2010. res.Cainfo = resSix10265.Cainfo
  2011. res.WarnMsg = resSix10265.WarnMsg
  2012. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2013. res.Infcode = infocode
  2014. }
  2015. if res.Infcode == 0 {
  2016. item.IsSale = 0
  2017. item.SaleDate = ""
  2018. item.Bchno = ""
  2019. err2 := service.SaveDF(item)
  2020. if err2 == nil {
  2021. var struct3507_2 models.Struct3507
  2022. struct3507_2.OrgName = miConfig.OrgName
  2023. struct3507_2.AccessKey = miConfig.AccessKey
  2024. struct3507_2.RequestUrl = miConfig.Url
  2025. struct3507_2.Opter = roles.UserName
  2026. struct3507_2.FixmedinsCode = miConfig.Code
  2027. struct3507_2.Code = miConfig.Code
  2028. struct3507_2.SecretKey = miConfig.SecretKey
  2029. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2030. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2031. struct3507_2.Url = miConfig.Url
  2032. struct3507_2.AppId = miConfig.Cainfo
  2033. struct3507_2.AppSecret = miConfig.AppSecret
  2034. struct3507_2.Enckey = miConfig.EncKey
  2035. struct3507_2.SignKey = miConfig.SignKey
  2036. struct3507_2.SecretKey = miConfig.SecretKey
  2037. struct3507_2.FixmedinsBchno = item.BgBchno
  2038. struct3507_2.InvDataType = "2"
  2039. //result11, result22, _ := service.FJyb3507(struct3507_2)
  2040. //saveLog(result11, result22, "3507", "3507")
  2041. //var respJSON3 map[string]interface{}
  2042. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2043. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2044. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2045. // return
  2046. //}
  2047. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2048. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  2049. // utils.ErrorLog("解析失败:%v", err)
  2050. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2051. // return
  2052. //}
  2053. if miConfig.MdtrtareaAdmvs == "350500" {
  2054. result11, result22, _ := service.FJyb3507(struct3507_2)
  2055. saveLog(result11, result22, "3507", "3507")
  2056. var respJSON3 map[string]interface{}
  2057. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2058. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2060. return
  2061. }
  2062. userJSONBytes3, _ := json.Marshal(respJSON3)
  2063. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  2064. utils.ErrorLog("解析失败:%v", err)
  2065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2066. return
  2067. }
  2068. } else {
  2069. data := make(map[string]interface{})
  2070. data["struct_3507s"] = struct3507_2
  2071. client := &http.Client{}
  2072. bytesData, _ := json.Marshal(data)
  2073. var req *http.Request
  2074. if miConfig.MdtrtareaAdmvs == "320830" {
  2075. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2076. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2077. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2078. } else {
  2079. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2080. }
  2081. resp, _ := client.Do(req)
  2082. defer resp.Body.Close()
  2083. body, ioErr := ioutil.ReadAll(resp.Body)
  2084. if ioErr != nil {
  2085. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2086. }
  2087. var respJSON map[string]interface{}
  2088. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2089. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2091. return
  2092. }
  2093. var resSix10265 ResultSix10265 //1101结果
  2094. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2095. result, _ := json.Marshal(respJSON)
  2096. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2097. utils.ErrorLog("解析失败:%v", err)
  2098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2099. return
  2100. }
  2101. res2.InfRefmsgid = resSix10265.InfRefmsgid
  2102. //res.Output = resSix10265.Output
  2103. res2.ErrMsg = resSix10265.ErrMsg
  2104. res2.Cainfo = resSix10265.Cainfo
  2105. res2.WarnMsg = resSix10265.WarnMsg
  2106. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2107. res2.Infcode = infocode
  2108. }
  2109. if res2.Infcode == 0 {
  2110. item.IsChange = 0
  2111. item.BgBchno = ""
  2112. service.SaveDF2(item)
  2113. } else {
  2114. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2115. }
  2116. }
  2117. } else {
  2118. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  2119. }
  2120. }
  2121. if item.IsSale == 1 && item.IsChange == 0 {
  2122. var res FJ3507Result
  2123. var struct3507 models.Struct3507
  2124. struct3507.FixmedinsBchno = item.Bchno
  2125. struct3507.InvDataType = "4"
  2126. struct3507.Opter = roles.UserName
  2127. struct3507.FixmedinsCode = miConfig.Code
  2128. struct3507.Code = miConfig.Code
  2129. struct3507.OrgName = miConfig.OrgName
  2130. struct3507.AccessKey = miConfig.AccessKey
  2131. struct3507.RequestUrl = miConfig.Url
  2132. struct3507.SecretKey = miConfig.SecretKey
  2133. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2134. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2135. struct3507.Url = miConfig.Url
  2136. struct3507.AppId = miConfig.Cainfo
  2137. struct3507.AppSecret = miConfig.AppSecret
  2138. struct3507.Enckey = miConfig.EncKey
  2139. struct3507.SignKey = miConfig.SignKey
  2140. struct3507.SecretKey = miConfig.SecretKey
  2141. //result, result1, _ := service.FJyb3507(struct3507)
  2142. //saveLog(result, result1, "3507", "3507")
  2143. //
  2144. //var respJSON3 map[string]interface{}
  2145. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2146. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2147. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2148. // return
  2149. //}
  2150. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2151. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2152. // utils.ErrorLog("解析失败:%v", err)
  2153. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2154. // return
  2155. //}
  2156. if miConfig.MdtrtareaAdmvs == "350500" {
  2157. result, result1, _ := service.FJyb3507(struct3507)
  2158. saveLog(result, result1, "3507", "3507")
  2159. var respJSON2 map[string]interface{}
  2160. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2161. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2163. return
  2164. }
  2165. userJSONBytes2, _ := json.Marshal(respJSON2)
  2166. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2167. utils.ErrorLog("解析失败:%v", err)
  2168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2169. return
  2170. }
  2171. } else {
  2172. data := make(map[string]interface{})
  2173. data["struct_3507s"] = struct3507
  2174. client := &http.Client{}
  2175. bytesData, _ := json.Marshal(data)
  2176. var req *http.Request
  2177. if miConfig.MdtrtareaAdmvs == "320830" {
  2178. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2179. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2180. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2181. } else {
  2182. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2183. }
  2184. resp, _ := client.Do(req)
  2185. defer resp.Body.Close()
  2186. body, ioErr := ioutil.ReadAll(resp.Body)
  2187. if ioErr != nil {
  2188. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2189. }
  2190. var respJSON map[string]interface{}
  2191. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2192. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2194. return
  2195. }
  2196. var resSix10265 ResultSix10265 //1101结果
  2197. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2198. result, _ := json.Marshal(respJSON)
  2199. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2200. utils.ErrorLog("解析失败:%v", err)
  2201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2202. return
  2203. }
  2204. res.InfRefmsgid = resSix10265.InfRefmsgid
  2205. //res.Output = resSix10265.Output
  2206. res.ErrMsg = resSix10265.ErrMsg
  2207. res.Cainfo = resSix10265.Cainfo
  2208. res.WarnMsg = resSix10265.WarnMsg
  2209. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2210. res.Infcode = infocode
  2211. }
  2212. if res.Infcode == 0 {
  2213. item.IsSale = 0
  2214. item.SaleDate = ""
  2215. service.SaveDF(item)
  2216. } else {
  2217. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2218. }
  2219. }
  2220. if item.IsSale == 2 && item.IsChange == 0 {
  2221. var res FJ3507Result
  2222. var struct3507 models.Struct3507
  2223. struct3507.FixmedinsBchno = item.Bchno
  2224. struct3507.InvDataType = "4"
  2225. struct3507.Opter = roles.UserName
  2226. struct3507.FixmedinsCode = miConfig.Code
  2227. struct3507.Code = miConfig.Code
  2228. struct3507.OrgName = miConfig.OrgName
  2229. struct3507.AccessKey = miConfig.AccessKey
  2230. struct3507.RequestUrl = miConfig.Url
  2231. struct3507.SecretKey = miConfig.SecretKey
  2232. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2233. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2234. struct3507.Url = miConfig.Url
  2235. struct3507.AppId = miConfig.Cainfo
  2236. struct3507.AppSecret = miConfig.AppSecret
  2237. struct3507.Enckey = miConfig.EncKey
  2238. struct3507.SignKey = miConfig.SignKey
  2239. struct3507.SecretKey = miConfig.SecretKey
  2240. //result, result1, _ := service.FJyb3507(struct3507)
  2241. //saveLog(result, result1, "3507", "3507")
  2242. //
  2243. //var respJSON3 map[string]interface{}
  2244. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2245. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2246. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2247. // return
  2248. //}
  2249. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2250. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2251. // utils.ErrorLog("解析失败:%v", err)
  2252. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2253. // return
  2254. //}
  2255. if miConfig.MdtrtareaAdmvs == "350500" {
  2256. result, result1, _ := service.FJyb3507(struct3507)
  2257. saveLog(result, result1, "3507", "3507")
  2258. var respJSON2 map[string]interface{}
  2259. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2260. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2262. return
  2263. }
  2264. userJSONBytes2, _ := json.Marshal(respJSON2)
  2265. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2266. utils.ErrorLog("解析失败:%v", err)
  2267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2268. return
  2269. }
  2270. } else {
  2271. data := make(map[string]interface{})
  2272. data["struct_3507s"] = struct3507
  2273. client := &http.Client{}
  2274. bytesData, _ := json.Marshal(data)
  2275. var req *http.Request
  2276. if miConfig.MdtrtareaAdmvs == "320830" {
  2277. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2278. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2279. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2280. } else {
  2281. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2282. }
  2283. resp, _ := client.Do(req)
  2284. defer resp.Body.Close()
  2285. body, ioErr := ioutil.ReadAll(resp.Body)
  2286. if ioErr != nil {
  2287. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2288. }
  2289. var respJSON map[string]interface{}
  2290. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2291. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2293. return
  2294. }
  2295. var resSix10265 ResultSix10265 //1101结果
  2296. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2297. result, _ := json.Marshal(respJSON)
  2298. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2299. utils.ErrorLog("解析失败:%v", err)
  2300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2301. return
  2302. }
  2303. res.InfRefmsgid = resSix10265.InfRefmsgid
  2304. //res.Output = resSix10265.Output
  2305. res.ErrMsg = resSix10265.ErrMsg
  2306. res.Cainfo = resSix10265.Cainfo
  2307. res.WarnMsg = resSix10265.WarnMsg
  2308. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2309. res.Infcode = infocode
  2310. }
  2311. if res.Infcode == 0 {
  2312. item.IsSale = 0
  2313. item.SaleDate = ""
  2314. item.Bchno = ""
  2315. service.SaveDF(item)
  2316. } else {
  2317. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2318. }
  2319. }
  2320. if item.IsSale == 0 && item.IsChange == 1 {
  2321. var res FJ3507Result
  2322. var struct3507 models.Struct3507
  2323. struct3507.FixmedinsBchno = item.BgBchno
  2324. struct3507.InvDataType = "2"
  2325. struct3507.Opter = roles.UserName
  2326. struct3507.FixmedinsCode = miConfig.Code
  2327. struct3507.Code = miConfig.Code
  2328. struct3507.OrgName = miConfig.OrgName
  2329. struct3507.AccessKey = miConfig.AccessKey
  2330. struct3507.RequestUrl = miConfig.Url
  2331. struct3507.SecretKey = miConfig.SecretKey
  2332. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2333. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2334. struct3507.Url = miConfig.Url
  2335. struct3507.AppId = miConfig.Cainfo
  2336. struct3507.AppSecret = miConfig.AppSecret
  2337. struct3507.Enckey = miConfig.EncKey
  2338. struct3507.SignKey = miConfig.SignKey
  2339. struct3507.SecretKey = miConfig.SecretKey
  2340. //result, result1, _ := service.FJyb3507(struct3507)
  2341. //saveLog(result, result1, "3507", "3507")
  2342. //
  2343. //var respJSON3 map[string]interface{}
  2344. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2345. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2346. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2347. // return
  2348. //}
  2349. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2350. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2351. // utils.ErrorLog("解析失败:%v", err)
  2352. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2353. // return
  2354. //}
  2355. if miConfig.MdtrtareaAdmvs == "350500" {
  2356. result, result1, _ := service.FJyb3507(struct3507)
  2357. saveLog(result, result1, "3507", "3507")
  2358. var respJSON2 map[string]interface{}
  2359. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2360. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2362. return
  2363. }
  2364. userJSONBytes2, _ := json.Marshal(respJSON2)
  2365. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2366. utils.ErrorLog("解析失败:%v", err)
  2367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2368. return
  2369. }
  2370. } else {
  2371. data := make(map[string]interface{})
  2372. data["struct_3507s"] = struct3507
  2373. client := &http.Client{}
  2374. bytesData, _ := json.Marshal(data)
  2375. var req *http.Request
  2376. if miConfig.MdtrtareaAdmvs == "320830" {
  2377. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2378. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2379. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2380. } else {
  2381. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2382. }
  2383. resp, _ := client.Do(req)
  2384. defer resp.Body.Close()
  2385. body, ioErr := ioutil.ReadAll(resp.Body)
  2386. if ioErr != nil {
  2387. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2388. }
  2389. var respJSON map[string]interface{}
  2390. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2391. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2393. return
  2394. }
  2395. var resSix10265 ResultSix10265 //1101结果
  2396. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2397. result, _ := json.Marshal(respJSON)
  2398. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2399. utils.ErrorLog("解析失败:%v", err)
  2400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2401. return
  2402. }
  2403. res.InfRefmsgid = resSix10265.InfRefmsgid
  2404. //res.Output = resSix10265.Output
  2405. res.ErrMsg = resSix10265.ErrMsg
  2406. res.Cainfo = resSix10265.Cainfo
  2407. res.WarnMsg = resSix10265.WarnMsg
  2408. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2409. res.Infcode = infocode
  2410. }
  2411. if res.Infcode == 0 {
  2412. item.IsChange = 0
  2413. item.BgBchno = ""
  2414. service.SaveDF2(item)
  2415. } else {
  2416. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2417. }
  2418. }
  2419. }
  2420. if len(err) == 0 {
  2421. c.ServeSuccessJSON(map[string]interface{}{
  2422. "msg": "删除销售变更成功",
  2423. })
  2424. } else {
  2425. c.ServeSuccessJSON(map[string]interface{}{
  2426. "failed_code": -10,
  2427. "msg": err,
  2428. })
  2429. }
  2430. }
  2431. //func (c *HisApiController) BatchFJ3501AND3502() {
  2432. // //ids := c.GetString("ids")
  2433. // start_time := c.GetString("start_time")
  2434. // end_time := c.GetString("end_time")
  2435. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2436. //
  2437. //
  2438. // timeLayout := "2006-01-02"
  2439. // loc, _ := time.LoadLocation("Local")
  2440. // startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  2441. // endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  2442. //
  2443. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2444. // //id_arr := strings.Split(ids, ",")
  2445. // drugs, _ := service.GetNewDrugWarehouseInfobytime(c.GetAdminUserInfo().CurrentOrgId, startime,endtime)
  2446. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2447. // //库盘
  2448. // var errs []string
  2449. // for _, drug := range drugs {
  2450. // if drug.IsPc == 0 && drug.IsBg == 0 {
  2451. // var res2 ResultSix
  2452. // var res3 ResultSix
  2453. //
  2454. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  2455. // var struct3501 models.Struct3501
  2456. // struct3501.Code = miConfig.Code
  2457. // struct3501.OrgName = miConfig.OrgName
  2458. // struct3501.AccessKey = miConfig.AccessKey
  2459. // struct3501.Opter = roles.UserName
  2460. // struct3501.RequestUrl = miConfig.Url
  2461. // struct3501.Url = miConfig.Url
  2462. // struct3501.AppId = miConfig.Cainfo
  2463. // struct3501.AppSecret = miConfig.AppSecret
  2464. // struct3501.Enckey = miConfig.EncKey
  2465. // struct3501.SignKey = miConfig.SignKey
  2466. // struct3501.SecretKey = miConfig.SecretKey
  2467. // struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2468. // struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2469. // struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2470. // struct3501.RxFlag = "1"
  2471. // struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  2472. // struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  2473. //
  2474. // struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2475. // struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2476. // struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  2477. // struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  2478. // struct3501.FixmedinsBchno = number
  2479. // struct3501.DrugTracCodg = drug.DrugCode
  2480. // memo := make(map[string]interface{})
  2481. // memo["pric"] = drug.Price
  2482. // bytesData, _ := json.Marshal(memo)
  2483. // struct3501.Memo = string(bytesData)
  2484. //
  2485. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  2486. //
  2487. // result1, result2, _ := service.FJyb3501(struct3501)
  2488. // saveLog(result1, result2, "3501", "3501")
  2489. // //saveLog(result, requestLog, "2201", "挂号")
  2490. //
  2491. // var respJSON2 map[string]interface{}
  2492. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2493. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2494. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2495. // return
  2496. // }
  2497. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2498. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2499. // utils.ErrorLog("解析失败:%v", err)
  2500. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2501. // return
  2502. // }
  2503. //
  2504. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  2505. // data := make(map[string]interface{})
  2506. // data["struct_3501s"] = struct3501
  2507. // client := &http.Client{}
  2508. // bytesData, _ := json.Marshal(data)
  2509. // var req *http.Request
  2510. // if miConfig.MdtrtareaAdmvs == "320921" {
  2511. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2512. // } else {
  2513. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2514. // }
  2515. //
  2516. // resp, _ := client.Do(req)
  2517. // defer resp.Body.Close()
  2518. // body, ioErr := ioutil.ReadAll(resp.Body)
  2519. // if ioErr != nil {
  2520. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2521. // }
  2522. // var respJSON map[string]interface{}
  2523. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2524. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2525. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2526. // return
  2527. // }
  2528. // var resSix10265 ResultSix10265 //1101结果
  2529. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2530. // result, _ := json.Marshal(respJSON)
  2531. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2532. // utils.ErrorLog("解析失败:%v", err)
  2533. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2534. // return
  2535. // }
  2536. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2537. // res2.Output = resSix10265.Output
  2538. // res2.ErrMsg = resSix10265.ErrMsg
  2539. // res2.Cainfo = resSix10265.Cainfo
  2540. // res2.WarnMsg = resSix10265.WarnMsg
  2541. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2542. // res2.Infcode = infocode
  2543. //
  2544. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  2545. // data := make(map[string]interface{})
  2546. // data["struct_3501s"] = struct3501
  2547. // client := &http.Client{}
  2548. // bytesData, _ := json.Marshal(data)
  2549. // var req *http.Request
  2550. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2551. // resp, _ := client.Do(req)
  2552. // defer resp.Body.Close()
  2553. // body, ioErr := ioutil.ReadAll(resp.Body)
  2554. // if ioErr != nil {
  2555. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2556. // }
  2557. // var respJSON map[string]interface{}
  2558. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2559. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2560. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2561. // return
  2562. // }
  2563. // var resSix10265 ResultSix10265 //1101结果
  2564. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2565. // result, _ := json.Marshal(respJSON)
  2566. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2567. // utils.ErrorLog("解析失败:%v", err)
  2568. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2569. // return
  2570. // }
  2571. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2572. // res2.Output = resSix10265.Output
  2573. // res2.ErrMsg = resSix10265.ErrMsg
  2574. // res2.Cainfo = resSix10265.Cainfo
  2575. // res2.WarnMsg = resSix10265.WarnMsg
  2576. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2577. // res2.Infcode = infocode
  2578. //
  2579. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  2580. // data := make(map[string]interface{})
  2581. // data["struct_3501s"] = struct3501
  2582. // client := &http.Client{}
  2583. // bytesData, _ := json.Marshal(data)
  2584. // var req *http.Request
  2585. // req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  2586. // resp, _ := client.Do(req)
  2587. // defer resp.Body.Close()
  2588. // body, ioErr := ioutil.ReadAll(resp.Body)
  2589. // if ioErr != nil {
  2590. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2591. // }
  2592. // var respJSON map[string]interface{}
  2593. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2594. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2595. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2596. // return
  2597. // }
  2598. // var resSix10265 ResultSix10265 //1101结果
  2599. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2600. // result, _ := json.Marshal(respJSON)
  2601. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2602. // utils.ErrorLog("解析失败:%v", err)
  2603. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2604. // return
  2605. // }
  2606. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2607. // res2.Output = resSix10265.Output
  2608. // res2.ErrMsg = resSix10265.ErrMsg
  2609. // res2.Cainfo = resSix10265.Cainfo
  2610. // res2.WarnMsg = resSix10265.WarnMsg
  2611. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2612. // res2.Infcode = infocode
  2613. //
  2614. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  2615. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2616. // saveLog(result1, result2, "3501", "3501")
  2617. // //saveLog(result, requestLog, "2201", "挂号")
  2618. //
  2619. // var respJSON2 map[string]interface{}
  2620. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2621. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2622. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2623. // return
  2624. // }
  2625. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2626. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2627. // utils.ErrorLog("解析失败:%v", err)
  2628. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2629. // return
  2630. // }
  2631. //
  2632. // }
  2633. //
  2634. // if res2.Infcode != -1 {
  2635. // drug.IsPc = 1
  2636. // drug.Bchno = number
  2637. // drug.PcDate = time.Now().Unix()
  2638. // err := service.SaveW(drug)
  2639. // if err == nil {
  2640. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2641. // var struct3502 models.Struct3502
  2642. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2643. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2644. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2645. // struct3502.FixmedinsCode = miConfig.Code
  2646. // struct3502.Code = miConfig.Code
  2647. //
  2648. // struct3502.RxFlag = "0"
  2649. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2650. // struct3502.OrgName = miConfig.OrgName
  2651. // struct3502.Opter = roles.UserName
  2652. // struct3502.AccessKey = miConfig.AccessKey
  2653. // struct3502.RequestUrl = miConfig.Url
  2654. // struct3502.SecretKey = miConfig.SecretKey
  2655. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2656. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2657. // struct3502.Url = miConfig.Url
  2658. // struct3502.AppId = miConfig.Cainfo
  2659. // struct3502.AppSecret = miConfig.AppSecret
  2660. // struct3502.Enckey = miConfig.EncKey
  2661. // struct3502.SignKey = miConfig.SignKey
  2662. // struct3502.SecretKey = miConfig.SecretKey
  2663. // struct3502.DrugTracCodg = drug.DrugCode
  2664. //
  2665. // struct3502.Memo = ""
  2666. // struct3502.InvChgType = "108"
  2667. // struct3502.FixmedinsBchno = bg_number
  2668. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2669. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2670. //
  2671. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2672. // result11, result22, _ := service.FJyb3502(struct3502)
  2673. // saveLog(result11, result22, "3502", "3502")
  2674. //
  2675. // var respJSON3 map[string]interface{}
  2676. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2677. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2678. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2679. // return
  2680. // }
  2681. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2682. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2683. // utils.ErrorLog("解析失败:%v", err)
  2684. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2685. // return
  2686. // }
  2687. //
  2688. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2689. // data := make(map[string]interface{})
  2690. // data["struct_3502s"] = struct3502
  2691. // client := &http.Client{}
  2692. // bytesData, _ := json.Marshal(data)
  2693. // var req *http.Request
  2694. // if miConfig.MdtrtareaAdmvs == "320921" {
  2695. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2696. // } else {
  2697. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2698. // }
  2699. //
  2700. // resp, _ := client.Do(req)
  2701. // defer resp.Body.Close()
  2702. // body, ioErr := ioutil.ReadAll(resp.Body)
  2703. // if ioErr != nil {
  2704. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2705. // }
  2706. // var respJSON map[string]interface{}
  2707. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2708. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2709. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2710. // return
  2711. // }
  2712. // var resSix10265 ResultSix10265 //1101结果
  2713. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2714. // result, _ := json.Marshal(respJSON)
  2715. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2716. // utils.ErrorLog("解析失败:%v", err)
  2717. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2718. // return
  2719. // }
  2720. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2721. // res3.Output = resSix10265.Output
  2722. // res3.ErrMsg = resSix10265.ErrMsg
  2723. // res3.Cainfo = resSix10265.Cainfo
  2724. // res3.WarnMsg = resSix10265.WarnMsg
  2725. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2726. // res3.Infcode = infocode
  2727. //
  2728. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2729. //
  2730. // data := make(map[string]interface{})
  2731. // data["struct_3502s"] = struct3502
  2732. // client := &http.Client{}
  2733. // bytesData, _ := json.Marshal(data)
  2734. // var req *http.Request
  2735. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  2736. // resp, _ := client.Do(req)
  2737. // defer resp.Body.Close()
  2738. // body, ioErr := ioutil.ReadAll(resp.Body)
  2739. // if ioErr != nil {
  2740. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2741. // }
  2742. // var respJSON map[string]interface{}
  2743. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2744. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2745. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2746. // return
  2747. // }
  2748. // var resSix10265 ResultSix10265 //1101结果
  2749. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2750. // result, _ := json.Marshal(respJSON)
  2751. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2752. // utils.ErrorLog("解析失败:%v", err)
  2753. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2754. // return
  2755. // }
  2756. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2757. // res3.Output = resSix10265.Output
  2758. // res3.ErrMsg = resSix10265.ErrMsg
  2759. // res3.Cainfo = resSix10265.Cainfo
  2760. // res3.WarnMsg = resSix10265.WarnMsg
  2761. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2762. // res3.Infcode = infocode
  2763. //
  2764. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2765. //
  2766. // data := make(map[string]interface{})
  2767. // data["struct_3501s"] = struct3501
  2768. // client := &http.Client{}
  2769. // bytesData, _ := json.Marshal(data)
  2770. // var req *http.Request
  2771. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2772. // resp, _ := client.Do(req)
  2773. // defer resp.Body.Close()
  2774. // body, ioErr := ioutil.ReadAll(resp.Body)
  2775. // if ioErr != nil {
  2776. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2777. // }
  2778. // var respJSON map[string]interface{}
  2779. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2780. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2781. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2782. // return
  2783. // }
  2784. // var resSix10265 ResultSix10265 //1101结果
  2785. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2786. // result, _ := json.Marshal(respJSON)
  2787. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2788. // utils.ErrorLog("解析失败:%v", err)
  2789. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2790. // return
  2791. // }
  2792. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2793. // res2.Output = resSix10265.Output
  2794. // res2.ErrMsg = resSix10265.ErrMsg
  2795. // res2.Cainfo = resSix10265.Cainfo
  2796. // res2.WarnMsg = resSix10265.WarnMsg
  2797. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2798. // res2.Infcode = infocode
  2799. //
  2800. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2801. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  2802. // saveLog(result11, result22, "3502", "3502")
  2803. //
  2804. // var respJSON3 map[string]interface{}
  2805. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2806. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2807. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2808. // return
  2809. // }
  2810. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2811. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2812. // utils.ErrorLog("解析失败:%v", err)
  2813. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2814. // return
  2815. // }
  2816. // }
  2817. // if res3.Infcode == -1 {
  2818. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2819. // c.ServeSuccessJSON(map[string]interface{}{
  2820. // "failed_code": -10,
  2821. // "msg": res3.ErrMsg,
  2822. // })
  2823. // } else {
  2824. // drug.IsBg = 1
  2825. // drug.BgBchno = bg_number
  2826. // service.SaveW(drug)
  2827. // }
  2828. // }
  2829. // } else {
  2830. // errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  2831. // }
  2832. // }
  2833. // //变更
  2834. // if drug.IsPc == 1 && drug.IsBg == 0 {
  2835. // var res3 ResultSix
  2836. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2837. //
  2838. // var struct3502 models.Struct3502
  2839. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2840. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2841. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2842. // struct3502.FixmedinsCode = miConfig.Code
  2843. // struct3502.Code = miConfig.Code
  2844. //
  2845. // struct3502.Opter = roles.UserName
  2846. // struct3502.RxFlag = "0"
  2847. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2848. // struct3502.OrgName = miConfig.OrgName
  2849. // struct3502.AccessKey = miConfig.AccessKey
  2850. // struct3502.RequestUrl = miConfig.Url
  2851. // struct3502.SecretKey = miConfig.SecretKey
  2852. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2853. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2854. // struct3502.InvChgType = "108"
  2855. // struct3502.DrugTracCodg = drug.DrugCode
  2856. //
  2857. // struct3502.Url = miConfig.Url
  2858. // struct3502.AppId = miConfig.Cainfo
  2859. // struct3502.AppSecret = miConfig.AppSecret
  2860. // struct3502.Enckey = miConfig.EncKey
  2861. // struct3502.SignKey = miConfig.SignKey
  2862. // struct3502.SecretKey = miConfig.SecretKey
  2863. //
  2864. // struct3502.FixmedinsBchno = bg_number
  2865. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2866. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2867. //
  2868. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2869. // result1, result2, _ := service.FJyb3502(struct3502)
  2870. // saveLog(result1, result2, "3502", "3502")
  2871. // var respJSON3 map[string]interface{}
  2872. // if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  2873. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2874. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2875. // return
  2876. // }
  2877. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2878. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2879. // utils.ErrorLog("解析失败:%v", err)
  2880. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2881. // return
  2882. // }
  2883. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2884. // data := make(map[string]interface{})
  2885. // data["struct_3502s"] = struct3502
  2886. // client := &http.Client{}
  2887. // bytesData, _ := json.Marshal(data)
  2888. // var req *http.Request
  2889. // if miConfig.MdtrtareaAdmvs == "320921" {
  2890. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2891. // } else {
  2892. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2893. // }
  2894. // resp, _ := client.Do(req)
  2895. // defer resp.Body.Close()
  2896. // body, ioErr := ioutil.ReadAll(resp.Body)
  2897. // if ioErr != nil {
  2898. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2899. // }
  2900. // var respJSON map[string]interface{}
  2901. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2902. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2903. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2904. // return
  2905. // }
  2906. // var resSix10265 ResultSix10265 //1101结果
  2907. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2908. // result, _ := json.Marshal(respJSON)
  2909. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2910. // utils.ErrorLog("解析失败:%v", err)
  2911. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2912. // return
  2913. // }
  2914. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2915. // res3.Output = resSix10265.Output
  2916. // res3.ErrMsg = resSix10265.ErrMsg
  2917. // res3.Cainfo = resSix10265.Cainfo
  2918. // res3.WarnMsg = resSix10265.WarnMsg
  2919. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2920. // res3.Infcode = infocode
  2921. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2922. //
  2923. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2924. //
  2925. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  2926. //
  2927. // }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2928. //
  2929. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2930. // saveLog(result1, result2, "3501", "3501")
  2931. // //saveLog(result, requestLog, "2201", "挂号")
  2932. //
  2933. // var respJSON2 map[string]interface{}
  2934. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2935. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2936. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2937. // return
  2938. // }
  2939. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2940. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2941. // utils.ErrorLog("解析失败:%v", err)
  2942. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2943. // return
  2944. // }
  2945. //
  2946. // }
  2947. // if res3.Infcode == -1 {
  2948. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2949. // } else {
  2950. // drug.IsBg = 1
  2951. // drug.BgBchno = bg_number
  2952. // service.SaveW(drug)
  2953. // }
  2954. // }
  2955. // }
  2956. //
  2957. // if len(errs) == 0 {
  2958. // c.ServeSuccessJSON(map[string]interface{}{
  2959. // "msg": "盘存变更成功",
  2960. // })
  2961. // } else {
  2962. // c.ServeSuccessJSON(map[string]interface{}{
  2963. // "failed_code": -10,
  2964. // "msg": errs,
  2965. // })
  2966. // }
  2967. //}
  2968. func (c *HisApiController) DeleteXSandBGTwo() {
  2969. id, _ := c.GetInt64("id")
  2970. admin_user_id, _ := c.GetInt64("admin_user_id")
  2971. var errs []string
  2972. advicelist, _ := service.FindHisAdviceDocAdvice(id)
  2973. for _, item := range advicelist {
  2974. prescription := service.GetHisPrescriptionByID(item.PrescriptionId)
  2975. if prescription.OrderStatus != 2 {
  2976. // 将时间戳转换为time.Time类型
  2977. t := time.Unix(item.RecordDate, 0) // 注意第二个参数是纳秒,这里是0
  2978. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, item.PatientId)
  2979. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.AdviceName+"医嘱没结算无法撤销上传")
  2980. }
  2981. if len(item.DrugCode) > 0 {
  2982. t := time.Unix(item.RecordDate, 0) // 注意第二个参数是纳秒,这里是0
  2983. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, item.PatientId)
  2984. codes := strings.Split(item.DrugCode, ",")
  2985. for _, code := range codes {
  2986. if len(code) > 0 {
  2987. if len(code) != 20 {
  2988. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.AdviceName+" 溯源码"+code+"位数不是20位")
  2989. }
  2990. if IsDigit(code) == false {
  2991. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.AdviceName+" 溯源码"+code+"不是纯数字")
  2992. }
  2993. }
  2994. }
  2995. }
  2996. }
  2997. utils.ErrorLog("接口返回数据解析JSON失败: %v", errs)
  2998. if len(errs) > 0 {
  2999. c.ServeSuccessJSON(map[string]interface{}{
  3000. "failed_code": -10,
  3001. "msg": errs,
  3002. })
  3003. return
  3004. }
  3005. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3006. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3007. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3008. for _, item := range advicelist {
  3009. flow, _ := service.GetNewDrugFlowInfoByPatient(item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3010. //Drug ,_ := service.GetDrugLibById( drug.DrugId)
  3011. prescription := service.GetHisPrescriptionByID(item.PrescriptionId)
  3012. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId,prescription,flow,miConfig,"", roles, item.ID,item)
  3013. saveLog(result111, result222, "3506", "销售退货")
  3014. var res7 FJ3507Result
  3015. //进行商品销售接口
  3016. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3017. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3018. var respJSON3 map[string]interface{}
  3019. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3020. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3022. return
  3023. }
  3024. userJSONBytes3, _ := json.Marshal(respJSON3)
  3025. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3026. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3027. utils.ErrorLog("解析失败:%v", err)
  3028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3029. return
  3030. }
  3031. //if res3507for10188.Infcode
  3032. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3033. //res.Output = resSix10265.Output
  3034. res7.ErrMsg = res3507for10188.ErrMsg
  3035. res7.Cainfo = res3507for10188.Cainfo
  3036. res7.WarnMsg = res3507for10188.WarnMsg
  3037. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3038. res7.Infcode = infocode
  3039. } else {
  3040. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3041. utils.ErrorLog("解析失败:%v", err)
  3042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3043. return
  3044. }
  3045. }
  3046. if res7.Infcode == 0 {
  3047. service.SaveDoctoradviceStatus(item.ID,time.Now().Format("2006-01-02"))
  3048. } else {
  3049. errs = append(errs, item.AdviceName+",销售失败:"+res.ErrMsg)
  3050. }
  3051. }
  3052. c.ServeSuccessJSON(map[string]interface{}{
  3053. "msg": "删除销售数据成功",
  3054. })
  3055. }
  3056. // 删除
  3057. //func (c *HisApiController) DeleteXSandBGThree() {
  3058. // id, _ := c.GetInt64("id")
  3059. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3060. //
  3061. // advicelist, _ := service.FinddelHisAdviceDocAdvice(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. //
  3068. // //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3069. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3070. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3071. //
  3072. // var err []string
  3073. // for _, item := range advicelist {
  3074. //
  3075. // var res FJ3507Result
  3076. //
  3077. // var struct3507 models.Struct3507
  3078. // struct3507.FixmedinsBchno = item.ID
  3079. // struct3507.InvDataType = "4"
  3080. // struct3507.Opter = roles.UserName
  3081. // struct3507.OrgName = miConfig.OrgName
  3082. // struct3507.AccessKey = miConfig.AccessKey
  3083. // struct3507.RequestUrl = miConfig.Url
  3084. // struct3507.FixmedinsCode = miConfig.Code
  3085. // struct3507.SecretKey = miConfig.SecretKey
  3086. // struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3087. // struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3088. // struct3507.Url = miConfig.Url
  3089. // struct3507.AppId = miConfig.Cainfo
  3090. // struct3507.AppSecret = miConfig.AppSecret
  3091. // struct3507.Enckey = miConfig.EncKey
  3092. // struct3507.SignKey = miConfig.SignKey
  3093. // struct3507.SecretKey = miConfig.SecretKey
  3094. //
  3095. // if miConfig.MdtrtareaAdmvs == "350500" {
  3096. // result, result1, _ := service.FJyb3507(struct3507)
  3097. // saveLog(result, result1, "3507", "3507")
  3098. // var respJSON2 map[string]interface{}
  3099. // if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3100. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3101. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3102. // return
  3103. // }
  3104. // userJSONBytes2, _ := json.Marshal(respJSON2)
  3105. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3106. // utils.ErrorLog("解析失败:%v", err)
  3107. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3108. // return
  3109. // }
  3110. // } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  3111. // data := make(map[string]interface{})
  3112. // data["struct_3507s"] = struct3507
  3113. // client := &http.Client{}
  3114. // bytesData, _ := json.Marshal(data)
  3115. // var req *http.Request
  3116. // if miConfig.MdtrtareaAdmvs == "320830" {
  3117. // req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  3118. // } else if miConfig.MdtrtareaAdmvs == "320921" {
  3119. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3120. // } else {
  3121. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3122. // }
  3123. //
  3124. // resp, _ := client.Do(req)
  3125. // defer resp.Body.Close()
  3126. // body, ioErr := ioutil.ReadAll(resp.Body)
  3127. // if ioErr != nil {
  3128. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3129. // }
  3130. // var respJSON map[string]interface{}
  3131. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3132. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3133. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3134. // return
  3135. // }
  3136. // var resSix10265 ResultSix10265 //1101结果
  3137. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3138. // result, _ := json.Marshal(respJSON)
  3139. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3140. // utils.ErrorLog("解析失败:%v", err)
  3141. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3142. // return
  3143. // }
  3144. // res.InfRefmsgid = resSix10265.InfRefmsgid
  3145. // //res.Output = resSix10265.Output
  3146. // res.ErrMsg = resSix10265.ErrMsg
  3147. // res.Cainfo = resSix10265.Cainfo
  3148. // res.WarnMsg = resSix10265.WarnMsg
  3149. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3150. // res.Infcode = infocode
  3151. // } else if miConfig.MdtrtareaAdmvs == "440100" {
  3152. // result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  3153. // saveLog(result2, result1, "3507", "3507")
  3154. // var respJSON2 map[string]interface{}
  3155. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3156. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3157. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3158. // return
  3159. // }
  3160. // userJSONBytes2, _ := json.Marshal(respJSON2)
  3161. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3162. // utils.ErrorLog("解析失败:%v", err)
  3163. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3164. // return
  3165. // }
  3166. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  3167. // result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  3168. // saveLog(result2, result1, "3507", "3507")
  3169. // var respJSON2 map[string]interface{}
  3170. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3171. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3172. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3173. // return
  3174. // }
  3175. // userJSONBytes2, _ := json.Marshal(respJSON2)
  3176. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3177. // utils.ErrorLog("解析失败:%v", err)
  3178. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3179. // return
  3180. // }
  3181. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  3182. // result1, result2 := service.Jxyb3507(struct3507)
  3183. // saveLog(result2, result1, "3507", "3507")
  3184. // var respJSON2 map[string]interface{}
  3185. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3186. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3187. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3188. // return
  3189. // }
  3190. // userJSONBytes2, _ := json.Marshal(respJSON2)
  3191. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3192. // utils.ErrorLog("解析失败:%v", err)
  3193. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3194. // return
  3195. // }
  3196. // } else if miConfig.MdtrtareaAdmvs == "340699" {
  3197. // result1, result2 := service.AHyb3507(struct3507)
  3198. // saveLog(result2, result1, "3507", "3507")
  3199. // var respJSON2 map[string]interface{}
  3200. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3201. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3202. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3203. // return
  3204. // }
  3205. // userJSONBytes2, _ := json.Marshal(respJSON2)
  3206. // if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3207. // utils.ErrorLog("解析失败:%v", err)
  3208. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3209. // return
  3210. // }
  3211. // } else if miConfig.MdtrtareaAdmvs == "150404" {
  3212. //
  3213. // data := make(map[string]interface{})
  3214. // data["struct_3507s"] = struct3507
  3215. // client := &http.Client{}
  3216. // bytesData, _ := json.Marshal(data)
  3217. // var req *http.Request
  3218. //
  3219. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  3220. //
  3221. // resp, _ := client.Do(req)
  3222. // defer resp.Body.Close()
  3223. // body, ioErr := ioutil.ReadAll(resp.Body)
  3224. // if ioErr != nil {
  3225. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3226. // }
  3227. // var respJSON map[string]interface{}
  3228. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3229. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3230. // }
  3231. //
  3232. // var resSix10265 ResultSix10265 //1101结果
  3233. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3234. // result, _ := json.Marshal(respJSON)
  3235. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3236. // utils.ErrorLog("解析失败:%v", err)
  3237. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3238. // return
  3239. // }
  3240. // res.InfRefmsgid = resSix10265.InfRefmsgid
  3241. // res.ErrMsg = resSix10265.ErrMsg
  3242. // res.Cainfo = resSix10265.Cainfo
  3243. // res.WarnMsg = resSix10265.WarnMsg
  3244. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3245. // res.Infcode = infocode
  3246. // }
  3247. //
  3248. // if res.Infcode == 0 {
  3249. // service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  3250. // item.IsSale = 0
  3251. // item.SaleDate = ""
  3252. // item.Bchno = ""
  3253. // service.SaveDF(item)
  3254. // } else {
  3255. // err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  3256. // }
  3257. // }
  3258. //
  3259. // c.ServeSuccessJSON(map[string]interface{}{
  3260. // "msg": "删除销售数据成功",
  3261. // })
  3262. //
  3263. //}
  3264. // 获取当天起止时间戳
  3265. func GetNowTime() (int64, int64) {
  3266. t := time.Now()
  3267. addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
  3268. timesamp := addTime.Unix()
  3269. return timesamp, timesamp + 86399
  3270. }
  3271. func (c *HisApiController) ChangeDrugfour() {
  3272. patient_id, _ := c.GetInt64("patient_id")
  3273. admin_user_id, _ := c.GetInt64("admin_user_id")
  3274. times := c.GetString("time", "")
  3275. timeLayout := "2006-01-02"
  3276. loc, _ := time.LoadLocation("Local")
  3277. var stime, etime int64
  3278. if times == "" {
  3279. stime, etime = GetNowTime()
  3280. } else {
  3281. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3282. stime = stmp.Unix()
  3283. etime = stime + 86399
  3284. }
  3285. advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3286. //var flows []*models.DrugFlow
  3287. //for _, item := range advicelist {
  3288. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  3289. // flows = append(flows, flow...)
  3290. //}
  3291. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3292. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3293. var err []string
  3294. for _, item := range advicelist {
  3295. prescription := service.GetHisPrescriptionByID(item.PrescriptionId)
  3296. if prescription.OrderStatus == 2 {
  3297. var res FJ3507Result
  3298. var res3507for10188 FJ3507ResultFor10188
  3299. number := strconv.FormatInt(item.ID, 10)
  3300. //进行商品销售接口
  3301. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number,stime)
  3302. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3303. var respJSON3 map[string]interface{}
  3304. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3305. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3307. return
  3308. }
  3309. userJSONBytes3, _ := json.Marshal(respJSON3)
  3310. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 || c.GetAdminUserInfo().CurrentOrgId == 10633{
  3311. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3312. utils.ErrorLog("解析失败:%v", err)
  3313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3314. return
  3315. }
  3316. //if res3507for10188.Infcode
  3317. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3318. //res.Output = resSix10265.Output
  3319. res.ErrMsg = res3507for10188.ErrMsg
  3320. res.Cainfo = res3507for10188.Cainfo
  3321. res.WarnMsg = res3507for10188.WarnMsg
  3322. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3323. res.Infcode = infocode
  3324. } else {
  3325. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3326. utils.ErrorLog("解析失败:%v", err)
  3327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3328. return
  3329. }
  3330. }
  3331. if res.Infcode == 0 {
  3332. service.SaveDoctoradviceStatus(item.ID,time.Now().Format("2006-01-02"))
  3333. } else {
  3334. err = append(err, item.AdviceName+",销售失败:"+res.ErrMsg)
  3335. }
  3336. } else { //还没结,提示用户去结算,并药品追溯上传
  3337. err = append(err, item.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3338. }
  3339. }
  3340. str := strings.Join(err, " ")
  3341. saveLog(str, str, "3505", "3505自动上传日志")
  3342. c.ServeSuccessJSON(map[string]interface{}{
  3343. "status": "1",
  3344. "msg": err,
  3345. })
  3346. }
  3347. func (c *HisApiController) ChangeDrugFive() {
  3348. id := c.GetString("id")
  3349. ids := strings.Split(id, ",")
  3350. admin_user_id, _ := c.GetInt64("admin_user_id")
  3351. var errs []string
  3352. //校验gui'ge
  3353. for _, value := range ids {
  3354. intValue, _ := strconv.ParseInt(value, 10, 64)
  3355. //file := strconv.FormatInt(int64(num), 10)
  3356. advicelist, _ := service.FindHisAdviceDocAdvice(intValue)
  3357. //for _, item := range advicelist {
  3358. // flow, _ := service.GetNewDrugFlowInfoByPatient(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3359. // flows = append(flows, flow...)
  3360. //}
  3361. //roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3362. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3363. for _, item := range advicelist {
  3364. prescription := service.GetHisPrescriptionByID(item.PrescriptionId)
  3365. if prescription.OrderStatus != 2 {
  3366. // 将时间戳转换为time.Time类型
  3367. t := time.Unix(item.RecordDate, 0) // 注意第二个参数是纳秒,这里是0
  3368. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, item.PatientId)
  3369. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.AdviceName+"医嘱没结算无法上传")
  3370. }
  3371. if len(item.DrugCode) > 0 {
  3372. t := time.Unix(item.RecordDate, 0) // 注意第二个参数是纳秒,这里是0
  3373. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, item.PatientId)
  3374. codes := strings.Split(item.DrugCode, ",")
  3375. for _, code := range codes {
  3376. if len(code) > 0 {
  3377. if len(code) != 20 {
  3378. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.AdviceName+" 溯源码"+code+"位数不是20位")
  3379. }
  3380. if IsDigit(code) == false {
  3381. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.AdviceName+" 溯源码"+code+"不是纯数字")
  3382. }
  3383. }
  3384. }
  3385. }
  3386. }
  3387. }
  3388. utils.ErrorLog("接口返回数据解析JSON失败: %v", errs)
  3389. if len(errs) > 0 {
  3390. c.ServeSuccessJSON(map[string]interface{}{
  3391. "failed_code": -10,
  3392. "msg": errs,
  3393. })
  3394. return
  3395. }
  3396. for _, value := range ids {
  3397. intValue, _ := strconv.ParseInt(value, 10, 64)
  3398. //file := strconv.FormatInt(int64(num), 10)
  3399. advicelist, _ := service.FindHisAdviceDocAdvice(intValue)
  3400. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3401. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3402. for _, item := range advicelist{
  3403. prescription := service.GetHisPrescriptionByID(item.PrescriptionId)
  3404. if prescription.OrderStatus == 2 {
  3405. var res FJ3507Result
  3406. var res3507for10188 FJ3507ResultFor10188
  3407. number := strconv.FormatInt(item.ID, 10)
  3408. //进行商品销售接口
  3409. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number,item.RecordDate)
  3410. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3411. var respJSON3 map[string]interface{}
  3412. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3413. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3415. return
  3416. }
  3417. userJSONBytes3, _ := json.Marshal(respJSON3)
  3418. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 || c.GetAdminUserInfo().CurrentOrgId == 10633 {
  3419. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3420. utils.ErrorLog("解析失败:%v", err)
  3421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3422. return
  3423. }
  3424. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3425. res.ErrMsg = res3507for10188.ErrMsg
  3426. res.Cainfo = res3507for10188.Cainfo
  3427. res.WarnMsg = res3507for10188.WarnMsg
  3428. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3429. res.Infcode = infocode
  3430. } else {
  3431. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3432. utils.ErrorLog("解析失败:%v", err)
  3433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3434. return
  3435. }
  3436. }
  3437. if res.Infcode == 0 {
  3438. service.SaveDoctoradviceStatus(item.ID,time.Now().Format("2006-01-02"))
  3439. } else {
  3440. errs = append(errs, item.AdviceName+",销售失败:"+res.ErrMsg)
  3441. }
  3442. } else { //还没结,提示用户去结算,并药品追溯上传
  3443. errs = append(errs, item.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3444. }
  3445. }
  3446. str := strings.Join(errs, " ")
  3447. saveLog(str, str, "3505", "3505自动上传日志")
  3448. }
  3449. c.ServeSuccessJSON(map[string]interface{}{
  3450. "status": "1",
  3451. "msg": errs,
  3452. })
  3453. }
  3454. //func (c *HisApiController) ChangeDrugfour() {
  3455. // patient_id, _ := c.GetInt64("patient_id")
  3456. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3457. // //id_arr := strings.Split(ids, ",")
  3458. // times := c.GetString("time", "")
  3459. // timeLayout := "2006-01-02"
  3460. // loc, _ := time.LoadLocation("Local")
  3461. // var stime, etime int64
  3462. // if times == "" {
  3463. // stime, etime = GetNowTime()
  3464. // } else {
  3465. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3466. // stime = stmp.Unix()
  3467. // etime = stime + 86399
  3468. // }
  3469. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3470. // var flows []*models.DrugFlow
  3471. // for _, item := range advicelist {
  3472. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
  3473. // flows = append(flows, flow...)
  3474. // }
  3475. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3476. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3477. // var err []string
  3478. //
  3479. // for _, item := range flows {
  3480. // var res3 ResultSix
  3481. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3482. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3483. // if prescription.OrderStatus == 2 {
  3484. // //已经结算
  3485. // //判断是否已经销售
  3486. // if item.IsSale == 1 { //是否已经销售,1是 0否
  3487. // //是否已经变更 1是 0否
  3488. // if item.IsChange == 0 { //没变更,进行变更操作
  3489. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3490. //
  3491. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3492. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3493. // var respJSON3 map[string]interface{}
  3494. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3495. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3496. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3497. // return
  3498. // }
  3499. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3500. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3501. // utils.ErrorLog("解析失败:%v", err)
  3502. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3503. // return
  3504. // }
  3505. // if res3.Infcode == 0 {
  3506. // item.IsChange = 1
  3507. // item.BgBchno = bg_number
  3508. // service.SaveDF2(item)
  3509. // } else {
  3510. //
  3511. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3512. // }
  3513. // }
  3514. // } else { //没销售,
  3515. // var res FJ3507Result
  3516. // var res3507for10188 FJ3507ResultFor10188
  3517. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3518. //
  3519. // //进行商品销售接口
  3520. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3521. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3522. // var respJSON3 map[string]interface{}
  3523. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3524. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3525. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3526. // return
  3527. // }
  3528. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3529. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3530. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3531. // utils.ErrorLog("解析失败:%v", err)
  3532. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3533. // return
  3534. // }
  3535. // //if res3507for10188.Infcode
  3536. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  3537. // //res.Output = resSix10265.Output
  3538. // res.ErrMsg = res3507for10188.ErrMsg
  3539. // res.Cainfo = res3507for10188.Cainfo
  3540. // res.WarnMsg = res3507for10188.WarnMsg
  3541. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3542. // res.Infcode = infocode
  3543. // } else {
  3544. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3545. // utils.ErrorLog("解析失败:%v", err)
  3546. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3547. // return
  3548. // }
  3549. //
  3550. // }
  3551. // if res.Infcode == 0 {
  3552. // item.IsSale = 1
  3553. // item.Bchno = number
  3554. // item.SaleDate = time.Now().Format("2006-01-02")
  3555. //
  3556. // err5 := service.SaveDF(item)
  3557. // if err5 == nil {
  3558. // if item.IsChange == 0 { //没变更,进行变更操作
  3559. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3560. //
  3561. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3562. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3563. //
  3564. // var respJSON3 map[string]interface{}
  3565. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3566. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3567. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3568. // return
  3569. // }
  3570. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3571. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3572. // utils.ErrorLog("解析失败:%v", err)
  3573. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3574. // return
  3575. // }
  3576. // //if res3507for10188.Infcode
  3577. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3578. // //res.Output = resSix10265.Output
  3579. // res3.ErrMsg = res3507for10188.ErrMsg
  3580. // res3.Cainfo = res3507for10188.Cainfo
  3581. // res3.WarnMsg = res3507for10188.WarnMsg
  3582. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3583. // res3.Infcode = infocode
  3584. // } else {
  3585. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3586. // utils.ErrorLog("解析失败:%v", err)
  3587. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3588. // return
  3589. // }
  3590. // }
  3591. // if res3.Infcode == 0 {
  3592. // item.IsChange = 1
  3593. // item.BgBchno = bg_number
  3594. // service.SaveDF2(item)
  3595. // } else {
  3596. //
  3597. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3598. // }
  3599. // }
  3600. // }
  3601. // } else {
  3602. //
  3603. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3604. // }
  3605. // }
  3606. //
  3607. // } else { //还没结,提示用户去结算,并药品追溯上传
  3608. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3609. // }
  3610. // }
  3611. // }
  3612. // if len(err) == 0 {
  3613. // c.ServeSuccessJSON(map[string]interface{}{
  3614. // "msg": "销售变更成功",
  3615. // })
  3616. // } else {
  3617. // c.ServeSuccessJSON(map[string]interface{}{
  3618. // "failed_code": -10,
  3619. // "msg": err,
  3620. // })
  3621. // }
  3622. //}
  3623. //func (c *HisApiController) ChangeDrug() {
  3624. // ids := c.GetString("ids")
  3625. // id_arr := strings.Split(ids, ",")
  3626. // flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3627. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3628. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3629. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3630. // var err []string
  3631. // for _, item := range flows {
  3632. // var res3 ResultSix
  3633. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3634. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3635. // if prescription.OrderStatus == 2 {
  3636. // //已经结算
  3637. // //判断是否已经销售
  3638. // if item.IsSale == 1 { //是否已经销售,1是 0否
  3639. // //是否已经变更 1是 0否
  3640. // if item.IsChange == 0 { //没变更,进行变更操作
  3641. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3642. //
  3643. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3644. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3645. // var respJSON3 map[string]interface{}
  3646. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3647. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3648. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3649. // return
  3650. // }
  3651. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3652. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3653. // utils.ErrorLog("解析失败:%v", err)
  3654. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3655. // return
  3656. // }
  3657. // if res3.Infcode == 0 {
  3658. // item.IsChange = 1
  3659. // item.BgBchno = bg_number
  3660. // service.SaveDF2(item)
  3661. // } else {
  3662. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3663. // }
  3664. // }
  3665. // } else { //没销售,
  3666. // var res FJ3507Result
  3667. // var res3507for10188 FJ3507ResultFor10188
  3668. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3669. //
  3670. // //进行商品销售接口
  3671. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3672. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3673. // var respJSON3 map[string]interface{}
  3674. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3675. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3676. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3677. // return
  3678. // }
  3679. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3680. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3681. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3682. // utils.ErrorLog("解析失败:%v", err)
  3683. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3684. // return
  3685. // }
  3686. // //if res3507for10188.Infcode
  3687. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  3688. // //res.Output = resSix10265.Output
  3689. // res.ErrMsg = res3507for10188.ErrMsg
  3690. // res.Cainfo = res3507for10188.Cainfo
  3691. // res.WarnMsg = res3507for10188.WarnMsg
  3692. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3693. // res.Infcode = infocode
  3694. // } else {
  3695. //
  3696. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3697. // utils.ErrorLog("解析失败:%v", err)
  3698. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3699. // return
  3700. // }
  3701. //
  3702. // }
  3703. //
  3704. // if res.Infcode == 0 {
  3705. // item.IsSale = 1
  3706. // item.Bchno = number
  3707. // item.SaleDate = time.Now().Format("2006-01-02")
  3708. //
  3709. // err5 := service.SaveDF(item)
  3710. // if err5 == nil {
  3711. // if item.IsChange == 0 { //没变更,进行变更操作
  3712. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3713. //
  3714. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3715. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3716. //
  3717. // var respJSON3 map[string]interface{}
  3718. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3719. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3720. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3721. // return
  3722. // }
  3723. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3724. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3725. // utils.ErrorLog("解析失败:%v", err)
  3726. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3727. // return
  3728. // }
  3729. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3730. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3731. // utils.ErrorLog("解析失败:%v", err)
  3732. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3733. // return
  3734. // }
  3735. // //if res3507for10188.Infcode
  3736. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3737. // //res.Output = resSix10265.Output
  3738. // res3.ErrMsg = res3507for10188.ErrMsg
  3739. // res3.Cainfo = res3507for10188.Cainfo
  3740. // res3.WarnMsg = res3507for10188.WarnMsg
  3741. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3742. // res3.Infcode = infocode
  3743. // } else {
  3744. //
  3745. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3746. // utils.ErrorLog("解析失败:%v", err)
  3747. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3748. // return
  3749. // }
  3750. //
  3751. // }
  3752. //
  3753. // if res3.Infcode == 0 {
  3754. // item.IsChange = 1
  3755. // item.BgBchno = bg_number
  3756. // service.SaveDF2(item)
  3757. // } else {
  3758. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3759. // }
  3760. // }
  3761. // }
  3762. // } else {
  3763. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3764. // }
  3765. // }
  3766. //
  3767. // } else { //还没结算
  3768. // var res3507for10188 FJ3507ResultFor10188
  3769. //
  3770. // if item.IsChange == 0 { //没变更,进行变更操作
  3771. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3772. //
  3773. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3774. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3775. //
  3776. // var respJSON3 map[string]interface{}
  3777. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3778. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3779. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3780. // return
  3781. // }
  3782. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3783. //
  3784. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3785. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3786. // utils.ErrorLog("解析失败:%v", err)
  3787. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3788. // return
  3789. // }
  3790. // //if res3507for10188.Infcode
  3791. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3792. // //res.Output = resSix10265.Output
  3793. // res3.ErrMsg = res3507for10188.ErrMsg
  3794. // res3.Cainfo = res3507for10188.Cainfo
  3795. // res3.WarnMsg = res3507for10188.WarnMsg
  3796. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3797. // res3.Infcode = infocode
  3798. // } else {
  3799. //
  3800. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3801. // utils.ErrorLog("解析失败:%v", err)
  3802. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3803. // return
  3804. // }
  3805. //
  3806. // }
  3807. //
  3808. // if res3.Infcode == 0 {
  3809. // item.IsChange = 1
  3810. // item.BgBchno = bg_number
  3811. // service.SaveDF2(item)
  3812. // } else {
  3813. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3814. // }
  3815. // }
  3816. // }
  3817. // } else if item.ConsumableType == 7 {
  3818. // var res3507for10188 FJ3507ResultFor10188
  3819. //
  3820. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3821. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3822. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3823. // //判断是否已经销售
  3824. // if item.IsSale == 2 { //是否已经销售,1是 0否
  3825. // //是否已经变更 1是 0否
  3826. // if item.IsChange == 0 { //没变更,进行变更操作
  3827. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3828. //
  3829. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3830. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3831. //
  3832. // var respJSON3 map[string]interface{}
  3833. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3834. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3835. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3836. // return
  3837. // }
  3838. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3839. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3840. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3841. // utils.ErrorLog("解析失败:%v", err)
  3842. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3843. // return
  3844. // }
  3845. // //if res3507for10188.Infcode
  3846. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3847. // //res.Output = resSix10265.Output
  3848. // res3.ErrMsg = res3507for10188.ErrMsg
  3849. // res3.Cainfo = res3507for10188.Cainfo
  3850. // res3.WarnMsg = res3507for10188.WarnMsg
  3851. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3852. // res3.Infcode = infocode
  3853. // } else {
  3854. //
  3855. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3856. // utils.ErrorLog("解析失败:%v", err)
  3857. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3858. // return
  3859. // }
  3860. //
  3861. // }
  3862. // if res3.Infcode == 0 {
  3863. // item.IsChange = 1
  3864. // item.BgBchno = bg_number
  3865. // service.SaveDF2(item)
  3866. // } else {
  3867. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3868. // }
  3869. // }
  3870. // } else { //没销售,
  3871. // //进行商品销售退货接口
  3872. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3873. //
  3874. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3875. // saveLog(result111, result222, "3506", "销售退货")
  3876. // var res7 FJ3507Result
  3877. //
  3878. // //进行商品销售接口
  3879. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3880. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3881. // var respJSON3 map[string]interface{}
  3882. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3883. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3884. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3885. // return
  3886. // }
  3887. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3888. //
  3889. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3890. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3891. // utils.ErrorLog("解析失败:%v", err)
  3892. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3893. // return
  3894. // }
  3895. // //if res3507for10188.Infcode
  3896. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3897. // //res.Output = resSix10265.Output
  3898. // res7.ErrMsg = res3507for10188.ErrMsg
  3899. // res7.Cainfo = res3507for10188.Cainfo
  3900. // res7.WarnMsg = res3507for10188.WarnMsg
  3901. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3902. // res7.Infcode = infocode
  3903. // } else {
  3904. //
  3905. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3906. // utils.ErrorLog("解析失败:%v", err)
  3907. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3908. // return
  3909. // }
  3910. //
  3911. // }
  3912. // if res7.Infcode == 0 {
  3913. // item.IsSale = 2
  3914. // item.SaleDate = item.SaleDate
  3915. // item.Bchno = number
  3916. // service.SaveDF(item)
  3917. // if item.IsChange == 0 { //没变更,进行变更操作
  3918. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3919. //
  3920. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3921. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3922. //
  3923. // var respJSON3 map[string]interface{}
  3924. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3925. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3926. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3927. // return
  3928. // }
  3929. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3930. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3931. // // utils.ErrorLog("解析失败:%v", err)
  3932. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3933. // // return
  3934. // //}
  3935. //
  3936. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3937. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3938. // utils.ErrorLog("解析失败:%v", err)
  3939. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3940. // return
  3941. // }
  3942. // //if res3507for10188.Infcode
  3943. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3944. // //res.Output = resSix10265.Output
  3945. // res3.ErrMsg = res3507for10188.ErrMsg
  3946. // res3.Cainfo = res3507for10188.Cainfo
  3947. // res3.WarnMsg = res3507for10188.WarnMsg
  3948. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3949. // res3.Infcode = infocode
  3950. // } else {
  3951. //
  3952. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3953. // utils.ErrorLog("解析失败:%v", err)
  3954. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3955. // return
  3956. // }
  3957. //
  3958. // }
  3959. // if res3.Infcode == 0 {
  3960. // item.IsChange = 1
  3961. // item.BgBchno = bg_number
  3962. // service.SaveDF2(item)
  3963. // } else {
  3964. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3965. // }
  3966. // }
  3967. // } else {
  3968. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3969. // }
  3970. // }
  3971. // } else { //还没结算
  3972. // if item.IsChange == 0 { //没变更,进行变更操作
  3973. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3974. //
  3975. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3976. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3977. //
  3978. // var respJSON3 map[string]interface{}
  3979. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3980. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3981. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3982. // return
  3983. // }
  3984. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3985. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3986. // // utils.ErrorLog("解析失败:%v", err)
  3987. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3988. // // return
  3989. // //}
  3990. //
  3991. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3992. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3993. // utils.ErrorLog("解析失败:%v", err)
  3994. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3995. // return
  3996. // }
  3997. // //if res3507for10188.Infcode
  3998. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3999. // //res.Output = resSix10265.Output
  4000. // res3.ErrMsg = res3507for10188.ErrMsg
  4001. // res3.Cainfo = res3507for10188.Cainfo
  4002. // res3.WarnMsg = res3507for10188.WarnMsg
  4003. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4004. // res3.Infcode = infocode
  4005. // } else {
  4006. //
  4007. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4008. // utils.ErrorLog("解析失败:%v", err)
  4009. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4010. // return
  4011. // }
  4012. //
  4013. // }
  4014. // if res3.Infcode == 0 {
  4015. // item.IsChange = 1
  4016. // item.BgBchno = bg_number
  4017. // service.SaveDF2(item)
  4018. // } else {
  4019. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4020. // }
  4021. // }
  4022. // }
  4023. // }
  4024. // }
  4025. // if len(err) == 0 {
  4026. // c.ServeSuccessJSON(map[string]interface{}{
  4027. // "msg": "销售变更成功",
  4028. // })
  4029. // } else {
  4030. // c.ServeSuccessJSON(map[string]interface{}{
  4031. // "failed_code": -10,
  4032. // "msg": err,
  4033. // })
  4034. // }
  4035. //}
  4036. //func (c *HisApiController) ChangeDrugtwo() {
  4037. //
  4038. // //ids := c.GetString("ids")
  4039. // //id_arr := strings.Split(ids, ",")
  4040. // flows, _ := service.GetNewDrugFlowInfothree123()
  4041. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4042. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4043. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4044. // var err []string
  4045. // for _, item := range flows {
  4046. // var res3 ResultSix
  4047. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4048. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4049. // if prescription.OrderStatus == 2 {
  4050. // //已经结算
  4051. // //判断是否已经销售
  4052. // //if item.IsSale == 1 { //是否已经销售,1是 0否
  4053. // // //是否已经变更 1是 0否
  4054. // // if item.IsChange == 0 { //没变更,进行变更操作
  4055. // // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4056. // //
  4057. // // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4058. // // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4059. // // var respJSON3 map[string]interface{}
  4060. // // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4061. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4062. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4063. // // return
  4064. // // }
  4065. // // userJSONBytes3, _ := json.Marshal(respJSON3)
  4066. // // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4067. // // utils.ErrorLog("解析失败:%v", err)
  4068. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4069. // // return
  4070. // // }
  4071. // // if res3.Infcode == 0 {
  4072. // // item.IsChange = 1
  4073. // // item.BgBchno = bg_number
  4074. // // service.SaveDF2(item)
  4075. // // } else {
  4076. // // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4077. // // }
  4078. // // }
  4079. // //}
  4080. // //else
  4081. // { //没销售,
  4082. // var res FJ3507Result
  4083. // var res3507for10188 FJ3507ResultFor10188
  4084. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4085. //
  4086. // //进行商品销售接口
  4087. // result3, result4 := SaleStock10217(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4088. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4089. // var respJSON3 map[string]interface{}
  4090. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4091. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4092. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4093. // return
  4094. // }
  4095. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4096. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4097. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4098. // utils.ErrorLog("解析失败:%v", err)
  4099. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4100. // return
  4101. // }
  4102. // //if res3507for10188.Infcode
  4103. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  4104. // //res.Output = resSix10265.Output
  4105. // res.ErrMsg = res3507for10188.ErrMsg
  4106. // res.Cainfo = res3507for10188.Cainfo
  4107. // res.WarnMsg = res3507for10188.WarnMsg
  4108. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4109. // res.Infcode = infocode
  4110. // } else {
  4111. //
  4112. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4113. // utils.ErrorLog("解析失败:%v", err)
  4114. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4115. // return
  4116. // }
  4117. //
  4118. // }
  4119. //
  4120. // if res.Infcode == 0 {
  4121. // item.IsSale = 1
  4122. // item.Bchno = number
  4123. // item.SaleDate = time.Now().Format("2006-01-02")
  4124. //
  4125. // service.SaveDF(item)
  4126. // //if err5 == nil {
  4127. // // if item.IsChange == 0 { //没变更,进行变更操作
  4128. // // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4129. // //
  4130. // // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4131. // // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4132. // //
  4133. // // var respJSON3 map[string]interface{}
  4134. // // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4135. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4136. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4137. // // return
  4138. // // }
  4139. // //
  4140. // // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4141. // // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4142. // // utils.ErrorLog("解析失败:%v", err)
  4143. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4144. // // return
  4145. // // }
  4146. // // //if res3507for10188.Infcode
  4147. // // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4148. // // //res.Output = resSix10265.Output
  4149. // // res3.ErrMsg = res3507for10188.ErrMsg
  4150. // // res3.Cainfo = res3507for10188.Cainfo
  4151. // // res3.WarnMsg = res3507for10188.WarnMsg
  4152. // // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4153. // // res3.Infcode = infocode
  4154. // // } else {
  4155. // //
  4156. // // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4157. // // utils.ErrorLog("解析失败:%v", err)
  4158. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4159. // // return
  4160. // // }
  4161. // //
  4162. // // }
  4163. // //
  4164. // // if res3.Infcode == 0 {
  4165. // // item.IsChange = 1
  4166. // // item.BgBchno = bg_number
  4167. // // service.SaveDF2(item)
  4168. // // } else {
  4169. // // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4170. // // }
  4171. // // }
  4172. // //}
  4173. // } else {
  4174. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4175. // }
  4176. // }
  4177. //
  4178. // } else { //还没结算
  4179. // var res3507for10188 FJ3507ResultFor10188
  4180. //
  4181. // if item.IsChange == 0 { //没变更,进行变更操作
  4182. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4183. //
  4184. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4185. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4186. //
  4187. // var respJSON3 map[string]interface{}
  4188. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4189. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4190. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4191. // return
  4192. // }
  4193. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4194. //
  4195. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4196. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4197. // utils.ErrorLog("解析失败:%v", err)
  4198. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4199. // return
  4200. // }
  4201. // //if res3507for10188.Infcode
  4202. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4203. // //res.Output = resSix10265.Output
  4204. // res3.ErrMsg = res3507for10188.ErrMsg
  4205. // res3.Cainfo = res3507for10188.Cainfo
  4206. // res3.WarnMsg = res3507for10188.WarnMsg
  4207. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4208. // res3.Infcode = infocode
  4209. // } else {
  4210. //
  4211. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4212. // utils.ErrorLog("解析失败:%v", err)
  4213. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4214. // return
  4215. // }
  4216. //
  4217. // }
  4218. //
  4219. // if res3.Infcode == 0 {
  4220. // item.IsChange = 1
  4221. // item.BgBchno = bg_number
  4222. // service.SaveDF2(item)
  4223. // } else {
  4224. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4225. // }
  4226. // }
  4227. // }
  4228. // }
  4229. // //if item.ConsumableType == 7 {
  4230. // // var res3507for10188 FJ3507ResultFor10188
  4231. // //
  4232. // // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4233. // // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4234. // // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4235. // // //判断是否已经销售
  4236. // // if item.IsSale == 2 { //是否已经销售,1是 0否
  4237. // // //是否已经变更 1是 0否
  4238. // // if item.IsChange == 0 { //没变更,进行变更操作
  4239. // // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4240. // //
  4241. // // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4242. // // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4243. // //
  4244. // // var respJSON3 map[string]interface{}
  4245. // // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4246. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4247. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4248. // // return
  4249. // // }
  4250. // // userJSONBytes3, _ := json.Marshal(respJSON3)
  4251. // // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4252. // // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4253. // // utils.ErrorLog("解析失败:%v", err)
  4254. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4255. // // return
  4256. // // }
  4257. // // //if res3507for10188.Infcode
  4258. // // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4259. // // //res.Output = resSix10265.Output
  4260. // // res3.ErrMsg = res3507for10188.ErrMsg
  4261. // // res3.Cainfo = res3507for10188.Cainfo
  4262. // // res3.WarnMsg = res3507for10188.WarnMsg
  4263. // // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4264. // // res3.Infcode = infocode
  4265. // // } else {
  4266. // //
  4267. // // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4268. // // utils.ErrorLog("解析失败:%v", err)
  4269. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4270. // // return
  4271. // // }
  4272. // //
  4273. // // }
  4274. // // if res3.Infcode == 0 {
  4275. // // item.IsChange = 1
  4276. // // item.BgBchno = bg_number
  4277. // // service.SaveDF2(item)
  4278. // // } else {
  4279. // // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4280. // // }
  4281. // // }
  4282. // // } else { //没销售,
  4283. // // //进行商品销售退货接口
  4284. // // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4285. // //
  4286. // // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4287. // // saveLog(result111, result222, "3506", "销售退货")
  4288. // // var res7 FJ3507Result
  4289. // //
  4290. // // //进行商品销售接口
  4291. // // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4292. // // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4293. // // var respJSON3 map[string]interface{}
  4294. // // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4295. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4296. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4297. // // return
  4298. // // }
  4299. // // userJSONBytes3, _ := json.Marshal(respJSON3)
  4300. // //
  4301. // // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4302. // // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4303. // // utils.ErrorLog("解析失败:%v", err)
  4304. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4305. // // return
  4306. // // }
  4307. // // //if res3507for10188.Infcode
  4308. // // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4309. // // //res.Output = resSix10265.Output
  4310. // // res7.ErrMsg = res3507for10188.ErrMsg
  4311. // // res7.Cainfo = res3507for10188.Cainfo
  4312. // // res7.WarnMsg = res3507for10188.WarnMsg
  4313. // // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4314. // // res7.Infcode = infocode
  4315. // // } else {
  4316. // //
  4317. // // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4318. // // utils.ErrorLog("解析失败:%v", err)
  4319. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4320. // // return
  4321. // // }
  4322. // //
  4323. // // }
  4324. // // if res7.Infcode == 0 {
  4325. // // item.IsSale = 2
  4326. // // item.SaleDate = item.SaleDate
  4327. // // item.Bchno = number
  4328. // // service.SaveDF(item)
  4329. // // if item.IsChange == 0 { //没变更,进行变更操作
  4330. // // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4331. // //
  4332. // // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4333. // // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4334. // //
  4335. // // var respJSON3 map[string]interface{}
  4336. // // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4337. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4338. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4339. // // return
  4340. // // }
  4341. // // userJSONBytes3, _ := json.Marshal(respJSON3)
  4342. // // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4343. // // // utils.ErrorLog("解析失败:%v", err)
  4344. // // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4345. // // // return
  4346. // // //}
  4347. // //
  4348. // // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4349. // // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4350. // // utils.ErrorLog("解析失败:%v", err)
  4351. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4352. // // return
  4353. // // }
  4354. // // //if res3507for10188.Infcode
  4355. // // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4356. // // //res.Output = resSix10265.Output
  4357. // // res3.ErrMsg = res3507for10188.ErrMsg
  4358. // // res3.Cainfo = res3507for10188.Cainfo
  4359. // // res3.WarnMsg = res3507for10188.WarnMsg
  4360. // // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4361. // // res3.Infcode = infocode
  4362. // // } else {
  4363. // //
  4364. // // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4365. // // utils.ErrorLog("解析失败:%v", err)
  4366. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4367. // // return
  4368. // // }
  4369. // //
  4370. // // }
  4371. // // if res3.Infcode == 0 {
  4372. // // item.IsChange = 1
  4373. // // item.BgBchno = bg_number
  4374. // // service.SaveDF2(item)
  4375. // // } else {
  4376. // // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4377. // // }
  4378. // // }
  4379. // // } else {
  4380. // // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4381. // // }
  4382. // // }
  4383. // // } else { //还没结算
  4384. // // if item.IsChange == 0 { //没变更,进行变更操作
  4385. // // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4386. // //
  4387. // // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4388. // // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4389. // //
  4390. // // var respJSON3 map[string]interface{}
  4391. // // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4392. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4393. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4394. // // return
  4395. // // }
  4396. // // userJSONBytes3, _ := json.Marshal(respJSON3)
  4397. // // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4398. // // // utils.ErrorLog("解析失败:%v", err)
  4399. // // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4400. // // // return
  4401. // // //}
  4402. // //
  4403. // // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4404. // // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4405. // // utils.ErrorLog("解析失败:%v", err)
  4406. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4407. // // return
  4408. // // }
  4409. // // //if res3507for10188.Infcode
  4410. // // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4411. // // //res.Output = resSix10265.Output
  4412. // // res3.ErrMsg = res3507for10188.ErrMsg
  4413. // // res3.Cainfo = res3507for10188.Cainfo
  4414. // // res3.WarnMsg = res3507for10188.WarnMsg
  4415. // // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4416. // // res3.Infcode = infocode
  4417. // // } else {
  4418. // //
  4419. // // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4420. // // utils.ErrorLog("解析失败:%v", err)
  4421. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4422. // // return
  4423. // // }
  4424. // //
  4425. // // }
  4426. // // if res3.Infcode == 0 {
  4427. // // item.IsChange = 1
  4428. // // item.BgBchno = bg_number
  4429. // // service.SaveDF2(item)
  4430. // // } else {
  4431. // // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4432. // // }
  4433. // // }
  4434. // // }
  4435. // //}
  4436. // }
  4437. // if len(err) == 0 {
  4438. // c.ServeSuccessJSON(map[string]interface{}{
  4439. // "msg": "销售变更成功",
  4440. // })
  4441. // } else {
  4442. // c.ServeSuccessJSON(map[string]interface{}{
  4443. // "failed_code": -10,
  4444. // "msg": err,
  4445. // })
  4446. // }
  4447. //}
  4448. //
  4449. //func (c *HisApiController) ChangeDrugthree() {
  4450. //
  4451. // //ids := c.GetString("ids")
  4452. // //id_arr := strings.Split(ids, ",")
  4453. // flows, _ := service.GetNewDrugFlowInfothree()
  4454. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4455. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4456. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4457. // var err []string
  4458. // for _, item := range flows {
  4459. // var res3 ResultSix
  4460. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4461. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4462. // if prescription.OrderStatus == 2 {
  4463. // //已经结算
  4464. // //判断是否已经销售
  4465. // if item.IsSale == 1 { //是否已经销售,1是 0否
  4466. // //是否已经变更 1是 0否
  4467. // if item.IsChange == 0 { //没变更,进行变更操作
  4468. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4469. //
  4470. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4471. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4472. // var respJSON3 map[string]interface{}
  4473. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4474. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4475. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4476. // return
  4477. // }
  4478. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4479. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4480. // utils.ErrorLog("解析失败:%v", err)
  4481. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4482. // return
  4483. // }
  4484. // if res3.Infcode == 0 {
  4485. // item.IsChange = 1
  4486. // item.BgBchno = bg_number
  4487. // service.SaveDF2(item)
  4488. // } else {
  4489. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4490. // }
  4491. // }
  4492. // } else { //没销售,
  4493. // var res FJ3507Result
  4494. // var res3507for10188 FJ3507ResultFor10188
  4495. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4496. //
  4497. // //进行商品销售接口
  4498. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4499. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4500. // var respJSON3 map[string]interface{}
  4501. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4502. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4503. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4504. // return
  4505. // }
  4506. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4507. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4508. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4509. // utils.ErrorLog("解析失败:%v", err)
  4510. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4511. // return
  4512. // }
  4513. // //if res3507for10188.Infcode
  4514. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  4515. // //res.Output = resSix10265.Output
  4516. // res.ErrMsg = res3507for10188.ErrMsg
  4517. // res.Cainfo = res3507for10188.Cainfo
  4518. // res.WarnMsg = res3507for10188.WarnMsg
  4519. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4520. // res.Infcode = infocode
  4521. // } else {
  4522. //
  4523. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4524. // utils.ErrorLog("解析失败:%v", err)
  4525. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4526. // return
  4527. // }
  4528. //
  4529. // }
  4530. //
  4531. // if res.Infcode == 0 {
  4532. // item.IsSale = 1
  4533. // item.Bchno = number
  4534. // item.SaleDate = time.Now().Format("2006-01-02")
  4535. //
  4536. // err5 := service.SaveDF(item)
  4537. // if err5 == nil {
  4538. // if item.IsChange == 0 { //没变更,进行变更操作
  4539. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4540. //
  4541. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4542. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4543. //
  4544. // var respJSON3 map[string]interface{}
  4545. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4546. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4547. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4548. // return
  4549. // }
  4550. //
  4551. // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4552. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4553. // utils.ErrorLog("解析失败:%v", err)
  4554. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4555. // return
  4556. // }
  4557. // //if res3507for10188.Infcode
  4558. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4559. // //res.Output = resSix10265.Output
  4560. // res3.ErrMsg = res3507for10188.ErrMsg
  4561. // res3.Cainfo = res3507for10188.Cainfo
  4562. // res3.WarnMsg = res3507for10188.WarnMsg
  4563. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4564. // res3.Infcode = infocode
  4565. // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4566. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4567. // utils.ErrorLog("解析失败:%v", err)
  4568. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4569. // return
  4570. // }
  4571. // //if res3507for10188.Infcode
  4572. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4573. // //res.Output = resSix10265.Output
  4574. // res3.ErrMsg = res3507for10188.ErrMsg
  4575. // res3.Cainfo = res3507for10188.Cainfo
  4576. // res3.WarnMsg = res3507for10188.WarnMsg
  4577. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4578. // res3.Infcode = infocode
  4579. //
  4580. // } else {
  4581. //
  4582. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4583. // utils.ErrorLog("解析失败:%v", err)
  4584. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4585. // return
  4586. // }
  4587. //
  4588. // }
  4589. //
  4590. // if res3.Infcode == 0 {
  4591. // item.IsChange = 1
  4592. // item.BgBchno = bg_number
  4593. // service.SaveDF2(item)
  4594. // } else {
  4595. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4596. // }
  4597. // }
  4598. // }
  4599. // } else {
  4600. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4601. // }
  4602. // }
  4603. //
  4604. // } else { //还没结算
  4605. // var res3507for10188 FJ3507ResultFor10188
  4606. //
  4607. // if item.IsChange == 0 { //没变更,进行变更操作
  4608. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4609. //
  4610. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4611. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4612. //
  4613. // var respJSON3 map[string]interface{}
  4614. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4615. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4616. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4617. // return
  4618. // }
  4619. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4620. //
  4621. // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4622. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4623. // utils.ErrorLog("解析失败:%v", err)
  4624. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4625. // return
  4626. // }
  4627. // //if res3507for10188.Infcode
  4628. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4629. // //res.Output = resSix10265.Output
  4630. // res3.ErrMsg = res3507for10188.ErrMsg
  4631. // res3.Cainfo = res3507for10188.Cainfo
  4632. // res3.WarnMsg = res3507for10188.WarnMsg
  4633. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4634. // res3.Infcode = infocode
  4635. // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4636. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4637. // utils.ErrorLog("解析失败:%v", err)
  4638. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4639. // return
  4640. // }
  4641. // //if res3507for10188.Infcode
  4642. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4643. // //res.Output = resSix10265.Output
  4644. // res3.ErrMsg = res3507for10188.ErrMsg
  4645. // res3.Cainfo = res3507for10188.Cainfo
  4646. // res3.WarnMsg = res3507for10188.WarnMsg
  4647. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4648. // res3.Infcode = infocode
  4649. //
  4650. // } else {
  4651. //
  4652. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4653. // utils.ErrorLog("解析失败:%v", err)
  4654. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4655. // return
  4656. // }
  4657. //
  4658. // }
  4659. //
  4660. // if res3.Infcode == 0 {
  4661. // item.IsChange = 1
  4662. // item.BgBchno = bg_number
  4663. // service.SaveDF2(item)
  4664. // } else {
  4665. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4666. // }
  4667. // }
  4668. // }
  4669. // } else if item.ConsumableType == 7 {
  4670. // var res3507for10188 FJ3507ResultFor10188
  4671. //
  4672. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4673. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4674. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4675. // //判断是否已经销售
  4676. // if item.IsSale == 2 { //是否已经销售,1是 0否
  4677. // //是否已经变更 1是 0否
  4678. // if item.IsChange == 0 { //没变更,进行变更操作
  4679. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4680. //
  4681. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4682. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4683. //
  4684. // var respJSON3 map[string]interface{}
  4685. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4686. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4687. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4688. // return
  4689. // }
  4690. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4691. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4692. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4693. // utils.ErrorLog("解析失败:%v", err)
  4694. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4695. // return
  4696. // }
  4697. // //if res3507for10188.Infcode
  4698. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4699. // //res.Output = resSix10265.Output
  4700. // res3.ErrMsg = res3507for10188.ErrMsg
  4701. // res3.Cainfo = res3507for10188.Cainfo
  4702. // res3.WarnMsg = res3507for10188.WarnMsg
  4703. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4704. // res3.Infcode = infocode
  4705. // } else {
  4706. //
  4707. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4708. // utils.ErrorLog("解析失败:%v", err)
  4709. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4710. // return
  4711. // }
  4712. //
  4713. // }
  4714. // if res3.Infcode == 0 {
  4715. // item.IsChange = 1
  4716. // item.BgBchno = bg_number
  4717. // service.SaveDF2(item)
  4718. // } else {
  4719. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4720. // }
  4721. // }
  4722. // } else { //没销售,
  4723. // //进行商品销售退货接口
  4724. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4725. //
  4726. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4727. // saveLog(result111, result222, "3506", "销售退货")
  4728. // var res7 FJ3507Result
  4729. //
  4730. // //进行商品销售接口
  4731. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4732. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4733. // var respJSON3 map[string]interface{}
  4734. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4735. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4736. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4737. // return
  4738. // }
  4739. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4740. //
  4741. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4742. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4743. // utils.ErrorLog("解析失败:%v", err)
  4744. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4745. // return
  4746. // }
  4747. // //if res3507for10188.Infcode
  4748. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4749. // //res.Output = resSix10265.Output
  4750. // res7.ErrMsg = res3507for10188.ErrMsg
  4751. // res7.Cainfo = res3507for10188.Cainfo
  4752. // res7.WarnMsg = res3507for10188.WarnMsg
  4753. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4754. // res7.Infcode = infocode
  4755. // } else {
  4756. //
  4757. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4758. // utils.ErrorLog("解析失败:%v", err)
  4759. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4760. // return
  4761. // }
  4762. //
  4763. // }
  4764. // if res7.Infcode == 0 {
  4765. // item.IsSale = 2
  4766. // item.SaleDate = item.SaleDate
  4767. // item.Bchno = number
  4768. // service.SaveDF(item)
  4769. // if item.IsChange == 0 { //没变更,进行变更操作
  4770. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4771. //
  4772. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4773. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4774. //
  4775. // var respJSON3 map[string]interface{}
  4776. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4777. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4778. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4779. // return
  4780. // }
  4781. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4782. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4783. // // utils.ErrorLog("解析失败:%v", err)
  4784. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4785. // // return
  4786. // //}
  4787. //
  4788. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4789. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4790. // utils.ErrorLog("解析失败:%v", err)
  4791. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4792. // return
  4793. // }
  4794. // //if res3507for10188.Infcode
  4795. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4796. // //res.Output = resSix10265.Output
  4797. // res3.ErrMsg = res3507for10188.ErrMsg
  4798. // res3.Cainfo = res3507for10188.Cainfo
  4799. // res3.WarnMsg = res3507for10188.WarnMsg
  4800. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4801. // res3.Infcode = infocode
  4802. // } else {
  4803. //
  4804. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4805. // utils.ErrorLog("解析失败:%v", err)
  4806. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4807. // return
  4808. // }
  4809. //
  4810. // }
  4811. // if res3.Infcode == 0 {
  4812. // item.IsChange = 1
  4813. // item.BgBchno = bg_number
  4814. // service.SaveDF2(item)
  4815. // } else {
  4816. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4817. // }
  4818. // }
  4819. // } else {
  4820. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4821. // }
  4822. // }
  4823. // } else { //还没结算
  4824. // if item.IsChange == 0 { //没变更,进行变更操作
  4825. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4826. //
  4827. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4828. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4829. //
  4830. // var respJSON3 map[string]interface{}
  4831. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4832. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4833. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4834. // return
  4835. // }
  4836. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4837. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4838. // // utils.ErrorLog("解析失败:%v", err)
  4839. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4840. // // return
  4841. // //}
  4842. //
  4843. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4844. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4845. // utils.ErrorLog("解析失败:%v", err)
  4846. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4847. // return
  4848. // }
  4849. // //if res3507for10188.Infcode
  4850. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4851. // //res.Output = resSix10265.Output
  4852. // res3.ErrMsg = res3507for10188.ErrMsg
  4853. // res3.Cainfo = res3507for10188.Cainfo
  4854. // res3.WarnMsg = res3507for10188.WarnMsg
  4855. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4856. // res3.Infcode = infocode
  4857. // } else {
  4858. //
  4859. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4860. // utils.ErrorLog("解析失败:%v", err)
  4861. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4862. // return
  4863. // }
  4864. //
  4865. // }
  4866. // if res3.Infcode == 0 {
  4867. // item.IsChange = 1
  4868. // item.BgBchno = bg_number
  4869. // service.SaveDF2(item)
  4870. // } else {
  4871. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4872. // }
  4873. // }
  4874. // }
  4875. // }
  4876. // }
  4877. // if len(err) == 0 {
  4878. // c.ServeSuccessJSON(map[string]interface{}{
  4879. // "msg": "销售变更成功",
  4880. // })
  4881. // } else {
  4882. // c.ServeSuccessJSON(map[string]interface{}{
  4883. // "failed_code": -10,
  4884. // "msg": err,
  4885. // })
  4886. // }
  4887. //}
  4888. //func (c *HisApiController) ChangeDrugTen() {
  4889. // start_time_str := c.GetString("start_time")
  4890. // end_time_str := c.GetString("end_time")
  4891. // //ids := c.GetString("ids")
  4892. // //id_arr := strings.Split(ids, ",")
  4893. // timeLayout := "2006-01-02"
  4894. // loc, _ := time.LoadLocation("Local")
  4895. // theStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4896. //
  4897. // recordStartTime := theStartTime.Unix()
  4898. //
  4899. // theEndTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4900. //
  4901. // recordEndTime := theEndTime.Unix()
  4902. //
  4903. // //timestamp := int64(1729612800)
  4904. // flows, _ := service.GetNewDrugFlowInforTenone(recordStartTime, recordEndTime, c.GetAdminUserInfo().CurrentOrgId)
  4905. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4906. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4907. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4908. // var err []string
  4909. // for _, item := range flows {
  4910. // var res3 ResultSix
  4911. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4912. // if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4913. // continue
  4914. // }
  4915. // if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4916. // continue
  4917. // }
  4918. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4919. //
  4920. // if prescription.OrderStatus == 2 {
  4921. // //已经结算
  4922. // //判断 是否已经销售
  4923. // //if item.IsSale == 1 { //是否已经销售,1是 0否
  4924. // ////是否已经变更 1是 0否
  4925. // //if item.IsChange == 0 { //没变更,进行变更操作
  4926. // // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4927. // //
  4928. // // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4929. // // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4930. // // var respJSON3 map[string]interface{}
  4931. // // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4932. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4933. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4934. // // return
  4935. // // }
  4936. // // userJSONBytes3, _ := json.Marshal(respJSON3)
  4937. // // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4938. // // utils.ErrorLog("解析失败:%v", err)
  4939. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4940. // // return
  4941. // // }
  4942. // // if res3.Infcode == 0 {
  4943. // // item.IsChange = 1
  4944. // // item.BgBchno = bg_number
  4945. // // service.SaveDF2(item)
  4946. // // } else {
  4947. // // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4948. // // }
  4949. // //}
  4950. //
  4951. // //} else
  4952. // if item.IsSale == 0 { //没销售,
  4953. // var res FJ3507Result
  4954. // var res3507for10188 FJ3507ResultFor10188
  4955. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4956. //
  4957. // //进行商品销售接口
  4958. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4959. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4960. // var respJSON3 map[string]interface{}
  4961. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4962. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4963. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4964. // return
  4965. // }
  4966. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4967. // if c.GetAdminUserInfo().CurrentOrgId == 10265 || c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 || c.GetAdminUserInfo().CurrentOrgId == 10633 {
  4968. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4969. // utils.ErrorLog("解析失败:%v", err)
  4970. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4971. // return
  4972. // }
  4973. // //if res3507for10188.Infcode
  4974. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  4975. // //res.Output = resSix10265.Output
  4976. // res.ErrMsg = res3507for10188.ErrMsg
  4977. // res.Cainfo = res3507for10188.Cainfo
  4978. // res.WarnMsg = res3507for10188.WarnMsg
  4979. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4980. // res.Infcode = infocode
  4981. // } else if c.GetAdminUserInfo().CurrentOrgId == 10480 {
  4982. //
  4983. // } else {
  4984. //
  4985. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4986. // utils.ErrorLog("解析失败:%v", err)
  4987. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4988. // return
  4989. // }
  4990. //
  4991. // }
  4992. //
  4993. // if res.Infcode == 0 {
  4994. // item.IsSale = 1
  4995. // item.Bchno = number
  4996. // item.SaleDate = time.Now().Format("2006-01-02")
  4997. // service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  4998. //
  4999. // err5 := service.SaveDF(item)
  5000. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err5)
  5001. // //if err5 == nil {
  5002. // //
  5003. // // if item.IsChange == 1 { //没变更,进行变更操作
  5004. // // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5005. // //
  5006. // // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  5007. // // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  5008. // //
  5009. // // var respJSON3 map[string]interface{}
  5010. // // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5011. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5012. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5013. // // return
  5014. // // }
  5015. // //
  5016. // // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  5017. // // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5018. // // utils.ErrorLog("解析失败:%v", err)
  5019. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5020. // // return
  5021. // // }
  5022. // // //if res3507for10188.Infcode
  5023. // // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5024. // // //res.Output = resSix10265.Output
  5025. // // res3.ErrMsg = res3507for10188.ErrMsg
  5026. // // res3.Cainfo = res3507for10188.Cainfo
  5027. // // res3.WarnMsg = res3507for10188.WarnMsg
  5028. // // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5029. // // res3.Infcode = infocode
  5030. // // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5031. // // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5032. // // utils.ErrorLog("解析失败:%v", err)
  5033. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5034. // // return
  5035. // // }
  5036. // // //if res3507for10188.Infcode
  5037. // // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5038. // // //res.Output = resSix10265.Output
  5039. // // res3.ErrMsg = res3507for10188.ErrMsg
  5040. // // res3.Cainfo = res3507for10188.Cainfo
  5041. // // res3.WarnMsg = res3507for10188.WarnMsg
  5042. // // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5043. // // res3.Infcode = infocode
  5044. // //
  5045. // // } else {
  5046. // //
  5047. // // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5048. // // utils.ErrorLog("解析失败:%v", err)
  5049. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5050. // // return
  5051. // // }
  5052. // //
  5053. // // }
  5054. // //
  5055. // // if res3.Infcode == 0 {
  5056. // // item.IsChange = 1
  5057. // // item.BgBchno = bg_number
  5058. // // service.SaveDF2(item)
  5059. // // return
  5060. // // } else {
  5061. // // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5062. // // }
  5063. // // }
  5064. // //}
  5065. // } else {
  5066. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  5067. // }
  5068. // }
  5069. //
  5070. // }
  5071. // } else if item.ConsumableType == 7 {
  5072. // var res3507for10188 FJ3507ResultFor10188
  5073. //
  5074. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  5075. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  5076. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  5077. // //判断是否已经销售
  5078. // if item.IsSale == 2 { //是否已经销售,1是 0否
  5079. // //是否已经变更 1是 0否
  5080. // if item.IsChange == 0 { //没变更,进行变更操作
  5081. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5082. //
  5083. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  5084. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  5085. //
  5086. // var respJSON3 map[string]interface{}
  5087. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5088. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5089. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5090. // return
  5091. // }
  5092. // userJSONBytes3, _ := json.Marshal(respJSON3)
  5093. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5094. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5095. // utils.ErrorLog("解析失败:%v", err)
  5096. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5097. // return
  5098. // }
  5099. // //if res3507for10188.Infcode
  5100. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5101. // //res.Output = resSix10265.Output
  5102. // res3.ErrMsg = res3507for10188.ErrMsg
  5103. // res3.Cainfo = res3507for10188.Cainfo
  5104. // res3.WarnMsg = res3507for10188.WarnMsg
  5105. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5106. // res3.Infcode = infocode
  5107. // } else {
  5108. //
  5109. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5110. // utils.ErrorLog("解析失败:%v", err)
  5111. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5112. // return
  5113. // }
  5114. //
  5115. // }
  5116. // if res3.Infcode == 0 {
  5117. // item.IsChange = 1
  5118. // item.BgBchno = bg_number
  5119. // service.SaveDF2(item)
  5120. // } else {
  5121. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5122. // }
  5123. // }
  5124. // } else { //没销售,
  5125. // //进行商品销售退货接口
  5126. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  5127. //
  5128. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  5129. // saveLog(result111, result222, "3506", "销售退货")
  5130. // var res7 FJ3507Result
  5131. //
  5132. // //进行商品销售接口
  5133. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  5134. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  5135. // var respJSON3 map[string]interface{}
  5136. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  5137. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5138. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5139. // return
  5140. // }
  5141. // userJSONBytes3, _ := json.Marshal(respJSON3)
  5142. //
  5143. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5144. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5145. // utils.ErrorLog("解析失败:%v", err)
  5146. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5147. // return
  5148. // }
  5149. // //if res3507for10188.Infcode
  5150. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  5151. // //res.Output = resSix10265.Output
  5152. // res7.ErrMsg = res3507for10188.ErrMsg
  5153. // res7.Cainfo = res3507for10188.Cainfo
  5154. // res7.WarnMsg = res3507for10188.WarnMsg
  5155. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5156. // res7.Infcode = infocode
  5157. // } else {
  5158. //
  5159. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  5160. // utils.ErrorLog("解析失败:%v", err)
  5161. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5162. // return
  5163. // }
  5164. //
  5165. // }
  5166. // if res7.Infcode == 0 {
  5167. // item.IsSale = 2
  5168. // item.SaleDate = item.SaleDate
  5169. // item.Bchno = number
  5170. // service.SaveDF(item)
  5171. // if item.IsChange == 0 { //没变更,进行变更操作
  5172. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5173. //
  5174. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  5175. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  5176. //
  5177. // var respJSON3 map[string]interface{}
  5178. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5179. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5180. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5181. // return
  5182. // }
  5183. // userJSONBytes3, _ := json.Marshal(respJSON3)
  5184. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5185. // // utils.ErrorLog("解析失败:%v", err)
  5186. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5187. // // return
  5188. // //}
  5189. //
  5190. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5191. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5192. // utils.ErrorLog("解析失败:%v", err)
  5193. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5194. // return
  5195. // }
  5196. // //if res3507for10188.Infcode
  5197. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5198. // //res.Output = resSix10265.Output
  5199. // res3.ErrMsg = res3507for10188.ErrMsg
  5200. // res3.Cainfo = res3507for10188.Cainfo
  5201. // res3.WarnMsg = res3507for10188.WarnMsg
  5202. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5203. // res3.Infcode = infocode
  5204. // } else {
  5205. //
  5206. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5207. // utils.ErrorLog("解析失败:%v", err)
  5208. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5209. // return
  5210. // }
  5211. //
  5212. // }
  5213. // if res3.Infcode == 0 {
  5214. // item.IsChange = 1
  5215. // item.BgBchno = bg_number
  5216. // service.SaveDF2(item)
  5217. // } else {
  5218. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5219. // }
  5220. // }
  5221. // } else {
  5222. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  5223. // }
  5224. // }
  5225. // } else { //还没结算
  5226. // if item.IsChange == 0 { //没变更,进行变更操作
  5227. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5228. //
  5229. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  5230. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  5231. //
  5232. // var respJSON3 map[string]interface{}
  5233. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5234. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5235. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5236. // return
  5237. // }
  5238. // userJSONBytes3, _ := json.Marshal(respJSON3)
  5239. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5240. // // utils.ErrorLog("解析失败:%v", err)
  5241. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5242. // // return
  5243. // //}
  5244. //
  5245. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5246. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5247. // utils.ErrorLog("解析失败:%v", err)
  5248. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5249. // return
  5250. // }
  5251. // //if res3507for10188.Infcode
  5252. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5253. // //res.Output = resSix10265.Output
  5254. // res3.ErrMsg = res3507for10188.ErrMsg
  5255. // res3.Cainfo = res3507for10188.Cainfo
  5256. // res3.WarnMsg = res3507for10188.WarnMsg
  5257. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5258. // res3.Infcode = infocode
  5259. // } else {
  5260. //
  5261. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5262. // utils.ErrorLog("解析失败:%v", err)
  5263. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5264. // return
  5265. // }
  5266. //
  5267. // }
  5268. // if res3.Infcode == 0 {
  5269. // item.IsChange = 1
  5270. // item.BgBchno = bg_number
  5271. // service.SaveDF2(item)
  5272. // } else {
  5273. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5274. // }
  5275. // }
  5276. // }
  5277. // }
  5278. // }
  5279. // if len(err) == 0 {
  5280. // c.ServeSuccessJSON(map[string]interface{}{
  5281. // "msg": "销售变更成功",
  5282. // })
  5283. // } else {
  5284. // c.ServeSuccessJSON(map[string]interface{}{
  5285. // "failed_code": -10,
  5286. // "msg": err,
  5287. // })
  5288. // }
  5289. //}
  5290. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5291. var struct3502 models.Struct3502
  5292. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5293. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5294. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5295. struct3502.FixmedinsCode = miConfig.Code
  5296. struct3502.Code = miConfig.Code
  5297. struct3502.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5298. struct3502.Opter = role.UserName
  5299. struct3502.RxFlag = "1"
  5300. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  5301. struct3502.OrgName = miConfig.OrgName
  5302. struct3502.AccessKey = miConfig.AccessKey
  5303. struct3502.RequestUrl = miConfig.Url
  5304. struct3502.SecretKey = miConfig.SecretKey
  5305. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5306. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5307. struct3502.Url = miConfig.Url
  5308. struct3502.AppId = miConfig.Cainfo
  5309. struct3502.AppSecret = miConfig.AppSecret
  5310. struct3502.Enckey = miConfig.EncKey
  5311. struct3502.SignKey = miConfig.SignKey
  5312. struct3502.SecretKey = miConfig.SecretKey
  5313. struct3502.InvChgType = chgType
  5314. struct3502.FixmedinsBchno = number
  5315. struct3502.Cnt = strconv.FormatInt(count, 10)
  5316. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  5317. //result1, result2, _ := service.FJyb3502(struct3502)
  5318. if miConfig.MdtrtareaAdmvs == "350500" {
  5319. result1, result2, _ := service.FJyb3502(struct3502)
  5320. //saveLog(result1, result2, "3502", "3502")
  5321. return result1, result2
  5322. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5323. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  5324. return result1, result2
  5325. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5326. result1, result2 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  5327. return result1, result2
  5328. } else {
  5329. data := make(map[string]interface{})
  5330. data["struct_3502s"] = struct3502
  5331. client := &http.Client{}
  5332. bytesData, _ := json.Marshal(data)
  5333. var req *http.Request
  5334. if miConfig.MdtrtareaAdmvs == "320830" {
  5335. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3502", bytes.NewReader(bytesData))
  5336. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5337. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  5338. } else {
  5339. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  5340. }
  5341. resp, _ := client.Do(req)
  5342. defer resp.Body.Close()
  5343. body, ioErr := ioutil.ReadAll(resp.Body)
  5344. if ioErr != nil {
  5345. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5346. }
  5347. var respJSON map[string]interface{}
  5348. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5349. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5350. }
  5351. //var resSix10265 ResultSix10265 //1101结果
  5352. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5353. result, _ := json.Marshal(respJSON)
  5354. return string(result), ""
  5355. }
  5356. }
  5357. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.HisDoctorAdviceInfo, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string,stime int64) (string, string) {
  5358. flow, _ := service.GetNewDrugFlowInfoByPatient(drug.DrugId, stime, org_id)
  5359. Drug ,_ := service.GetDrugLibById( drug.DrugId)
  5360. var struct3505 models.Struct3505
  5361. struct3505.MedListCodg = Drug.MedicalInsuranceNumber
  5362. struct3505.FixmedinsHilistId = Drug.MedicalInsuranceNumber
  5363. struct3505.FixmedinsHilistName = Drug.DrugName
  5364. struct3505.FixmedinsBchno = number
  5365. struct3505.Opter = role.UserName
  5366. struct3505.Bchno = "---"
  5367. struct3505.FixmedinsCode = miConfig.Code
  5368. struct3505.Code = miConfig.Code
  5369. struct3505.FinlTrnsPric = strconv.FormatFloat(drug.Price, 'f', -1, 64)
  5370. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5371. struct3505.PrscDrName = roles.UserName
  5372. if org_id == 10191 {
  5373. struct3505.PharName = "刘水山"
  5374. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5375. }
  5376. if org_id == 10188 {
  5377. struct3505.PharName = "李汉清"
  5378. struct3505.PharPracCertNo = "30220200932022010034"
  5379. }
  5380. if org_id == 10217 {
  5381. struct3505.PharName = "张敏"
  5382. struct3505.PharPracCertNo = "30220230432090100108"
  5383. }
  5384. if org_id == 10318 {
  5385. struct3505.PharName = "邹刘阳"
  5386. struct3505.PharPracCertNo = "210441200001378"
  5387. }
  5388. if org_id == 10402 {
  5389. struct3505.PharName = "刘韶健"
  5390. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5391. }
  5392. if org_id == 9919 {
  5393. struct3505.PharName = "周君权"
  5394. struct3505.PharPracCertNo = "089644396094401375"
  5395. }
  5396. if org_id == 10644 {
  5397. struct3505.PharName = "陈金娣"
  5398. struct3505.PharPracCertNo = "20181441500320100066"
  5399. }
  5400. if org_id == 10567 {
  5401. struct3505.PharName = "范小兰"
  5402. struct3505.PharPracCertNo = "0200102079485"
  5403. }
  5404. if org_id == 10721 {
  5405. struct3505.PharName = "孙莉侠"
  5406. struct3505.PharPracCertNo = "060399"
  5407. }
  5408. if org_id == 10726 {
  5409. struct3505.PharName = "彭建福"
  5410. struct3505.PharPracCertNo = "D445281006261"
  5411. }
  5412. if org_id == 10697 {
  5413. struct3505.PharName = "陶海兰"
  5414. struct3505.PharPracCertNo = "0010933"
  5415. }
  5416. if org_id == 10265 {
  5417. struct3505.PharName = "李彩星"
  5418. struct3505.PharPracCertNo = "20171110600110100019"
  5419. }
  5420. if org_id == 10028 {
  5421. struct3505.PharName = "曾细平"
  5422. struct3505.PharPracCertNo = "D440307022134"
  5423. }
  5424. if org_id == 10138 {
  5425. struct3505.PharName = "彭斯遥"
  5426. struct3505.PharPracCertNo = "30220200943042010052"
  5427. }
  5428. if org_id == 10278 {
  5429. struct3505.PharName = "彭斯遥"
  5430. struct3505.PharPracCertNo = "30220200943042010052"
  5431. }
  5432. if org_id == 10610 {
  5433. struct3505.PharName = "彭斯遥"
  5434. struct3505.PharPracCertNo = "30220200943042010052"
  5435. }
  5436. if org_id == 10537 {
  5437. struct3505.PharName = "彭斯遥"
  5438. struct3505.PharPracCertNo = "30220200943042010052"
  5439. }
  5440. if org_id == 9504 {
  5441. struct3505.PharName = "资美红"
  5442. struct3505.PharPracCertNo = "D440904006635"
  5443. }
  5444. if org_id == 10480 {
  5445. struct3505.PharName = "陈思"
  5446. struct3505.PharPracCertNo = "30220240434110010470"
  5447. }
  5448. if org_id == 10653 {
  5449. struct3505.PharName = "邓树英"
  5450. struct3505.PharPracCertNo = "201910026440004734"
  5451. }
  5452. if org_id == 10571 {
  5453. struct3505.PharName = "廖志平"
  5454. struct3505.PharPracCertNo = "0136425"
  5455. }
  5456. if org_id == 10387 {
  5457. struct3505.PharName = "易圣"
  5458. struct3505.PharPracCertNo = "D430726002209"
  5459. }
  5460. if org_id == 10633 {
  5461. struct3505.PharName = "王敏"
  5462. struct3505.PharPracCertNo = "342222199107214042"
  5463. }
  5464. if org_id == 9478 {
  5465. struct3505.PharName = "祁仲钰"
  5466. struct3505.PharPracCertNo = "D440111043488"
  5467. }
  5468. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5469. struct3505.SetlId = order.SetlId
  5470. struct3505.MdtrtSn = order.MdtrtId
  5471. struct3505.ManuLotnum = flow.BatchNumber
  5472. struct3505.ManuDate = time.Unix(flow.ProductDate, 0).Format("2006-01-02")
  5473. struct3505.ExpyEnd = time.Unix(flow.ExpireDate, 0).Format("2006-01-02")
  5474. struct3505.RxFlag = "1"
  5475. if drug.PrescribingNumberUnit != drug.BaseDrugLib.MinUnit {
  5476. struct3505.TrdnFlag = "0"
  5477. } else {
  5478. struct3505.TrdnFlag = "1"
  5479. }
  5480. if drug.ZeroFlag == 1 {
  5481. struct3505.TrdnFlag = "1"
  5482. }
  5483. if drug.ZeroFlag == 2 {
  5484. struct3505.TrdnFlag = "0"
  5485. }
  5486. if org_id == 10610 || org_id == 10278 || org_id == 10138 || org_id == 10537 || org_id == 10028 || org_id == 10191 || org_id == 9478{
  5487. if Drug.IsZeroFlag == 1 {
  5488. struct3505.TrdnFlag = "1"
  5489. }
  5490. if Drug.IsZeroFlag == 2 {
  5491. struct3505.TrdnFlag = "0"
  5492. }
  5493. }
  5494. struct3505.RtalDocno = order.Number
  5495. struct3505.PsnCertType = "01"
  5496. struct3505.CertNo = order.Certno
  5497. struct3505.PsnNo = order.PsnNo
  5498. struct3505.PsnName = order.PsnName
  5499. struct3505.Url = miConfig.Url
  5500. struct3505.AppId = miConfig.Cainfo
  5501. struct3505.AppSecret = miConfig.AppSecret
  5502. struct3505.Enckey = miConfig.EncKey
  5503. struct3505.SignKey = miConfig.SignKey
  5504. struct3505.SecretKey = miConfig.SecretKey
  5505. strValue := fmt.Sprintf("%.2f", drug.PrescribingNumber)
  5506. struct3505.SelRetnCnt = strValue
  5507. struct3505.SelRetnTime = time.Unix(drug.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5508. struct3505.SelRetnOpterName = role.UserName
  5509. if order.IsMedicineInsurance == 1 {
  5510. struct3505.MdtrtSetlType = "1"
  5511. } else {
  5512. struct3505.MdtrtSetlType = "2"
  5513. }
  5514. struct3505.OrgName = miConfig.OrgName
  5515. struct3505.AccessKey = miConfig.AccessKey
  5516. struct3505.RequestUrl = miConfig.Url
  5517. struct3505.SecretKey = miConfig.SecretKey
  5518. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5519. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5520. struct3505.Cainfo = miConfig.Cainfo
  5521. struct3505.DrugTracCodg = drug.DrugCode
  5522. if miConfig.MdtrtareaAdmvs == "350500" {
  5523. result1, result2, _ := service.FJyb3505(struct3505)
  5524. return result1, result2
  5525. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5526. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5527. return result1, result2
  5528. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5529. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5530. return result1, result2
  5531. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5532. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5533. return result1, result2
  5534. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "360") {
  5535. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5536. return result1, result2
  5537. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5538. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5539. return result1, result2
  5540. } else if miConfig.MdtrtareaAdmvs == "150404" {
  5541. data := make(map[string]interface{})
  5542. data["struct_3505s"] = struct3505
  5543. client := &http.Client{}
  5544. bytesData, _ := json.Marshal(data)
  5545. var req *http.Request
  5546. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3505", bytes.NewReader(bytesData))
  5547. resp, _ := client.Do(req)
  5548. defer resp.Body.Close()
  5549. body, ioErr := ioutil.ReadAll(resp.Body)
  5550. if ioErr != nil {
  5551. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5552. }
  5553. var respJSON map[string]interface{}
  5554. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5555. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5556. }
  5557. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5558. result, _ := json.Marshal(respJSON)
  5559. return string(result), ""
  5560. } else if miConfig.MdtrtareaAdmvs == "341203" {
  5561. data := make(map[string]interface{})
  5562. data["struct_3505s"] = struct3505
  5563. client := &http.Client{}
  5564. bytesData, _ := json.Marshal(data)
  5565. var req *http.Request
  5566. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3505", bytes.NewReader(bytesData))
  5567. resp, _ := client.Do(req)
  5568. defer resp.Body.Close()
  5569. body, ioErr := ioutil.ReadAll(resp.Body)
  5570. if ioErr != nil {
  5571. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5572. }
  5573. var respJSON map[string]interface{}
  5574. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5575. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5576. }
  5577. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5578. if status == "0" {
  5579. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5580. utils.ErrorLog("接口返回数据读取失败: %v", err_msg)
  5581. }
  5582. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5583. result, _ := json.Marshal(respJSON)
  5584. return string(result), ""
  5585. } else if miConfig.MdtrtareaAdmvs == "430800" {
  5586. result1, result2 := service.Hnyb3505(struct3505)
  5587. return result1, result2
  5588. } else {
  5589. data := make(map[string]interface{})
  5590. data["struct_3505s"] = struct3505
  5591. client := &http.Client{}
  5592. bytesData, _ := json.Marshal(data)
  5593. var req *http.Request
  5594. if miConfig.MdtrtareaAdmvs == "320830" {
  5595. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3505", bytes.NewReader(bytesData))
  5596. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5597. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5598. } else {
  5599. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5600. }
  5601. resp, _ := client.Do(req)
  5602. defer resp.Body.Close()
  5603. body, ioErr := ioutil.ReadAll(resp.Body)
  5604. if ioErr != nil {
  5605. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5606. }
  5607. var respJSON map[string]interface{}
  5608. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5609. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5610. }
  5611. //var resSix10265 ResultSix10265 //1101结果
  5612. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5613. result, _ := json.Marshal(respJSON)
  5614. return string(result), ""
  5615. }
  5616. }
  5617. func SaleStock10217(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5618. var struct3505 models.Struct3505
  5619. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5620. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5621. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5622. struct3505.FixmedinsBchno = number
  5623. struct3505.Opter = role.UserName
  5624. struct3505.FixmedinsCode = miConfig.Code
  5625. struct3505.Code = miConfig.Code
  5626. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5627. struct3505.PrscDrName = roles.UserName
  5628. if org_id == 10191 {
  5629. struct3505.PharName = "刘水山"
  5630. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5631. }
  5632. if org_id == 10188 {
  5633. struct3505.PharName = "李汉清"
  5634. struct3505.PharPracCertNo = "30220200932022010034"
  5635. }
  5636. if org_id == 10217 {
  5637. struct3505.PharName = "张敏"
  5638. struct3505.PharPracCertNo = "30220230432090100108"
  5639. }
  5640. if org_id == 10318 {
  5641. struct3505.PharName = "邹刘阳"
  5642. struct3505.PharPracCertNo = "210441200001378"
  5643. }
  5644. if org_id == 10402 {
  5645. struct3505.PharName = "刘韶健"
  5646. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5647. }
  5648. if org_id == 9919 {
  5649. struct3505.PharName = "周君权"
  5650. struct3505.PharPracCertNo = "089644396094401375"
  5651. }
  5652. if org_id == 10644 {
  5653. struct3505.PharName = "陈金娣"
  5654. struct3505.PharPracCertNo = "20181441500320100066"
  5655. }
  5656. if org_id == 10567 {
  5657. struct3505.PharName = "范小兰"
  5658. struct3505.PharPracCertNo = "0200102079485"
  5659. }
  5660. if org_id == 10721 {
  5661. struct3505.PharName = "孙莉侠"
  5662. struct3505.PharPracCertNo = "060399"
  5663. }
  5664. if org_id == 10726 {
  5665. struct3505.PharName = "彭建福"
  5666. struct3505.PharPracCertNo = "D445281006261"
  5667. }
  5668. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5669. struct3505.SetlId = order.SetlId
  5670. struct3505.MdtrtSn = order.MdtrtId
  5671. struct3505.ManuLotnum = drug.Number
  5672. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5673. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5674. struct3505.RxFlag = "1"
  5675. struct3505.TrdnFlag = "0"
  5676. struct3505.RtalDocno = order.Number
  5677. struct3505.PsnCertType = "01"
  5678. struct3505.CertNo = order.Certno
  5679. struct3505.PsnNo = order.PsnNo
  5680. struct3505.PsnName = order.PsnName
  5681. struct3505.Url = miConfig.Url
  5682. struct3505.AppId = miConfig.Cainfo
  5683. struct3505.AppSecret = miConfig.AppSecret
  5684. struct3505.Enckey = miConfig.EncKey
  5685. struct3505.SignKey = miConfig.SignKey
  5686. struct3505.SecretKey = miConfig.SecretKey
  5687. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5688. struct3505.SelRetnCnt = strValue
  5689. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5690. struct3505.SelRetnOpterName = role.UserName
  5691. if order.IsMedicineInsurance == 1 {
  5692. struct3505.MdtrtSetlType = "1"
  5693. } else {
  5694. struct3505.MdtrtSetlType = "2"
  5695. }
  5696. struct3505.OrgName = miConfig.OrgName
  5697. struct3505.AccessKey = miConfig.AccessKey
  5698. struct3505.RequestUrl = miConfig.Url
  5699. struct3505.SecretKey = miConfig.SecretKey
  5700. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5701. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5702. struct3505.Cainfo = miConfig.Cainfo
  5703. struct3505.DrugTracCodg = drug.DrugCode
  5704. if miConfig.MdtrtareaAdmvs == "350500" {
  5705. result1, result2, _ := service.FJyb3505(struct3505)
  5706. return result1, result2
  5707. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5708. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5709. return result1, result2
  5710. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5711. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5712. return result1, result2
  5713. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5714. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5715. return result1, result2
  5716. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5717. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5718. return result1, result2
  5719. } else {
  5720. data := make(map[string]interface{})
  5721. data["struct_3505s"] = struct3505
  5722. client := &http.Client{}
  5723. bytesData, _ := json.Marshal(data)
  5724. var req *http.Request
  5725. if miConfig.MdtrtareaAdmvs == "320830" {
  5726. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3505", bytes.NewReader(bytesData))
  5727. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5728. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5729. } else {
  5730. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5731. }
  5732. resp, _ := client.Do(req)
  5733. defer resp.Body.Close()
  5734. body, ioErr := ioutil.ReadAll(resp.Body)
  5735. if ioErr != nil {
  5736. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5737. }
  5738. var respJSON map[string]interface{}
  5739. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5740. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5741. }
  5742. //var resSix10265 ResultSix10265 //1101结果
  5743. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5744. result, _ := json.Marshal(respJSON)
  5745. return string(result), ""
  5746. }
  5747. }
  5748. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string,doc models.HisDoctorAdviceInfo) (string, string) {
  5749. var struct3506 models.Struct3506
  5750. struct3506.MedListCodg = doc.BaseDrugLib.MedicalInsuranceNumber
  5751. struct3506.FixmedinsHilistId = doc.BaseDrugLib.MedicalInsuranceNumber
  5752. struct3506.FixmedinsHilistName = doc.BaseDrugLib.DrugName
  5753. struct3506.FixmedinsCode = miConfig.Code
  5754. struct3506.Code = miConfig.Code
  5755. struct3506.FixmedinsBchno = number
  5756. struct3506.Opter = role.UserName
  5757. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5758. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  5759. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5760. struct3506.MdtrtSn = order.MdtrtId
  5761. struct3506.ExpyEnd = ""
  5762. struct3506.RxFlag = "0"
  5763. struct3506.TrdnFlag = "1"
  5764. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5765. struct3506.SelRetnCnt = strValue
  5766. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5767. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  5768. struct3506.SelRetnOpterName = role.UserName
  5769. struct3506.OrgName = miConfig.OrgName
  5770. struct3506.AccessKey = miConfig.AccessKey
  5771. struct3506.RequestUrl = miConfig.Url
  5772. struct3506.SecretKey = miConfig.SecretKey
  5773. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5774. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5775. struct3506.Url = miConfig.Url
  5776. struct3506.AppId = miConfig.Cainfo
  5777. struct3506.AppSecret = miConfig.AppSecret
  5778. struct3506.Enckey = miConfig.EncKey
  5779. struct3506.SignKey = miConfig.SignKey
  5780. struct3506.SecretKey = miConfig.SecretKey
  5781. struct3506.DrugTracCodg = drug.DrugCode
  5782. if miConfig.MdtrtareaAdmvs == "350500" {
  5783. result1, result2, _ := service.FJyb3506(struct3506)
  5784. return result1, result2
  5785. } else {
  5786. data := make(map[string]interface{})
  5787. data["struct_3506s"] = struct3506
  5788. client := &http.Client{}
  5789. bytesData, _ := json.Marshal(data)
  5790. var req *http.Request
  5791. if miConfig.MdtrtareaAdmvs == "320830" {
  5792. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3506", bytes.NewReader(bytesData))
  5793. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5794. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5795. } else {
  5796. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5797. }
  5798. resp, _ := client.Do(req)
  5799. defer resp.Body.Close()
  5800. body, ioErr := ioutil.ReadAll(resp.Body)
  5801. if ioErr != nil {
  5802. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5803. }
  5804. var respJSON map[string]interface{}
  5805. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5806. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5807. }
  5808. //var resSix10265 ResultSix10265 //1101结果
  5809. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5810. result, _ := json.Marshal(respJSON)
  5811. return string(result), ""
  5812. }
  5813. }
  5814. func (c *HisApiController) Get1318() {
  5815. adminUser := c.GetAdminUserInfo()
  5816. admin_user_id, _ := c.GetInt64("admin_user_id")
  5817. code := c.GetString("code")
  5818. code = ""
  5819. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5820. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5821. api := ""
  5822. if miConfig.MdtrtareaAdmvs == "320830" {
  5823. api = miConfig.AppSecret + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5824. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5825. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5826. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5827. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5828. } else {
  5829. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5830. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5831. }
  5832. resp, requestErr := http.Get(api)
  5833. if requestErr != nil {
  5834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5835. return
  5836. }
  5837. body, ioErr := ioutil.ReadAll(resp.Body)
  5838. if ioErr != nil {
  5839. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5841. return
  5842. }
  5843. var respJSON map[string]interface{}
  5844. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5845. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5847. return
  5848. }
  5849. //var res Result2406
  5850. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5851. result, _ := json.Marshal(respJSON)
  5852. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5853. utils.ErrorLog("解析失败:%v", err)
  5854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5855. return
  5856. }
  5857. if res.Infcode == "0" {
  5858. c.ServeSuccessJSON(map[string]interface{}{
  5859. "result": "",
  5860. })
  5861. } else {
  5862. c.ServeSuccessJSON(map[string]interface{}{
  5863. "failed_code": -10,
  5864. "msg": res.ErrMsg,
  5865. })
  5866. */return
  5867. //}
  5868. }
  5869. func (c *HisApiController) Get2503() {
  5870. adminUser := c.GetAdminUserInfo()
  5871. admin_user_id, _ := c.GetInt64("admin_user_id")
  5872. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5873. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5874. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  5875. }
  5876. func (c *HisApiController) Get2406() {
  5877. id, _ := c.GetInt64("id")
  5878. record_time := c.GetString("record_time")
  5879. his_patient_id, _ := c.GetInt64("his_patient_id")
  5880. admin_user_id, _ := c.GetInt64("admin_user_id")
  5881. diagnosis_id := c.GetString("diagnosis")
  5882. timeLayout := "2006-01-02"
  5883. loc, _ := time.LoadLocation("Local")
  5884. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5885. if err != nil {
  5886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5887. return
  5888. }
  5889. recordDateTime := theTime.Unix()
  5890. adminUser := c.GetAdminUserInfo()
  5891. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5892. var config []*models.HisXtDiagnoseConfig
  5893. for _, item := range diagnosis_ids {
  5894. id, _ := strconv.ParseInt(item, 10, 64)
  5895. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5896. config = append(config, &diagnosisConfig)
  5897. }
  5898. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5899. fmt.Println(his_patient_id)
  5900. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5901. //timestamp := time.Now().Unix()
  5902. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5903. var patientPrescription models.HisPrescriptionInfo
  5904. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5905. if patientPrescription.ID == 0 {
  5906. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5907. }
  5908. var res2 Result2406
  5909. if miConfig.MdtrtareaAdmvs == "341203" {
  5910. data := make(map[string]interface{})
  5911. client := &http.Client{}
  5912. data["psn_no"] = his.PsnNo
  5913. data["mdtrt_id"] = his.Number
  5914. data["operator"] = roles.UserName
  5915. data["cert_no"] = his.IdCardNo
  5916. data["org_name"] = miConfig.OrgName
  5917. data["psn_name"] = his.Name
  5918. data["ipt_otp_no"] = his.IptOtpNo
  5919. data["ipt_psn_sp_flag_type"] = "0901"
  5920. data["ipt_psn_sp_flag"] = "1"
  5921. data["fixmedins_code"] = miConfig.Code
  5922. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5923. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5924. data["url"] = miConfig.Url
  5925. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5926. bytesData, _ := json.Marshal(data)
  5927. var req *http.Request
  5928. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5929. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5930. resp, _ := client.Do(req)
  5931. defer resp.Body.Close()
  5932. body, ioErr := ioutil.ReadAll(resp.Body)
  5933. if ioErr != nil {
  5934. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5936. return
  5937. }
  5938. var respJSON map[string]interface{}
  5939. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5940. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5942. return
  5943. }
  5944. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5945. if status == "0" {
  5946. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5947. c.ServeSuccessJSON(map[string]interface{}{
  5948. "failed_code": -10,
  5949. "msg": err_msg,
  5950. })
  5951. return
  5952. }
  5953. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5954. userJSONBytes, _ := json.Marshal(respJSON)
  5955. fmt.Println("log")
  5956. fmt.Println(string(userJSONBytes))
  5957. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5958. utils.ErrorLog("解析失败:%v", err)
  5959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5960. return
  5961. }
  5962. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5963. data := make(map[string]interface{})
  5964. client := &http.Client{}
  5965. data["psn_no"] = his.PsnNo
  5966. data["mdtrt_id"] = his.Number
  5967. data["operator"] = roles.UserName
  5968. data["cert_no"] = his.IdCardNo
  5969. data["org_name"] = miConfig.OrgName
  5970. data["psn_name"] = his.Name
  5971. data["ipt_otp_no"] = his.IptOtpNo
  5972. data["ipt_psn_sp_flag_type"] = "0901"
  5973. data["ipt_psn_sp_flag"] = "1"
  5974. data["fixmedins_code"] = miConfig.Code
  5975. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5976. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5977. data["url"] = miConfig.Url
  5978. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5979. bytesData, _ := json.Marshal(data)
  5980. var req *http.Request
  5981. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5982. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5983. resp, _ := client.Do(req)
  5984. defer resp.Body.Close()
  5985. body, ioErr := ioutil.ReadAll(resp.Body)
  5986. if ioErr != nil {
  5987. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5989. return
  5990. }
  5991. var respJSON map[string]interface{}
  5992. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5993. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5995. return
  5996. }
  5997. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5998. if status == "0" {
  5999. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  6000. c.ServeSuccessJSON(map[string]interface{}{
  6001. "failed_code": -10,
  6002. "msg": err_msg,
  6003. })
  6004. return
  6005. }
  6006. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6007. userJSONBytes, _ := json.Marshal(respJSON)
  6008. fmt.Println("log")
  6009. fmt.Println(string(userJSONBytes))
  6010. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6011. utils.ErrorLog("解析失败:%v", err)
  6012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6013. return
  6014. }
  6015. }
  6016. if res2.Infcode != 0 {
  6017. adminUser := c.GetAdminUserInfo()
  6018. errlog := &models.HisOrderError{
  6019. UserOrgId: adminUser.CurrentOrgId,
  6020. Ctime: time.Now().Unix(),
  6021. Mtime: time.Now().Unix(),
  6022. ErrMsg: res2.ErrMsg,
  6023. Status: 1,
  6024. PatientId: id,
  6025. RecordTime: recordDateTime,
  6026. Stage: 3,
  6027. }
  6028. service.CreateErrMsgLog(errlog)
  6029. c.ServeSuccessJSON(map[string]interface{}{
  6030. "failed_code": -10,
  6031. "msg": res2.ErrMsg,
  6032. })
  6033. return
  6034. } else {
  6035. c.ServeSuccessJSON(map[string]interface{}{
  6036. "msg": "上传成功",
  6037. })
  6038. return
  6039. }
  6040. }
  6041. func (c *HisApiController) Get4105() {
  6042. }
  6043. func (c *HisApiController) Post5302() {
  6044. patient_id, _ := c.GetInt64("id")
  6045. admin_user_id, _ := c.GetInt64("admin_user_id")
  6046. p, _ := service.GetHisPatientById(patient_id)
  6047. adminUser := c.GetAdminUserInfo()
  6048. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6049. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6050. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  6051. }
  6052. func (c *HisApiController) Get4104() {
  6053. }
  6054. type Output struct {
  6055. CertNo string `json:"certno"`
  6056. PsnName string `json:"psn_name"`
  6057. CardNo string `json:"card_no"`
  6058. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  6059. CardSN string `json:"card_sn"`
  6060. PsnCertType string `json:"psn_cert_type"`
  6061. MdtrtCertNo string `json:"mdtrt_cert_no"`
  6062. MdtrtCertType string `json:"mdtrt_cert_type"`
  6063. QRCode string `json:"qrCode"`
  6064. EcToken string `json:"ecToken"`
  6065. }
  6066. type AHResponse struct {
  6067. Body AHBody `json:"body"`
  6068. Code int `json:"code"`
  6069. CSBCode int `json:"csbCode"`
  6070. Message string `json:"message"`
  6071. RequestID string `json:"requestId"`
  6072. State struct{} `json:"state"`
  6073. }
  6074. type AHBody struct {
  6075. ErrMsg string `json:"err_msg"`
  6076. InfRefMsgID string `json:"inf_refmsgid"`
  6077. InfCode int `json:"infcode"`
  6078. Output struct {
  6079. Result []struct {
  6080. BasMednFlag string `json:"bas_medn_flag"`
  6081. ChldMedcFlag string `json:"chld_medc_flag"`
  6082. ChrgitmLv string `json:"chrgitm_lv"`
  6083. Cnt float64 `json:"cnt"`
  6084. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  6085. DrtReimFlag string `json:"drt_reim_flag"`
  6086. FeedetlSn string `json:"feedetl_sn"`
  6087. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6088. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  6089. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6090. ListSpItemFlag string `json:"list_sp_item_flag"`
  6091. LmtUsedFlag string `json:"lmt_used_flag"`
  6092. MedChrgitmType string `json:"med_chrgitm_type"`
  6093. Memo string `json:"memo"`
  6094. OverlmtAmt float64 `json:"overlmt_amt"`
  6095. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6096. Pric float64 `json:"pric"`
  6097. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  6098. SelfpayProp float64 `json:"selfpay_prop"`
  6099. } `json:"result"`
  6100. } `json:"output"`
  6101. }
  6102. type Response struct {
  6103. Output Output `json:"output"`
  6104. Infcode int `json:"infcode"`
  6105. InfRefMsgID string `json:"inf_refmsgid"`
  6106. RefMsgTime string `json:"refmsg_time"`
  6107. RespondTime string `json:"respond_time"`
  6108. ErrMsg string `json:"err_msg"`
  6109. WarnMsg string `json:"warn_msg"`
  6110. SignType string `json:"signtype"`
  6111. CAInfo string `json:"cainfo"`
  6112. }
  6113. func (c *HisApiController) Getquerydata() {
  6114. query_type, _ := c.GetInt64("type")
  6115. refd_setl_flag := c.GetString("refd_setl_flag")
  6116. med_type := c.GetString("med_type")
  6117. //admin_user_id,_ := c.GetInt64("admin_user_id")
  6118. cert_no := c.GetString("cert_no")
  6119. psn_no := c.GetString("psn_no")
  6120. start_time := c.GetString("start_time")
  6121. end_time := c.GetString("end_time")
  6122. page, _ := c.GetInt64("page")
  6123. limit, _ := c.GetInt64("limit")
  6124. var bp models.BusinessParams5262
  6125. bp.RefdSetlFlag = refd_setl_flag
  6126. bp.MedType = med_type
  6127. bp.Certno = cert_no
  6128. bp.Psnno = psn_no
  6129. bp.QBegntime = start_time
  6130. bp.QEndtime = end_time
  6131. if query_type == 1 { //本地
  6132. Post5262(c, bp, page, limit)
  6133. } else { //异地
  6134. Post5267(c, bp, page, limit)
  6135. }
  6136. }
  6137. func (c *HisApiController) Drugscheck() {
  6138. admin_user_id, _ := c.GetInt64("admin_user_id")
  6139. adminUser := c.GetAdminUserInfo()
  6140. var queryResult []QueryResult
  6141. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  6142. for _, item := range drugs {
  6143. result := QueryResult{
  6144. ID: item.ID,
  6145. Name: item.DrugName,
  6146. Code: item.MedicalInsuranceNumber,
  6147. List_type_code: "101",
  6148. }
  6149. queryResult = append(queryResult, result)
  6150. }
  6151. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6152. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6153. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6154. for _, item := range queryResult {
  6155. 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)
  6156. }
  6157. }
  6158. func (c *HisApiController) Goodcheck() {
  6159. admin_user_id, _ := c.GetInt64("admin_user_id")
  6160. adminUser := c.GetAdminUserInfo()
  6161. var queryResult []QueryResult
  6162. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  6163. for _, item := range goods {
  6164. result := QueryResult{
  6165. ID: item.ID,
  6166. Name: item.GoodName,
  6167. Code: item.SocialSecurityDirectoryCode,
  6168. List_type_code: "301",
  6169. }
  6170. queryResult = append(queryResult, result)
  6171. }
  6172. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6173. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6174. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6175. for _, item := range queryResult {
  6176. 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)
  6177. //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)
  6178. }
  6179. }
  6180. func (c *HisApiController) Projectcheck() {
  6181. admin_user_id, _ := c.GetInt64("admin_user_id")
  6182. adminUser := c.GetAdminUserInfo()
  6183. var queryResult []QueryResult
  6184. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  6185. for _, item := range projects {
  6186. result := QueryResult{
  6187. ID: item.ID,
  6188. Name: item.ProjectName,
  6189. Code: item.MedicalCode,
  6190. List_type_code: "201",
  6191. }
  6192. queryResult = append(queryResult, result)
  6193. }
  6194. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6195. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6196. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6197. for _, item := range queryResult {
  6198. 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)
  6199. }
  6200. }
  6201. //func (c *HisApiController)CancleDia(){
  6202. //
  6203. // id, _ := c.GetInt64("id")
  6204. // record_time := c.GetString("record_time")
  6205. // his_patient_id, _ := c.GetInt64("his_patient_id")
  6206. //
  6207. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6208. //
  6209. // diagnosis_id := c.GetString("diagnosis")
  6210. // sick_type, _ := c.GetInt64("sick_type")
  6211. // reg_type, _ := c.GetInt64("p_type")
  6212. // begin_time := c.GetString("begin_time")
  6213. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  6214. //
  6215. //
  6216. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  6217. //
  6218. // fmt.Println(acct_used_flag)
  6219. //
  6220. //
  6221. // timeLayout := "2006-01-02"
  6222. // loc, _ := time.LoadLocation("Local")
  6223. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6224. // if err != nil {
  6225. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6226. // return
  6227. // }
  6228. // recordDateTime := theTime.Unix()
  6229. // adminUser := c.GetAdminUserInfo()
  6230. //
  6231. //
  6232. //
  6233. //
  6234. //
  6235. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6236. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6237. // var patientPrescription models.HisPrescriptionInfo
  6238. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6239. // if patientPrescription.ID == 0 {
  6240. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6241. // }
  6242. // //if patientPrescription.Do
  6243. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6244. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6245. //
  6246. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6247. //
  6248. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  6249. //
  6250. // var config []*models.HisXtDiagnoseConfig
  6251. // for _, item := range diagnosis_ids {
  6252. // id, _ := strconv.ParseInt(item, 10, 64)
  6253. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  6254. // config = append(config, &diagnosisConfig)
  6255. // }
  6256. //
  6257. // sickConfig, _ := service.FindSickById(sick_type)
  6258. //
  6259. //
  6260. // data := make(map[string]interface{})
  6261. // client := &http.Client{}
  6262. // data["psn_no"] = his.PsnNo
  6263. // data["mdtrt_id"] = his.Number
  6264. // data["doctor"] = roles.UserName
  6265. // data["department"] = department.Name
  6266. // data["org_name"] = miConfig.OrgName
  6267. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  6268. // data["doctor_id"] = doctor_info.DoctorNumber
  6269. // data["new_doctor_name"] = doctor_info.UserName
  6270. // data["fixmedins_code"] = miConfig.Code
  6271. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6272. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6273. // data["secret_key"] = miConfig.SecretKey
  6274. // data["sick_code"] = sickConfig.CountryCode
  6275. // data["sick_name"] = sickConfig.ClassName
  6276. // data["url"] = miConfig.Url
  6277. // data["ak"] = miConfig.AccessKey
  6278. // data["begin_time"] = begin_time
  6279. // data["cainfo"] = miConfig.Cainfo
  6280. // data["is_vaild"] = "0"
  6281. //
  6282. // data["dept"] = strconv.FormatInt(department.ID, 10)
  6283. // data["config"] = config
  6284. // bytesData, _ := json.Marshal(data)
  6285. //
  6286. // var req *http.Request
  6287. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  6288. // resp, _ := client.Do(req)
  6289. // defer resp.Body.Close()
  6290. // body, ioErr := ioutil.ReadAll(resp.Body)
  6291. // if ioErr != nil {
  6292. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6293. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6294. // return
  6295. // }
  6296. // var respJSON map[string]interface{}
  6297. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6298. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6299. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6300. // return
  6301. // }
  6302. //
  6303. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6304. // userJSONBytes, _ := json.Marshal(respJSON)
  6305. // fmt.Println("log")
  6306. // fmt.Println(string(userJSONBytes))
  6307. //
  6308. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  6309. // utils.ErrorLog("解析失败:%v", err)
  6310. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6311. // return
  6312. // }
  6313. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  6314. // res2.Output = ressix10265.Output
  6315. // res2.ErrMsg = ressix10265.ErrMsg
  6316. // res2.Cainfo = ressix10265.Cainfo
  6317. // res2.WarnMsg = ressix10265.WarnMsg
  6318. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  6319. // res2.Infcode = infocode
  6320. //
  6321. //}
  6322. func (c *HisApiController) Get4102() {
  6323. order_id, _ := c.GetInt64("order_id")
  6324. admin_user_id, _ := c.GetInt64("admin_user_id")
  6325. stas_type := c.GetString("stas_type")
  6326. order, _ := service.GetHisOrderByIDTwo(order_id)
  6327. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6328. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6329. var pp models.PublicParams
  6330. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6331. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6332. pp.FixmedinsName = miConfig.OrgName
  6333. pp.FixmedinsCode = miConfig.Code
  6334. pp.RequestUrl = miConfig.Url
  6335. pp.Cainfo = miConfig.Cainfo
  6336. pp.SecretKey = miConfig.SecretKey
  6337. pp.AccessKey = miConfig.AccessKey
  6338. pp.OpterName = curRoles.UserName
  6339. if miConfig.MdtrtareaAdmvs == "350500" {
  6340. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  6341. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  6342. saveLog(result, request, "4102", "清单确认")
  6343. var dat map[string]interface{}
  6344. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6345. fmt.Println(dat)
  6346. } else {
  6347. fmt.Println(err)
  6348. }
  6349. var empty ResultFourteen
  6350. userJSONBytes, _ := json.Marshal(dat)
  6351. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  6352. utils.ErrorLog("解析失败:%v", err)
  6353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6354. return
  6355. }
  6356. if empty.Infcode == 0 {
  6357. c.ServeSuccessJSON(map[string]interface{}{
  6358. "msg": "确认成功",
  6359. })
  6360. return
  6361. }
  6362. } else {
  6363. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  6364. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  6365. result3, request3 := service.Jxyb4105(pp)
  6366. saveLog(result, request, "4102", "清单确认")
  6367. saveLog(result2, request2, "4103", "清单确认")
  6368. saveLog(result3, request3, "4105", "清单统计")
  6369. var dat map[string]interface{}
  6370. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6371. fmt.Println(dat)
  6372. } else {
  6373. fmt.Println(err)
  6374. }
  6375. var empty ResultFourteen
  6376. userJSONBytes, _ := json.Marshal(dat)
  6377. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  6378. utils.ErrorLog("解析失败:%v", err)
  6379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6380. return
  6381. }
  6382. if empty.Infcode == 0 {
  6383. c.ServeSuccessJSON(map[string]interface{}{
  6384. "msg": "确认成功",
  6385. })
  6386. return
  6387. }
  6388. }
  6389. }
  6390. // 对账权限查询
  6391. func (c *HisApiController) Get3260() {
  6392. admin_user_id, _ := c.GetInt64("admin_user_id")
  6393. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6394. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6395. var api string
  6396. var res models.JSResult3260
  6397. if miConfig.MdtrtareaAdmvs == "320830" {
  6398. api = miConfig.AppSecret + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6399. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6400. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6401. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "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
  6403. } else {
  6404. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "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
  6406. }
  6407. resp, requestErr := http.Get(api)
  6408. if requestErr != nil {
  6409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6410. return
  6411. }
  6412. body, ioErr := ioutil.ReadAll(resp.Body)
  6413. if ioErr != nil {
  6414. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6416. return
  6417. }
  6418. var respJSON map[string]interface{}
  6419. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6420. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6422. return
  6423. }
  6424. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6425. result, _ := json.Marshal(respJSON)
  6426. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6427. utils.ErrorLog("解析失败:%v", err)
  6428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6429. return
  6430. }
  6431. if res.Infcode == "0" {
  6432. c.ServeSuccessJSON(map[string]interface{}{
  6433. "result": res.Output.Data,
  6434. })
  6435. } else {
  6436. c.ServeSuccessJSON(map[string]interface{}{
  6437. "failed_code": -10,
  6438. "msg": res.ErrMsg,
  6439. })
  6440. return
  6441. }
  6442. }
  6443. func (c *HisApiController) Get3261() {
  6444. admin_user_id, _ := c.GetInt64("admin_user_id")
  6445. //month := c.GetString("month")
  6446. startTime := c.GetString("start_time")
  6447. //endTime, _ := c.GetString("end_time")
  6448. times := strings.Split(startTime, "-")
  6449. stmt_mon := times[0] + times[1]
  6450. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6451. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6452. var api string
  6453. var res models.JSResult3261
  6454. //var res10265 Result5301For10265
  6455. if miConfig.MdtrtareaAdmvs == "320830" {
  6456. api = miConfig.AppSecret + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6457. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6458. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6459. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6460. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6461. } else {
  6462. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6463. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6464. }
  6465. resp, requestErr := http.Get(api)
  6466. if requestErr != nil {
  6467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6468. return
  6469. }
  6470. body, ioErr := ioutil.ReadAll(resp.Body)
  6471. if ioErr != nil {
  6472. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6474. return
  6475. }
  6476. var respJSON map[string]interface{}
  6477. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6478. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6480. return
  6481. }
  6482. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6483. result, _ := json.Marshal(respJSON)
  6484. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6485. utils.ErrorLog("解析失败:%v", err)
  6486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6487. return
  6488. }
  6489. if res.Infcode == "0" {
  6490. c.ServeSuccessJSON(map[string]interface{}{
  6491. "result": res.Output,
  6492. })
  6493. } else {
  6494. c.ServeSuccessJSON(map[string]interface{}{
  6495. "failed_code": -10,
  6496. "msg": res.ErrMsg,
  6497. })
  6498. return
  6499. }
  6500. }
  6501. type TempFun struct {
  6502. FundKey string
  6503. FundCode string
  6504. }
  6505. func (c *HisApiController) Get3262() {
  6506. admin_user_id, _ := c.GetInt64("admin_user_id")
  6507. startTime := c.GetString("start_time")
  6508. endTime := c.GetString("end_time")
  6509. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6510. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6511. //timeLayout := "2006-01-02"
  6512. //loc, _ := time.LoadLocation("Local")
  6513. //var theStartTIme int64
  6514. //if len(startTime) > 0 {
  6515. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  6516. // if err != nil {
  6517. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6518. // return
  6519. // }
  6520. // theStartTIme = theTime.Unix()
  6521. //}
  6522. //var theEndtTIme int64
  6523. //if len(endTime) > 0 {
  6524. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  6525. // if err != nil {
  6526. // utils.ErrorLog(err.Error())
  6527. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6528. // return
  6529. // }
  6530. // theEndtTIme = theTime.Unix()
  6531. //}
  6532. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6533. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6534. for _, team := range datas {
  6535. fmt.Println(team.PsnTime)
  6536. for _, team_two := range datas_two {
  6537. fmt.Println(team_two.PsnTime)
  6538. if team.FundKey == team_two.FundKey {
  6539. fmt.Println(team_two.PsnTime)
  6540. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  6541. fmt.Println(team.PsnTime)
  6542. }
  6543. }
  6544. }
  6545. fmt.Println("1111")
  6546. fmt.Println(datas)
  6547. fmt.Println("1111")
  6548. var twos []models.FixMonRecDetailFileInTwo
  6549. for _, team := range datas {
  6550. var two models.FixMonRecDetailFileInTwo
  6551. two.MedType = team.MedType
  6552. two.Insutype = team.Insutype
  6553. two.PsnType = team.PsnType
  6554. two.MedType = team.MedType
  6555. two.FixBlngAdmdvs = "999999"
  6556. two.InsuAdmdvs = "555555"
  6557. two.PsnTime = team.PsnTime
  6558. two.PsnCnt = team.PsnCnt
  6559. two.FundKey = team.FundKey
  6560. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6561. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6562. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6563. two.MedfeeSumAmt = ms
  6564. two.InscpAmt = ia
  6565. two.FundPaySumAmt = fps
  6566. twos = append(twos, two)
  6567. }
  6568. //startTime := c.GetString("start_time")
  6569. //endTime, _ := c.GetString("end_time")
  6570. times := strings.Split(startTime, "-")
  6571. stmt_mon := times[0] + times[1]
  6572. var funs []models.FundDetail
  6573. for _, item := range datas {
  6574. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6575. funs = append(funs, fun...)
  6576. }
  6577. var funInfos []models.Fund
  6578. //for _, item := range funs {
  6579. // var rf []models.FundInfo
  6580. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6581. // for _, subitem := range rf {
  6582. // var fund models.Fund
  6583. // fund.FundCode = subitem.FundPayType
  6584. // fund.FundName = subitem.FundPayTypeName
  6585. // fund.FundAmt = subitem.FundPayAmt
  6586. // fund.FundKey = item.FundKey
  6587. // fund.InsuAdmdvs = "555555"
  6588. // fund.FixBlngAdmdvs = "999999"
  6589. // funInfos = append(funInfos, fund)
  6590. // }
  6591. //}
  6592. var tempFuns []TempFun
  6593. for _, funInfo := range funInfos {
  6594. var tempFun TempFun
  6595. tempFun.FundKey = funInfo.FundKey
  6596. tempFun.FundCode = funInfo.FundCode
  6597. tempFuns = append(tempFuns, tempFun)
  6598. }
  6599. tempFuns = RemoveRepeatedFunElement(tempFuns)
  6600. fmt.Println(tempFuns)
  6601. var funInfosTwo []models.Fund
  6602. decimal.DivisionPrecision = 2
  6603. for _, item := range tempFuns {
  6604. var fund models.Fund
  6605. for _, subItem := range funInfos {
  6606. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  6607. fund.FundKey = subItem.FundKey
  6608. fund.InsuAdmdvs = subItem.InsuAdmdvs
  6609. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  6610. fund.FundName = subItem.FundName
  6611. fund.FundCode = subItem.FundCode
  6612. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  6613. }
  6614. }
  6615. funInfosTwo = append(funInfosTwo, fund)
  6616. }
  6617. fmt.Println("funInfosTwo")
  6618. fmt.Println(funInfosTwo)
  6619. var upld_btch string
  6620. var empty models.JSResultEmpty
  6621. data := make(map[string]interface{})
  6622. data["org_name"] = miConfig.OrgName
  6623. data["doctor"] = curRoles.UserName
  6624. data["doctor_name"] = curRoles.UserName
  6625. data["fixmedins_code"] = miConfig.Code
  6626. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6627. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6628. data["secret_key"] = miConfig.SecretKey
  6629. data["url"] = miConfig.Url
  6630. data["ak"] = miConfig.AccessKey
  6631. data["cainfo"] = miConfig.Cainfo
  6632. data["datas"] = twos
  6633. data["fund"] = funInfosTwo
  6634. fmt.Println(twos)
  6635. month := time.Unix(1557042972, 0).Format("1")
  6636. year := time.Now().Format("2006")
  6637. month = time.Now().Format("01")
  6638. day := time.Now().Format("02")
  6639. hour := time.Now().Format("15")
  6640. min := time.Now().Format("04")
  6641. sec := time.Now().Format("05")
  6642. fix_fill_date := year + month + day + hour + min + sec
  6643. data["fix_fill_dept"] = miConfig.OrgName
  6644. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6645. data["fix_fill_psn"] = curRoles.UserName
  6646. data["fix_fill_date"] = fix_fill_date
  6647. data["stmt_loc"] = "2"
  6648. data["setl_mon"] = stmt_mon
  6649. upld_btch = "0"
  6650. data["upld_btch"] = upld_btch
  6651. //fmt.Println(data)
  6652. client := &http.Client{}
  6653. bytesData, _ := json.Marshal(data)
  6654. var req *http.Request
  6655. if miConfig.MdtrtareaAdmvs == "320830" {
  6656. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3262", bytes.NewReader(bytesData))
  6657. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6658. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6659. } else {
  6660. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6661. }
  6662. resp, _ := client.Do(req)
  6663. defer resp.Body.Close()
  6664. body, ioErr := ioutil.ReadAll(resp.Body)
  6665. if ioErr != nil {
  6666. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6668. }
  6669. var respJSON map[string]interface{}
  6670. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6671. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6673. }
  6674. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6675. //fmt.Println(respJSON)
  6676. result, _ := json.Marshal(respJSON)
  6677. //fmt.Println(result)
  6678. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6679. utils.ErrorLog("解析失败:%v", err)
  6680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6681. }
  6682. if empty.Infcode != "0" {
  6683. c.ServeSuccessJSON(map[string]interface{}{
  6684. "failed_code": -10,
  6685. "msg": empty.ErrMsg,
  6686. })
  6687. return
  6688. } else {
  6689. c.ServeSuccessJSON(map[string]interface{}{
  6690. "msg": "上传成功",
  6691. })
  6692. return
  6693. }
  6694. }
  6695. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  6696. newArr = make([]TempFun, 0)
  6697. for i := 0; i < len(arr); i++ {
  6698. repeat := false
  6699. for j := i + 1; j < len(arr); j++ {
  6700. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  6701. repeat = true
  6702. break
  6703. }
  6704. }
  6705. if !repeat {
  6706. newArr = append(newArr, arr[i])
  6707. }
  6708. }
  6709. return
  6710. }
  6711. func (c *HisApiController) Get3263() {
  6712. admin_user_id, _ := c.GetInt64("admin_user_id")
  6713. startTime := c.GetString("start_time")
  6714. //endTime, _ := c.GetString("end_time")
  6715. times := strings.Split(startTime, "-")
  6716. setl_mon := times[0] + times[1]
  6717. upld_btch := "0"
  6718. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6719. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6720. var result3263 models.JSResult3263
  6721. data := make(map[string]interface{})
  6722. data["org_name"] = miConfig.OrgName
  6723. data["doctor"] = curRoles.UserName
  6724. data["doctor_name"] = curRoles.UserName
  6725. data["fixmedins_code"] = miConfig.Code
  6726. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6727. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6728. data["secret_key"] = miConfig.SecretKey
  6729. data["url"] = miConfig.Url
  6730. data["ak"] = miConfig.AccessKey
  6731. data["cainfo"] = miConfig.Cainfo
  6732. data["setl_mon"] = setl_mon
  6733. data["stmt_loc"] = "2"
  6734. data["upld_btch"] = upld_btch
  6735. client := &http.Client{}
  6736. bytesData, _ := json.Marshal(data)
  6737. var req *http.Request
  6738. if miConfig.MdtrtareaAdmvs == "320830" {
  6739. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3263", bytes.NewReader(bytesData))
  6740. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6741. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6742. } else {
  6743. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6744. }
  6745. resp, _ := client.Do(req)
  6746. defer resp.Body.Close()
  6747. body, ioErr := ioutil.ReadAll(resp.Body)
  6748. if ioErr != nil {
  6749. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6751. }
  6752. var respJSON map[string]interface{}
  6753. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6754. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6756. }
  6757. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6758. fmt.Println(respJSON)
  6759. result, _ := json.Marshal(respJSON)
  6760. fmt.Println(result)
  6761. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6762. utils.ErrorLog("解析失败:%v", err)
  6763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6764. }
  6765. if result3263.Infcode != "0" {
  6766. c.ServeSuccessJSON(map[string]interface{}{
  6767. "failed_code": -10,
  6768. "msg": result3263.ErrMsg,
  6769. })
  6770. return
  6771. } else {
  6772. c.ServeSuccessJSON(map[string]interface{}{
  6773. "list": result3263.Output,
  6774. })
  6775. return
  6776. }
  6777. }
  6778. func (c *HisApiController) Get3264() {
  6779. admin_user_id, _ := c.GetInt64("admin_user_id")
  6780. startTime := c.GetString("start_time")
  6781. //endTime, _ := c.GetString("end_time")
  6782. times := strings.Split(startTime, "-")
  6783. setl_mon := times[0] + times[1]
  6784. upld_btch := "0"
  6785. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6786. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6787. //solidify_id := []
  6788. var result3263 models.JSResult3263
  6789. data := make(map[string]interface{})
  6790. data["org_name"] = miConfig.OrgName
  6791. data["doctor"] = curRoles.UserName
  6792. data["doctor_name"] = curRoles.UserName
  6793. data["fixmedins_code"] = miConfig.Code
  6794. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6795. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6796. data["secret_key"] = miConfig.SecretKey
  6797. data["url"] = miConfig.Url
  6798. data["ak"] = miConfig.AccessKey
  6799. data["cainfo"] = miConfig.Cainfo
  6800. data["setl_mon"] = setl_mon
  6801. data["stmt_loc"] = "2"
  6802. data["upld_btch"] = upld_btch
  6803. client := &http.Client{}
  6804. bytesData, _ := json.Marshal(data)
  6805. var req3263 *http.Request
  6806. if miConfig.MdtrtareaAdmvs == "320830" {
  6807. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3263", bytes.NewReader(bytesData))
  6808. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6809. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6810. } else {
  6811. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6812. }
  6813. resp, _ := client.Do(req3263)
  6814. defer resp.Body.Close()
  6815. body, ioErr := ioutil.ReadAll(resp.Body)
  6816. if ioErr != nil {
  6817. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6819. }
  6820. var respJSON3263 map[string]interface{}
  6821. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  6822. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6824. }
  6825. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6826. fmt.Println(respJSON3263)
  6827. result, _ := json.Marshal(respJSON3263)
  6828. fmt.Println(result)
  6829. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6830. utils.ErrorLog("解析失败:%v", err)
  6831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6832. }
  6833. var ids []string
  6834. for _, item := range result3263.Output {
  6835. ids = append(ids, item.SolidifyID)
  6836. }
  6837. var empty models.JSResultEmpty
  6838. data2 := make(map[string]interface{})
  6839. data2["org_name"] = miConfig.OrgName
  6840. data2["doctor"] = curRoles.UserName
  6841. data2["doctor_name"] = curRoles.UserName
  6842. data2["fixmedins_code"] = miConfig.Code
  6843. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6844. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6845. data2["secret_key"] = miConfig.SecretKey
  6846. data2["url"] = miConfig.Url
  6847. data2["ak"] = miConfig.AccessKey
  6848. data2["cainfo"] = miConfig.Cainfo
  6849. data2["setl_mon"] = setl_mon
  6850. data2["stmt_loc"] = "2"
  6851. data2["upld_btch"] = upld_btch
  6852. data2["solidify_id"] = ids
  6853. client2 := &http.Client{}
  6854. bytesData2, _ := json.Marshal(data2)
  6855. var req *http.Request
  6856. if miConfig.MdtrtareaAdmvs == "320830" {
  6857. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3264", bytes.NewReader(bytesData))
  6858. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6859. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6860. } else {
  6861. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6862. }
  6863. resp2, _ := client2.Do(req)
  6864. defer resp.Body.Close()
  6865. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6866. if ioErr2 != nil {
  6867. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6869. }
  6870. var respJSON map[string]interface{}
  6871. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  6872. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6874. }
  6875. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6876. fmt.Println(respJSON)
  6877. result2, _ := json.Marshal(respJSON)
  6878. fmt.Println(result2)
  6879. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  6880. utils.ErrorLog("解析失败:%v", err)
  6881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6882. }
  6883. if empty.Infcode != "0" {
  6884. c.ServeSuccessJSON(map[string]interface{}{
  6885. "failed_code": -10,
  6886. "msg": empty.ErrMsg,
  6887. })
  6888. return
  6889. } else {
  6890. c.ServeSuccessJSON(map[string]interface{}{
  6891. "msg": "",
  6892. })
  6893. return
  6894. }
  6895. }
  6896. func (c *HisApiController) Get3265() {
  6897. admin_user_id, _ := c.GetInt64("admin_user_id")
  6898. startTime := c.GetString("start_time")
  6899. //endTime, _ := c.GetString("end_time")
  6900. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6901. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6902. times := strings.Split(startTime, "-")
  6903. setl_mon := times[0] + times[1]
  6904. var upld_btch string
  6905. upld_btch = "0"
  6906. //var empty models.JSResultEmpty
  6907. var result3265 models.JSResult3264
  6908. var result3263 models.JSResult3263
  6909. data2 := make(map[string]interface{})
  6910. data2["org_name"] = miConfig.OrgName
  6911. data2["doctor"] = curRoles.UserName
  6912. data2["doctor_name"] = curRoles.UserName
  6913. data2["fixmedins_code"] = miConfig.Code
  6914. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6915. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6916. data2["secret_key"] = miConfig.SecretKey
  6917. data2["url"] = miConfig.Url
  6918. data2["ak"] = miConfig.AccessKey
  6919. data2["cainfo"] = miConfig.Cainfo
  6920. data2["setl_mon"] = setl_mon
  6921. data2["stmt_loc"] = "2"
  6922. data2["upld_btch"] = upld_btch
  6923. client2 := &http.Client{}
  6924. bytesData2, _ := json.Marshal(data2)
  6925. var req3263 *http.Request
  6926. if miConfig.MdtrtareaAdmvs == "320830" {
  6927. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3263", bytes.NewReader(bytesData2))
  6928. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6929. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6930. } else {
  6931. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6932. }
  6933. resp2, _ := client2.Do(req3263)
  6934. defer resp2.Body.Close()
  6935. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6936. if ioErr2 != nil {
  6937. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6939. }
  6940. var respJSON3263 map[string]interface{}
  6941. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6942. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6944. }
  6945. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6946. fmt.Println(respJSON3263)
  6947. result2, _ := json.Marshal(respJSON3263)
  6948. fmt.Println(result2)
  6949. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6950. utils.ErrorLog("解析失败:%v", err)
  6951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6952. }
  6953. var ids []string
  6954. for _, item := range result3263.Output {
  6955. ids = append(ids, item.SolidifyID)
  6956. }
  6957. data := make(map[string]interface{})
  6958. data["org_name"] = miConfig.OrgName
  6959. data["doctor"] = curRoles.UserName
  6960. data["doctor_name"] = curRoles.UserName
  6961. data["fixmedins_code"] = miConfig.Code
  6962. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6963. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6964. data["secret_key"] = miConfig.SecretKey
  6965. data["url"] = miConfig.Url
  6966. data["ak"] = miConfig.AccessKey
  6967. data["cainfo"] = miConfig.Cainfo
  6968. data["setl_mon"] = setl_mon
  6969. data["solidify_id"] = ids
  6970. month := time.Unix(1557042972, 0).Format("1")
  6971. year := time.Now().Format("2006")
  6972. month = time.Now().Format("01")
  6973. day := time.Now().Format("02")
  6974. hour := time.Now().Format("15")
  6975. min := time.Now().Format("04")
  6976. sec := time.Now().Format("05")
  6977. fix_fill_date := year + month + day + hour + min + sec
  6978. data["fix_fill_dept"] = miConfig.OrgName
  6979. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6980. data["fix_fill_psn"] = curRoles.UserName
  6981. data["fix_fill_date"] = fix_fill_date
  6982. data["stmt_loc"] = "2"
  6983. data["upld_btch"] = upld_btch
  6984. client := &http.Client{}
  6985. bytesData, _ := json.Marshal(data)
  6986. var req *http.Request
  6987. if miConfig.MdtrtareaAdmvs == "320830" {
  6988. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3265", bytes.NewReader(bytesData2))
  6989. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6990. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6991. } else {
  6992. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6993. }
  6994. resp, _ := client.Do(req)
  6995. defer resp.Body.Close()
  6996. body, ioErr := ioutil.ReadAll(resp.Body)
  6997. if ioErr != nil {
  6998. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7000. }
  7001. var respJSON map[string]interface{}
  7002. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7003. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7005. }
  7006. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7007. fmt.Println(respJSON)
  7008. result, _ := json.Marshal(respJSON)
  7009. fmt.Println(result)
  7010. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7011. utils.ErrorLog("解析失败:%v", err)
  7012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7013. }
  7014. if result3265.Infcode != "0" {
  7015. c.ServeSuccessJSON(map[string]interface{}{
  7016. "failed_code": -10,
  7017. "msg": result3265.ErrMsg,
  7018. })
  7019. return
  7020. } else {
  7021. c.ServeSuccessJSON(map[string]interface{}{
  7022. "info": result3265.Output,
  7023. })
  7024. return
  7025. }
  7026. }
  7027. func (c *HisApiController) Get3266() {
  7028. admin_user_id, _ := c.GetInt64("admin_user_id")
  7029. startTime := c.GetString("start_time")
  7030. //endTime, _ := c.GetString("end_time")
  7031. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7032. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7033. times := strings.Split(startTime, "-")
  7034. stmt_mon := times[0] + times[1]
  7035. var upld_btch string
  7036. //var empty models.JSResultEmpty
  7037. var result3265 models.JSResult3264
  7038. data := make(map[string]interface{})
  7039. data["org_name"] = miConfig.OrgName
  7040. data["doctor"] = curRoles.UserName
  7041. data["doctor_name"] = curRoles.UserName
  7042. data["fixmedins_code"] = miConfig.Code
  7043. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7044. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7045. data["secret_key"] = miConfig.SecretKey
  7046. data["url"] = miConfig.Url
  7047. data["ak"] = miConfig.AccessKey
  7048. data["cainfo"] = miConfig.Cainfo
  7049. data["setl_mon"] = stmt_mon
  7050. month := time.Unix(1557042972, 0).Format("1")
  7051. year := time.Now().Format("2006")
  7052. month = time.Now().Format("01")
  7053. day := time.Now().Format("02")
  7054. hour := time.Now().Format("15")
  7055. min := time.Now().Format("04")
  7056. sec := time.Now().Format("05")
  7057. fix_fill_date := year + month + day + hour + min + sec
  7058. data["fix_fill_dept"] = miConfig.OrgName
  7059. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7060. data["fix_fill_psn"] = curRoles.UserName
  7061. data["fix_fill_date"] = fix_fill_date
  7062. data["stmt_loc"] = "2"
  7063. upld_btch = "0"
  7064. data["upld_btch"] = upld_btch
  7065. client := &http.Client{}
  7066. bytesData, _ := json.Marshal(data)
  7067. var req *http.Request
  7068. if miConfig.MdtrtareaAdmvs == "320830" {
  7069. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3266", bytes.NewReader(bytesData))
  7070. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7071. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  7072. } else {
  7073. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  7074. }
  7075. resp, _ := client.Do(req)
  7076. defer resp.Body.Close()
  7077. body, ioErr := ioutil.ReadAll(resp.Body)
  7078. if ioErr != nil {
  7079. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7081. }
  7082. var respJSON map[string]interface{}
  7083. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7084. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7086. }
  7087. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7088. fmt.Println(respJSON)
  7089. result, _ := json.Marshal(respJSON)
  7090. fmt.Println(result)
  7091. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7092. utils.ErrorLog("解析失败:%v", err)
  7093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7094. }
  7095. if result3265.Infcode != "0" {
  7096. c.ServeSuccessJSON(map[string]interface{}{
  7097. "failed_code": -10,
  7098. "msg": result3265.ErrMsg,
  7099. })
  7100. return
  7101. } else {
  7102. c.ServeSuccessJSON(map[string]interface{}{
  7103. "info": result3265.Output,
  7104. })
  7105. return
  7106. }
  7107. }
  7108. func (c *HisApiController) Get3267() {
  7109. admin_user_id, _ := c.GetInt64("admin_user_id")
  7110. startTime := c.GetString("start_time")
  7111. //endTime, _ := c.GetString("end_time")
  7112. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7113. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7114. times := strings.Split(startTime, "-")
  7115. setl_mon := times[0] + times[1]
  7116. var upld_btch string
  7117. //var empty models.JSResultEmpty
  7118. var result3265 models.JSResult3264
  7119. upld_btch = "0"
  7120. data := make(map[string]interface{})
  7121. data["org_name"] = miConfig.OrgName
  7122. data["doctor"] = curRoles.UserName
  7123. data["doctor_name"] = curRoles.UserName
  7124. data["fixmedins_code"] = miConfig.Code
  7125. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7126. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7127. data["secret_key"] = miConfig.SecretKey
  7128. data["url"] = miConfig.Url
  7129. data["ak"] = miConfig.AccessKey
  7130. data["cainfo"] = miConfig.Cainfo
  7131. data["setl_mon"] = setl_mon
  7132. data["stmt_loc"] = "2"
  7133. data["upld_btch"] = upld_btch
  7134. client := &http.Client{}
  7135. bytesData, _ := json.Marshal(data)
  7136. var req *http.Request
  7137. if miConfig.MdtrtareaAdmvs == "320830" {
  7138. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3267", bytes.NewReader(bytesData))
  7139. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7140. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  7141. } else {
  7142. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  7143. }
  7144. resp, _ := client.Do(req)
  7145. defer resp.Body.Close()
  7146. body, ioErr := ioutil.ReadAll(resp.Body)
  7147. if ioErr != nil {
  7148. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7150. }
  7151. var respJSON map[string]interface{}
  7152. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7153. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7155. }
  7156. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7157. fmt.Println(respJSON)
  7158. result, _ := json.Marshal(respJSON)
  7159. fmt.Println(result)
  7160. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7161. utils.ErrorLog("解析失败:%v", err)
  7162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7163. }
  7164. if result3265.Infcode != "0" {
  7165. c.ServeSuccessJSON(map[string]interface{}{
  7166. "failed_code": -10,
  7167. "msg": result3265.ErrMsg,
  7168. })
  7169. return
  7170. } else {
  7171. c.ServeSuccessJSON(map[string]interface{}{
  7172. "info": result3265.Output.Data,
  7173. })
  7174. return
  7175. }
  7176. }
  7177. func (c *HisApiController) Get3268() {
  7178. admin_user_id, _ := c.GetInt64("admin_user_id")
  7179. startTime := c.GetString("start_time")
  7180. endTime := c.GetString("end_time")
  7181. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7182. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7183. times := strings.Split(startTime, "-")
  7184. setl_mon := times[0] + times[1]
  7185. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  7186. var twos []models.FixMonRecDetailFileInTwo
  7187. var funs []models.FundDetail
  7188. for _, item := range datas {
  7189. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  7190. funs = append(funs, fun...)
  7191. }
  7192. var funInfos []models.Fund
  7193. //for _, item := range funs {
  7194. // var rf []models.FundInfo
  7195. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  7196. // for _, subitem := range rf {
  7197. // var fund models.Fund
  7198. // fund.FundCode = subitem.FundPayType
  7199. // fund.FundName = subitem.FundPayTypeName
  7200. // fund.FundAmt = subitem.FundPayAmt
  7201. // fund.FundKey = item.FundKey
  7202. // fund.InsuAdmdvs = "555555"
  7203. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  7204. // funInfos = append(funInfos, fund)
  7205. // }
  7206. //}
  7207. for _, team := range datas {
  7208. var two models.FixMonRecDetailFileInTwo
  7209. two.SetlDate = time.Now().Format("2006-01-02")
  7210. two.MedType = team.MedType
  7211. two.Insutype = team.Insutype
  7212. two.PsnType = team.PsnType
  7213. two.MedType = team.MedType
  7214. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  7215. two.InsuAdmdvs = team.InsuAdmdvs
  7216. two.PsnTime = team.PsnTime
  7217. two.PsnCnt = team.PsnCnt
  7218. two.FundKey = team.FundKey
  7219. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  7220. fps, _ := strconv.ParseFloat(team.Fund, 64)
  7221. ia, _ := strconv.ParseFloat(team.Amt, 64)
  7222. two.MedfeeSumAmt = ms
  7223. two.InscpAmt = ia
  7224. two.FundPaySumAmt = fps
  7225. twos = append(twos, two)
  7226. }
  7227. var upld_btch string
  7228. upld_btch = "0"
  7229. var empty models.JSResultEmpty
  7230. data := make(map[string]interface{})
  7231. data["org_name"] = miConfig.OrgName
  7232. data["doctor"] = curRoles.UserName
  7233. data["doctor_name"] = curRoles.UserName
  7234. data["fixmedins_code"] = miConfig.Code
  7235. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7236. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7237. data["secret_key"] = miConfig.SecretKey
  7238. data["url"] = miConfig.Url
  7239. data["ak"] = miConfig.AccessKey
  7240. data["cainfo"] = miConfig.Cainfo
  7241. data["datas"] = twos
  7242. data["fund"] = funInfos
  7243. data["setl_mon"] = setl_mon
  7244. month := time.Unix(1557042972, 0).Format("1")
  7245. year := time.Now().Format("2006")
  7246. month = time.Now().Format("01")
  7247. day := time.Now().Format("02")
  7248. hour := time.Now().Format("15")
  7249. min := time.Now().Format("04")
  7250. sec := time.Now().Format("05")
  7251. fix_fill_date := year + month + day + hour + min + sec
  7252. data["fix_fill_dept"] = miConfig.OrgName
  7253. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7254. data["fix_fill_psn"] = curRoles.UserName
  7255. data["fix_fill_date"] = fix_fill_date
  7256. data["stmt_loc"] = "2"
  7257. data["upld_btch"] = upld_btch
  7258. client := &http.Client{}
  7259. bytesData, _ := json.Marshal(data)
  7260. var req *http.Request
  7261. if miConfig.MdtrtareaAdmvs == "320830" {
  7262. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3268", bytes.NewReader(bytesData))
  7263. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7264. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  7265. } else {
  7266. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  7267. }
  7268. resp, _ := client.Do(req)
  7269. defer resp.Body.Close()
  7270. body, ioErr := ioutil.ReadAll(resp.Body)
  7271. if ioErr != nil {
  7272. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7274. }
  7275. var respJSON map[string]interface{}
  7276. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7277. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7279. }
  7280. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7281. fmt.Println(respJSON)
  7282. result, _ := json.Marshal(respJSON)
  7283. fmt.Println(result)
  7284. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  7285. utils.ErrorLog("解析失败:%v", err)
  7286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7287. }
  7288. if empty.Infcode != "0" {
  7289. c.ServeSuccessJSON(map[string]interface{}{
  7290. "failed_code": -10,
  7291. "msg": empty.ErrMsg,
  7292. })
  7293. return
  7294. } else {
  7295. c.ServeSuccessJSON(map[string]interface{}{
  7296. "msg": "上传成功",
  7297. })
  7298. return
  7299. }
  7300. }
  7301. func (c *HisApiController) Get3269() {
  7302. admin_user_id, _ := c.GetInt64("admin_user_id")
  7303. startTime := c.GetString("start_time")
  7304. //endTime, _ := c.GetString("end_time")
  7305. times := strings.Split(startTime, "-")
  7306. setl_mon := times[0] + times[1]
  7307. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7308. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7309. var result3263 models.JSResult3263
  7310. data := make(map[string]interface{})
  7311. data["org_name"] = miConfig.OrgName
  7312. data["doctor"] = curRoles.UserName
  7313. data["doctor_name"] = curRoles.UserName
  7314. data["fixmedins_code"] = miConfig.Code
  7315. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7316. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7317. data["secret_key"] = miConfig.SecretKey
  7318. data["url"] = miConfig.Url
  7319. data["ak"] = miConfig.AccessKey
  7320. data["cainfo"] = miConfig.Cainfo
  7321. data["setl_mon"] = setl_mon
  7322. data["stmt_loc"] = "2"
  7323. client := &http.Client{}
  7324. bytesData, _ := json.Marshal(data)
  7325. var req *http.Request
  7326. if miConfig.MdtrtareaAdmvs == "320830" {
  7327. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3269", bytes.NewReader(bytesData))
  7328. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7329. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  7330. } else {
  7331. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  7332. }
  7333. resp, _ := client.Do(req)
  7334. defer resp.Body.Close()
  7335. body, ioErr := ioutil.ReadAll(resp.Body)
  7336. if ioErr != nil {
  7337. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7339. }
  7340. var respJSON map[string]interface{}
  7341. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7342. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7344. }
  7345. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7346. fmt.Println(respJSON)
  7347. result, _ := json.Marshal(respJSON)
  7348. fmt.Println(result)
  7349. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  7350. utils.ErrorLog("解析失败:%v", err)
  7351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7352. }
  7353. if result3263.Infcode != "0" {
  7354. c.ServeSuccessJSON(map[string]interface{}{
  7355. "failed_code": -10,
  7356. "msg": result3263.ErrMsg,
  7357. })
  7358. return
  7359. } else {
  7360. c.ServeSuccessJSON(map[string]interface{}{
  7361. "msg": "上传成功",
  7362. })
  7363. return
  7364. }
  7365. }
  7366. func (c *HisApiController) Get3270() {
  7367. admin_user_id, _ := c.GetInt64("admin_user_id")
  7368. startTime := c.GetString("start_time")
  7369. //endTime, _ := c.GetString("end_time")
  7370. times := strings.Split(startTime, "-")
  7371. setl_mon := times[0] + times[1]
  7372. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7373. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7374. var result3263 models.JSResult3263
  7375. data2 := make(map[string]interface{})
  7376. data2["org_name"] = miConfig.OrgName
  7377. data2["doctor"] = curRoles.UserName
  7378. data2["doctor_name"] = curRoles.UserName
  7379. data2["fixmedins_code"] = miConfig.Code
  7380. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7381. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7382. data2["secret_key"] = miConfig.SecretKey
  7383. data2["url"] = miConfig.Url
  7384. data2["ak"] = miConfig.AccessKey
  7385. data2["cainfo"] = miConfig.Cainfo
  7386. data2["setl_mon"] = setl_mon
  7387. data2["stmt_loc"] = "2"
  7388. client2 := &http.Client{}
  7389. bytesData2, _ := json.Marshal(data2)
  7390. var req3263 *http.Request
  7391. if miConfig.MdtrtareaAdmvs == "320830" {
  7392. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3269", bytes.NewReader(bytesData2))
  7393. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7394. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7395. } else {
  7396. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7397. }
  7398. resp2, _ := client2.Do(req3263)
  7399. defer resp2.Body.Close()
  7400. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7401. if ioErr2 != nil {
  7402. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7404. }
  7405. var respJSON3263 map[string]interface{}
  7406. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7407. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7409. }
  7410. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7411. fmt.Println(respJSON3263)
  7412. result2, _ := json.Marshal(respJSON3263)
  7413. fmt.Println(result2)
  7414. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7415. utils.ErrorLog("解析失败:%v", err)
  7416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7417. }
  7418. var ids []string
  7419. for _, item := range result3263.Output {
  7420. ids = append(ids, item.SolidifyID)
  7421. }
  7422. var result3264 models.JSResult3264
  7423. data := make(map[string]interface{})
  7424. data["org_name"] = miConfig.OrgName
  7425. data["doctor"] = curRoles.UserName
  7426. data["doctor_name"] = curRoles.UserName
  7427. data["fixmedins_code"] = miConfig.Code
  7428. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7429. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7430. data["secret_key"] = miConfig.SecretKey
  7431. data["url"] = miConfig.Url
  7432. data["ak"] = miConfig.AccessKey
  7433. data["cainfo"] = miConfig.Cainfo
  7434. data["setl_mon"] = setl_mon
  7435. data["stmt_loc"] = "2"
  7436. data["solidify_id"] = ids
  7437. client := &http.Client{}
  7438. bytesData, _ := json.Marshal(data)
  7439. var req *http.Request
  7440. if miConfig.MdtrtareaAdmvs == "320830" {
  7441. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3270", bytes.NewReader(bytesData))
  7442. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7443. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7444. } else {
  7445. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7446. }
  7447. resp, _ := client.Do(req)
  7448. defer resp.Body.Close()
  7449. body, ioErr := ioutil.ReadAll(resp.Body)
  7450. if ioErr != nil {
  7451. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7453. }
  7454. var respJSON map[string]interface{}
  7455. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7456. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7458. }
  7459. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7460. fmt.Println(respJSON)
  7461. result, _ := json.Marshal(respJSON)
  7462. fmt.Println(result)
  7463. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  7464. utils.ErrorLog("解析失败:%v", err)
  7465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7466. }
  7467. if result3264.Infcode != "0" {
  7468. c.ServeSuccessJSON(map[string]interface{}{
  7469. "failed_code": -10,
  7470. "msg": result3264.ErrMsg,
  7471. })
  7472. return
  7473. } else {
  7474. c.ServeSuccessJSON(map[string]interface{}{
  7475. "info": result3264.Output,
  7476. })
  7477. return
  7478. }
  7479. }
  7480. func (c *HisApiController) Get3271() {
  7481. admin_user_id, _ := c.GetInt64("admin_user_id")
  7482. startTime := c.GetString("start_time")
  7483. //endTime, _ := c.GetString("end_time")
  7484. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7485. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7486. times := strings.Split(startTime, "-")
  7487. setl_mon := times[0] + times[1]
  7488. //var empty models.JSResultEmpty
  7489. var result3265 models.JSResult3264
  7490. var result3263 models.JSResult3263
  7491. data2 := make(map[string]interface{})
  7492. data2["org_name"] = miConfig.OrgName
  7493. data2["doctor"] = curRoles.UserName
  7494. data2["doctor_name"] = curRoles.UserName
  7495. data2["fixmedins_code"] = miConfig.Code
  7496. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7497. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7498. data2["secret_key"] = miConfig.SecretKey
  7499. data2["url"] = miConfig.Url
  7500. data2["ak"] = miConfig.AccessKey
  7501. data2["cainfo"] = miConfig.Cainfo
  7502. data2["setl_mon"] = setl_mon
  7503. data2["stmt_loc"] = "2"
  7504. client2 := &http.Client{}
  7505. bytesData2, _ := json.Marshal(data2)
  7506. var req3263 *http.Request
  7507. if miConfig.MdtrtareaAdmvs == "320830" {
  7508. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3269", bytes.NewReader(bytesData2))
  7509. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7510. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7511. } else {
  7512. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7513. }
  7514. resp2, _ := client2.Do(req3263)
  7515. defer resp2.Body.Close()
  7516. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7517. if ioErr2 != nil {
  7518. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7520. }
  7521. var respJSON3263 map[string]interface{}
  7522. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7523. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7525. }
  7526. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7527. fmt.Println(respJSON3263)
  7528. result2, _ := json.Marshal(respJSON3263)
  7529. fmt.Println(result2)
  7530. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7531. utils.ErrorLog("解析失败:%v", err)
  7532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7533. }
  7534. var ids []string
  7535. for _, item := range result3263.Output {
  7536. ids = append(ids, item.SolidifyID)
  7537. }
  7538. data := make(map[string]interface{})
  7539. data["org_name"] = miConfig.OrgName
  7540. data["doctor"] = curRoles.UserName
  7541. data["doctor_name"] = curRoles.UserName
  7542. data["fixmedins_code"] = miConfig.Code
  7543. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7544. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7545. data["secret_key"] = miConfig.SecretKey
  7546. data["url"] = miConfig.Url
  7547. data["ak"] = miConfig.AccessKey
  7548. data["cainfo"] = miConfig.Cainfo
  7549. data["setl_mon"] = setl_mon
  7550. data["solidify_id"] = ids
  7551. month := time.Unix(1557042972, 0).Format("1")
  7552. year := time.Now().Format("2006")
  7553. month = time.Now().Format("01")
  7554. day := time.Now().Format("02")
  7555. hour := time.Now().Format("15")
  7556. min := time.Now().Format("04")
  7557. sec := time.Now().Format("05")
  7558. fix_fill_date := year + month + day + hour + min + sec
  7559. data["fix_fill_dept"] = miConfig.OrgName
  7560. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7561. data["fix_fill_psn"] = curRoles.UserName
  7562. data["fix_fill_date"] = fix_fill_date
  7563. data["stmt_loc"] = "2"
  7564. client := &http.Client{}
  7565. bytesData, _ := json.Marshal(data)
  7566. var req *http.Request
  7567. if miConfig.MdtrtareaAdmvs == "320830" {
  7568. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3271", bytes.NewReader(bytesData2))
  7569. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7570. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7571. } else {
  7572. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7573. }
  7574. resp, _ := client.Do(req)
  7575. defer resp.Body.Close()
  7576. body, ioErr := ioutil.ReadAll(resp.Body)
  7577. if ioErr != nil {
  7578. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7580. }
  7581. var respJSON map[string]interface{}
  7582. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7583. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7585. }
  7586. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7587. fmt.Println(respJSON)
  7588. result, _ := json.Marshal(respJSON)
  7589. fmt.Println(result)
  7590. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7591. utils.ErrorLog("解析失败:%v", err)
  7592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7593. }
  7594. if result3265.Infcode != "0" {
  7595. c.ServeSuccessJSON(map[string]interface{}{
  7596. "failed_code": -10,
  7597. "msg": result3265.ErrMsg,
  7598. })
  7599. return
  7600. } else {
  7601. c.ServeSuccessJSON(map[string]interface{}{
  7602. "info": result3265.Output.Data,
  7603. })
  7604. return
  7605. }
  7606. }
  7607. func (c *HisApiController) Get3272() {
  7608. admin_user_id, _ := c.GetInt64("admin_user_id")
  7609. startTime := c.GetString("start_time")
  7610. //endTime, _ := c.GetString("end_time")
  7611. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7612. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7613. times := strings.Split(startTime, "-")
  7614. setl_mon := times[0] + times[1]
  7615. var upld_btch string
  7616. //var empty models.JSResultEmpty
  7617. var result3265 models.JSResult3264
  7618. data := make(map[string]interface{})
  7619. data["org_name"] = miConfig.OrgName
  7620. data["doctor"] = curRoles.UserName
  7621. data["doctor_name"] = curRoles.UserName
  7622. data["fixmedins_code"] = miConfig.Code
  7623. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7624. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7625. data["secret_key"] = miConfig.SecretKey
  7626. data["url"] = miConfig.Url
  7627. data["ak"] = miConfig.AccessKey
  7628. data["cainfo"] = miConfig.Cainfo
  7629. data["setl_mon"] = setl_mon
  7630. month := time.Unix(1557042972, 0).Format("1")
  7631. year := time.Now().Format("2006")
  7632. month = time.Now().Format("01")
  7633. day := time.Now().Format("02")
  7634. hour := time.Now().Format("15")
  7635. min := time.Now().Format("04")
  7636. sec := time.Now().Format("05")
  7637. fix_fill_date := year + month + day + hour + min + sec
  7638. data["fix_fill_dept"] = miConfig.OrgName
  7639. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7640. data["fix_fill_psn"] = curRoles.UserName
  7641. data["fix_fill_date"] = fix_fill_date
  7642. data["stmt_loc"] = "2"
  7643. data["upld_btch"] = upld_btch
  7644. client := &http.Client{}
  7645. bytesData, _ := json.Marshal(data)
  7646. var req *http.Request
  7647. if miConfig.MdtrtareaAdmvs == "320830" {
  7648. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3272", bytes.NewReader(bytesData))
  7649. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7650. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7651. } else {
  7652. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7653. }
  7654. resp, _ := client.Do(req)
  7655. defer resp.Body.Close()
  7656. body, ioErr := ioutil.ReadAll(resp.Body)
  7657. if ioErr != nil {
  7658. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7660. }
  7661. var respJSON map[string]interface{}
  7662. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7663. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7665. }
  7666. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7667. fmt.Println(respJSON)
  7668. result, _ := json.Marshal(respJSON)
  7669. fmt.Println(result)
  7670. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7671. utils.ErrorLog("解析失败:%v", err)
  7672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7673. }
  7674. if result3265.Infcode != "0" {
  7675. c.ServeSuccessJSON(map[string]interface{}{
  7676. "failed_code": -10,
  7677. "msg": result3265.ErrMsg,
  7678. })
  7679. return
  7680. } else {
  7681. c.ServeSuccessJSON(map[string]interface{}{
  7682. "info": result3265.Output,
  7683. })
  7684. return
  7685. }
  7686. }
  7687. func (c *HisApiController) Get3273() {
  7688. admin_user_id, _ := c.GetInt64("admin_user_id")
  7689. startTime := c.GetString("start_time")
  7690. //endTime, _ := c.GetString("end_time")
  7691. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7692. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7693. times := strings.Split(startTime, "-")
  7694. setl_mon := times[0] + times[1]
  7695. var result3265 models.JSResult3264
  7696. data := make(map[string]interface{})
  7697. data["org_name"] = miConfig.OrgName
  7698. data["doctor"] = curRoles.UserName
  7699. data["doctor_name"] = curRoles.UserName
  7700. data["fixmedins_code"] = miConfig.Code
  7701. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7702. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7703. data["secret_key"] = miConfig.SecretKey
  7704. data["url"] = miConfig.Url
  7705. data["ak"] = miConfig.AccessKey
  7706. data["cainfo"] = miConfig.Cainfo
  7707. data["setl_mon"] = setl_mon
  7708. data["stmt_loc"] = "2"
  7709. client := &http.Client{}
  7710. bytesData, _ := json.Marshal(data)
  7711. var req *http.Request
  7712. if miConfig.MdtrtareaAdmvs == "320921" {
  7713. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7714. } else {
  7715. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7716. }
  7717. resp, _ := client.Do(req)
  7718. defer resp.Body.Close()
  7719. body, ioErr := ioutil.ReadAll(resp.Body)
  7720. if ioErr != nil {
  7721. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7723. }
  7724. var respJSON map[string]interface{}
  7725. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7726. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7728. }
  7729. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7730. fmt.Println(respJSON)
  7731. result, _ := json.Marshal(respJSON)
  7732. fmt.Println(result)
  7733. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7734. utils.ErrorLog("解析失败:%v", err)
  7735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7736. }
  7737. if result3265.Infcode != "0" {
  7738. c.ServeSuccessJSON(map[string]interface{}{
  7739. "failed_code": -10,
  7740. "msg": result3265.ErrMsg,
  7741. })
  7742. return
  7743. } else {
  7744. c.ServeSuccessJSON(map[string]interface{}{
  7745. "info": result3265.Output.Data,
  7746. })
  7747. return
  7748. }
  7749. }
  7750. func (c *HisApiController) Get3274() {
  7751. //if miConfig.MdtrtareaAdmvs == "320921" {
  7752. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7753. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7754. // "&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
  7755. //
  7756. //} else {
  7757. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7758. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7759. // "&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
  7760. //
  7761. //}
  7762. }
  7763. func (c *HisApiController) Get3275() {
  7764. //if miConfig.MdtrtareaAdmvs == "320921" {
  7765. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7766. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7767. // "&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
  7768. //
  7769. //} else {
  7770. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7771. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7772. // "&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
  7773. //
  7774. //}
  7775. }
  7776. func (c *HisApiController) Get3276() {
  7777. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7778. //month := c.GetString("month")
  7779. //
  7780. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7781. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7782. //var api string
  7783. //var res Result5301
  7784. //
  7785. //if miConfig.MdtrtareaAdmvs == "320921" {
  7786. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7787. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7788. //} else {
  7789. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7790. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7791. //}
  7792. //
  7793. //resp, requestErr := http.Get(api)
  7794. //if requestErr != nil {
  7795. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7796. // return
  7797. //}
  7798. //
  7799. //body, ioErr := ioutil.ReadAll(resp.Body)
  7800. //if ioErr != nil {
  7801. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7802. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7803. // return
  7804. //}
  7805. //var respJSON map[string]interface{}
  7806. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7807. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7808. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7809. // return
  7810. //}
  7811. //
  7812. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7813. //result, _ := json.Marshal(respJSON)
  7814. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7815. // utils.ErrorLog("解析失败:%v", err)
  7816. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7817. // return
  7818. //}
  7819. }
  7820. func (c *HisApiController) Get3277() {
  7821. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7822. //month := c.GetString("month")
  7823. //
  7824. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7825. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7826. //var api string
  7827. //var res Result5301
  7828. //
  7829. //if miConfig.MdtrtareaAdmvs == "320921" {
  7830. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7831. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7832. //} else {
  7833. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7834. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7835. //}
  7836. //
  7837. //resp, requestErr := http.Get(api)
  7838. //if requestErr != nil {
  7839. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7840. // return
  7841. //}
  7842. //
  7843. //body, ioErr := ioutil.ReadAll(resp.Body)
  7844. //if ioErr != nil {
  7845. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7846. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7847. // return
  7848. //}
  7849. //var respJSON map[string]interface{}
  7850. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7851. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7852. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7853. // return
  7854. //}
  7855. //
  7856. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7857. //result, _ := json.Marshal(respJSON)
  7858. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7859. // utils.ErrorLog("解析失败:%v", err)
  7860. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7861. // return
  7862. //}
  7863. }
  7864. func (c *HisApiController) GetCFYLJG001() {
  7865. admin_user_id, _ := c.GetInt64("admin_user_id")
  7866. patient_id, _ := c.GetInt64("patient_id")
  7867. his_patient_id, _ := c.GetInt64("his_patient_id")
  7868. record_time := c.GetString("record_time")
  7869. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7870. psn, _ := service.GetPsnByPatientId(patient_id)
  7871. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7872. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7873. var cFYLJG001 models.CFYLJG001
  7874. timeLayout := "2006-01-02"
  7875. loc, _ := time.LoadLocation("Local")
  7876. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7877. if err != nil {
  7878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7879. return
  7880. }
  7881. recordDateTime := theTime.Unix()
  7882. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7883. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7884. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7885. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7886. //dept, _ := service.GetDepartMentDetail(info.Departments)
  7887. for _, item := range prescriptions {
  7888. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  7889. if his.IdCardType == 1 {
  7890. bas := strings.Split(psn.CardInfo, "|")
  7891. basNumber := bas[1]
  7892. fmt.Println(basNumber)
  7893. card_sn := bas[3]
  7894. card_no := bas[2]
  7895. cFYLJG001.MdtrtCertType = "03"
  7896. cFYLJG001.CardSn = card_sn
  7897. cFYLJG001.MdtrtCertNo = card_no
  7898. cFYLJG001.EcToken = ""
  7899. cFYLJG001.AuthNo = ""
  7900. } else if his.IdCardType == 2 {
  7901. cFYLJG001.MdtrtCertType = "02"
  7902. cFYLJG001.CardSn = ""
  7903. cFYLJG001.MdtrtCertNo = his.IdCardNo
  7904. cFYLJG001.EcToken = ""
  7905. cFYLJG001.AuthNo = ""
  7906. } else if his.IdCardType == 4 {
  7907. cFYLJG001.MdtrtCertType = "01"
  7908. cFYLJG001.CardSn = ""
  7909. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  7910. cFYLJG001.EcToken = psn.VerifyNumber
  7911. cFYLJG001.AuthNo = ""
  7912. }
  7913. cFYLJG001.BizTypeCode = "01"
  7914. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  7915. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  7916. cFYLJG001.RxTypeCode = "1"
  7917. tempTime := time.Unix(item.PreTime, 0)
  7918. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  7919. cFYLJG001.PrscTime = timeFormatOne
  7920. var count float64
  7921. if item.Type == 1 {
  7922. for _, sumItem := range item.HisDoctorAdviceInfo {
  7923. count = count + sumItem.PrescribingNumber
  7924. }
  7925. }
  7926. cFYLJG001.RxDrugCnt = count
  7927. cFYLJG001.ValiDays = "2"
  7928. ts := time.Unix(item.PreTime, 0)
  7929. record_time2 := ts.AddDate(0, 0, int(2)).Unix()
  7930. tempTime3 := time.Unix(record_time2, 0)
  7931. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  7932. cFYLJG001.ValiEndTime = timeFormat3
  7933. cFYLJG001.RxCotnFlag = "0"
  7934. for _, subItem := range item.HisDoctorAdviceInfo {
  7935. var drug models.RxDrug
  7936. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7937. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7938. drug.RxItemTypeCode = "11"
  7939. drug.DrugDosform = "剂" //TODO
  7940. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  7941. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7942. }
  7943. drug.MedcWayDscr = subItem.DeliveryWay
  7944. tempTime2 := time.Unix(subItem.StartTime, 0)
  7945. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7946. drug.MedcBegntime = timeFormatTwo
  7947. if subItem.Day > 0 {
  7948. ts := time.Unix(subItem.StartTime, 0)
  7949. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  7950. tempTime4 := time.Unix(record_time, 0)
  7951. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  7952. drug.MedcEndtime = timeFormat5
  7953. } else {
  7954. tempTime2 := time.Unix(subItem.StartTime, 0)
  7955. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7956. drug.MedcEndtime = timeFormatTwo
  7957. }
  7958. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  7959. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  7960. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  7961. drug.DrugCnt = subItem.PrescribingNumber
  7962. drug.DrugDosunt = subItem.PrescribingNumberUnit
  7963. drug.DrugGenname = subItem.AdviceName
  7964. drug.MedcWayCodg = subItem.DeliveryWay
  7965. //drug.DrugTotlcnt = subItem.PrescribingNumber
  7966. drug.SinDoscnt = subItem.SingleDose
  7967. drug.SinDosunt = subItem.SingleDoseUnit
  7968. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  7969. drug.UsedFrquName = subItem.ExecutionFrequency
  7970. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7971. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  7972. drug.HospApprFlag = "1"
  7973. cFYLJG001.List = append(cFYLJG001.List, drug)
  7974. }
  7975. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  7976. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.OrgName
  7977. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  7978. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  7979. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  7980. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  7981. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  7982. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  7983. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  7984. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  7985. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7986. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  7987. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  7988. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  7989. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7990. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  7991. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  7992. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  7993. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  7994. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  7995. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  7996. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  7997. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  7998. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  7999. tempTime2 := time.Now().Unix()
  8000. tempTime6 := time.Unix(tempTime2, 0)
  8001. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  8002. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  8003. cFYLJG001.Mdtrtinfo.DiseCodg = ""
  8004. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  8005. cFYLJG001.Mdtrtinfo.MaindiagCode = "I10.x00x002"
  8006. cFYLJG001.Mdtrtinfo.MaindiagName = "高血压"
  8007. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  8008. var config []*models.HisXtDiagnoseConfig
  8009. for _, item := range diagnosis_ids {
  8010. id, _ := strconv.ParseInt(item, 10, 64)
  8011. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8012. config = append(config, &diagnosisConfig)
  8013. }
  8014. for index, subitem := range config {
  8015. if index == 0 {
  8016. var dia models.DiseInfo
  8017. dia.DiagType = "1"
  8018. dia.MaindiagFlag = "1"
  8019. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8020. dia.DiagCode = subitem.CountryCode
  8021. dia.DiagName = subitem.ClassName
  8022. dia.DiagDept = "肾内科"
  8023. dia.DiagDrNo = doctor.DoctorNumber
  8024. dia.DiagDrName = doctor.UserName
  8025. tempTime3 := time.Unix(item.PreTime, 0)
  8026. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  8027. dia.DiagTime = timeFormatTwo
  8028. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  8029. } else {
  8030. var dia models.DiseInfo
  8031. dia.DiagType = "1"
  8032. dia.MaindiagFlag = "0"
  8033. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8034. dia.DiagCode = subitem.CountryCode
  8035. dia.DiagName = subitem.ClassName
  8036. dia.DiagDept = "肾内科"
  8037. dia.DiagDrNo = doctor.DoctorNumber
  8038. dia.DiagDrName = doctor.UserName
  8039. tempTime3 := time.Unix(item.PreTime, 0)
  8040. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  8041. dia.DiagTime = timeFormatTwo
  8042. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  8043. }
  8044. }
  8045. if miConfig.MdtrtareaAdmvs == "340699" {
  8046. result, request := service.GetAHCFYLJG001("http://10.66.149.64:8080/epc/api", cFYLJG001, his.Insutype)
  8047. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  8048. var res ResultCFYLJG001AH
  8049. var respJSON2 map[string]interface{}
  8050. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8051. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8053. return
  8054. }
  8055. userJSONBytes2, _ := json.Marshal(respJSON2)
  8056. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8057. utils.ErrorLog("解析失败:%v", err)
  8058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8059. return
  8060. }
  8061. var flow models.HisPrescriptionFlow
  8062. flow.Ctime = time.Now().Unix()
  8063. flow.SignDigest = ""
  8064. flow.RxTraceCode = res.RxTraceCode
  8065. flow.HiRxno = res.HiRxno
  8066. flow.MID = his.Number
  8067. flow.Status = 1
  8068. flow.DCode = doctor_info.DoctorNumber
  8069. flow.OriginalRxFile = ""
  8070. flow.OriginalValue = ""
  8071. flow.SignCertDn = ""
  8072. flow.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  8073. flow.SignCertSn = ""
  8074. flow.Mtime = time.Now().Unix()
  8075. service.Createflow(&flow)
  8076. c.ServeSuccessJSON(map[string]interface{}{
  8077. "msg": "上传成功",
  8078. })
  8079. } else {
  8080. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  8081. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  8082. var res ResultCFYLJG001
  8083. var respJSON2 map[string]interface{}
  8084. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8085. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8087. return
  8088. }
  8089. userJSONBytes2, _ := json.Marshal(respJSON2)
  8090. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8091. utils.ErrorLog("解析失败:%v", err)
  8092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8093. return
  8094. }
  8095. if res.Infcode == -1 {
  8096. c.ServeSuccessJSON(map[string]interface{}{
  8097. "failed_code": -10,
  8098. "msg": res.ErrMsg,
  8099. })
  8100. return
  8101. } else {
  8102. var flow models.HisPrescriptionFlow
  8103. flow.Ctime = time.Now().Unix()
  8104. flow.SignDigest = ""
  8105. flow.RxTraceCode = res.Output.RxTraceCode
  8106. flow.HiRxno = res.Output.HiRxno
  8107. flow.MID = his.Number
  8108. flow.Status = 1
  8109. flow.DCode = doctor_info.DoctorNumber
  8110. flow.OriginalRxFile = ""
  8111. flow.OriginalValue = ""
  8112. flow.SignCertDn = ""
  8113. flow.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  8114. flow.SignCertSn = ""
  8115. flow.Mtime = time.Now().Unix()
  8116. service.Createflow(&flow)
  8117. c.ServeSuccessJSON(map[string]interface{}{
  8118. "msg": "上传成功",
  8119. })
  8120. }
  8121. }
  8122. }
  8123. }
  8124. func (c *HisApiController) GetCFYLJG12() {
  8125. admin_user_id, _ := c.GetInt64("admin_user_id")
  8126. his_patient_id, _ := c.GetInt64("his_patient_id")
  8127. record_time := c.GetString("record_time")
  8128. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8129. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8130. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8131. flow, _ := service.Getflowtwo(his.Number)
  8132. patient_id, _ := c.GetInt64("patient_id")
  8133. timeLayout := "2006-01-02"
  8134. loc, _ := time.LoadLocation("Local")
  8135. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8136. if err != nil {
  8137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8138. return
  8139. }
  8140. recordDateTime := theTime.Unix()
  8141. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8142. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8143. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8144. dept, _ := service.GetDepartMentDetail(info.Departments)
  8145. inputData := make(map[string]interface{})
  8146. inputData["rxTraceCode"] = flow.RxTraceCode
  8147. inputData["hiRxno"] = flow.HiRxno
  8148. inputData["mdtrtId"] = flow.MID
  8149. inputData["patnName"] = his.PsnName
  8150. inputData["psnCertType"] = his.PsnCertType
  8151. inputData["certno"] = his.Certno
  8152. inputData["fixmedinsName"] = miConfig.OrgName
  8153. inputData["fixmedinsCode"] = miConfig.Code
  8154. inputData["drCode"] = doctor_info.DoctorNumber
  8155. inputData["prscDrName"] = doctor_info.UserName
  8156. inputData["pharDeptName"] = dept.Name
  8157. inputData["pharDeptCode"] = dept.Number
  8158. inputData["pharProfttlCodg"] = ""
  8159. inputData["pharProfttlName"] = ""
  8160. inputData["pharCode"] = "HY340621000425"
  8161. inputData["pharCertType"] = "01"
  8162. inputData["pharCertno"] = ""
  8163. inputData["pharName"] = "孙莉侠"
  8164. inputData["pharPracCertNo"] = ""
  8165. tempTime2 := time.Unix(info.Ctime, 0)
  8166. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8167. inputData["pharChkTime"] = timeFormatTwo
  8168. bytesData, _ := json.Marshal(inputData)
  8169. fmt.Println(string(bytesData))
  8170. encoded := base64.StdEncoding.EncodeToString(bytesData)
  8171. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  8172. if err != nil {
  8173. fmt.Println("Error reading PDF file:", err)
  8174. return
  8175. }
  8176. // 将 PDF 文件内容进行 Base64 编码
  8177. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  8178. fmt.Println(err)
  8179. if miConfig.MdtrtareaAdmvs == "340699" {
  8180. data := make(map[string]interface{})
  8181. data["rx_encoded"] = rx_encoded
  8182. data["code"] = miConfig.Code
  8183. data["url"] = "http://10.66.149.64:8080/epc/api"
  8184. data["encoded"] = encoded
  8185. client := &http.Client{}
  8186. bytesData, _ := json.Marshal(data)
  8187. var req *http.Request
  8188. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/02", bytes.NewReader(bytesData))
  8189. resp, _ := client.Do(req)
  8190. defer resp.Body.Close()
  8191. body, ioErr := ioutil.ReadAll(resp.Body)
  8192. if ioErr != nil {
  8193. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8194. }
  8195. var respJSON map[string]interface{}
  8196. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8197. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8199. return
  8200. }
  8201. var resSix10265 ResultSix10265 //1101结果
  8202. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8203. result, _ := json.Marshal(respJSON)
  8204. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  8205. utils.ErrorLog("解析失败:%v", err)
  8206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8207. return
  8208. }
  8209. utils.ErrorLog("接口返回数据解析JSON失败: %v", result)
  8210. //saveLog(result, "", "GetCFYLJG002", "GetCFYLJG002")
  8211. } else {
  8212. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8213. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  8214. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8215. var res2 AhResult002
  8216. var respJSON2 map[string]interface{}
  8217. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8218. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8220. return
  8221. }
  8222. userJSONBytes2, _ := json.Marshal(respJSON2)
  8223. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8224. utils.ErrorLog("解析失败:%v", err)
  8225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8226. return
  8227. }
  8228. flow.Ctime = time.Now().Unix()
  8229. flow.SignDigest = res2.SignDigest
  8230. flow.RxFile = res2.RxFile
  8231. flow.MID = his.Number
  8232. flow.Status = 1
  8233. flow.DCode = doctor_info.DoctorNumber
  8234. flow.OriginalRxFile = rx_encoded
  8235. flow.OriginalValue = encoded
  8236. flow.SignCertDn = res2.SignCertDn
  8237. flow.SignCertSn = res2.SignCertSn
  8238. flow.Mtime = time.Now().Unix()
  8239. service.Saveflow(flow)
  8240. c.ServeSuccessJSON(map[string]interface{}{
  8241. "msg": "预签名成功",
  8242. })
  8243. }
  8244. }
  8245. func (c *HisApiController) GetCFYLJG13() {
  8246. admin_user_id, _ := c.GetInt64("admin_user_id")
  8247. his_patient_id, _ := c.GetInt64("his_patient_id")
  8248. record_time := c.GetString("record_time")
  8249. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8250. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8251. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8252. flow, _ := service.Getflowtwo(his.Number)
  8253. patient_id, _ := c.GetInt64("patient_id")
  8254. timeLayout := "2006-01-02"
  8255. loc, _ := time.LoadLocation("Local")
  8256. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8257. if err != nil {
  8258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8259. return
  8260. }
  8261. recordDateTime := theTime.Unix()
  8262. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8263. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8264. dept, _ := service.GetDepartMentDetail(info.Departments)
  8265. var cFYLJG003 models.CFYLJG003
  8266. cFYLJG003.RxTraceCode = flow.RxTraceCode
  8267. cFYLJG003.HiRxno = flow.HiRxno
  8268. cFYLJG003.MdtrtID = flow.MID
  8269. cFYLJG003.PatnName = his.Name
  8270. cFYLJG003.Certno = his.Certno
  8271. cFYLJG003.FixmedinsName = miConfig.OrgName
  8272. cFYLJG003.FixmedinsCode = miConfig.Code
  8273. cFYLJG003.DrCode = doctor_info.DoctorNumber
  8274. cFYLJG003.PrscDrName = doctor_info.UserName
  8275. cFYLJG003.PharDeptName = dept.Name
  8276. cFYLJG003.PharDeptCode = dept.Number
  8277. if c.GetAdminUserInfo().CurrentOrgId == 10721 {
  8278. cFYLJG003.PharName = "孙莉侠"
  8279. cFYLJG003.PharPracCertNo = "060399"
  8280. cFYLJG003.PharCode = "HY340621000425"
  8281. cFYLJG003.PharCertType = "01"
  8282. cFYLJG003.PharCertno = ""
  8283. } else {
  8284. cFYLJG003.PharName = "彭斯遥"
  8285. cFYLJG003.PharPracCertNo = "30220200943042010052"
  8286. cFYLJG003.PharCode = "HY440309002107"
  8287. cFYLJG003.PharCertType = "01"
  8288. cFYLJG003.PharCertno = "430482199408260023"
  8289. }
  8290. cFYLJG003.PsnCertType = "01"
  8291. cFYLJG003.RxFile = flow.RxFile
  8292. cFYLJG003.SignDigest = flow.SignDigest
  8293. cFYLJG003.FixmedinsCode = miConfig.Code
  8294. cFYLJG003.PsnCertType = "01"
  8295. cFYLJG003.PharProfttlCodg = dept.Name
  8296. tempTime2 := time.Unix(info.Ctime, 0)
  8297. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8298. cFYLJG003.PharChkTime = timeFormatTwo
  8299. if miConfig.MdtrtareaAdmvs == "340699" {
  8300. data := make(map[string]interface{})
  8301. data["url"] = "http://10.66.149.64:8080/epc/api"
  8302. data["13"] = cFYLJG003
  8303. client := &http.Client{}
  8304. bytesData, _ := json.Marshal(data)
  8305. var req *http.Request
  8306. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/03", bytes.NewReader(bytesData))
  8307. resp, _ := client.Do(req)
  8308. defer resp.Body.Close()
  8309. body, ioErr := ioutil.ReadAll(resp.Body)
  8310. if ioErr != nil {
  8311. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8312. }
  8313. var respJSON map[string]interface{}
  8314. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8315. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8317. return
  8318. }
  8319. var resSix10265 ResultSix10265 //1101结果
  8320. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8321. result, _ := json.Marshal(respJSON)
  8322. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  8323. utils.ErrorLog("解析失败:%v", err)
  8324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8325. return
  8326. }
  8327. utils.ErrorLog("接口返回数据解析JSON失败: %v", result)
  8328. //saveLog(result, "", "GetCFYLJG013", "GetCFYLJG013")
  8329. } else {
  8330. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8331. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  8332. var res ResultCFYLJG003
  8333. var respJSON2 map[string]interface{}
  8334. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8335. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8337. return
  8338. }
  8339. userJSONBytes2, _ := json.Marshal(respJSON2)
  8340. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8341. utils.ErrorLog("解析失败:%v", err)
  8342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8343. return
  8344. }
  8345. if res.Infcode == -1 {
  8346. c.ServeSuccessJSON(map[string]interface{}{
  8347. "failed_code": -10,
  8348. "msg": res.ErrMsg,
  8349. })
  8350. return
  8351. } else {
  8352. c.ServeSuccessJSON(map[string]interface{}{
  8353. "info": res.Output,
  8354. })
  8355. }
  8356. }
  8357. }
  8358. func (c *HisApiController) GetCFYLJG002() {
  8359. admin_user_id, _ := c.GetInt64("admin_user_id")
  8360. his_patient_id, _ := c.GetInt64("his_patient_id")
  8361. record_time := c.GetString("record_time")
  8362. admin_user_id = 3626
  8363. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8364. //id, _ := c.GetInt64("id")
  8365. admin_user_id = 3626
  8366. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8367. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8368. flow, _ := service.Getflowtwo(his.Number)
  8369. //his, _ := service.GetHisPatientByNumber(flow.MID)
  8370. //record_time := c.GetString("record_time")
  8371. patient_id, _ := c.GetInt64("patient_id")
  8372. //patient_id = 23834
  8373. //record_time = "2023-09-18"
  8374. timeLayout := "2006-01-02"
  8375. loc, _ := time.LoadLocation("Local")
  8376. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8377. if err != nil {
  8378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8379. return
  8380. }
  8381. recordDateTime := theTime.Unix()
  8382. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8383. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8384. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8385. dept, _ := service.GetDepartMentDetail(info.Departments)
  8386. inputData := make(map[string]interface{})
  8387. inputData["rxTraceCode"] = flow.RxTraceCode
  8388. inputData["hiRxno"] = flow.HiRxno
  8389. inputData["mdtrtId"] = flow.MID
  8390. inputData["patnName"] = his.PsnName
  8391. inputData["psnCertType"] = his.PsnCertType
  8392. inputData["certno"] = his.Certno
  8393. inputData["fixmedinsName"] = miConfig.OrgName
  8394. inputData["fixmedinsCode"] = miConfig.Code
  8395. inputData["drCode"] = doctor_info.DoctorNumber
  8396. inputData["prscDrName"] = doctor_info.UserName
  8397. inputData["pharDeptName"] = dept.Name
  8398. inputData["pharDeptCode"] = dept.Number
  8399. inputData["pharProfttlCodg"] = ""
  8400. inputData["pharProfttlName"] = ""
  8401. inputData["pharCode"] = "HY340621000425"
  8402. inputData["pharCertType"] = "01"
  8403. inputData["pharCertno"] = ""
  8404. inputData["pharName"] = "孙莉侠"
  8405. inputData["pharPracCertNo"] = "060399"
  8406. tempTime2 := time.Unix(info.Ctime, 0)
  8407. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8408. inputData["pharChkTime"] = timeFormatTwo
  8409. bytesData, _ := json.Marshal(inputData)
  8410. fmt.Println(string(bytesData))
  8411. encoded := base64.StdEncoding.EncodeToString(bytesData)
  8412. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  8413. if err != nil {
  8414. fmt.Println("Error reading PDF file:", err)
  8415. return
  8416. }
  8417. // 将 PDF 文件内容进行 Base64 编码
  8418. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  8419. fmt.Println(err)
  8420. if miConfig.MdtrtareaAdmvs == "340699" {
  8421. result, request := service.GetAHCFYLJG002(miConfig.Code, "http://10.66.149.64:8080/epc/api", encoded, rx_encoded, "")
  8422. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8423. var res2 AhResult002
  8424. var respJSON2 map[string]interface{}
  8425. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8426. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8428. return
  8429. }
  8430. userJSONBytes2, _ := json.Marshal(respJSON2)
  8431. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8432. utils.ErrorLog("解析失败:%v", err)
  8433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8434. return
  8435. }
  8436. flow.Ctime = time.Now().Unix()
  8437. flow.SignDigest = res2.SignDigest
  8438. flow.RxFile = res2.RxFile
  8439. flow.MID = his.Number
  8440. flow.Status = 1
  8441. flow.DCode = doctor_info.DoctorNumber
  8442. flow.OriginalRxFile = rx_encoded
  8443. flow.OriginalValue = encoded
  8444. flow.SignCertDn = res2.SignCertDn
  8445. flow.SignCertSn = res2.SignCertSn
  8446. flow.Mtime = time.Now().Unix()
  8447. service.Saveflow(flow)
  8448. c.ServeSuccessJSON(map[string]interface{}{
  8449. "msg": "预签名成功",
  8450. })
  8451. } else {
  8452. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8453. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  8454. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8455. var res2 Result002
  8456. var respJSON2 map[string]interface{}
  8457. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8458. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8460. return
  8461. }
  8462. userJSONBytes2, _ := json.Marshal(respJSON2)
  8463. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8464. utils.ErrorLog("解析失败:%v", err)
  8465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8466. return
  8467. }
  8468. if res2.Infcode == 0 {
  8469. flow.Ctime = time.Now().Unix()
  8470. flow.SignDigest = res2.Output.SignDigest
  8471. flow.RxFile = res2.Output.RxFile
  8472. flow.MID = his.Number
  8473. flow.Status = 1
  8474. flow.DCode = doctor_info.DoctorNumber
  8475. flow.OriginalRxFile = rx_encoded
  8476. flow.OriginalValue = encoded
  8477. flow.SignCertDn = res2.Output.SignCertDn
  8478. flow.SignCertSn = res2.Output.SignCertSn
  8479. flow.Mtime = time.Now().Unix()
  8480. service.Saveflow(flow)
  8481. c.ServeSuccessJSON(map[string]interface{}{
  8482. "msg": "预签名成功",
  8483. })
  8484. } else {
  8485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8486. return
  8487. }
  8488. }
  8489. }
  8490. func (c *HisApiController) GetCFYLJG003() {
  8491. admin_user_id, _ := c.GetInt64("admin_user_id")
  8492. his_patient_id, _ := c.GetInt64("his_patient_id")
  8493. record_time := c.GetString("record_time")
  8494. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8495. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8496. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8497. flow, _ := service.Getflowtwo(his.Number)
  8498. patient_id, _ := c.GetInt64("patient_id")
  8499. timeLayout := "2006-01-02"
  8500. loc, _ := time.LoadLocation("Local")
  8501. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8502. if err != nil {
  8503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8504. return
  8505. }
  8506. recordDateTime := theTime.Unix()
  8507. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8508. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8509. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8510. dept, _ := service.GetDepartMentDetail(info.Departments)
  8511. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  8512. var cFYLJG003 models.CFYLJG003
  8513. cFYLJG003.RxTraceCode = flow.RxTraceCode
  8514. cFYLJG003.HiRxno = flow.HiRxno
  8515. cFYLJG003.MdtrtID = flow.MID
  8516. cFYLJG003.PatnName = his.PsnName
  8517. cFYLJG003.Certno = his.Certno
  8518. cFYLJG003.FixmedinsName = miConfig.OrgName
  8519. cFYLJG003.FixmedinsCode = miConfig.Code
  8520. cFYLJG003.DrCode = doctor_info.DoctorNumber
  8521. cFYLJG003.PrscDrName = doctor_info.UserName
  8522. cFYLJG003.PharDeptName = dept.Name
  8523. cFYLJG003.PharDeptCode = dept.Number
  8524. if c.GetAdminUserInfo().CurrentOrgId == 10721 {
  8525. cFYLJG003.PharName = "孙莉侠"
  8526. cFYLJG003.PharPracCertNo = "060399"
  8527. cFYLJG003.PharCode = "HY340621000425"
  8528. cFYLJG003.PharCertType = "01"
  8529. cFYLJG003.PharCertno = ""
  8530. } else {
  8531. cFYLJG003.PharName = "彭斯遥"
  8532. cFYLJG003.PharPracCertNo = "30220200943042010052"
  8533. cFYLJG003.PharCode = "HY440309002107"
  8534. cFYLJG003.PharCertType = "01"
  8535. cFYLJG003.PharCertno = "430482199408260023"
  8536. }
  8537. cFYLJG003.RxFile = flow.RxFile
  8538. cFYLJG003.SignDigest = flow.SignDigest
  8539. cFYLJG003.FixmedinsCode = miConfig.Code
  8540. cFYLJG003.PsnCertType = his.PsnCertType
  8541. tempTime2 := time.Unix(info.Ctime, 0)
  8542. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8543. cFYLJG003.PharChkTime = timeFormatTwo
  8544. if miConfig.MdtrtareaAdmvs == "340699" {
  8545. result, request := service.GetAHCFYLJG003("http://10.66.149.64:8080/epc/api", cFYLJG003)
  8546. saveLog(result, request, "GetAHCFYLJG003", "GetAHCFYLJG003")
  8547. var res AHResult003
  8548. var respJSON2 map[string]interface{}
  8549. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8550. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8552. return
  8553. }
  8554. userJSONBytes2, _ := json.Marshal(respJSON2)
  8555. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8556. utils.ErrorLog("解析失败:%v", err)
  8557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8558. return
  8559. }
  8560. {
  8561. c.ServeSuccessJSON(map[string]interface{}{
  8562. "info": res,
  8563. })
  8564. }
  8565. } else {
  8566. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8567. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  8568. var res ResultCFYLJG003
  8569. var respJSON2 map[string]interface{}
  8570. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8571. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8573. return
  8574. }
  8575. userJSONBytes2, _ := json.Marshal(respJSON2)
  8576. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8577. utils.ErrorLog("解析失败:%v", err)
  8578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8579. return
  8580. }
  8581. if res.Infcode == -1 {
  8582. c.ServeSuccessJSON(map[string]interface{}{
  8583. "failed_code": -10,
  8584. "msg": res.ErrMsg,
  8585. })
  8586. return
  8587. } else {
  8588. c.ServeSuccessJSON(map[string]interface{}{
  8589. "info": res.Output,
  8590. })
  8591. }
  8592. }
  8593. }
  8594. func (c *HisApiController) GetCFYLJG004() {
  8595. admin_user_id, _ := c.GetInt64("admin_user_id")
  8596. his_patient_id, _ := c.GetInt64("his_patient_id")
  8597. record_time := c.GetString("record_time")
  8598. admin_user_id = 3626
  8599. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8600. //id, _ := c.GetInt64("id")
  8601. admin_user_id = 3626
  8602. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8603. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8604. flow, _ := service.Getflowtwo(his.Number)
  8605. //id = 3
  8606. patient_id, _ := c.GetInt64("patient_id")
  8607. //patient_id = 23834
  8608. //record_time = "2023-09-18"
  8609. timeLayout := "2006-01-02"
  8610. loc, _ := time.LoadLocation("Local")
  8611. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8612. if err != nil {
  8613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8614. return
  8615. }
  8616. recordDateTime := theTime.Unix()
  8617. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8618. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8619. var cFYLJG004 models.CFYLJG004
  8620. cFYLJG004.HiRxno = flow.HiRxno
  8621. cFYLJG004.FixmedinsCode = miConfig.Code
  8622. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  8623. cFYLJG004.UndoDrCertType = "01"
  8624. cFYLJG004.UndoRea = "撤销处方"
  8625. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  8626. cFYLJG004.UndoDrName = doctor_info.UserName
  8627. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  8628. if miConfig.MdtrtareaAdmvs == "340699" {
  8629. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8630. //result, request := service.GetAHCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8631. //saveLog(result, request, "GetAHCFYLJG004", "GetAHCFYLJG004")
  8632. } else {
  8633. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  8634. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  8635. var res ResultCFYLJG004
  8636. var respJSON2 map[string]interface{}
  8637. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8638. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8640. return
  8641. }
  8642. userJSONBytes2, _ := json.Marshal(respJSON2)
  8643. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8644. utils.ErrorLog("解析失败:%v", err)
  8645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8646. return
  8647. }
  8648. if res.Infcode == -1 {
  8649. c.ServeSuccessJSON(map[string]interface{}{
  8650. "failed_code": -10,
  8651. "msg": res.ErrMsg,
  8652. })
  8653. return
  8654. } else {
  8655. flow.Status = 0
  8656. service.Saveflow(flow)
  8657. c.ServeSuccessJSON(map[string]interface{}{
  8658. "msg": "撤销成功",
  8659. })
  8660. return
  8661. }
  8662. }
  8663. }
  8664. func (c *HisApiController) GetCFYLJG005() {
  8665. admin_user_id, _ := c.GetInt64("admin_user_id")
  8666. his_patient_id, _ := c.GetInt64("his_patient_id")
  8667. //record_time := c.GetString("record_time")
  8668. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8669. //id, _ := c.GetInt64("id")
  8670. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8671. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8672. flow, _ := service.Getflowtwo(his.Number)
  8673. //id = 3
  8674. var cFYLJG005 models.CFYLJG005
  8675. //patient_id, _ := c.GetInt64("patient_id")
  8676. cFYLJG005.HiRxno = flow.HiRxno
  8677. cFYLJG005.MdtrtID = flow.MID
  8678. cFYLJG005.EcToken = ""
  8679. cFYLJG005.PsnName = his.Name
  8680. cFYLJG005.PsnCertType = "01"
  8681. cFYLJG005.Certno = his.IdCardNo
  8682. if miConfig.MdtrtareaAdmvs == "340699" {
  8683. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8684. result, request := service.GetAHCFYLJG005(miConfig.Code, cFYLJG005)
  8685. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  8686. } else {
  8687. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  8688. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  8689. var res ResultCFYLJG005
  8690. var respJSON2 map[string]interface{}
  8691. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8692. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8694. return
  8695. }
  8696. userJSONBytes2, _ := json.Marshal(respJSON2)
  8697. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8698. utils.ErrorLog("解析失败:%v", err)
  8699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8700. return
  8701. }
  8702. if res.Infcode == -1 {
  8703. c.ServeSuccessJSON(map[string]interface{}{
  8704. "failed_code": -10,
  8705. "msg": res.ErrMsg,
  8706. })
  8707. return
  8708. } else {
  8709. c.ServeSuccessJSON(map[string]interface{}{
  8710. "info": res.Output,
  8711. })
  8712. return
  8713. }
  8714. }
  8715. }
  8716. func (c *HisApiController) GetCFYLJG006() {
  8717. admin_user_id, _ := c.GetInt64("admin_user_id")
  8718. his_patient_id, _ := c.GetInt64("his_patient_id")
  8719. admin_user_id = 3626
  8720. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8721. //id, _ := c.GetInt64("id")
  8722. admin_user_id = 3626
  8723. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8724. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8725. flow, _ := service.Getflowtwo(his.Number)
  8726. //id = 3
  8727. patient_id, _ := c.GetInt64("patient_id")
  8728. var cFYLJG006 models.CFYLJG006
  8729. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8730. cFYLJG006.HiRxno = flow.HiRxno
  8731. cFYLJG006.MdtrtID = flow.MID
  8732. cFYLJG006.PsnName = patient.Name
  8733. cFYLJG006.PsnCertType = "01"
  8734. cFYLJG006.Certno = patient.IdCardNo
  8735. if miConfig.MdtrtareaAdmvs == "340699" {
  8736. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8737. //result, request := service.GetAHCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8738. //saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8739. } else {
  8740. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8741. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8742. var res ResultCFYLJG006
  8743. var respJSON2 map[string]interface{}
  8744. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8745. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8747. return
  8748. }
  8749. userJSONBytes2, _ := json.Marshal(respJSON2)
  8750. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8751. utils.ErrorLog("解析失败:%v", err)
  8752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8753. return
  8754. }
  8755. if res.Infcode == -1 {
  8756. c.ServeSuccessJSON(map[string]interface{}{
  8757. "failed_code": -10,
  8758. "msg": res.ErrMsg,
  8759. })
  8760. return
  8761. } else {
  8762. c.ServeSuccessJSON(map[string]interface{}{
  8763. "info": res.Output,
  8764. })
  8765. return
  8766. }
  8767. }
  8768. }
  8769. func (c *HisApiController) GetCFYLJG007() {
  8770. admin_user_id, _ := c.GetInt64("admin_user_id")
  8771. his_patient_id, _ := c.GetInt64("his_patient_id")
  8772. admin_user_id = 3626
  8773. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8774. //id, _ := c.GetInt64("id")
  8775. admin_user_id = 3626
  8776. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8777. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8778. flow, _ := service.Getflowtwo(his.Number)
  8779. //id = 3
  8780. patient_id, _ := c.GetInt64("patient_id")
  8781. var cFYLJG007 models.CFYLJG007
  8782. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8783. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8784. cFYLJG007.HiRxno = flow.HiRxno
  8785. cFYLJG007.MdtrtID = flow.MID
  8786. cFYLJG007.PsnNo = his.PsnNo
  8787. cFYLJG007.PsnCertType = "01"
  8788. cFYLJG007.Certno = patient.IdCardNo
  8789. cFYLJG007.PsnName = patient.Name
  8790. if miConfig.MdtrtareaAdmvs == "340699" {
  8791. //result, request := service.GetAHCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8792. //saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8793. } else {
  8794. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8795. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8796. var res ResultCFYLJG007
  8797. var respJSON2 map[string]interface{}
  8798. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8799. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8801. return
  8802. }
  8803. userJSONBytes2, _ := json.Marshal(respJSON2)
  8804. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8805. utils.ErrorLog("解析失败:%v", err)
  8806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8807. return
  8808. }
  8809. if res.Infcode == -1 {
  8810. c.ServeSuccessJSON(map[string]interface{}{
  8811. "failed_code": -10,
  8812. "msg": res.ErrMsg,
  8813. })
  8814. return
  8815. } else {
  8816. c.ServeSuccessJSON(map[string]interface{}{
  8817. "info": res,
  8818. })
  8819. return
  8820. }
  8821. }
  8822. }
  8823. func (c *HisApiController) GetCFYLJG008() {
  8824. admin_user_id, _ := c.GetInt64("admin_user_id")
  8825. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8826. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8827. var cFYLJG008 models.CFYLJG008
  8828. //id, _ := c.GetInt64("id")
  8829. patient_id, _ := c.GetInt64("patient_id")
  8830. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8831. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8832. //id = 3
  8833. //flow, _ := service.Getflow(id)
  8834. //his, _ := service.GetHisPatientByNumber(flow.MID)
  8835. //
  8836. //admin_user_id, _ := c.GetInt64("admin_user_id")
  8837. //patient_id, _ := c.GetInt64("patient_id")
  8838. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8839. record_time := c.GetString("record_time")
  8840. admin_user_id = 3626
  8841. patient_id = 19424
  8842. //his_patient_id = 263947
  8843. record_time = "2023-08-29"
  8844. timeLayout := "2006-01-02"
  8845. loc, _ := time.LoadLocation("Local")
  8846. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8847. if err != nil {
  8848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8849. return
  8850. }
  8851. recordDateTime := theTime.Unix()
  8852. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8853. cFYLJG008.FixmedinsName = ""
  8854. cFYLJG008.Lat = ""
  8855. cFYLJG008.Lng = ""
  8856. cFYLJG008.OrderType = "1"
  8857. cFYLJG008.PoolareaNo = ""
  8858. cFYLJG008.Lng = ""
  8859. cFYLJG008.PageNum = 1
  8860. cFYLJG008.PageSize = 10
  8861. var MPI models.MedinsProdInvChgDDTO
  8862. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  8863. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  8864. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  8865. if miConfig.MdtrtareaAdmvs == "340699" {
  8866. //result, request := service.GetAHCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8867. //saveLog(result, request, "GetAHCFYLJG008", "GetAHCFYLJG008")
  8868. } else {
  8869. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8870. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  8871. var res ResultCFYLJG008
  8872. var respJSON2 map[string]interface{}
  8873. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8874. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8876. return
  8877. }
  8878. userJSONBytes2, _ := json.Marshal(respJSON2)
  8879. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8880. utils.ErrorLog("解析失败:%v", err)
  8881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8882. return
  8883. }
  8884. if res.Infcode == -1 {
  8885. c.ServeSuccessJSON(map[string]interface{}{
  8886. "failed_code": -10,
  8887. "msg": res.ErrMsg,
  8888. })
  8889. return
  8890. } else {
  8891. c.ServeSuccessJSON(map[string]interface{}{
  8892. "info": res.Output,
  8893. })
  8894. return
  8895. }
  8896. }
  8897. }
  8898. func (c *HisApiController) GetBL4201A() {
  8899. order_id, _ := c.GetInt64("order_id")
  8900. admin_user_id, _ := c.GetInt64("admin_user_id")
  8901. order, _ := service.GetHisOrderByIDTwo(order_id)
  8902. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8903. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8904. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8905. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8906. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8907. department, _ := service.GetDepartMentDetail(his.Departments)
  8908. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8909. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8910. if order.ID == 0 {
  8911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8912. return
  8913. }
  8914. var struct4201A models.Struct4201A
  8915. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8916. for _, items := range order_info {
  8917. memo := make(map[string]interface{})
  8918. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8919. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8920. fsiOPFLD.MedType = "14"
  8921. fsiOPFLD.BkkpSn = items.FeedetlSn
  8922. fsiOPFLD.FixmedinsCode = miConfig.Code
  8923. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8924. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8925. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8926. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8927. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8928. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8929. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8930. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8931. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8932. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8933. fsiOPFLD.BilgDeptName = department.Name
  8934. fsiOPFLD.BilgDeptCodg = department.Number
  8935. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8936. fsiOPFLD.BilgDrName = doctor.UserName
  8937. fsiOPFLD.MedChrgitmType = "09"
  8938. memo["hosp_appr_flag"] = "1"
  8939. memo["invoice_no"] = order.MdtrtId
  8940. memo["memo"] = "自费"
  8941. bytesData, _ := json.Marshal(memo)
  8942. fsiOPFLD.Memo = string(bytesData)
  8943. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8944. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8945. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8946. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8947. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8948. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8949. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8950. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8951. fsiOPFLD.BilgDeptName = department.Name
  8952. fsiOPFLD.BilgDeptCodg = department.Number
  8953. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8954. fsiOPFLD.BilgDrName = doctor.UserName
  8955. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8956. case 0:
  8957. break
  8958. case 1:
  8959. fsiOPFLD.MedChrgitmType = "14"
  8960. break
  8961. case 2:
  8962. fsiOPFLD.MedChrgitmType = "05"
  8963. break
  8964. case 3:
  8965. fsiOPFLD.MedChrgitmType = "03"
  8966. break
  8967. case 4:
  8968. fsiOPFLD.MedChrgitmType = "03"
  8969. break
  8970. case 5:
  8971. fsiOPFLD.MedChrgitmType = "08"
  8972. break
  8973. case 6:
  8974. fsiOPFLD.MedChrgitmType = "14"
  8975. break
  8976. case 7:
  8977. fsiOPFLD.MedChrgitmType = "14"
  8978. break
  8979. case 8:
  8980. fsiOPFLD.MedChrgitmType = "03"
  8981. break
  8982. case 9:
  8983. fsiOPFLD.MedChrgitmType = "14"
  8984. break
  8985. case 10:
  8986. fsiOPFLD.MedChrgitmType = "14"
  8987. break
  8988. case 11:
  8989. fsiOPFLD.MedChrgitmType = "06"
  8990. break
  8991. case 12:
  8992. fsiOPFLD.MedChrgitmType = "12"
  8993. break
  8994. case 13:
  8995. fsiOPFLD.MedChrgitmType = "01"
  8996. break
  8997. case 14:
  8998. fsiOPFLD.MedChrgitmType = "04"
  8999. break
  9000. case 15:
  9001. fsiOPFLD.MedChrgitmType = "14"
  9002. break
  9003. }
  9004. memo["hosp_appr_flag"] = "1"
  9005. memo["invoice_no"] = order.MdtrtId
  9006. memo["memo"] = "自费"
  9007. bytesData, _ := json.Marshal(memo)
  9008. fsiOPFLD.Memo = string(bytesData)
  9009. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9010. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9011. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9012. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9013. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9014. fsiOPFLD.BilgDeptName = department.Name
  9015. fsiOPFLD.BilgDeptCodg = department.Number
  9016. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9017. fsiOPFLD.BilgDrName = doctor.UserName
  9018. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9019. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9020. fsiOPFLD.MedChrgitmType = "08"
  9021. memo["hosp_appr_flag"] = "1"
  9022. memo["invoice_no"] = order.MdtrtId
  9023. memo["memo"] = "自费"
  9024. bytesData, _ := json.Marshal(memo)
  9025. fsiOPFLD.Memo = string(bytesData)
  9026. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9027. }
  9028. }
  9029. }
  9030. for _, items := range order_info_two {
  9031. memo := make(map[string]interface{})
  9032. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9033. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9034. fsiOPFLD.MedType = "14"
  9035. fsiOPFLD.BkkpSn = items.FeedetlSn
  9036. fsiOPFLD.FixmedinsCode = miConfig.Code
  9037. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9038. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9039. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9040. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9041. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9042. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9043. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9044. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9045. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9046. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9047. fsiOPFLD.BilgDeptName = department.Name
  9048. fsiOPFLD.BilgDeptCodg = department.Number
  9049. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9050. fsiOPFLD.BilgDrName = doctor.UserName
  9051. fsiOPFLD.MedChrgitmType = "09"
  9052. memo["hosp_appr_flag"] = "1"
  9053. memo["invoice_no"] = order.MdtrtId
  9054. memo["memo"] = "自费"
  9055. bytesData, _ := json.Marshal(memo)
  9056. fsiOPFLD.Memo = string(bytesData)
  9057. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9058. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9059. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9060. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9061. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9062. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9063. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9064. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9065. fsiOPFLD.BilgDeptName = department.Name
  9066. fsiOPFLD.BilgDeptCodg = department.Number
  9067. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9068. fsiOPFLD.BilgDrName = doctor.UserName
  9069. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9070. case 0:
  9071. break
  9072. case 1:
  9073. fsiOPFLD.MedChrgitmType = "14"
  9074. break
  9075. case 2:
  9076. fsiOPFLD.MedChrgitmType = "05"
  9077. break
  9078. case 3:
  9079. fsiOPFLD.MedChrgitmType = "03"
  9080. break
  9081. case 4:
  9082. fsiOPFLD.MedChrgitmType = "03"
  9083. break
  9084. case 5:
  9085. fsiOPFLD.MedChrgitmType = "08"
  9086. break
  9087. case 6:
  9088. fsiOPFLD.MedChrgitmType = "14"
  9089. break
  9090. case 7:
  9091. fsiOPFLD.MedChrgitmType = "14"
  9092. break
  9093. case 8:
  9094. fsiOPFLD.MedChrgitmType = "03"
  9095. break
  9096. case 9:
  9097. fsiOPFLD.MedChrgitmType = "14"
  9098. break
  9099. case 10:
  9100. fsiOPFLD.MedChrgitmType = "14"
  9101. break
  9102. case 11:
  9103. fsiOPFLD.MedChrgitmType = "06"
  9104. break
  9105. case 12:
  9106. fsiOPFLD.MedChrgitmType = "12"
  9107. break
  9108. case 13:
  9109. fsiOPFLD.MedChrgitmType = "01"
  9110. break
  9111. case 14:
  9112. fsiOPFLD.MedChrgitmType = "04"
  9113. break
  9114. case 15:
  9115. fsiOPFLD.MedChrgitmType = "14"
  9116. break
  9117. }
  9118. memo["hosp_appr_flag"] = "1"
  9119. memo["invoice_no"] = order.MdtrtId
  9120. memo["memo"] = "自费"
  9121. bytesData, _ := json.Marshal(memo)
  9122. fsiOPFLD.Memo = string(bytesData)
  9123. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9124. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9125. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9126. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9127. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9128. fsiOPFLD.BilgDeptName = department.Name
  9129. fsiOPFLD.BilgDeptCodg = department.Number
  9130. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9131. fsiOPFLD.BilgDrName = doctor.UserName
  9132. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9133. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9134. fsiOPFLD.MedChrgitmType = "08"
  9135. memo["hosp_appr_flag"] = "1"
  9136. memo["invoice_no"] = order.MdtrtId
  9137. memo["memo"] = "自费"
  9138. bytesData, _ := json.Marshal(memo)
  9139. fsiOPFLD.Memo = string(bytesData)
  9140. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9141. }
  9142. }
  9143. }
  9144. fmt.Println(fsiOPFLDs)
  9145. struct4201A.Fopfd = fsiOPFLDs
  9146. fmt.Println(struct4201A.Fopfd)
  9147. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  9148. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  9149. var res2 ResultSix
  9150. var respJSON2 map[string]interface{}
  9151. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9152. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9154. return
  9155. }
  9156. userJSONBytes2, _ := json.Marshal(respJSON2)
  9157. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9158. utils.ErrorLog("解析失败:%v", err)
  9159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9160. return
  9161. }
  9162. if res2.Infcode != 0 {
  9163. c.ServeSuccessJSON(map[string]interface{}{
  9164. "failed_code": -10,
  9165. "msg": res2.ErrMsg,
  9166. })
  9167. return
  9168. } else {
  9169. order.IsUploadOrderInfo = 1
  9170. service.UpdateOrder(order)
  9171. c.ServeSuccessJSON(map[string]interface{}{
  9172. "msg": "上传成功",
  9173. })
  9174. }
  9175. }
  9176. func (c *HisApiController) Get3103() {
  9177. admin_user_id, _ := c.GetInt64("admin_user_id")
  9178. warm_type, _ := c.GetInt64("warm_type")
  9179. fk_state, _ := c.GetInt64("fk_state")
  9180. warm_ids := c.GetString("warm_ids")
  9181. desc := c.GetString("desc")
  9182. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9183. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9184. result, requestLog := service.Gdyb3103(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, warm_type, warm_ids, fk_state, desc)
  9185. saveLog(result, requestLog, "3103", "反馈")
  9186. var res2 ResultSix3103
  9187. var respJSON2 map[string]interface{}
  9188. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9189. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9191. return
  9192. }
  9193. userJSONBytes2, _ := json.Marshal(respJSON2)
  9194. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9195. utils.ErrorLog("解析失败:%v", err)
  9196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9197. return
  9198. }
  9199. if res2.Infcode != 0 {
  9200. c.ServeSuccessJSON(map[string]interface{}{
  9201. "failed_code": -10,
  9202. "msg": res2.ErrMsg,
  9203. })
  9204. return
  9205. } else {
  9206. c.ServeSuccessJSON(map[string]interface{}{
  9207. "msg": "反馈成功",
  9208. })
  9209. return
  9210. }
  9211. }
  9212. func (c *HisApiController) Get4201A() {
  9213. order_id, _ := c.GetInt64("order_id")
  9214. admin_user_id, _ := c.GetInt64("admin_user_id")
  9215. order, _ := service.GetHisOrderByIDTwo(order_id)
  9216. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9217. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  9218. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  9219. //order_info = append(order_info, order_info_two...)
  9220. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9221. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9222. department, _ := service.GetDepartMentDetail(his.Departments)
  9223. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  9224. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  9225. if order.ID == 0 {
  9226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9227. return
  9228. }
  9229. var struct4201A models.Struct4201A
  9230. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  9231. for _, items := range order_info {
  9232. memo := make(map[string]interface{})
  9233. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9234. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9235. fsiOPFLD.MedType = "14"
  9236. fsiOPFLD.BkkpSn = items.FeedetlSn
  9237. fsiOPFLD.FixmedinsCode = miConfig.Code
  9238. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9239. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9240. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9241. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9242. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9243. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9244. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9245. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9246. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9247. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9248. fsiOPFLD.BilgDeptName = department.Name
  9249. fsiOPFLD.BilgDeptCodg = department.Number
  9250. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9251. fsiOPFLD.BilgDrName = doctor.UserName
  9252. fsiOPFLD.MedChrgitmType = "09"
  9253. memo["hosp_appr_flag"] = "1"
  9254. memo["invoice_no"] = order.MdtrtId
  9255. memo["memo"] = "自费"
  9256. bytesData, _ := json.Marshal(memo)
  9257. fsiOPFLD.Memo = string(bytesData)
  9258. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9259. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9260. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9261. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9262. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9263. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9264. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9265. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9266. fsiOPFLD.BilgDeptName = department.Name
  9267. fsiOPFLD.BilgDeptCodg = department.Number
  9268. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9269. fsiOPFLD.BilgDrName = doctor.UserName
  9270. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9271. case 0:
  9272. break
  9273. case 1:
  9274. fsiOPFLD.MedChrgitmType = "14"
  9275. break
  9276. case 2:
  9277. fsiOPFLD.MedChrgitmType = "05"
  9278. break
  9279. case 3:
  9280. fsiOPFLD.MedChrgitmType = "03"
  9281. break
  9282. case 4:
  9283. fsiOPFLD.MedChrgitmType = "03"
  9284. break
  9285. case 5:
  9286. fsiOPFLD.MedChrgitmType = "08"
  9287. break
  9288. case 6:
  9289. fsiOPFLD.MedChrgitmType = "14"
  9290. break
  9291. case 7:
  9292. fsiOPFLD.MedChrgitmType = "14"
  9293. break
  9294. case 8:
  9295. fsiOPFLD.MedChrgitmType = "03"
  9296. break
  9297. case 9:
  9298. fsiOPFLD.MedChrgitmType = "14"
  9299. break
  9300. case 10:
  9301. fsiOPFLD.MedChrgitmType = "14"
  9302. break
  9303. case 11:
  9304. fsiOPFLD.MedChrgitmType = "06"
  9305. break
  9306. case 12:
  9307. fsiOPFLD.MedChrgitmType = "12"
  9308. break
  9309. case 13:
  9310. fsiOPFLD.MedChrgitmType = "01"
  9311. break
  9312. case 14:
  9313. fsiOPFLD.MedChrgitmType = "04"
  9314. break
  9315. case 15:
  9316. fsiOPFLD.MedChrgitmType = "14"
  9317. break
  9318. }
  9319. memo["hosp_appr_flag"] = "1"
  9320. memo["invoice_no"] = order.MdtrtId
  9321. memo["memo"] = "自费"
  9322. bytesData, _ := json.Marshal(memo)
  9323. fsiOPFLD.Memo = string(bytesData)
  9324. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9325. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9326. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9327. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9328. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9329. fsiOPFLD.BilgDeptName = department.Name
  9330. fsiOPFLD.BilgDeptCodg = department.Number
  9331. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9332. fsiOPFLD.BilgDrName = doctor.UserName
  9333. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9334. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9335. fsiOPFLD.MedChrgitmType = "08"
  9336. memo["hosp_appr_flag"] = "1"
  9337. memo["invoice_no"] = order.MdtrtId
  9338. memo["memo"] = "自费"
  9339. bytesData, _ := json.Marshal(memo)
  9340. fsiOPFLD.Memo = string(bytesData)
  9341. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9342. }
  9343. }
  9344. }
  9345. for _, items := range order_info_two {
  9346. memo := make(map[string]interface{})
  9347. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9348. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9349. fsiOPFLD.MedType = "14"
  9350. fsiOPFLD.BkkpSn = items.FeedetlSn
  9351. fsiOPFLD.FixmedinsCode = miConfig.Code
  9352. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9353. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9354. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9355. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9356. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9357. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9358. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9359. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9360. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9361. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9362. fsiOPFLD.BilgDeptName = department.Name
  9363. fsiOPFLD.BilgDeptCodg = department.Number
  9364. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9365. fsiOPFLD.BilgDrName = doctor.UserName
  9366. fsiOPFLD.MedChrgitmType = "09"
  9367. memo["hosp_appr_flag"] = "1"
  9368. memo["invoice_no"] = order.MdtrtId
  9369. memo["memo"] = "自费"
  9370. bytesData, _ := json.Marshal(memo)
  9371. fsiOPFLD.Memo = string(bytesData)
  9372. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9373. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9374. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9375. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9376. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9377. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9378. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9379. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9380. fsiOPFLD.BilgDeptName = department.Name
  9381. fsiOPFLD.BilgDeptCodg = department.Number
  9382. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9383. fsiOPFLD.BilgDrName = doctor.UserName
  9384. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9385. case 0:
  9386. break
  9387. case 1:
  9388. fsiOPFLD.MedChrgitmType = "14"
  9389. break
  9390. case 2:
  9391. fsiOPFLD.MedChrgitmType = "05"
  9392. break
  9393. case 3:
  9394. fsiOPFLD.MedChrgitmType = "03"
  9395. break
  9396. case 4:
  9397. fsiOPFLD.MedChrgitmType = "03"
  9398. break
  9399. case 5:
  9400. fsiOPFLD.MedChrgitmType = "08"
  9401. break
  9402. case 6:
  9403. fsiOPFLD.MedChrgitmType = "14"
  9404. break
  9405. case 7:
  9406. fsiOPFLD.MedChrgitmType = "14"
  9407. break
  9408. case 8:
  9409. fsiOPFLD.MedChrgitmType = "03"
  9410. break
  9411. case 9:
  9412. fsiOPFLD.MedChrgitmType = "14"
  9413. break
  9414. case 10:
  9415. fsiOPFLD.MedChrgitmType = "14"
  9416. break
  9417. case 11:
  9418. fsiOPFLD.MedChrgitmType = "06"
  9419. break
  9420. case 12:
  9421. fsiOPFLD.MedChrgitmType = "12"
  9422. break
  9423. case 13:
  9424. fsiOPFLD.MedChrgitmType = "01"
  9425. break
  9426. case 14:
  9427. fsiOPFLD.MedChrgitmType = "04"
  9428. break
  9429. case 15:
  9430. fsiOPFLD.MedChrgitmType = "14"
  9431. break
  9432. }
  9433. memo["hosp_appr_flag"] = "1"
  9434. memo["invoice_no"] = order.MdtrtId
  9435. memo["memo"] = "自费"
  9436. bytesData, _ := json.Marshal(memo)
  9437. fsiOPFLD.Memo = string(bytesData)
  9438. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9439. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9440. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9441. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9442. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9443. fsiOPFLD.BilgDeptName = department.Name
  9444. fsiOPFLD.BilgDeptCodg = department.Number
  9445. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9446. fsiOPFLD.BilgDrName = doctor.UserName
  9447. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9448. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9449. fsiOPFLD.MedChrgitmType = "08"
  9450. memo["hosp_appr_flag"] = "1"
  9451. memo["invoice_no"] = order.MdtrtId
  9452. memo["memo"] = "自费"
  9453. bytesData, _ := json.Marshal(memo)
  9454. fsiOPFLD.Memo = string(bytesData)
  9455. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9456. }
  9457. }
  9458. }
  9459. fmt.Println(fsiOPFLDs)
  9460. struct4201A.Fopfd = fsiOPFLDs
  9461. fmt.Println(struct4201A.Fopfd)
  9462. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  9463. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  9464. var res2 ResultSix
  9465. var respJSON2 map[string]interface{}
  9466. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9467. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9469. return
  9470. }
  9471. userJSONBytes2, _ := json.Marshal(respJSON2)
  9472. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9473. utils.ErrorLog("解析失败:%v", err)
  9474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9475. return
  9476. }
  9477. if res2.Infcode != 0 {
  9478. c.ServeSuccessJSON(map[string]interface{}{
  9479. "failed_code": -10,
  9480. "msg": res2.ErrMsg,
  9481. })
  9482. return
  9483. } else {
  9484. order.IsUploadOrderInfo = 1
  9485. service.UpdateOrder(order)
  9486. c.ServeSuccessJSON(map[string]interface{}{
  9487. "msg": "上传成功",
  9488. })
  9489. }
  9490. }
  9491. func (c *HisApiController) Get4202() {
  9492. order_id, _ := c.GetInt64("order_id")
  9493. admin_user_id, _ := c.GetInt64("admin_user_id")
  9494. order, _ := service.GetHisOrderByIDTwo(order_id)
  9495. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9496. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9497. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9498. if order.ID == 0 {
  9499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9500. return
  9501. }
  9502. var struct4202 models.Struct4202
  9503. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9504. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9505. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9506. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9507. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9508. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9509. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  9510. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  9511. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9512. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9513. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9514. var config []*models.HisXtDiagnoseConfig
  9515. for _, item := range diagnosis_ids {
  9516. id, _ := strconv.ParseInt(item, 10, 64)
  9517. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9518. config = append(config, &diagnosisConfig)
  9519. }
  9520. var tempDiaginfos []models.OwnPayPatnDiagListD
  9521. for index, item := range config {
  9522. if index == 0 {
  9523. var tempDiaginfo models.OwnPayPatnDiagListD
  9524. tempDiaginfo.InoutDiagType = "1"
  9525. tempDiaginfo.DiagCode = item.CountryCode
  9526. tempDiaginfo.DiagName = item.CountryContentName
  9527. tempDiaginfo.DiagType = "1"
  9528. tempDiaginfo.DiagSrtNo = "1"
  9529. tempDiaginfo.MaindiagFlag = "1"
  9530. tempDiaginfo.ValiFlag = "1"
  9531. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9532. } else {
  9533. var tempDiaginfo models.OwnPayPatnDiagListD
  9534. tempDiaginfo.DiagCode = item.CountryCode
  9535. tempDiaginfo.DiagName = item.CountryContentName
  9536. tempDiaginfo.DiagType = "2"
  9537. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9538. tempDiaginfo.MaindiagFlag = "0"
  9539. tempDiaginfo.ValiFlag = "1"
  9540. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9541. }
  9542. }
  9543. struct4202.ODiagListD = tempDiaginfos
  9544. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  9545. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  9546. var res2 ResultSix
  9547. var respJSON2 map[string]interface{}
  9548. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9549. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9551. return
  9552. }
  9553. userJSONBytes2, _ := json.Marshal(respJSON2)
  9554. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9555. utils.ErrorLog("解析失败:%v", err)
  9556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9557. return
  9558. }
  9559. if res2.Infcode != 0 {
  9560. c.ServeSuccessJSON(map[string]interface{}{
  9561. "failed_code": -10,
  9562. "msg": res2.ErrMsg,
  9563. })
  9564. return
  9565. } else {
  9566. order.IsUploadDiagnose = 1
  9567. service.UpdateOrder(order)
  9568. c.ServeSuccessJSON(map[string]interface{}{
  9569. "msg": "上传成功",
  9570. })
  9571. }
  9572. }
  9573. func (c *HisApiController) Get4203() {
  9574. admin_user_id, _ := c.GetInt64("admin_user_id")
  9575. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9576. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9577. order_id, _ := c.GetInt64("order_id")
  9578. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  9579. number := ""
  9580. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9581. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9582. if his.ID == 0 {
  9583. number = hospital.Number
  9584. } else {
  9585. number = his.Number
  9586. }
  9587. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  9588. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  9589. var res2 ResultSix
  9590. var respJSON2 map[string]interface{}
  9591. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9592. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9594. return
  9595. }
  9596. userJSONBytes2, _ := json.Marshal(respJSON2)
  9597. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9598. utils.ErrorLog("解析失败:%v", err)
  9599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9600. return
  9601. }
  9602. if res2.Infcode != 0 {
  9603. c.ServeSuccessJSON(map[string]interface{}{
  9604. "failed_code": -10,
  9605. "msg": res2.ErrMsg,
  9606. })
  9607. return
  9608. } else {
  9609. order.IsUploadSuccess = 1
  9610. service.UpdateOrderTwo(order)
  9611. c.ServeSuccessJSON(map[string]interface{}{
  9612. "msg": "上传成功",
  9613. })
  9614. }
  9615. }
  9616. func (c *HisApiController) Get4205() {
  9617. order_id, _ := c.GetInt64("order_id")
  9618. admin_user_id, _ := c.GetInt64("admin_user_id")
  9619. fapiao_code := c.GetString("fapiao_code")
  9620. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  9621. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9622. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9623. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9624. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  9625. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  9626. //order_info = append(order_info, order_info_two...)
  9627. department, _ := service.GetDepartMentDetail(his.Departments)
  9628. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  9629. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  9630. if order.ID == 0 {
  9631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9632. return
  9633. }
  9634. var struct4201A models.Struct4201A
  9635. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  9636. for _, items := range order_info {
  9637. memo := make(map[string]interface{})
  9638. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9639. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9640. fsiOPFLD.MedType = pre.MedType
  9641. fsiOPFLD.FixmedinsCode = miConfig.Code
  9642. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9643. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9644. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9645. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.Cnt * items.Pric)
  9646. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9647. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.StartTime, 0).Format("2006-01-02 15:04:05")
  9648. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9649. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  9650. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9651. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9652. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9653. fsiOPFLD.BilgDeptName = department.Name
  9654. fsiOPFLD.BilgDeptCodg = department.Number
  9655. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9656. fsiOPFLD.BilgDrName = doctor.UserName
  9657. fsiOPFLD.MedChrgitmType = "09"
  9658. memo["hosp_appr_flag"] = "1"
  9659. memo["invoice_no"] = fapiao_code
  9660. memo["memo"] = "自费"
  9661. bytesData, _ := json.Marshal(memo)
  9662. fsiOPFLD.Memo = string(bytesData)
  9663. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9664. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9665. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9666. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9667. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.StartTime, 0).Format("2006-01-02 15:04:05")
  9668. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9669. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9670. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9671. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9672. fsiOPFLD.BilgDeptName = department.Name
  9673. fsiOPFLD.BilgDeptCodg = department.Number
  9674. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9675. fsiOPFLD.BilgDrName = doctor.UserName
  9676. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9677. case 0:
  9678. break
  9679. case 1:
  9680. fsiOPFLD.MedChrgitmType = "14"
  9681. break
  9682. case 2:
  9683. fsiOPFLD.MedChrgitmType = "05"
  9684. break
  9685. case 3:
  9686. fsiOPFLD.MedChrgitmType = "03"
  9687. break
  9688. case 4:
  9689. fsiOPFLD.MedChrgitmType = "03"
  9690. break
  9691. case 5:
  9692. fsiOPFLD.MedChrgitmType = "08"
  9693. break
  9694. case 6:
  9695. fsiOPFLD.MedChrgitmType = "14"
  9696. break
  9697. case 7:
  9698. fsiOPFLD.MedChrgitmType = "14"
  9699. break
  9700. case 8:
  9701. fsiOPFLD.MedChrgitmType = "03"
  9702. break
  9703. case 9:
  9704. fsiOPFLD.MedChrgitmType = "14"
  9705. break
  9706. case 10:
  9707. fsiOPFLD.MedChrgitmType = "14"
  9708. break
  9709. case 11:
  9710. fsiOPFLD.MedChrgitmType = "06"
  9711. break
  9712. case 12:
  9713. fsiOPFLD.MedChrgitmType = "12"
  9714. break
  9715. case 13:
  9716. fsiOPFLD.MedChrgitmType = "01"
  9717. break
  9718. case 14:
  9719. fsiOPFLD.MedChrgitmType = "04"
  9720. break
  9721. case 15:
  9722. fsiOPFLD.MedChrgitmType = "14"
  9723. break
  9724. }
  9725. memo["hosp_appr_flag"] = "1"
  9726. memo["invoice_no"] = fapiao_code
  9727. memo["memo"] = "自费"
  9728. bytesData, _ := json.Marshal(memo)
  9729. fsiOPFLD.Memo = string(bytesData)
  9730. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9731. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9732. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9733. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9734. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9735. fsiOPFLD.BilgDeptName = department.Name
  9736. fsiOPFLD.BilgDeptCodg = department.Number
  9737. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9738. fsiOPFLD.BilgDrName = doctor.UserName
  9739. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9740. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9741. fsiOPFLD.MedChrgitmType = "08"
  9742. memo["hosp_appr_flag"] = "1"
  9743. memo["invoice_no"] = fapiao_code
  9744. memo["memo"] = "自费"
  9745. bytesData, _ := json.Marshal(memo)
  9746. fsiOPFLD.Memo = string(bytesData)
  9747. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9748. }
  9749. }
  9750. }
  9751. for _, items := range order_info_two {
  9752. memo := make(map[string]interface{})
  9753. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9754. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9755. fsiOPFLD.MedType = pre.MedType
  9756. fsiOPFLD.BkkpSn = items.FeedetlSn
  9757. fsiOPFLD.FixmedinsCode = miConfig.Code
  9758. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9759. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9760. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9761. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.Cnt * items.Pric)
  9762. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9763. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9764. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9765. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9766. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9767. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9768. fsiOPFLD.BilgDeptName = department.Name
  9769. fsiOPFLD.BilgDeptCodg = department.Number
  9770. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9771. fsiOPFLD.BilgDrName = doctor.UserName
  9772. fsiOPFLD.MedChrgitmType = "09"
  9773. memo["hosp_appr_flag"] = "1"
  9774. memo["invoice_no"] = fapiao_code
  9775. memo["memo"] = "自费"
  9776. bytesData, _ := json.Marshal(memo)
  9777. fsiOPFLD.Memo = string(bytesData)
  9778. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9779. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9780. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9781. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9782. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9783. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9784. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9785. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9786. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9787. fsiOPFLD.BilgDeptName = department.Name
  9788. fsiOPFLD.BilgDeptCodg = department.Number
  9789. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9790. fsiOPFLD.BilgDrName = doctor.UserName
  9791. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9792. case 0:
  9793. break
  9794. case 1:
  9795. fsiOPFLD.MedChrgitmType = "14"
  9796. break
  9797. case 2:
  9798. fsiOPFLD.MedChrgitmType = "05"
  9799. break
  9800. case 3:
  9801. fsiOPFLD.MedChrgitmType = "03"
  9802. break
  9803. case 4:
  9804. fsiOPFLD.MedChrgitmType = "03"
  9805. break
  9806. case 5:
  9807. fsiOPFLD.MedChrgitmType = "08"
  9808. break
  9809. case 6:
  9810. fsiOPFLD.MedChrgitmType = "14"
  9811. break
  9812. case 7:
  9813. fsiOPFLD.MedChrgitmType = "14"
  9814. break
  9815. case 8:
  9816. fsiOPFLD.MedChrgitmType = "03"
  9817. break
  9818. case 9:
  9819. fsiOPFLD.MedChrgitmType = "14"
  9820. break
  9821. case 10:
  9822. fsiOPFLD.MedChrgitmType = "14"
  9823. break
  9824. case 11:
  9825. fsiOPFLD.MedChrgitmType = "06"
  9826. break
  9827. case 12:
  9828. fsiOPFLD.MedChrgitmType = "12"
  9829. break
  9830. case 13:
  9831. fsiOPFLD.MedChrgitmType = "01"
  9832. break
  9833. case 14:
  9834. fsiOPFLD.MedChrgitmType = "04"
  9835. break
  9836. case 15:
  9837. fsiOPFLD.MedChrgitmType = "14"
  9838. break
  9839. }
  9840. memo["hosp_appr_flag"] = "1"
  9841. memo["invoice_no"] = fapiao_code
  9842. memo["memo"] = "自费"
  9843. bytesData, _ := json.Marshal(memo)
  9844. fsiOPFLD.Memo = string(bytesData)
  9845. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9846. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9847. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9848. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9849. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9850. fsiOPFLD.BilgDeptName = department.Name
  9851. fsiOPFLD.BilgDeptCodg = department.Number
  9852. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9853. fsiOPFLD.BilgDrName = doctor.UserName
  9854. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9855. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9856. fsiOPFLD.MedChrgitmType = "08"
  9857. memo["hosp_appr_flag"] = "1"
  9858. memo["invoice_no"] = fapiao_code
  9859. memo["memo"] = "自费"
  9860. bytesData, _ := json.Marshal(memo)
  9861. fsiOPFLD.Memo = string(bytesData)
  9862. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9863. }
  9864. }
  9865. }
  9866. fmt.Println(fsiOPFLDs)
  9867. struct4201A.Fopfd = fsiOPFLDs
  9868. fmt.Println(struct4201A.Fopfd)
  9869. var struct4202 models.Struct4202
  9870. timeLayout := "2006-01-02 15:04:05"
  9871. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  9872. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9873. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9874. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9875. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9876. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9877. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9878. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  9879. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  9880. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9881. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9882. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9883. var config []*models.HisXtDiagnoseConfig
  9884. for _, item := range diagnosis_ids {
  9885. id, _ := strconv.ParseInt(item, 10, 64)
  9886. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9887. config = append(config, &diagnosisConfig)
  9888. }
  9889. var tempDiaginfos []models.OwnPayPatnDiagListD
  9890. for index, item := range config {
  9891. if index == 0 {
  9892. var tempDiaginfo models.OwnPayPatnDiagListD
  9893. tempDiaginfo.InoutDiagType = "1"
  9894. tempDiaginfo.DiagCode = item.CountryCode
  9895. tempDiaginfo.DiagName = item.CountryContentName
  9896. tempDiaginfo.DiagType = "1"
  9897. tempDiaginfo.DiagSrtNo = "1"
  9898. tempDiaginfo.MaindiagFlag = "1"
  9899. tempDiaginfo.ValiFlag = "1"
  9900. tempDiaginfo.DiagDrName = doctor.UserName
  9901. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9902. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9903. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9904. } else {
  9905. var tempDiaginfo models.OwnPayPatnDiagListD
  9906. tempDiaginfo.DiagCode = item.CountryCode
  9907. tempDiaginfo.DiagName = item.CountryContentName
  9908. tempDiaginfo.DiagType = "2"
  9909. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9910. tempDiaginfo.MaindiagFlag = "0"
  9911. tempDiaginfo.ValiFlag = "1"
  9912. tempDiaginfo.DiagDrName = doctor.UserName
  9913. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9914. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9915. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9916. }
  9917. }
  9918. struct4202.ODiagListD = tempDiaginfos
  9919. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  9920. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  9921. var res2 ResultSix
  9922. var respJSON2 map[string]interface{}
  9923. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9924. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9926. return
  9927. }
  9928. userJSONBytes2, _ := json.Marshal(respJSON2)
  9929. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9930. utils.ErrorLog("解析失败:%v", err)
  9931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9932. return
  9933. }
  9934. if res2.Infcode != 0 {
  9935. c.ServeSuccessJSON(map[string]interface{}{
  9936. "failed_code": -10,
  9937. "msg": res2.ErrMsg,
  9938. })
  9939. return
  9940. } else {
  9941. order.IsUploadDiagnose = 1
  9942. order.IsUploadOrderInfo = 1
  9943. service.UpdateOrderTwo(order)
  9944. c.ServeSuccessJSON(map[string]interface{}{
  9945. "msg": "上传成功",
  9946. })
  9947. }
  9948. }
  9949. func (c *HisApiController) Get4207() {
  9950. admin_user_id, _ := c.GetInt64("admin_user_id")
  9951. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9952. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9953. order_id, _ := c.GetInt64("order_id")
  9954. order, _ := service.GetHisOrderByIDTwo(order_id)
  9955. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9956. var struct4207 models.Struct4207
  9957. struct4207.PageNum = "1"
  9958. struct4207.PageSize = "1000"
  9959. struct4207.FixmedinsCode = miConfig.Code
  9960. struct4207.FixmedinsMdtrtID = order.Number
  9961. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  9962. saveLog(result, requestLog, "4207", "查询")
  9963. var res2 ResultSix
  9964. var respJSON2 map[string]interface{}
  9965. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9966. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9968. return
  9969. }
  9970. userJSONBytes2, _ := json.Marshal(respJSON2)
  9971. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9972. utils.ErrorLog("解析失败:%v", err)
  9973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9974. return
  9975. }
  9976. if res2.Infcode != 0 {
  9977. c.ServeSuccessJSON(map[string]interface{}{
  9978. "failed_code": -10,
  9979. "msg": res2.ErrMsg,
  9980. })
  9981. return
  9982. } else {
  9983. c.ServeSuccessJSON(map[string]interface{}{
  9984. "msg": "查询成功",
  9985. })
  9986. }
  9987. }
  9988. func (c *HisApiController) Get4208() {
  9989. admin_user_id, _ := c.GetInt64("admin_user_id")
  9990. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9991. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9992. order_id, _ := c.GetInt64("order_id")
  9993. order, _ := service.GetHisOrderByIDTwo(order_id)
  9994. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9995. var struct4208 models.Struct4208
  9996. struct4208.PageNum = "1"
  9997. struct4208.PageSize = "1000"
  9998. struct4208.PsnCertType = "01"
  9999. struct4208.Certno = his.Certno
  10000. struct4208.MedType = order.MedType
  10001. struct4208.PsnName = his.Name
  10002. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  10003. saveLog(result, requestLog, "4208", "查询")
  10004. var res2 ResultSix
  10005. var respJSON2 map[string]interface{}
  10006. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10009. return
  10010. }
  10011. userJSONBytes2, _ := json.Marshal(respJSON2)
  10012. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10013. utils.ErrorLog("解析失败:%v", err)
  10014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10015. return
  10016. }
  10017. if res2.Infcode != 0 {
  10018. c.ServeSuccessJSON(map[string]interface{}{
  10019. "failed_code": -10,
  10020. "msg": res2.ErrMsg,
  10021. })
  10022. return
  10023. } else {
  10024. c.ServeSuccessJSON(map[string]interface{}{
  10025. "msg": "查询成功",
  10026. })
  10027. }
  10028. }
  10029. func (c *HisApiController) Get4209() {
  10030. admin_user_id, _ := c.GetInt64("admin_user_id")
  10031. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10032. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10033. order_id, _ := c.GetInt64("order_id")
  10034. order, _ := service.GetHisOrderByIDTwo(order_id)
  10035. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  10036. var struct4209 models.Struct4209
  10037. struct4209.FixmedinsMdtrtID = order.Number
  10038. struct4209.FixmedinsCode = miConfig.Code
  10039. struct4209.PageSize = "1000"
  10040. struct4209.PageNum = "1"
  10041. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  10042. saveLog(result, requestLog, "4209", "查询")
  10043. var res2 ResultSix
  10044. var respJSON2 map[string]interface{}
  10045. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10046. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10048. return
  10049. }
  10050. userJSONBytes2, _ := json.Marshal(respJSON2)
  10051. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10052. utils.ErrorLog("解析失败:%v", err)
  10053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10054. return
  10055. }
  10056. if res2.Infcode != 0 {
  10057. c.ServeSuccessJSON(map[string]interface{}{
  10058. "failed_code": -10,
  10059. "msg": res2.ErrMsg,
  10060. })
  10061. return
  10062. } else {
  10063. c.ServeSuccessJSON(map[string]interface{}{
  10064. "msg": "查询成功",
  10065. })
  10066. }
  10067. }
  10068. type Result3101 struct {
  10069. Infcode string `json:"infcode"`
  10070. InfRefmsgid string `json:"inf_refmsgid"`
  10071. RefmsgTime string `json:"refmsg_time"`
  10072. RespondTime string `json:"respond_time"`
  10073. Enctype string `json:"enctype"`
  10074. Signtype string `json:"signtype"`
  10075. ErrMsg string `json:"err_msg"`
  10076. Output struct {
  10077. Result []struct {
  10078. JudgeResultDetailDtos []struct {
  10079. VolaItemType string `json:"vola_item_type"`
  10080. MdtrtID string `json:"mdtrt_id"`
  10081. JrdID string `json:"jrd_id"`
  10082. PatnID string `json:"patn_id"`
  10083. RxID string `json:"rx_id"`
  10084. VolaAmt interface{} `json:"vola_amt"`
  10085. } `json:"judge_result_detail_dtos"`
  10086. RuleID string `json:"rule_id"`
  10087. VolaEvid string `json:"vola_evid"`
  10088. MdtrtID string `json:"mdtrt_id"`
  10089. RuleName string `json:"rule_name"`
  10090. VolaAmtStas string `json:"vola_amt_stas"`
  10091. JrID string `json:"jr_id"`
  10092. PatnID string `json:"patn_id"`
  10093. SevDeg string `json:"sev_deg"`
  10094. VolaAmt float64 `json:"vola_amt"`
  10095. VolaBhvrType string `json:"vola_bhvr_type"`
  10096. VolaCont string `json:"vola_cont"`
  10097. } `json:"result"`
  10098. } `json:"output"`
  10099. }
  10100. type Resultgd3101 struct {
  10101. Infcode int64 `json:"infcode"`
  10102. InfRefmsgid string `json:"inf_refmsgid"`
  10103. RefmsgTime string `json:"refmsg_time"`
  10104. RespondTime string `json:"respond_time"`
  10105. Enctype string `json:"enctype"`
  10106. Signtype string `json:"signtype"`
  10107. ErrMsg string `json:"err_msg"`
  10108. Output struct {
  10109. Result []struct {
  10110. JudgeResultDetailDtos []struct {
  10111. VolaItemType string `json:"vola_item_type"`
  10112. MdtrtID string `json:"mdtrt_id"`
  10113. JrdID string `json:"jrd_id"`
  10114. PatnID string `json:"patn_id"`
  10115. RxID string `json:"rx_id"`
  10116. VolaAmt interface{} `json:"vola_amt"`
  10117. } `json:"judge_result_detail_dtos"`
  10118. RuleID string `json:"rule_id"`
  10119. VolaEvid string `json:"vola_evid"`
  10120. MdtrtID string `json:"mdtrt_id"`
  10121. RuleName string `json:"rule_name"`
  10122. VolaAmtStas string `json:"vola_amt_stas"`
  10123. JrID string `json:"jr_id"`
  10124. PatnID string `json:"patn_id"`
  10125. SevDeg string `json:"sev_deg"`
  10126. VolaAmt float64 `json:"vola_amt"`
  10127. VolaBhvrType string `json:"vola_bhvr_type"`
  10128. VolaCont string `json:"vola_cont"`
  10129. } `json:"result"`
  10130. } `json:"output"`
  10131. }
  10132. func (c *HisApiController) ReadEleToken() {
  10133. admin_user_id, _ := c.GetInt64("admin_user_id")
  10134. his_patient_id, _ := c.GetInt64("his_patient_id")
  10135. adminUser := c.GetAdminUserInfo()
  10136. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10137. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10138. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10139. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  10140. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10141. if len(tokens) > 0 {
  10142. c.ServeSuccessJSON(map[string]interface{}{
  10143. "msg": "读取成功",
  10144. })
  10145. } else {
  10146. c.ServeSuccessJSON(map[string]interface{}{
  10147. "failed_code": -10,
  10148. "msg": "读取失败",
  10149. })
  10150. }
  10151. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10152. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10153. if len(tokens) > 0 {
  10154. c.ServeSuccessJSON(map[string]interface{}{
  10155. "msg": "读取成功",
  10156. })
  10157. } else {
  10158. c.ServeSuccessJSON(map[string]interface{}{
  10159. "failed_code": -10,
  10160. "msg": "读取失败",
  10161. })
  10162. }
  10163. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10164. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10165. if len(tokens) > 0 {
  10166. c.ServeSuccessJSON(map[string]interface{}{
  10167. "msg": "读取成功",
  10168. })
  10169. } else {
  10170. c.ServeSuccessJSON(map[string]interface{}{
  10171. "failed_code": -10,
  10172. "msg": "读取失败",
  10173. })
  10174. }
  10175. } else if miConfig.MdtrtareaAdmvs == "150404" {
  10176. var api string
  10177. 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 +
  10178. "&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"
  10179. resp, requestErr := http.Get(api)
  10180. if requestErr != nil {
  10181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10182. }
  10183. body, ioErr := ioutil.ReadAll(resp.Body)
  10184. if ioErr != nil {
  10185. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10187. }
  10188. var respJSON map[string]interface{}
  10189. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10190. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10192. return
  10193. }
  10194. var status string
  10195. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10196. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10197. var token string
  10198. var res ResultTwo //1101结果
  10199. var res10265 ResultTwo10265 //1101结果
  10200. if status == "0" { //读卡成功
  10201. var card_info string //卡信息
  10202. var busi_card_info string
  10203. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10204. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10205. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10206. fmt.Println(card_info)
  10207. fmt.Println(busi_card_info)
  10208. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10209. result, _ := json.Marshal(respJSON)
  10210. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10211. utils.ErrorLog("解析失败:%v", err)
  10212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10213. return
  10214. }
  10215. res.ErrMsg = res10265.ErrMsg
  10216. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10217. res.Infcode = infocode
  10218. res.Output = res10265.Output
  10219. res.InfRefmsgid = res10265.InfRefmsgid
  10220. if res.Infcode == 0 {
  10221. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10222. if err == gorm.ErrRecordNotFound {
  10223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10224. return
  10225. } else if err != nil {
  10226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10227. return
  10228. } else {
  10229. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10230. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10231. infoStr := string(Iinfos)
  10232. idetinfoStr := string(Idetinfos)
  10233. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  10234. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  10235. psn := &models.HisPsn{
  10236. PsnNo: res.Output.Baseinfo.PsnNo,
  10237. PatientId: patient.ID,
  10238. Certno: res.Output.Baseinfo.Certno,
  10239. Gend: res.Output.Baseinfo.Gend,
  10240. Naty: res.Output.Baseinfo.Naty,
  10241. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10242. PsnName: res.Output.Baseinfo.PsnName,
  10243. Age: float64(age),
  10244. Brdy: b,
  10245. Idetinfo: idetinfoStr,
  10246. Insuinfo: infoStr,
  10247. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10248. CardInfo: card_info,
  10249. VerifyNumber: token,
  10250. IdCardType: 4,
  10251. }
  10252. var rf []*ResultFive
  10253. json.Unmarshal([]byte(infoStr), &rf)
  10254. var insutypes []*ResultFive
  10255. var insutype string
  10256. var is390 int = 0
  10257. var is310 int = 0
  10258. for _, item := range rf {
  10259. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10260. insutypes = append(insutypes, item)
  10261. }
  10262. }
  10263. if len(insutypes) == 1 {
  10264. insutype = insutypes[0].Insutype
  10265. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10266. } else {
  10267. for _, i := range insutypes {
  10268. if i.Insutype == "390" {
  10269. is390 = 1
  10270. }
  10271. if i.Insutype == "310" {
  10272. is310 = 1
  10273. }
  10274. }
  10275. }
  10276. if is390 == 1 {
  10277. insutype = "390"
  10278. }
  10279. if is310 == 1 {
  10280. insutype = "310"
  10281. }
  10282. if len(insutypes) == 0 {
  10283. insutype = "310"
  10284. }
  10285. service.CreateHisPsn(psn)
  10286. c.ServeSuccessJSON(map[string]interface{}{
  10287. "patient": patient,
  10288. "number": token,
  10289. "insutype": insutype,
  10290. })
  10291. }
  10292. } else {
  10293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10294. return
  10295. }
  10296. } else { //读卡失败
  10297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10298. return
  10299. }
  10300. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10301. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  10302. if len(errMsg) == 0 {
  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(outPutInfo), &ele)
  10321. if err != nil {
  10322. utils.ErrorLog("解析失败:%v", err)
  10323. }
  10324. token := ele.Data.EcToken
  10325. if len(token) > 0 {
  10326. psn := &models.HisPsn{
  10327. PsnNo: his.PsnNo,
  10328. Age: 0,
  10329. PatientId: his.PatientId,
  10330. Certno: his.Certno,
  10331. Brdy: his.Brdy,
  10332. Gend: his.Gend,
  10333. Naty: his.Naty,
  10334. PsnCertType: his.PsnCertType,
  10335. PsnName: his.PsnName,
  10336. Idetinfo: his.Idetinfo,
  10337. Insuinfo: his.Iinfo,
  10338. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10339. CardInfo: outPutInfo,
  10340. VerifyNumber: token,
  10341. }
  10342. service.CreateHisPsn(psn)
  10343. }
  10344. if len(token) > 0 {
  10345. c.ServeSuccessJSON(map[string]interface{}{
  10346. "msg": "读取成功",
  10347. })
  10348. } else {
  10349. c.ServeSuccessJSON(map[string]interface{}{
  10350. "failed_code": -10,
  10351. "msg": "读取失败",
  10352. })
  10353. }
  10354. }
  10355. } else if miConfig.MdtrtareaAdmvs == "360302" {
  10356. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10357. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10358. type ELeData struct {
  10359. Data struct {
  10360. IdNo string `json:"idNo"`
  10361. IdType string `json:"idType"`
  10362. UserName string `json:"userName"`
  10363. EcToken string `json:"ecToken"`
  10364. InsuOrg string `json:"insuOrg"`
  10365. Gender string `json:"gender"`
  10366. Birthday string `json:"birthday"`
  10367. Nationality string `json:"nationality"`
  10368. Email string `json:"email"`
  10369. Extra string `json:"extra"`
  10370. } `json:"data"`
  10371. Code int `json:"code"`
  10372. Message string `json:"message"`
  10373. }
  10374. var ele ELeData
  10375. err := json.Unmarshal([]byte(result), &ele)
  10376. if err != nil {
  10377. utils.ErrorLog("解析失败:%v", err)
  10378. }
  10379. token := ele.Data.EcToken
  10380. token = Remove0000(token)
  10381. fmt.Println(ele.Data.UserName)
  10382. 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)
  10383. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10384. var res ResultTwo
  10385. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10386. utils.ErrorLog("解析失败:%v", err)
  10387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10388. return
  10389. }
  10390. if res.Infcode == 0 {
  10391. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10392. if err == gorm.ErrRecordNotFound {
  10393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10394. return
  10395. } else if err != nil {
  10396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10397. return
  10398. } else {
  10399. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10400. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10401. infoStr := string(Iinfos)
  10402. idetinfoStr := string(Idetinfos)
  10403. psn := &models.HisPsn{
  10404. PsnNo: res.Output.Baseinfo.PsnNo,
  10405. PatientId: patient.ID,
  10406. Certno: res.Output.Baseinfo.Certno,
  10407. Gend: res.Output.Baseinfo.Gend,
  10408. Naty: res.Output.Baseinfo.Naty,
  10409. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10410. PsnName: res.Output.Baseinfo.PsnName,
  10411. Idetinfo: idetinfoStr,
  10412. Insuinfo: infoStr,
  10413. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10414. CardInfo: "",
  10415. VerifyNumber: token,
  10416. }
  10417. service.CreateHisPsn(psn)
  10418. c.ServeSuccessJSON(map[string]interface{}{
  10419. "patient": patient,
  10420. "number": token,
  10421. })
  10422. }
  10423. } else {
  10424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10425. return
  10426. }
  10427. } else if miConfig.MdtrtareaAdmvs == "361025" {
  10428. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10429. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10430. type ELeData struct {
  10431. Data struct {
  10432. IdNo string `json:"idNo"`
  10433. IdType string `json:"idType"`
  10434. UserName string `json:"userName"`
  10435. EcToken string `json:"ecToken"`
  10436. InsuOrg string `json:"insuOrg"`
  10437. Gender string `json:"gender"`
  10438. Birthday string `json:"birthday"`
  10439. Nationality string `json:"nationality"`
  10440. Email string `json:"email"`
  10441. Extra string `json:"extra"`
  10442. } `json:"data"`
  10443. Code int `json:"code"`
  10444. Message string `json:"message"`
  10445. }
  10446. var ele ELeData
  10447. err := json.Unmarshal([]byte(result), &ele)
  10448. if err != nil {
  10449. utils.ErrorLog("解析失败:%v", err)
  10450. }
  10451. token := ele.Data.EcToken
  10452. token = Remove0000(token)
  10453. fmt.Println(ele.Data.UserName)
  10454. 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)
  10455. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10456. var res ResultTwo
  10457. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10458. utils.ErrorLog("解析失败:%v", err)
  10459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10460. return
  10461. }
  10462. if res.Infcode == 0 {
  10463. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10464. if err == gorm.ErrRecordNotFound {
  10465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10466. return
  10467. } else if err != nil {
  10468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10469. return
  10470. } else {
  10471. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10472. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10473. infoStr := string(Iinfos)
  10474. idetinfoStr := string(Idetinfos)
  10475. psn := &models.HisPsn{
  10476. PsnNo: res.Output.Baseinfo.PsnNo,
  10477. PatientId: patient.ID,
  10478. Certno: res.Output.Baseinfo.Certno,
  10479. Gend: res.Output.Baseinfo.Gend,
  10480. Naty: res.Output.Baseinfo.Naty,
  10481. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10482. PsnName: res.Output.Baseinfo.PsnName,
  10483. Idetinfo: idetinfoStr,
  10484. Insuinfo: infoStr,
  10485. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10486. CardInfo: "",
  10487. VerifyNumber: token,
  10488. }
  10489. service.CreateHisPsn(psn)
  10490. c.ServeSuccessJSON(map[string]interface{}{
  10491. "patient": patient,
  10492. "number": token,
  10493. })
  10494. }
  10495. } else {
  10496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10497. return
  10498. }
  10499. } else if miConfig.MdtrtareaAdmvs == "360100" {
  10500. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10501. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10502. type ELeData struct {
  10503. Data struct {
  10504. IdNo string `json:"idNo"`
  10505. IdType string `json:"idType"`
  10506. UserName string `json:"userName"`
  10507. EcToken string `json:"ecToken"`
  10508. InsuOrg string `json:"insuOrg"`
  10509. Gender string `json:"gender"`
  10510. Birthday string `json:"birthday"`
  10511. Nationality string `json:"nationality"`
  10512. Email string `json:"email"`
  10513. Extra string `json:"extra"`
  10514. } `json:"data"`
  10515. Code int `json:"code"`
  10516. Message string `json:"message"`
  10517. }
  10518. var ele ELeData
  10519. err := json.Unmarshal([]byte(result), &ele)
  10520. if err != nil {
  10521. utils.ErrorLog("解析失败:%v", err)
  10522. }
  10523. token := ele.Data.EcToken
  10524. token = Remove0000(token)
  10525. fmt.Println(ele.Data.UserName)
  10526. 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)
  10527. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10528. var res ResultTwo
  10529. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10530. utils.ErrorLog("解析失败:%v", err)
  10531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10532. return
  10533. }
  10534. if res.Infcode == 0 {
  10535. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10536. if err == gorm.ErrRecordNotFound {
  10537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10538. return
  10539. } else if err != nil {
  10540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10541. return
  10542. } else {
  10543. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10544. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10545. infoStr := string(Iinfos)
  10546. idetinfoStr := string(Idetinfos)
  10547. psn := &models.HisPsn{
  10548. PsnNo: res.Output.Baseinfo.PsnNo,
  10549. PatientId: patient.ID,
  10550. Certno: res.Output.Baseinfo.Certno,
  10551. Gend: res.Output.Baseinfo.Gend,
  10552. Naty: res.Output.Baseinfo.Naty,
  10553. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10554. PsnName: res.Output.Baseinfo.PsnName,
  10555. Idetinfo: idetinfoStr,
  10556. Insuinfo: infoStr,
  10557. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10558. CardInfo: "",
  10559. VerifyNumber: token,
  10560. }
  10561. service.CreateHisPsn(psn)
  10562. c.ServeSuccessJSON(map[string]interface{}{
  10563. "patient": patient,
  10564. "number": token,
  10565. })
  10566. }
  10567. } else {
  10568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10569. return
  10570. }
  10571. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10572. //if initFlag == 0 {
  10573. //c.TestGetJiangXiBasBaseInit()
  10574. //}
  10575. //if initEleFlag == 0 {
  10576. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  10577. //}
  10578. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  10579. utils.ErrorLog("解析失败:%v", json_result)
  10580. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10581. type ELeData struct {
  10582. Data struct {
  10583. IdNo string `json:"idNo"`
  10584. IdType string `json:"idType"`
  10585. UserName string `json:"userName"`
  10586. EcToken string `json:"ecToken"`
  10587. InsuOrg string `json:"insuOrg"`
  10588. Gender string `json:"gender"`
  10589. Birthday string `json:"birthday"`
  10590. Nationality string `json:"nationality"`
  10591. Email string `json:"email"`
  10592. Extra string `json:"extra"`
  10593. } `json:"data"`
  10594. Code int `json:"code"`
  10595. Message string `json:"message"`
  10596. }
  10597. var ele ELeData
  10598. err := json.Unmarshal([]byte(json_result), &ele)
  10599. if err != nil {
  10600. utils.ErrorLog("解析失败:%v", err)
  10601. }
  10602. token := ele.Data.EcToken
  10603. token = Remove0000(token)
  10604. //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)
  10605. 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)
  10606. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  10607. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10608. var res ResultTwo
  10609. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10610. utils.ErrorLog("解析失败:%v", err)
  10611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10612. return
  10613. }
  10614. if res.Infcode == 0 {
  10615. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10616. if err == gorm.ErrRecordNotFound {
  10617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10618. return
  10619. } else if err != nil {
  10620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10621. return
  10622. } else {
  10623. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10624. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10625. infoStr := string(Iinfos)
  10626. idetinfoStr := string(Idetinfos)
  10627. psn := &models.HisPsn{
  10628. PsnNo: res.Output.Baseinfo.PsnNo,
  10629. PatientId: patient.ID,
  10630. Certno: res.Output.Baseinfo.Certno,
  10631. Gend: res.Output.Baseinfo.Gend,
  10632. Naty: res.Output.Baseinfo.Naty,
  10633. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10634. PsnName: res.Output.Baseinfo.PsnName,
  10635. Idetinfo: idetinfoStr,
  10636. Insuinfo: infoStr,
  10637. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10638. CardInfo: "",
  10639. VerifyNumber: token,
  10640. InsuplcAdmdvs: ele.Data.InsuOrg,
  10641. }
  10642. service.CreateHisPsn(psn)
  10643. c.ServeSuccessJSON(map[string]interface{}{
  10644. "patient": patient,
  10645. "number": token,
  10646. })
  10647. }
  10648. } else {
  10649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10650. return
  10651. }
  10652. } else if miConfig.MdtrtareaAdmvs == "450721" {
  10653. res := c.GetoleInfo()
  10654. if res.Infcode == 0 {
  10655. var result string
  10656. if res.Output.MdtrtCertType == "01" {
  10657. 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)
  10658. } else if res.Output.MdtrtCertType == "02" {
  10659. 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)
  10660. } else if res.Output.MdtrtCertType == "03" {
  10661. 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)
  10662. }
  10663. var dat map[string]interface{}
  10664. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10665. fmt.Println(dat)
  10666. } else {
  10667. fmt.Println(err)
  10668. }
  10669. userJSONBytes, _ := json.Marshal(dat)
  10670. var res2 ResultTwo
  10671. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10672. utils.ErrorLog("解析失败:%v", err)
  10673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10674. return
  10675. }
  10676. if res2.Infcode == 0 {
  10677. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  10678. if err == gorm.ErrRecordNotFound {
  10679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10680. return
  10681. } else if err != nil {
  10682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10683. return
  10684. } else {
  10685. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  10686. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  10687. infoStr := string(Iinfos)
  10688. idetinfoStr := string(Idetinfos)
  10689. var rf []*ResultFive
  10690. json.Unmarshal([]byte(infoStr), &rf)
  10691. var insutypes []*ResultFive
  10692. var insutype string
  10693. var is390 int = 0
  10694. var is310 int = 0
  10695. //var insuplc_admdvs string
  10696. for _, item := range rf {
  10697. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10698. insutypes = append(insutypes, item)
  10699. }
  10700. }
  10701. if len(insutypes) == 1 {
  10702. insutype = insutypes[0].Insutype
  10703. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10704. } else {
  10705. for _, i := range insutypes {
  10706. if i.Insutype == "390" {
  10707. is390 = 1
  10708. }
  10709. if i.Insutype == "310" {
  10710. is310 = 1
  10711. }
  10712. }
  10713. }
  10714. if is390 == 1 {
  10715. insutype = "390"
  10716. }
  10717. if is310 == 1 {
  10718. insutype = "310"
  10719. }
  10720. if len(insutypes) == 0 {
  10721. insutype = "310"
  10722. }
  10723. psn := &models.HisPsn{
  10724. PsnNo: res2.Output.Baseinfo.PsnNo,
  10725. PatientId: patient.ID,
  10726. Certno: res2.Output.Baseinfo.Certno,
  10727. Gend: res2.Output.Baseinfo.Gend,
  10728. Naty: res2.Output.Baseinfo.Naty,
  10729. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  10730. PsnName: res2.Output.Baseinfo.PsnName,
  10731. Idetinfo: idetinfoStr,
  10732. Insuinfo: infoStr,
  10733. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10734. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  10735. VerifyNumber: res.Output.EcToken,
  10736. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  10737. }
  10738. service.CreateHisPsn(psn)
  10739. c.ServeSuccessJSON(map[string]interface{}{
  10740. "patient": patient,
  10741. "number": res.Output.CardNo,
  10742. "insutype": insutype,
  10743. })
  10744. }
  10745. } else {
  10746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10747. return
  10748. }
  10749. } else {
  10750. c.ServeSuccessJSON(map[string]interface{}{
  10751. "failed_code": -10,
  10752. "msg": res.ErrMsg,
  10753. })
  10754. }
  10755. } else {
  10756. //if initFlag == 0 {
  10757. // c.TestGetBasBaseInit()
  10758. //}
  10759. //token := c.GetEleBaseInfo()
  10760. //token = Remove0000(token)
  10761. type ELeData struct {
  10762. Code string `json:"code"`
  10763. Data struct {
  10764. Aac002 string `json:"aac002"`
  10765. Aaz500 string `json:"aaz500"`
  10766. ActCardNo string `json:"actCardNo"`
  10767. Bab520 string `json:"bab520"`
  10768. Bkz543 string `json:"bkz543"`
  10769. BusinessType string `json:"businessType"`
  10770. CertfCodg string `json:"certfCodg"`
  10771. EcIndexNo string `json:"ecIndexNo"`
  10772. EcToken string `json:"ecToken"`
  10773. ID0000 string `json:"id0000"`
  10774. IDNo string `json:"idNo"`
  10775. IDType string `json:"idType"`
  10776. Idcode string `json:"idcode"`
  10777. IdentityToken string `json:"identity_token"`
  10778. InsuOrg string `json:"insuOrg"`
  10779. OfficeID string `json:"officeId"`
  10780. OfficeName string `json:"officeName"`
  10781. OperatorID string `json:"operatorId"`
  10782. OperatorName string `json:"operatorName"`
  10783. OrgID string `json:"orgId"`
  10784. UserName string `json:"userName"`
  10785. } `json:"data"`
  10786. Infno interface{} `json:"infno"`
  10787. Message string `json:"message"`
  10788. OrgID string `json:"orgId"`
  10789. TransType string `json:"transType"`
  10790. }
  10791. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10792. fmt.Println(result)
  10793. outPutInfo := Remove0000(result)
  10794. fmt.Println(outPutInfo)
  10795. var ele ELeData
  10796. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10797. if err != nil {
  10798. utils.ErrorLog("解析失败:%v", err)
  10799. }
  10800. token := ele.Data.EcToken
  10801. var result2 string
  10802. var requestLog2 string
  10803. if len(token) > 0 {
  10804. if strings.Contains(ele.Data.IDNo, "HKG") {
  10805. 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)
  10806. } else {
  10807. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  10808. }
  10809. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10810. var res ResultTwo
  10811. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10812. utils.ErrorLog("解析失败:%v", err)
  10813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10814. return
  10815. }
  10816. if res.Infcode == 0 {
  10817. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10818. if err == gorm.ErrRecordNotFound {
  10819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10820. return
  10821. } else if err != nil {
  10822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10823. return
  10824. } else {
  10825. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10826. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10827. infoStr := string(Iinfos)
  10828. idetinfoStr := string(Idetinfos)
  10829. psn := &models.HisPsn{
  10830. PsnNo: res.Output.Baseinfo.PsnNo,
  10831. PatientId: patient.ID,
  10832. Certno: res.Output.Baseinfo.Certno,
  10833. Gend: res.Output.Baseinfo.Gend,
  10834. Naty: res.Output.Baseinfo.Naty,
  10835. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10836. PsnName: res.Output.Baseinfo.PsnName,
  10837. Idetinfo: idetinfoStr,
  10838. Insuinfo: infoStr,
  10839. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10840. CardInfo: "",
  10841. VerifyNumber: token,
  10842. }
  10843. service.CreateHisPsn(psn)
  10844. c.ServeSuccessJSON(map[string]interface{}{
  10845. "msg": "读取成功",
  10846. })
  10847. }
  10848. } else {
  10849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10850. return
  10851. }
  10852. } else {
  10853. c.ServeSuccessJSON(map[string]interface{}{
  10854. "failed_code": -10,
  10855. "msg": "读取失败",
  10856. })
  10857. }
  10858. }
  10859. }
  10860. func (c *HisApiController) ReadEleFace() {
  10861. admin_user_id, _ := c.GetInt64("admin_user_id")
  10862. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10863. adminUser := c.GetAdminUserInfo()
  10864. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10865. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10866. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10867. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  10868. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10869. if len(tokens) > 0 {
  10870. c.ServeSuccessJSON(map[string]interface{}{
  10871. "msg": "读取成功",
  10872. })
  10873. } else {
  10874. c.ServeSuccessJSON(map[string]interface{}{
  10875. "failed_code": -10,
  10876. "msg": "读取失败",
  10877. })
  10878. }
  10879. }
  10880. }
  10881. func timestampToBirthdayString(timestamp int64) string {
  10882. // 将时间戳转换为 time.Time
  10883. t := time.Unix(timestamp, 0)
  10884. // 格式化时间为生日字符串,例如 "2006-01-02"
  10885. birthday := t.Format("2006-01-02")
  10886. return birthday
  10887. }
  10888. func (c *HisApiController) Get9001() {
  10889. adminUser := c.GetAdminUserInfo()
  10890. admin_user_id, _ := c.GetInt64("admin_user_id")
  10891. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10892. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10893. if miConfig.MdtrtareaAdmvs == "350500" {
  10894. service.GetFjAuthorizationInfo(miConfig.Code)
  10895. } else if miConfig.MdtrtareaAdmvs == "131023" {
  10896. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10897. var dat map[string]interface{}
  10898. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10899. fmt.Println(dat)
  10900. } else {
  10901. fmt.Println(err)
  10902. }
  10903. userJSONBytes, _ := json.Marshal(dat)
  10904. var res models.Result9001
  10905. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10906. utils.ErrorLog("解析失败:%v", err)
  10907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10908. return
  10909. }
  10910. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10911. fmt.Println(miConfig.SecretKey)
  10912. var res models.Result9001Two
  10913. 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 +
  10914. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10915. resp, requestErr := http.Get(api)
  10916. if requestErr != nil {
  10917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10918. return
  10919. }
  10920. body, ioErr := ioutil.ReadAll(resp.Body)
  10921. if ioErr != nil {
  10922. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10924. return
  10925. }
  10926. var respJSON map[string]interface{}
  10927. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10928. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10930. return
  10931. }
  10932. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10933. if status == "0" {
  10934. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10935. c.ServeSuccessJSON(map[string]interface{}{
  10936. "failed_code": -10,
  10937. "msg": err_msg,
  10938. })
  10939. return
  10940. }
  10941. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10942. result, _ := json.Marshal(respJSON)
  10943. fmt.Println("log")
  10944. fmt.Println(string(result))
  10945. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10946. utils.ErrorLog("解析失败:%v", err)
  10947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10948. return
  10949. }
  10950. if res.Infcode == 0 {
  10951. sign := models.HisSignIn{
  10952. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10953. SignNo: res.Output.Signinoutb.SignNo,
  10954. SignTime: "",
  10955. Ctime: time.Now().Unix(),
  10956. Mtime: time.Now().Unix(),
  10957. Status: 1,
  10958. InputLog: "",
  10959. OutputLog: "",
  10960. FixmedinsCode: miConfig.Code,
  10961. }
  10962. err := service.CreateSignIn(&sign)
  10963. if err == nil {
  10964. c.ServeSuccessJSON(map[string]interface{}{
  10965. "msg": "签到成功",
  10966. })
  10967. }
  10968. } else {
  10969. c.ServeSuccessJSON(map[string]interface{}{
  10970. "failed_code": -10,
  10971. "msg": res.ErrMsg,
  10972. })
  10973. return
  10974. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10975. //return
  10976. }
  10977. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10978. fmt.Println(miConfig.SecretKey)
  10979. var res models.Result9001Two
  10980. 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 +
  10981. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10982. resp, requestErr := http.Get(api)
  10983. if requestErr != nil {
  10984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10985. return
  10986. }
  10987. body, ioErr := ioutil.ReadAll(resp.Body)
  10988. if ioErr != nil {
  10989. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10991. return
  10992. }
  10993. var respJSON map[string]interface{}
  10994. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10995. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10997. return
  10998. }
  10999. status := respJSON["data"].(map[string]interface{})["status"].(string)
  11000. if status == "0" {
  11001. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  11002. c.ServeSuccessJSON(map[string]interface{}{
  11003. "failed_code": -10,
  11004. "msg": err_msg,
  11005. })
  11006. return
  11007. }
  11008. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11009. result, _ := json.Marshal(respJSON)
  11010. fmt.Println("log")
  11011. fmt.Println(string(result))
  11012. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11013. utils.ErrorLog("解析失败:%v", err)
  11014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11015. return
  11016. }
  11017. if res.Infcode == 0 {
  11018. sign := models.HisSignIn{
  11019. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11020. SignNo: res.Output.Signinoutb.SignNo,
  11021. SignTime: "",
  11022. Ctime: time.Now().Unix(),
  11023. Mtime: time.Now().Unix(),
  11024. Status: 1,
  11025. InputLog: "",
  11026. OutputLog: "",
  11027. FixmedinsCode: miConfig.Code,
  11028. }
  11029. err := service.CreateSignIn(&sign)
  11030. if err == nil {
  11031. c.ServeSuccessJSON(map[string]interface{}{
  11032. "msg": "签到成功",
  11033. })
  11034. }
  11035. } else {
  11036. c.ServeSuccessJSON(map[string]interface{}{
  11037. "failed_code": -10,
  11038. "msg": res.ErrMsg,
  11039. })
  11040. return
  11041. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11042. //return
  11043. }
  11044. } else {
  11045. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  11046. var dat map[string]interface{}
  11047. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11048. fmt.Println(dat)
  11049. } else {
  11050. fmt.Println(err)
  11051. }
  11052. userJSONBytes, _ := json.Marshal(dat)
  11053. var res models.Result9001
  11054. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11055. utils.ErrorLog("解析失败:%v", err)
  11056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11057. return
  11058. }
  11059. if res.Infcode == 0 {
  11060. sign := models.HisSignIn{
  11061. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11062. SignNo: res.Output.Signinoutb.SignNo,
  11063. SignTime: res.Output.Signinoutb.SignTime,
  11064. Ctime: time.Now().Unix(),
  11065. Mtime: time.Now().Unix(),
  11066. Status: 1,
  11067. InputLog: "",
  11068. OutputLog: "",
  11069. FixmedinsCode: miConfig.Code,
  11070. }
  11071. err := service.CreateSignIn(&sign)
  11072. if err == nil {
  11073. c.ServeSuccessJSON(map[string]interface{}{
  11074. "msg": "签到成功",
  11075. })
  11076. }
  11077. }
  11078. }
  11079. }
  11080. 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) {
  11081. var res Result3101
  11082. adminUser := c.GetAdminUserInfo()
  11083. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11084. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11085. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11086. //record_time := c.GetString("record_time")
  11087. //trig_scen := c.GetString("trig_scen")
  11088. timeLayout := "2006-01-02"
  11089. loc, _ := time.LoadLocation("Local")
  11090. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11091. if err != nil {
  11092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11093. return res
  11094. }
  11095. recordDateTime := theTime.Unix()
  11096. var patientPrescription models.HisPrescriptionInfo
  11097. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11098. //if patientPrescription.ID == 0 {
  11099. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11100. //}
  11101. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11102. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11103. //
  11104. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11105. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11106. var pp models.PublicParams
  11107. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11108. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11109. pp.FixmedinsName = miConfig.OrgName
  11110. pp.FixmedinsCode = miConfig.Code
  11111. pp.RequestUrl = miConfig.Url
  11112. pp.Cainfo = miConfig.Cainfo
  11113. pp.SecretKey = miConfig.SecretKey
  11114. pp.AccessKey = miConfig.AccessKey
  11115. pp.OpterName = roles.UserName
  11116. var config []*models.HisXtDiagnoseConfig
  11117. for _, item := range diagnosis_ids {
  11118. id, _ := strconv.ParseInt(item, 10, 64)
  11119. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11120. config = append(config, &diagnosisConfig)
  11121. }
  11122. var pd models.PatientDtos
  11123. pd.PatnID = his.PsnNo
  11124. pd.PatnName = his.Name
  11125. pd.Gend = his.Gend
  11126. pd.Brdy = his.Brdy
  11127. pd.Poolarea = miConfig.MdtrtareaAdmvs
  11128. pd.CurrMdtrtID = his.Number
  11129. var fed models.FsiEncounterDtos
  11130. fed.MdtrtID = his.Number
  11131. fed.MedinsID = miConfig.Code
  11132. fed.MedinsName = miConfig.OrgName
  11133. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11134. fed.MedMdtrtType = "1"
  11135. fed.MedinsType = "1"
  11136. fed.MedinsLv = "11"
  11137. tm := time.Unix(his.RecordDate, 0)
  11138. s_tm := tm.Format("2006-01-02 15:04:05")
  11139. fed.AdmDate = s_tm
  11140. fed.DscgDate = s_tm
  11141. fed.DscgMainDiseCodg = config[0].CountryCode
  11142. fed.DscgMainDiseName = config[0].CountryContentName
  11143. //诊断信息
  11144. var fdds []*models.FsiDiagnoseDtos
  11145. for index, item := range config {
  11146. if index == 0 {
  11147. var fdd models.FsiDiagnoseDtos
  11148. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11149. fdd.InoutDiseType = "1"
  11150. fdd.MaindiseFlag = "1"
  11151. fdd.DiseDate = s_tm
  11152. fdd.DiasSrtNo = "1"
  11153. fdd.DiseName = item.CountryContentName
  11154. fdd.DiseCodg = item.CountryCode
  11155. fdds = append(fdds, &fdd)
  11156. } else {
  11157. var fdd models.FsiDiagnoseDtos
  11158. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11159. fdd.InoutDiseType = "1"
  11160. fdd.MaindiseFlag = "1"
  11161. fdd.DiseDate = s_tm
  11162. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11163. fdd.DiseName = item.CountryContentName
  11164. fdd.DiseCodg = item.CountryCode
  11165. fdds = append(fdds, &fdd)
  11166. }
  11167. }
  11168. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11169. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  11170. fed.AdmDeptName = de.Name
  11171. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  11172. fed.DscgDeptName = de.Name
  11173. fed.MedMdtrtType = "1"
  11174. fed.MedType = "11"
  11175. //if his.Insutype == "390" {
  11176. // fed.MedType = "1402"
  11177. //} else {
  11178. // fed.MedType = "9933"
  11179. //}
  11180. var orders []*models.FsiOrderDtos
  11181. if trig_scen == "2" {
  11182. //处方医嘱信息
  11183. for _, item := range prescriptions {
  11184. for _, subItem := range item.HisDoctorAdviceInfo {
  11185. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11186. var order models.FsiOrderDtos
  11187. order.RxID = strconv.FormatInt(item.ID, 10)
  11188. order.Rxno = strconv.FormatInt(item.ID, 10)
  11189. order.LongDrordFlag = "0"
  11190. order.HilistType = "1"
  11191. order.ChrgType = "1"
  11192. order.DrordBhvr = "-"
  11193. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11194. order.HosplistName = subItem.BaseDrugLib.DrugName
  11195. order.HilistLv = "1"
  11196. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11197. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11198. order.HosplistName = subItem.BaseDrugLib.DrugName
  11199. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11200. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11201. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11202. order.OwnpayAmt = ""
  11203. order.SelfpayAmt = ""
  11204. order.Spec = ""
  11205. order.SpecUnt = ""
  11206. order.DrordBegnDate = s_tm
  11207. order.DrordStopDate = ""
  11208. order.DrordDrCodg = doctor_info.DoctorNumber
  11209. order.DrordDeptName = department.Name
  11210. order.DrordDeptCodg = department.Number
  11211. order.DrordDrName = doctor_info.UserName
  11212. order.DrordDrProfttl = "234"
  11213. order.CurrDrordFlag = "1"
  11214. orders = append(orders, &order)
  11215. }
  11216. }
  11217. for _, subItem := range item.HisPrescriptionProject {
  11218. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11219. var order models.FsiOrderDtos
  11220. order.RxID = strconv.FormatInt(item.ID, 10)
  11221. order.Rxno = strconv.FormatInt(item.ID, 10)
  11222. order.LongDrordFlag = "0"
  11223. order.HilistType = "1"
  11224. order.ChrgType = "1"
  11225. order.DrordBhvr = "-"
  11226. order.HilistCode = subItem.HisProject.MedicalCode
  11227. order.HosplistName = subItem.HisProject.ProjectName
  11228. order.HilistLv = "1"
  11229. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11230. order.HosplistCode = subItem.HisProject.MedicalCode
  11231. order.HosplistName = subItem.HisProject.ProjectName
  11232. order.Cnt = subItem.Count
  11233. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11234. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11235. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11236. order.OwnpayAmt = ""
  11237. order.SelfpayAmt = ""
  11238. order.Spec = ""
  11239. order.SpecUnt = ""
  11240. order.DrordBegnDate = s_tm
  11241. order.DrordStopDate = ""
  11242. order.DrordDrCodg = doctor_info.DoctorNumber
  11243. order.DrordDeptName = department.Name
  11244. order.DrordDeptCodg = department.Number
  11245. order.DrordDrName = doctor_info.UserName
  11246. order.DrordDrProfttl = "234"
  11247. order.CurrDrordFlag = "1"
  11248. orders = append(orders, &order)
  11249. }
  11250. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11251. var order models.FsiOrderDtos
  11252. order.RxID = strconv.FormatInt(item.ID, 10)
  11253. order.Rxno = strconv.FormatInt(item.ID, 10)
  11254. order.LongDrordFlag = "0"
  11255. order.HilistType = "1"
  11256. order.ChrgType = "1"
  11257. order.DrordBhvr = "-"
  11258. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11259. order.HosplistName = subItem.GoodInfo.GoodName
  11260. order.HilistLv = "1"
  11261. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11262. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11263. order.HosplistName = subItem.GoodInfo.GoodName
  11264. order.Cnt = subItem.Count
  11265. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11266. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11267. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11268. order.OwnpayAmt = ""
  11269. order.SelfpayAmt = ""
  11270. order.Spec = ""
  11271. order.SpecUnt = ""
  11272. order.DrordBegnDate = s_tm
  11273. order.DrordStopDate = ""
  11274. order.DrordDrCodg = doctor_info.DoctorNumber
  11275. order.DrordDeptName = department.Name
  11276. order.DrordDeptCodg = department.Number
  11277. order.DrordDrName = doctor_info.UserName
  11278. order.DrordDrProfttl = "234"
  11279. order.CurrDrordFlag = "1"
  11280. orders = append(orders, &order)
  11281. }
  11282. }
  11283. }
  11284. //处方医嘱信息
  11285. }
  11286. fed.MatnStas = "0"
  11287. fed.MedfeeSumamt = "0"
  11288. fed.OwnpayAmt = "0"
  11289. fed.SelfpayAmt = "0"
  11290. fed.AcctPayamt = "0"
  11291. fed.MaAmt = "0"
  11292. fed.HifpPayamt = "0"
  11293. fed.SetlTotlnum = "1"
  11294. fed.Insutype = his.Insutype
  11295. fed.ReimFlag = "0"
  11296. fed.OutSetlFlag = "0"
  11297. var fopd []*models.FsiOperationDtosData
  11298. data := make(map[string]interface{})
  11299. data["fed"] = fed
  11300. data["fdd"] = fdds
  11301. data["fod"] = orders
  11302. data["pd"] = pd
  11303. data["pp"] = pp
  11304. data["fopd"] = fopd
  11305. data["trig_scen"] = trig_scen
  11306. fmt.Println(data)
  11307. fmt.Println(fed)
  11308. fmt.Println(fdds)
  11309. fmt.Println(orders)
  11310. fmt.Println(pd)
  11311. fmt.Println(pp)
  11312. fmt.Println(fopd)
  11313. client := &http.Client{}
  11314. bytesData, _ := json.Marshal(data)
  11315. var req *http.Request
  11316. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  11317. if miConfig.MdtrtareaAdmvs == "320830" {
  11318. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  11319. } else if miConfig.MdtrtareaAdmvs == "320921" {
  11320. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11321. } else {
  11322. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11323. }
  11324. resp, _ := client.Do(req)
  11325. defer resp.Body.Close()
  11326. body, ioErr := ioutil.ReadAll(resp.Body)
  11327. if ioErr != nil {
  11328. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11330. return res
  11331. }
  11332. var respJSON map[string]interface{}
  11333. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11334. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11336. return res
  11337. }
  11338. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11339. fmt.Println(respJSON)
  11340. result, _ := json.Marshal(respJSON)
  11341. fmt.Println(result)
  11342. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11343. utils.ErrorLog("解析失败:%v", err)
  11344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11345. return res
  11346. }
  11347. return res
  11348. } else {
  11349. //if miConfig.MdtrtareaAdmvs == "441202" {
  11350. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11351. saveLog(output, input, "3101", "事前")
  11352. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11353. utils.ErrorLog("解析失败:%v", err)
  11354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11355. return
  11356. }
  11357. return res
  11358. //}
  11359. }
  11360. }
  11361. 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) {
  11362. adminUser := c.GetAdminUserInfo()
  11363. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11364. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11365. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11366. //record_time := c.GetString("record_time")
  11367. //trig_scen := c.GetString("trig_scen")
  11368. timeLayout := "2006-01-02"
  11369. loc, _ := time.LoadLocation("Local")
  11370. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11371. if err != nil {
  11372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11373. return res
  11374. }
  11375. recordDateTime := theTime.Unix()
  11376. var patientPrescription models.HisPrescriptionInfo
  11377. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11378. if patientPrescription.ID == 0 {
  11379. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11380. }
  11381. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11382. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11383. //
  11384. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11385. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11386. var pp models.PublicParams
  11387. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11388. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11389. pp.FixmedinsName = miConfig.OrgName
  11390. pp.FixmedinsCode = miConfig.Code
  11391. pp.RequestUrl = miConfig.Url
  11392. pp.Cainfo = miConfig.Cainfo
  11393. pp.SecretKey = miConfig.SecretKey
  11394. pp.AccessKey = miConfig.AccessKey
  11395. pp.OpterName = roles.UserName
  11396. var config []*models.HisXtDiagnoseConfig
  11397. for _, item := range diagnosis_ids {
  11398. id, _ := strconv.ParseInt(item, 10, 64)
  11399. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11400. config = append(config, &diagnosisConfig)
  11401. }
  11402. var pd models.PatientDtos
  11403. pd.PatnID = his.PsnNo
  11404. pd.PatnName = his.Name
  11405. pd.Gend = his.Gend
  11406. pd.Brdy = his.Brdy
  11407. pd.Poolarea = his.InsuplcAdmdvs
  11408. pd.CurrMdtrtID = his.Number
  11409. var fed models.FsiEncounterDtos
  11410. fed.MdtrtID = his.Number
  11411. fed.MedinsID = miConfig.Code
  11412. fed.MedinsName = miConfig.OrgName
  11413. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11414. fed.MedMdtrtType = "1"
  11415. fed.MedinsType = "1"
  11416. fed.MedinsLv = "11"
  11417. tm := time.Unix(his.RecordDate, 0)
  11418. s_tm := tm.Format("2006-01-02 15:04:05")
  11419. fed.AdmDate = s_tm
  11420. fed.DscgDate = s_tm
  11421. fed.DscgMainDiseCodg = config[0].CountryCode
  11422. fed.DscgMainDiseName = config[0].CountryContentName
  11423. //诊断信息
  11424. var fdds []*models.FsiDiagnoseDtos
  11425. for index, item := range config {
  11426. if index == 0 {
  11427. var fdd models.FsiDiagnoseDtos
  11428. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11429. fdd.InoutDiseType = "1"
  11430. fdd.MaindiseFlag = "1"
  11431. fdd.DiseDate = s_tm
  11432. fdd.DiasSrtNo = "1"
  11433. fdd.DiseName = item.CountryContentName
  11434. fdd.DiseCodg = item.CountryCode
  11435. fdds = append(fdds, &fdd)
  11436. } else {
  11437. var fdd models.FsiDiagnoseDtos
  11438. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11439. fdd.InoutDiseType = "1"
  11440. fdd.MaindiseFlag = "1"
  11441. fdd.DiseDate = s_tm
  11442. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11443. fdd.DiseName = item.CountryContentName
  11444. fdd.DiseCodg = item.CountryCode
  11445. fdds = append(fdds, &fdd)
  11446. }
  11447. }
  11448. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11449. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11450. fed.AdmDeptName = department.Name
  11451. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11452. fed.DscgDeptName = department.Name
  11453. fed.MedMdtrtType = "1"
  11454. fed.MedType = "11"
  11455. //if his.Insutype == "390" {
  11456. // fed.MedType = "1402"
  11457. //} else {
  11458. // fed.MedType = "9933"
  11459. //}
  11460. var orders []*models.FsiOrderDtos
  11461. if trig_scen == "2" {
  11462. //处方医嘱信息
  11463. for _, item := range prescriptions {
  11464. for _, subItem := range item.HisDoctorAdviceInfo {
  11465. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11466. var order models.FsiOrderDtos
  11467. order.RxID = strconv.FormatInt(item.ID, 10)
  11468. order.Rxno = strconv.FormatInt(item.ID, 10)
  11469. order.LongDrordFlag = "0"
  11470. order.HilistType = "1"
  11471. order.ChrgType = "1"
  11472. order.DrordBhvr = "-"
  11473. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11474. order.HosplistName = subItem.BaseDrugLib.DrugName
  11475. order.HilistLv = "1"
  11476. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11477. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11478. order.HosplistName = subItem.BaseDrugLib.DrugName
  11479. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11480. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11481. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11482. order.OwnpayAmt = ""
  11483. order.SelfpayAmt = ""
  11484. order.Spec = ""
  11485. order.SpecUnt = ""
  11486. order.DrordBegnDate = s_tm
  11487. order.DrordStopDate = ""
  11488. order.DrordDrCodg = doctor_info.DoctorNumber
  11489. order.DrordDeptName = department.Name
  11490. order.DrordDeptCodg = department.Number
  11491. order.DrordDrName = doctor_info.UserName
  11492. order.DrordDrProfttl = "234"
  11493. order.CurrDrordFlag = "1"
  11494. orders = append(orders, &order)
  11495. }
  11496. }
  11497. for _, subItem := range item.HisPrescriptionProject {
  11498. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11499. var order models.FsiOrderDtos
  11500. order.RxID = strconv.FormatInt(item.ID, 10)
  11501. order.Rxno = strconv.FormatInt(item.ID, 10)
  11502. order.LongDrordFlag = "0"
  11503. order.HilistType = "1"
  11504. order.ChrgType = "1"
  11505. order.DrordBhvr = "-"
  11506. order.HilistCode = subItem.HisProject.MedicalCode
  11507. order.HosplistName = subItem.HisProject.ProjectName
  11508. order.HilistLv = "1"
  11509. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11510. order.HosplistCode = subItem.HisProject.MedicalCode
  11511. order.HosplistName = subItem.HisProject.ProjectName
  11512. order.Cnt = subItem.Count
  11513. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11514. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11515. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11516. order.OwnpayAmt = ""
  11517. order.SelfpayAmt = ""
  11518. order.Spec = ""
  11519. order.SpecUnt = ""
  11520. order.DrordBegnDate = s_tm
  11521. order.DrordStopDate = ""
  11522. order.DrordDrCodg = doctor_info.DoctorNumber
  11523. order.DrordDeptName = department.Name
  11524. order.DrordDeptCodg = department.Number
  11525. order.DrordDrName = doctor_info.UserName
  11526. order.DrordDrProfttl = "234"
  11527. order.CurrDrordFlag = "1"
  11528. orders = append(orders, &order)
  11529. }
  11530. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11531. var order models.FsiOrderDtos
  11532. order.RxID = strconv.FormatInt(item.ID, 10)
  11533. order.Rxno = strconv.FormatInt(item.ID, 10)
  11534. order.LongDrordFlag = "0"
  11535. order.HilistType = "1"
  11536. order.ChrgType = "1"
  11537. order.DrordBhvr = "-"
  11538. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11539. order.HosplistName = subItem.GoodInfo.GoodName
  11540. order.HilistLv = "1"
  11541. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11542. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11543. order.HosplistName = subItem.GoodInfo.GoodName
  11544. order.Cnt = subItem.Count
  11545. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11546. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11547. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11548. order.OwnpayAmt = ""
  11549. order.SelfpayAmt = ""
  11550. order.Spec = ""
  11551. order.SpecUnt = ""
  11552. order.DrordBegnDate = s_tm
  11553. order.DrordStopDate = ""
  11554. order.DrordDrCodg = doctor_info.DoctorNumber
  11555. order.DrordDeptName = department.Name
  11556. order.DrordDeptCodg = department.Number
  11557. order.DrordDrName = doctor_info.UserName
  11558. order.DrordDrProfttl = "234"
  11559. order.CurrDrordFlag = "1"
  11560. orders = append(orders, &order)
  11561. }
  11562. }
  11563. }
  11564. //处方医嘱信息
  11565. }
  11566. fed.MatnStas = "0"
  11567. fed.MedfeeSumamt = "0"
  11568. fed.OwnpayAmt = "0"
  11569. fed.SelfpayAmt = "0"
  11570. fed.AcctPayamt = "0"
  11571. fed.MaAmt = "0"
  11572. fed.HifpPayamt = "0"
  11573. fed.SetlTotlnum = "1"
  11574. fed.Insutype = his.Insutype
  11575. fed.ReimFlag = "0"
  11576. fed.OutSetlFlag = "0"
  11577. var fopd []*models.FsiOperationDtosData
  11578. data := make(map[string]interface{})
  11579. data["fed"] = fed
  11580. data["fdd"] = fdds
  11581. data["fod"] = orders
  11582. data["pd"] = pd
  11583. data["pp"] = pp
  11584. data["fopd"] = fopd
  11585. data["trig_scen"] = trig_scen
  11586. fmt.Println(data)
  11587. fmt.Println(fed)
  11588. fmt.Println(fdds)
  11589. fmt.Println(orders)
  11590. fmt.Println(pd)
  11591. fmt.Println(pp)
  11592. fmt.Println(fopd)
  11593. client := &http.Client{}
  11594. bytesData, _ := json.Marshal(data)
  11595. var req *http.Request
  11596. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  11597. if miConfig.MdtrtareaAdmvs == "320830" {
  11598. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  11599. } else if miConfig.MdtrtareaAdmvs == "320921" {
  11600. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11601. } else {
  11602. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11603. }
  11604. resp, _ := client.Do(req)
  11605. defer resp.Body.Close()
  11606. body, ioErr := ioutil.ReadAll(resp.Body)
  11607. if ioErr != nil {
  11608. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11610. return res
  11611. }
  11612. var respJSON map[string]interface{}
  11613. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11614. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11616. return res
  11617. }
  11618. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11619. fmt.Println(respJSON)
  11620. result, _ := json.Marshal(respJSON)
  11621. fmt.Println(result)
  11622. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11623. utils.ErrorLog("解析失败:%v", err)
  11624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11625. return res
  11626. }
  11627. return res
  11628. } else {
  11629. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11630. saveLog(output, input, "3101", "事前")
  11631. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11632. utils.ErrorLog("解析失败:%v", err)
  11633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11634. return
  11635. }
  11636. return res
  11637. }
  11638. return res
  11639. }
  11640. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  11641. ////patient_id, _ := c.GetInt64("patient_id")
  11642. //order_id, _ := c.GetInt64("order_id")
  11643. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  11644. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  11645. //trig_scen := c.GetString("trig_scen")
  11646. adminUser := c.GetAdminUserInfo()
  11647. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11648. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11649. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11650. record_time := c.GetString("record_time")
  11651. order, _ := service.GetHisOrderByID(order_id)
  11652. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11653. timeLayout := "2006-01-02"
  11654. loc, _ := time.LoadLocation("Local")
  11655. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11656. if err != nil {
  11657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11658. return
  11659. }
  11660. recordDateTime := theTime.Unix()
  11661. var patientPrescription models.HisPrescriptionInfo
  11662. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11663. if patientPrescription.ID == 0 {
  11664. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11665. }
  11666. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11667. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11668. //
  11669. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11670. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11671. var pp models.PublicParams
  11672. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11673. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11674. pp.FixmedinsName = miConfig.OrgName
  11675. pp.FixmedinsCode = miConfig.Code
  11676. pp.RequestUrl = miConfig.Url
  11677. pp.Cainfo = miConfig.Cainfo
  11678. pp.SecretKey = miConfig.SecretKey
  11679. pp.AccessKey = miConfig.AccessKey
  11680. pp.OpterName = roles.UserName
  11681. var config []*models.HisXtDiagnoseConfig
  11682. for _, item := range diagnosis_ids {
  11683. id, _ := strconv.ParseInt(item, 10, 64)
  11684. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11685. config = append(config, &diagnosisConfig)
  11686. }
  11687. var pd models.PatientDtos
  11688. pd.PatnID = his.PsnNo
  11689. pd.PatnName = his.Name
  11690. pd.Gend = his.Gend
  11691. pd.Brdy = psn_info.Brdy
  11692. pd.Poolarea = his.InsuplcAdmdvs
  11693. pd.CurrMdtrtID = his.Number
  11694. var fed models.FsiEncounterDtos
  11695. fed.MdtrtID = his.Number
  11696. fed.MedinsID = miConfig.Code
  11697. fed.MedinsName = miConfig.OrgName
  11698. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11699. fed.MedMdtrtType = "1"
  11700. fed.MedinsType = "1"
  11701. fed.MedinsLv = "11"
  11702. tm := time.Unix(his.RecordDate, 0)
  11703. s_tm := tm.Format("2006-01-02 15:04:05")
  11704. fed.AdmDate = s_tm
  11705. fed.DscgDate = s_tm
  11706. fed.DscgMainDiseCodg = config[0].CountryCode
  11707. fed.DscgMainDiseName = config[0].CountryContentName
  11708. //诊断信息
  11709. var fdds []*models.FsiDiagnoseDtos
  11710. for index, item := range config {
  11711. if index == 0 {
  11712. var fdd models.FsiDiagnoseDtos
  11713. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11714. fdd.InoutDiseType = "1"
  11715. fdd.MaindiseFlag = "1"
  11716. fdd.DiseDate = s_tm
  11717. fdd.DiasSrtNo = "1"
  11718. fdd.DiseName = item.CountryContentName
  11719. fdd.DiseCodg = item.CountryCode
  11720. fdds = append(fdds, &fdd)
  11721. } else {
  11722. var fdd models.FsiDiagnoseDtos
  11723. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11724. fdd.InoutDiseType = "1"
  11725. fdd.MaindiseFlag = "1"
  11726. fdd.DiseDate = s_tm
  11727. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11728. fdd.DiseName = item.CountryContentName
  11729. fdd.DiseCodg = item.CountryCode
  11730. fdds = append(fdds, &fdd)
  11731. }
  11732. }
  11733. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11734. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11735. fed.AdmDeptName = department.Name
  11736. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11737. fed.DscgDeptName = department.Name
  11738. fed.MedType = order.MedType
  11739. //处方医嘱信息
  11740. var orders []*models.FsiOrderDtos
  11741. //for _, item := range prescriptions {
  11742. // for _, subItem := range item.HisDoctorAdviceInfo {
  11743. // var order models.FsiOrderDtos
  11744. // order.RxID = strconv.FormatInt(item.ID, 10)
  11745. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11746. // order.LongDrordFlag = "0"
  11747. // order.HilistType = "1"
  11748. // order.ChrgType = "1"
  11749. // order.DrordBhvr = "-"
  11750. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11751. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11752. // order.HilistLv = "1"
  11753. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11754. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11755. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11756. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11757. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11758. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11759. // order.OwnpayAmt = ""
  11760. // order.SelfpayAmt = ""
  11761. // order.Spec = ""
  11762. // order.SpecUnt = ""
  11763. // order.DrordBegnDate = s_tm
  11764. // order.DrordStopDate = ""
  11765. // order.DrordDrCodg = "1"
  11766. // order.DrordDeptName = department.Name
  11767. // order.DrordDrCodg = "1"
  11768. // order.DrordDrName = doctor_info.UserName
  11769. // order.DrordDrProfttl = ""
  11770. // order.CurrDrordFlag = "1"
  11771. // orders = append(orders, &order)
  11772. // }
  11773. // for _, subItem := range item.HisPrescriptionProject {
  11774. // if subItem.Type == 2 {
  11775. // var order models.FsiOrderDtos
  11776. // order.RxID = strconv.FormatInt(item.ID, 10)
  11777. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11778. // order.LongDrordFlag = "0"
  11779. // order.HilistType = "1"
  11780. // order.ChrgType = "1"
  11781. // order.DrordBhvr = "-"
  11782. // order.HilistCode = subItem.HisProject.MedicalCode
  11783. // order.HosplistName = subItem.HisProject.ProjectName
  11784. // order.HilistLv = "1"
  11785. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11786. // order.HosplistCode = subItem.HisProject.MedicalCode
  11787. // order.HosplistName = subItem.HisProject.ProjectName
  11788. // order.Cnt = subItem.Count
  11789. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11790. //
  11791. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11792. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11793. // order.OwnpayAmt = ""
  11794. // order.SelfpayAmt = ""
  11795. // order.Spec = ""
  11796. // order.SpecUnt = ""
  11797. // order.DrordBegnDate = s_tm
  11798. // order.DrordStopDate = ""
  11799. // order.DrordDrCodg = "1"
  11800. // order.DrordDeptName = department.Name
  11801. // order.DrordDrCodg = "1"
  11802. // order.DrordDrName = doctor_info.UserName
  11803. // order.DrordDrProfttl = ""
  11804. // order.CurrDrordFlag = "1"
  11805. // orders = append(orders, &order)
  11806. //
  11807. // }
  11808. // if subItem.Type == 3 {
  11809. //
  11810. // var order models.FsiOrderDtos
  11811. // order.RxID = strconv.FormatInt(item.ID, 10)
  11812. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11813. // order.LongDrordFlag = "0"
  11814. // order.HilistType = "1"
  11815. // order.ChrgType = "1"
  11816. // order.DrordBhvr = "-"
  11817. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11818. // order.HosplistName = subItem.GoodInfo.GoodName
  11819. // order.HilistLv = "1"
  11820. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11821. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11822. // order.HosplistName = subItem.GoodInfo.GoodName
  11823. // order.Cnt = subItem.Count
  11824. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11825. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11826. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11827. // order.OwnpayAmt = ""
  11828. // order.SelfpayAmt = ""
  11829. // order.Spec = ""
  11830. // order.SpecUnt = ""
  11831. // order.DrordBegnDate = s_tm
  11832. // order.DrordStopDate = ""
  11833. // order.DrordDrCodg = "1"
  11834. // order.DrordDeptName = department.Name
  11835. // order.DrordDrCodg = "1"
  11836. // order.DrordDrName = doctor_info.UserName
  11837. // order.DrordDrProfttl = ""
  11838. // order.CurrDrordFlag = "1"
  11839. // orders = append(orders, &order)
  11840. //
  11841. // }
  11842. // }
  11843. //}
  11844. for _, item := range prescriptions {
  11845. for _, subItem := range item.HisDoctorAdviceInfo {
  11846. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11847. var order models.FsiOrderDtos
  11848. order.RxID = strconv.FormatInt(item.ID, 10)
  11849. order.Rxno = strconv.FormatInt(item.ID, 10)
  11850. order.LongDrordFlag = "0"
  11851. order.HilistType = "101"
  11852. order.ChrgType = "1"
  11853. order.DrordBhvr = "-"
  11854. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11855. order.HosplistName = subItem.BaseDrugLib.DrugName
  11856. order.HilistLv = "1"
  11857. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11858. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11859. order.HosplistName = subItem.BaseDrugLib.DrugName
  11860. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11861. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11862. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11863. order.OwnpayAmt = ""
  11864. order.SelfpayAmt = ""
  11865. order.Spec = ""
  11866. order.SpecUnt = ""
  11867. order.DrordBegnDate = s_tm
  11868. order.DrordStopDate = ""
  11869. order.DrordDrCodg = doctor_info.DoctorNumber
  11870. order.DrordDeptName = department.Name
  11871. order.DrordDeptCodg = department.Number
  11872. order.DrordDrName = doctor_info.UserName
  11873. order.DrordDrProfttl = "234"
  11874. order.CurrDrordFlag = "1"
  11875. orders = append(orders, &order)
  11876. }
  11877. }
  11878. for _, subItem := range item.HisPrescriptionProject {
  11879. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11880. var order models.FsiOrderDtos
  11881. order.RxID = strconv.FormatInt(item.ID, 10)
  11882. order.Rxno = strconv.FormatInt(item.ID, 10)
  11883. order.LongDrordFlag = "0"
  11884. order.HilistType = "201"
  11885. order.ChrgType = "1"
  11886. order.DrordBhvr = "-"
  11887. order.HilistCode = subItem.HisProject.MedicalCode
  11888. order.HosplistName = subItem.HisProject.ProjectName
  11889. order.HilistLv = "1"
  11890. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11891. order.HosplistCode = subItem.HisProject.MedicalCode
  11892. order.HosplistName = subItem.HisProject.ProjectName
  11893. order.Cnt = subItem.Count
  11894. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11895. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11896. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11897. order.OwnpayAmt = ""
  11898. order.SelfpayAmt = ""
  11899. order.Spec = ""
  11900. order.SpecUnt = ""
  11901. order.DrordBegnDate = s_tm
  11902. order.DrordStopDate = ""
  11903. order.DrordDrCodg = doctor_info.DoctorNumber
  11904. order.DrordDeptName = department.Name
  11905. order.DrordDeptCodg = department.Number
  11906. order.DrordDrName = doctor_info.UserName
  11907. order.DrordDrProfttl = "234"
  11908. order.CurrDrordFlag = "1"
  11909. orders = append(orders, &order)
  11910. }
  11911. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11912. var order models.FsiOrderDtos
  11913. order.RxID = strconv.FormatInt(item.ID, 10)
  11914. order.Rxno = strconv.FormatInt(item.ID, 10)
  11915. order.LongDrordFlag = "0"
  11916. order.HilistType = "301"
  11917. order.ChrgType = "1"
  11918. order.DrordBhvr = "0"
  11919. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11920. order.HosplistName = subItem.GoodInfo.GoodName
  11921. order.HilistLv = "1"
  11922. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11923. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11924. order.HosplistName = subItem.GoodInfo.GoodName
  11925. order.Cnt = subItem.Count
  11926. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11927. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11928. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11929. order.OwnpayAmt = ""
  11930. order.SelfpayAmt = ""
  11931. order.Spec = ""
  11932. order.SpecUnt = ""
  11933. order.DrordBegnDate = s_tm
  11934. order.DrordStopDate = ""
  11935. order.DrordDrCodg = doctor_info.DoctorNumber
  11936. order.DrordDeptName = department.Name
  11937. order.DrordDeptCodg = department.Number
  11938. order.DrordDrName = doctor_info.UserName
  11939. order.DrordDrProfttl = "234"
  11940. order.CurrDrordFlag = "1"
  11941. orders = append(orders, &order)
  11942. }
  11943. }
  11944. }
  11945. //处方医嘱信息
  11946. fed.MatnStas = "0"
  11947. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11948. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11949. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11950. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11951. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11952. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11953. fed.SetlTotlnum = "1"
  11954. fed.Insutype = his.Insutype
  11955. fed.ReimFlag = "0"
  11956. fed.OutSetlFlag = "0"
  11957. var fopd []*models.FsiOperationDtosData
  11958. data := make(map[string]interface{})
  11959. data["fed"] = fed
  11960. data["fdd"] = fdds
  11961. data["fod"] = orders
  11962. data["pd"] = pd
  11963. data["pp"] = pp
  11964. data["fopd"] = fopd
  11965. data["trig_scen"] = trig_scen
  11966. client := &http.Client{}
  11967. bytesData, _ := json.Marshal(data)
  11968. var req *http.Request
  11969. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  11970. if miConfig.MdtrtareaAdmvs == "320830" {
  11971. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3102", bytes.NewReader(bytesData))
  11972. } else if miConfig.MdtrtareaAdmvs == "320921" {
  11973. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11974. } else {
  11975. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11976. }
  11977. resp, _ := client.Do(req)
  11978. defer resp.Body.Close()
  11979. body, ioErr := ioutil.ReadAll(resp.Body)
  11980. if ioErr != nil {
  11981. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11983. return res
  11984. }
  11985. var respJSON map[string]interface{}
  11986. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11987. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11989. return res
  11990. }
  11991. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11992. result, _ := json.Marshal(respJSON)
  11993. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11994. utils.ErrorLog("解析失败:%v", err)
  11995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11996. return res
  11997. }
  11998. return res
  11999. } else {
  12000. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12001. saveLog(output, input, "3102", "事中")
  12002. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12003. utils.ErrorLog("解析失败:%v", err)
  12004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12005. return
  12006. }
  12007. return res
  12008. }
  12009. return res
  12010. }
  12011. 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) {
  12012. var res Resultgd3101
  12013. adminUser := c.GetAdminUserInfo()
  12014. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12015. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12016. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12017. //record_time := c.GetString("record_time")
  12018. //trig_scen := c.GetString("trig_scen")
  12019. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  12020. //psn_info, _ := service.GetPatientId(patient_id)
  12021. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  12022. timeLayout := "2006-01-02"
  12023. loc, _ := time.LoadLocation("Local")
  12024. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12025. if err != nil {
  12026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12027. return res
  12028. }
  12029. recordDateTime := theTime.Unix()
  12030. var patientPrescription models.HisPrescriptionInfo
  12031. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12032. //if patientPrescription.ID == 0 {
  12033. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12034. //}
  12035. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12036. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12037. //
  12038. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  12039. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12040. var str string
  12041. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  12042. str = timestampToBirthdayString(patient.Birthday)
  12043. } else {
  12044. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  12045. }
  12046. var pp models.PublicParams
  12047. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12048. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12049. pp.FixmedinsName = miConfig.OrgName
  12050. pp.FixmedinsCode = miConfig.Code
  12051. pp.RequestUrl = miConfig.Url
  12052. pp.Cainfo = miConfig.Cainfo
  12053. pp.SecretKey = miConfig.SecretKey
  12054. pp.AccessKey = miConfig.AccessKey
  12055. pp.OpterName = roles.UserName
  12056. var config []*models.HisXtDiagnoseConfig
  12057. for _, item := range diagnosis_ids {
  12058. id, _ := strconv.ParseInt(item, 10, 64)
  12059. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12060. config = append(config, &diagnosisConfig)
  12061. }
  12062. if len(config) == 0{
  12063. var config1 models.HisXtDiagnoseConfig
  12064. config1.CountryCode = "N18.500"
  12065. config1.CountryContentName = "慢性肾脏病5期"
  12066. config = append(config, &config1)
  12067. }
  12068. var pd models.PatientDtos
  12069. pd.PatnID = his.PsnNo
  12070. pd.PatnName = his.Name
  12071. pd.Gend = his.Gend
  12072. pd.Brdy = str
  12073. pd.Poolarea = miConfig.MdtrtareaAdmvs
  12074. pd.CurrMdtrtID = his.Number
  12075. var fed models.FsiEncounterDtos
  12076. fed.MdtrtID = his.Number
  12077. fed.MedinsID = miConfig.Code
  12078. fed.MedinsName = miConfig.OrgName
  12079. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12080. fed.MedMdtrtType = "1"
  12081. fed.MedinsType = "1"
  12082. fed.MedinsLv = "11"
  12083. tm := time.Unix(his.RecordDate, 0)
  12084. s_tm := tm.Format("2006-01-02 15:04:05")
  12085. fed.AdmDate = s_tm
  12086. fed.DscgDate = s_tm
  12087. fed.DscgMainDiseCodg = config[0].CountryCode
  12088. fed.DscgMainDiseName = config[0].CountryContentName
  12089. //诊断信息
  12090. var fdds []*models.FsiDiagnoseDtos
  12091. for index, item := range config {
  12092. if index == 0 {
  12093. var fdd models.FsiDiagnoseDtos
  12094. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12095. fdd.InoutDiseType = "1"
  12096. fdd.MaindiseFlag = "1"
  12097. fdd.DiseDate = s_tm
  12098. fdd.DiasSrtNo = "1"
  12099. fdd.DiseName = item.CountryContentName
  12100. fdd.DiseCodg = item.CountryCode
  12101. fdds = append(fdds, &fdd)
  12102. } else {
  12103. var fdd models.FsiDiagnoseDtos
  12104. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12105. fdd.InoutDiseType = "1"
  12106. fdd.MaindiseFlag = "1"
  12107. fdd.DiseDate = s_tm
  12108. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12109. fdd.DiseName = item.CountryContentName
  12110. fdd.DiseCodg = item.CountryCode
  12111. fdds = append(fdds, &fdd)
  12112. }
  12113. }
  12114. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12115. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  12116. fed.AdmDeptName = de.Name
  12117. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  12118. fed.DscgDeptName = de.Name
  12119. fed.MedMdtrtType = "1"
  12120. fed.MedType = "11"
  12121. //if his.Insutype == "390" {
  12122. // fed.MedType = "1402"
  12123. //} else {
  12124. // fed.MedType = "9933"
  12125. //}
  12126. var orders []*models.FsiOrderDtos
  12127. if trig_scen == "2" {
  12128. //处方医嘱信息
  12129. for _, item := range prescriptions {
  12130. for _, subItem := range item.HisDoctorAdviceInfo {
  12131. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12132. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12133. var order models.FsiOrderDtos
  12134. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12135. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12136. order.LongDrordFlag = "0"
  12137. order.HilistType = "101"
  12138. order.ChrgType = "1"
  12139. order.DrordBhvr = "0"
  12140. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12141. order.HosplistName = subItem.BaseDrugLib.DrugName
  12142. order.HilistLv = "1"
  12143. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12144. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12145. order.HosplistName = subItem.BaseDrugLib.DrugName
  12146. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12147. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12148. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12149. order.OwnpayAmt = ""
  12150. order.SelfpayAmt = ""
  12151. order.Spec = spec
  12152. order.SpecUnt = subItem.PrescribingNumberUnit
  12153. order.DrordBegnDate = s_tm
  12154. order.DrordStopDate = ""
  12155. order.DrordDrCodg = doctor_info.DoctorNumber
  12156. order.DrordDeptName = department.Name
  12157. order.DrordDeptCodg = department.Number
  12158. order.DrordDrName = doctor_info.UserName
  12159. order.DrordDrProfttl = "234"
  12160. order.CurrDrordFlag = "1"
  12161. orders = append(orders, &order)
  12162. }
  12163. }
  12164. for _, subItem := range item.HisPrescriptionProject {
  12165. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12166. var order models.FsiOrderDtos
  12167. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12168. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12169. order.LongDrordFlag = "0"
  12170. order.HilistType = "201"
  12171. order.ChrgType = "1"
  12172. order.DrordBhvr = "0"
  12173. order.HilistCode = subItem.HisProject.MedicalCode
  12174. order.HosplistName = subItem.HisProject.ProjectName
  12175. order.HilistLv = "1"
  12176. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12177. order.HosplistCode = subItem.HisProject.MedicalCode
  12178. order.HosplistName = subItem.HisProject.ProjectName
  12179. order.Cnt = subItem.Count
  12180. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12181. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12182. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12183. order.OwnpayAmt = ""
  12184. order.SelfpayAmt = ""
  12185. if subItem.Unit == ""{
  12186. order.Spec = "次"
  12187. order.SpecUnt = "次"
  12188. }else{
  12189. order.Spec = subItem.Unit
  12190. order.SpecUnt = subItem.Unit
  12191. }
  12192. order.DrordBegnDate = s_tm
  12193. order.DrordStopDate = ""
  12194. order.DrordDrCodg = doctor_info.DoctorNumber
  12195. order.DrordDeptName = department.Name
  12196. order.DrordDeptCodg = department.Number
  12197. order.DrordDrName = doctor_info.UserName
  12198. order.DrordDrProfttl = "234"
  12199. order.CurrDrordFlag = "1"
  12200. orders = append(orders, &order)
  12201. }
  12202. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12203. var order models.FsiOrderDtos
  12204. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12205. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12206. order.LongDrordFlag = "0"
  12207. order.HilistType = "301"
  12208. order.ChrgType = "1"
  12209. order.DrordBhvr = "0"
  12210. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12211. order.HosplistName = subItem.GoodInfo.GoodName
  12212. order.HilistLv = "1"
  12213. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12214. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12215. order.HosplistName = subItem.GoodInfo.GoodName
  12216. order.Cnt = subItem.Count
  12217. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12218. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12219. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12220. order.OwnpayAmt = ""
  12221. order.SelfpayAmt = ""
  12222. order.Spec = subItem.GoodInfo.SpecificationName
  12223. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12224. order.DrordBegnDate = s_tm
  12225. order.DrordStopDate = ""
  12226. order.DrordDrCodg = doctor_info.DoctorNumber
  12227. order.DrordDeptName = department.Name
  12228. order.DrordDeptCodg = department.Number
  12229. order.DrordDrName = doctor_info.UserName
  12230. order.DrordDrProfttl = "234"
  12231. order.CurrDrordFlag = "1"
  12232. orders = append(orders, &order)
  12233. }
  12234. }
  12235. }
  12236. //处方医嘱信息
  12237. }
  12238. fed.MatnStas = "0"
  12239. fed.MedfeeSumamt = "0"
  12240. fed.OwnpayAmt = "0"
  12241. fed.SelfpayAmt = "0"
  12242. fed.AcctPayamt = "0"
  12243. fed.MaAmt = "0"
  12244. fed.HifpPayamt = "0"
  12245. fed.SetlTotlnum = "1"
  12246. fed.Insutype = his.Insutype
  12247. fed.ReimFlag = "0"
  12248. fed.OutSetlFlag = "0"
  12249. var fopd []*models.FsiOperationDtosData
  12250. data := make(map[string]interface{})
  12251. data["fed"] = fed
  12252. data["fdd"] = fdds
  12253. data["fod"] = orders
  12254. data["pd"] = pd
  12255. data["pp"] = pp
  12256. data["fopd"] = fopd
  12257. data["trig_scen"] = trig_scen
  12258. fmt.Println(data)
  12259. fmt.Println(fed)
  12260. fmt.Println(fdds)
  12261. fmt.Println(orders)
  12262. fmt.Println(pd)
  12263. fmt.Println(pp)
  12264. fmt.Println(fopd)
  12265. client := &http.Client{}
  12266. bytesData, _ := json.Marshal(data)
  12267. var req *http.Request
  12268. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12269. if miConfig.MdtrtareaAdmvs == "320830" {
  12270. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  12271. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12272. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12273. } else {
  12274. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12275. }
  12276. resp, _ := client.Do(req)
  12277. defer resp.Body.Close()
  12278. body, ioErr := ioutil.ReadAll(resp.Body)
  12279. if ioErr != nil {
  12280. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12282. return res
  12283. }
  12284. var respJSON map[string]interface{}
  12285. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12286. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12288. return res
  12289. }
  12290. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12291. fmt.Println(respJSON)
  12292. result, _ := json.Marshal(respJSON)
  12293. fmt.Println(result)
  12294. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12295. utils.ErrorLog("解析失败:%v", err)
  12296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12297. return res
  12298. }
  12299. return res
  12300. } else {
  12301. //if miConfig.MdtrtareaAdmvs == "441202" {
  12302. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12303. saveLog(output, input, "3101", "事前")
  12304. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12305. utils.ErrorLog("解析失败:%v", err)
  12306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12307. return
  12308. }
  12309. return res
  12310. //}
  12311. }
  12312. }
  12313. 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) {
  12314. adminUser := c.GetAdminUserInfo()
  12315. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12316. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12317. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12318. //record_time := c.GetString("record_time")
  12319. //trig_scen := c.GetString("trig_scen")
  12320. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  12321. timeLayout := "2006-01-02"
  12322. loc, _ := time.LoadLocation("Local")
  12323. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12324. if err != nil {
  12325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12326. return res
  12327. }
  12328. recordDateTime := theTime.Unix()
  12329. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  12330. var patientPrescription models.HisPrescriptionInfo
  12331. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12332. if patientPrescription.ID == 0 {
  12333. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12334. }
  12335. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12336. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12337. //
  12338. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  12339. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12340. var pp models.PublicParams
  12341. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12342. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12343. pp.FixmedinsName = miConfig.OrgName
  12344. pp.FixmedinsCode = miConfig.Code
  12345. pp.RequestUrl = miConfig.Url
  12346. pp.Cainfo = miConfig.Cainfo
  12347. pp.SecretKey = miConfig.SecretKey
  12348. pp.AccessKey = miConfig.AccessKey
  12349. pp.OpterName = roles.UserName
  12350. var config []*models.HisXtDiagnoseConfig
  12351. for _, item := range diagnosis_ids {
  12352. id, _ := strconv.ParseInt(item, 10, 64)
  12353. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12354. config = append(config, &diagnosisConfig)
  12355. }
  12356. //str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  12357. var str string
  12358. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  12359. str = timestampToBirthdayString(patient.Birthday)
  12360. } else {
  12361. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  12362. }
  12363. var pd models.PatientDtos
  12364. pd.PatnID = his.PsnNo
  12365. pd.PatnName = his.Name
  12366. pd.Gend = his.Gend
  12367. pd.Brdy = str
  12368. pd.Poolarea = his.InsuplcAdmdvs
  12369. pd.CurrMdtrtID = his.Number
  12370. var fed models.FsiEncounterDtos
  12371. fed.MdtrtID = his.Number
  12372. fed.MedinsID = miConfig.Code
  12373. fed.MedinsName = miConfig.OrgName
  12374. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12375. fed.MedMdtrtType = "1"
  12376. fed.MedinsType = "1"
  12377. fed.MedinsLv = "11"
  12378. tm := time.Unix(his.RecordDate, 0)
  12379. s_tm := tm.Format("2006-01-02 15:04:05")
  12380. fed.AdmDate = s_tm
  12381. fed.DscgDate = s_tm
  12382. fed.DscgMainDiseCodg = config[0].CountryCode
  12383. fed.DscgMainDiseName = config[0].CountryContentName
  12384. //诊断信息
  12385. var fdds []*models.FsiDiagnoseDtos
  12386. for index, item := range config {
  12387. if index == 0 {
  12388. var fdd models.FsiDiagnoseDtos
  12389. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12390. fdd.InoutDiseType = "1"
  12391. fdd.MaindiseFlag = "1"
  12392. fdd.DiseDate = s_tm
  12393. fdd.DiasSrtNo = "1"
  12394. fdd.DiseName = item.CountryContentName
  12395. fdd.DiseCodg = item.CountryCode
  12396. fdds = append(fdds, &fdd)
  12397. } else {
  12398. var fdd models.FsiDiagnoseDtos
  12399. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12400. fdd.InoutDiseType = "1"
  12401. fdd.MaindiseFlag = "1"
  12402. fdd.DiseDate = s_tm
  12403. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12404. fdd.DiseName = item.CountryContentName
  12405. fdd.DiseCodg = item.CountryCode
  12406. fdds = append(fdds, &fdd)
  12407. }
  12408. }
  12409. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12410. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  12411. fed.AdmDeptName = department.Name
  12412. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  12413. fed.DscgDeptName = department.Name
  12414. fed.MedMdtrtType = "1"
  12415. fed.MedType = "11"
  12416. //if his.Insutype == "390" {
  12417. // fed.MedType = "1402"
  12418. //} else {
  12419. // fed.MedType = "9933"
  12420. //}
  12421. var orders []*models.FsiOrderDtos
  12422. if trig_scen == "2" {
  12423. //处方医嘱信息
  12424. for _, item := range prescriptions {
  12425. for _, subItem := range item.HisDoctorAdviceInfo {
  12426. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12427. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "/" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit
  12428. var order models.FsiOrderDtos
  12429. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12430. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12431. order.LongDrordFlag = "0"
  12432. order.HilistType = "101"
  12433. order.ChrgType = "1"
  12434. order.DrordBhvr = "0"
  12435. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12436. order.HosplistName = subItem.BaseDrugLib.DrugName
  12437. order.HilistLv = "1"
  12438. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12439. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12440. order.HosplistName = subItem.BaseDrugLib.DrugName
  12441. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12442. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12443. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12444. order.OwnpayAmt = ""
  12445. order.SelfpayAmt = ""
  12446. order.Spec = spec
  12447. order.SpecUnt = subItem.PrescribingNumberUnit
  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. for _, subItem := range item.HisPrescriptionProject {
  12460. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12461. var order models.FsiOrderDtos
  12462. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12463. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12464. order.LongDrordFlag = "0"
  12465. order.HilistType = "201"
  12466. order.ChrgType = "1"
  12467. order.DrordBhvr = "0"
  12468. order.HilistCode = subItem.HisProject.MedicalCode
  12469. order.HosplistName = subItem.HisProject.ProjectName
  12470. order.HilistLv = "1"
  12471. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12472. order.HosplistCode = subItem.HisProject.MedicalCode
  12473. order.HosplistName = subItem.HisProject.ProjectName
  12474. order.Cnt = subItem.Count
  12475. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12476. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12477. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12478. order.OwnpayAmt = ""
  12479. order.SelfpayAmt = ""
  12480. if subItem.Unit == ""{
  12481. order.Spec = "次"
  12482. order.SpecUnt = "次"
  12483. }else{
  12484. order.Spec = subItem.Unit
  12485. order.SpecUnt = subItem.Unit
  12486. }
  12487. order.DrordBegnDate = s_tm
  12488. order.DrordStopDate = ""
  12489. order.DrordDrCodg = doctor_info.DoctorNumber
  12490. order.DrordDeptName = department.Name
  12491. order.DrordDeptCodg = department.Number
  12492. order.DrordDrName = doctor_info.UserName
  12493. order.DrordDrProfttl = "234"
  12494. order.CurrDrordFlag = "1"
  12495. orders = append(orders, &order)
  12496. }
  12497. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12498. var order models.FsiOrderDtos
  12499. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12500. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12501. order.LongDrordFlag = "0"
  12502. order.HilistType = "301"
  12503. order.ChrgType = "1"
  12504. order.DrordBhvr = "0"
  12505. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12506. order.HosplistName = subItem.GoodInfo.GoodName
  12507. order.HilistLv = "1"
  12508. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12509. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12510. order.HosplistName = subItem.GoodInfo.GoodName
  12511. order.Cnt = subItem.Count
  12512. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12513. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12514. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12515. order.OwnpayAmt = ""
  12516. order.SelfpayAmt = ""
  12517. order.Spec = subItem.GoodInfo.SpecificationName
  12518. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12519. order.DrordBegnDate = s_tm
  12520. order.DrordStopDate = ""
  12521. order.DrordDrCodg = doctor_info.DoctorNumber
  12522. order.DrordDeptName = department.Name
  12523. order.DrordDeptCodg = department.Number
  12524. order.DrordDrName = doctor_info.UserName
  12525. order.DrordDrProfttl = "234"
  12526. order.CurrDrordFlag = "1"
  12527. orders = append(orders, &order)
  12528. }
  12529. }
  12530. }
  12531. //处方医嘱信息
  12532. }
  12533. fed.MatnStas = "0"
  12534. fed.MedfeeSumamt = "0"
  12535. fed.OwnpayAmt = "0"
  12536. fed.SelfpayAmt = "0"
  12537. fed.AcctPayamt = "0"
  12538. fed.MaAmt = "0"
  12539. fed.HifpPayamt = "0"
  12540. fed.SetlTotlnum = "1"
  12541. fed.Insutype = his.Insutype
  12542. fed.ReimFlag = "0"
  12543. fed.OutSetlFlag = "0"
  12544. var fopd []*models.FsiOperationDtosData
  12545. data := make(map[string]interface{})
  12546. data["fed"] = fed
  12547. data["fdd"] = fdds
  12548. data["fod"] = orders
  12549. data["pd"] = pd
  12550. data["pp"] = pp
  12551. data["fopd"] = fopd
  12552. data["trig_scen"] = trig_scen
  12553. fmt.Println(data)
  12554. fmt.Println(fed)
  12555. fmt.Println(fdds)
  12556. fmt.Println(orders)
  12557. fmt.Println(pd)
  12558. fmt.Println(pp)
  12559. fmt.Println(fopd)
  12560. client := &http.Client{}
  12561. bytesData, _ := json.Marshal(data)
  12562. var req *http.Request
  12563. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12564. if miConfig.MdtrtareaAdmvs == "320830" {
  12565. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  12566. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12567. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12568. } else {
  12569. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12570. }
  12571. resp, _ := client.Do(req)
  12572. defer resp.Body.Close()
  12573. body, ioErr := ioutil.ReadAll(resp.Body)
  12574. if ioErr != nil {
  12575. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12577. return res
  12578. }
  12579. var respJSON map[string]interface{}
  12580. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12581. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12583. return res
  12584. }
  12585. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12586. fmt.Println(respJSON)
  12587. result, _ := json.Marshal(respJSON)
  12588. fmt.Println(result)
  12589. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12590. utils.ErrorLog("解析失败:%v", err)
  12591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12592. return res
  12593. }
  12594. return res
  12595. } else {
  12596. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12597. saveLog(output, input, "3101", "事前")
  12598. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12599. utils.ErrorLog("解析失败:%v", err)
  12600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12601. return
  12602. }
  12603. return res
  12604. }
  12605. return res
  12606. }
  12607. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  12608. adminUser := c.GetAdminUserInfo()
  12609. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12610. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12611. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12612. record_time := c.GetString("record_time")
  12613. order, _ := service.GetHisOrderByID(order_id)
  12614. timeLayout := "2006-01-02"
  12615. loc, _ := time.LoadLocation("Local")
  12616. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12617. if err != nil {
  12618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12619. return
  12620. }
  12621. recordDateTime := theTime.Unix()
  12622. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  12623. var patientPrescription models.HisPrescriptionInfo
  12624. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12625. if patientPrescription.ID == 0 {
  12626. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12627. }
  12628. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12629. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12630. //
  12631. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  12632. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12633. var pp models.PublicParams
  12634. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12635. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12636. pp.FixmedinsName = miConfig.OrgName
  12637. pp.FixmedinsCode = miConfig.Code
  12638. pp.RequestUrl = miConfig.Url
  12639. pp.Cainfo = miConfig.Cainfo
  12640. pp.SecretKey = miConfig.SecretKey
  12641. pp.AccessKey = miConfig.AccessKey
  12642. pp.OpterName = roles.UserName
  12643. var config []*models.HisXtDiagnoseConfig
  12644. for _, item := range diagnosis_ids {
  12645. id, _ := strconv.ParseInt(item, 10, 64)
  12646. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12647. config = append(config, &diagnosisConfig)
  12648. }
  12649. //str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  12650. var str string
  12651. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  12652. str = timestampToBirthdayString(patient.Birthday)
  12653. } else {
  12654. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  12655. }
  12656. var pd models.PatientDtos
  12657. pd.PatnID = his.PsnNo
  12658. pd.PatnName = his.Name
  12659. pd.Gend = his.Gend
  12660. pd.Brdy = str
  12661. pd.Poolarea = his.InsuplcAdmdvs
  12662. pd.CurrMdtrtID = his.Number
  12663. var fed models.FsiEncounterDtos
  12664. fed.MdtrtID = his.Number
  12665. fed.MedinsID = miConfig.Code
  12666. fed.MedinsName = miConfig.OrgName
  12667. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12668. fed.MedMdtrtType = "1"
  12669. fed.MedinsType = "1"
  12670. fed.MedinsLv = "11"
  12671. tm := time.Unix(his.RecordDate, 0)
  12672. s_tm := tm.Format("2006-01-02 15:04:05")
  12673. fed.AdmDate = s_tm
  12674. fed.DscgDate = s_tm
  12675. fed.DscgMainDiseCodg = config[0].CountryCode
  12676. fed.DscgMainDiseName = config[0].CountryContentName
  12677. //诊断信息
  12678. var fdds []*models.FsiDiagnoseDtos
  12679. for index, item := range config {
  12680. if index == 0 {
  12681. var fdd models.FsiDiagnoseDtos
  12682. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12683. fdd.InoutDiseType = "1"
  12684. fdd.MaindiseFlag = "1"
  12685. fdd.DiseDate = s_tm
  12686. fdd.DiasSrtNo = "1"
  12687. fdd.DiseName = item.CountryContentName
  12688. fdd.DiseCodg = item.CountryCode
  12689. fdds = append(fdds, &fdd)
  12690. } else {
  12691. var fdd models.FsiDiagnoseDtos
  12692. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12693. fdd.InoutDiseType = "1"
  12694. fdd.MaindiseFlag = "1"
  12695. fdd.DiseDate = s_tm
  12696. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12697. fdd.DiseName = item.CountryContentName
  12698. fdd.DiseCodg = item.CountryCode
  12699. fdds = append(fdds, &fdd)
  12700. }
  12701. }
  12702. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12703. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  12704. fed.AdmDeptName = department.Name
  12705. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  12706. fed.DscgDeptName = department.Name
  12707. fed.MedType = order.MedType
  12708. //处方医嘱信息
  12709. var orders []*models.FsiOrderDtos
  12710. //for _, item := range prescriptions {
  12711. // for _, subItem := range item.HisDoctorAdviceInfo {
  12712. // var order models.FsiOrderDtos
  12713. // order.RxID = strconv.FormatInt(item.ID, 10)
  12714. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12715. // order.LongDrordFlag = "0"
  12716. // order.HilistType = "1"
  12717. // order.ChrgType = "1"
  12718. // order.DrordBhvr = "-"
  12719. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12720. // order.HosplistName = subItem.BaseDrugLib.DrugName
  12721. // order.HilistLv = "1"
  12722. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12723. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12724. // order.HosplistName = subItem.BaseDrugLib.DrugName
  12725. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  12726. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12727. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  12728. // order.OwnpayAmt = ""
  12729. // order.SelfpayAmt = ""
  12730. // order.Spec = ""
  12731. // order.SpecUnt = ""
  12732. // order.DrordBegnDate = s_tm
  12733. // order.DrordStopDate = ""
  12734. // order.DrordDrCodg = "1"
  12735. // order.DrordDeptName = department.Name
  12736. // order.DrordDrCodg = "1"
  12737. // order.DrordDrName = doctor_info.UserName
  12738. // order.DrordDrProfttl = ""
  12739. // order.CurrDrordFlag = "1"
  12740. // orders = append(orders, &order)
  12741. // }
  12742. // for _, subItem := range item.HisPrescriptionProject {
  12743. // if subItem.Type == 2 {
  12744. // var order models.FsiOrderDtos
  12745. // order.RxID = strconv.FormatInt(item.ID, 10)
  12746. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12747. // order.LongDrordFlag = "0"
  12748. // order.HilistType = "1"
  12749. // order.ChrgType = "1"
  12750. // order.DrordBhvr = "-"
  12751. // order.HilistCode = subItem.HisProject.MedicalCode
  12752. // order.HosplistName = subItem.HisProject.ProjectName
  12753. // order.HilistLv = "1"
  12754. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12755. // order.HosplistCode = subItem.HisProject.MedicalCode
  12756. // order.HosplistName = subItem.HisProject.ProjectName
  12757. // order.Cnt = subItem.Count
  12758. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12759. //
  12760. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12761. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  12762. // order.OwnpayAmt = ""
  12763. // order.SelfpayAmt = ""
  12764. // order.Spec = ""
  12765. // order.SpecUnt = ""
  12766. // order.DrordBegnDate = s_tm
  12767. // order.DrordStopDate = ""
  12768. // order.DrordDrCodg = "1"
  12769. // order.DrordDeptName = department.Name
  12770. // order.DrordDrCodg = "1"
  12771. // order.DrordDrName = doctor_info.UserName
  12772. // order.DrordDrProfttl = ""
  12773. // order.CurrDrordFlag = "1"
  12774. // orders = append(orders, &order)
  12775. //
  12776. // }
  12777. // if subItem.Type == 3 {
  12778. //
  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 = "1"
  12784. // order.ChrgType = "1"
  12785. // order.DrordBhvr = "-"
  12786. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12787. // order.HosplistName = subItem.GoodInfo.GoodName
  12788. // order.HilistLv = "1"
  12789. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12790. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12791. // order.HosplistName = subItem.GoodInfo.GoodName
  12792. // order.Cnt = subItem.Count
  12793. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12794. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12795. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  12796. // order.OwnpayAmt = ""
  12797. // order.SelfpayAmt = ""
  12798. // order.Spec = ""
  12799. // order.SpecUnt = ""
  12800. // order.DrordBegnDate = s_tm
  12801. // order.DrordStopDate = ""
  12802. // order.DrordDrCodg = "1"
  12803. // order.DrordDeptName = department.Name
  12804. // order.DrordDrCodg = "1"
  12805. // order.DrordDrName = doctor_info.UserName
  12806. // order.DrordDrProfttl = ""
  12807. // order.CurrDrordFlag = "1"
  12808. // orders = append(orders, &order)
  12809. //
  12810. // }
  12811. // }
  12812. //}
  12813. for _, item := range prescriptions {
  12814. for _, subItem := range item.HisDoctorAdviceInfo {
  12815. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12816. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12817. var order models.FsiOrderDtos
  12818. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12819. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12820. order.LongDrordFlag = "0"
  12821. order.HilistType = "101"
  12822. order.ChrgType = "01"
  12823. order.DrordBhvr = "0"
  12824. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12825. order.HosplistName = subItem.BaseDrugLib.DrugName
  12826. order.HilistLv = "1"
  12827. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12828. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12829. order.HosplistName = subItem.BaseDrugLib.DrugName
  12830. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12831. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12832. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12833. order.OwnpayAmt = ""
  12834. order.SelfpayAmt = ""
  12835. order.Spec = spec
  12836. order.SpecUnt = subItem.PrescribingNumberUnit
  12837. order.DrordBegnDate = s_tm
  12838. order.DrordStopDate = ""
  12839. order.DrordDrCodg = doctor_info.DoctorNumber
  12840. order.DrordDeptName = department.Name
  12841. order.DrordDeptCodg = department.Number
  12842. order.DrordDrName = doctor_info.UserName
  12843. order.DrordDrProfttl = "234"
  12844. order.CurrDrordFlag = "1"
  12845. orders = append(orders, &order)
  12846. }
  12847. }
  12848. for _, subItem := range item.HisPrescriptionProject {
  12849. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12850. var order models.FsiOrderDtos
  12851. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12852. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12853. order.LongDrordFlag = "0"
  12854. order.HilistType = "201"
  12855. order.ChrgType = "05"
  12856. order.DrordBhvr = "0"
  12857. order.HilistCode = subItem.HisProject.MedicalCode
  12858. order.HosplistName = subItem.HisProject.ProjectName
  12859. order.HilistLv = "1"
  12860. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12861. order.HosplistCode = subItem.HisProject.MedicalCode
  12862. order.HosplistName = subItem.HisProject.ProjectName
  12863. order.Cnt = subItem.Count
  12864. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12865. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12866. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12867. order.OwnpayAmt = ""
  12868. order.SelfpayAmt = ""
  12869. if subItem.Unit == ""{
  12870. order.Spec = "次"
  12871. order.SpecUnt = "次"
  12872. }else{
  12873. order.Spec = subItem.Unit
  12874. order.SpecUnt = subItem.Unit
  12875. }
  12876. order.DrordBegnDate = s_tm
  12877. order.DrordStopDate = ""
  12878. order.DrordDrCodg = doctor_info.DoctorNumber
  12879. order.DrordDeptName = department.Name
  12880. order.DrordDeptCodg = department.Number
  12881. order.DrordDrName = doctor_info.UserName
  12882. order.DrordDrProfttl = "234"
  12883. order.CurrDrordFlag = "1"
  12884. orders = append(orders, &order)
  12885. }
  12886. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12887. var order models.FsiOrderDtos
  12888. order.RxID = strconv.FormatInt(subItem.ID, 10)
  12889. order.Rxno = strconv.FormatInt(subItem.ID, 10)
  12890. order.LongDrordFlag = "0"
  12891. order.HilistType = "301"
  12892. order.ChrgType = "08"
  12893. order.DrordBhvr = "0"
  12894. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12895. order.HosplistName = subItem.GoodInfo.GoodName
  12896. order.HilistLv = "1"
  12897. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12898. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12899. order.HosplistName = subItem.GoodInfo.GoodName
  12900. order.Cnt = subItem.Count
  12901. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12902. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12903. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12904. order.OwnpayAmt = ""
  12905. order.SelfpayAmt = ""
  12906. order.Spec = subItem.GoodInfo.SpecificationName
  12907. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12908. order.DrordBegnDate = s_tm
  12909. order.DrordStopDate = ""
  12910. order.DrordDrCodg = doctor_info.DoctorNumber
  12911. order.DrordDeptName = department.Name
  12912. order.DrordDeptCodg = department.Number
  12913. order.DrordDrName = doctor_info.UserName
  12914. order.DrordDrProfttl = "234"
  12915. order.CurrDrordFlag = "1"
  12916. orders = append(orders, &order)
  12917. }
  12918. }
  12919. }
  12920. //处方医嘱信息
  12921. fed.MatnStas = "0"
  12922. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  12923. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  12924. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  12925. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  12926. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  12927. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  12928. fed.SetlTotlnum = "1"
  12929. fed.Insutype = his.Insutype
  12930. fed.ReimFlag = "0"
  12931. fed.OutSetlFlag = "0"
  12932. var fopd []*models.FsiOperationDtosData
  12933. data := make(map[string]interface{})
  12934. data["fed"] = fed
  12935. data["fdd"] = fdds
  12936. data["fod"] = orders
  12937. data["pd"] = pd
  12938. data["pp"] = pp
  12939. data["fopd"] = fopd
  12940. data["trig_scen"] = trig_scen
  12941. client := &http.Client{}
  12942. bytesData, _ := json.Marshal(data)
  12943. var req *http.Request
  12944. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12945. if miConfig.MdtrtareaAdmvs == "320830" {
  12946. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3102", bytes.NewReader(bytesData))
  12947. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12948. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12949. } else {
  12950. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12951. }
  12952. resp, _ := client.Do(req)
  12953. defer resp.Body.Close()
  12954. body, ioErr := ioutil.ReadAll(resp.Body)
  12955. if ioErr != nil {
  12956. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12958. return res
  12959. }
  12960. var respJSON map[string]interface{}
  12961. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12962. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12964. return res
  12965. }
  12966. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12967. result, _ := json.Marshal(respJSON)
  12968. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12969. utils.ErrorLog("解析失败:%v", err)
  12970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12971. return res
  12972. }
  12973. return res
  12974. } else {
  12975. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12976. saveLog(output, input, "3102", "事中")
  12977. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12978. utils.ErrorLog("解析失败:%v", err)
  12979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12980. return
  12981. }
  12982. return res
  12983. }
  12984. return res
  12985. }
  12986. func (c *HisApiController) Check() {
  12987. psn_no := c.GetString("psn_no")
  12988. in := c.GetString("in")
  12989. mt := c.GetString("mt")
  12990. baseParams := models.BaseParams{
  12991. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  12992. FixmedinsCode: "H15049901371",
  12993. InsuplcAdmdvs: "150404",
  12994. MdtrtareaAdmvs: "150404",
  12995. OrgName: "赤峰费森血液透析中心",
  12996. Doctor: "1111",
  12997. }
  12998. service.Gdyb2001(baseParams, psn_no, in, mt)
  12999. }
  13000. func (c *HisApiController) GetPsnNcdsInfo() {
  13001. admin_user_id, _ := c.GetInt64("admin_user_id")
  13002. patient_id, _ := c.GetInt64("patient_id")
  13003. //id, _ := c.GetInt64("id")
  13004. adminUser := c.GetAdminUserInfo()
  13005. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13006. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13007. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  13008. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13009. //psn_record, _ := service.GetP(id)
  13010. psn_info, _ := service.GetPsnByPatientId(patient_id)
  13011. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  13012. //
  13013. //if psn_record.ID == 0 {
  13014. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  13015. // return
  13016. //}
  13017. var res Result5301
  13018. var res10265 Result5301For10265
  13019. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  13020. psn_info, _ := service.GetPsnByPatientId(patient_id)
  13021. var api string
  13022. if miConfig.MdtrtareaAdmvs == "320830" {
  13023. api = miConfig.AppSecret + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  13024. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  13025. } else if miConfig.MdtrtareaAdmvs == "320921" {
  13026. 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 +
  13027. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  13028. } else {
  13029. 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 +
  13030. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  13031. }
  13032. resp, requestErr := http.Get(api)
  13033. if requestErr != nil {
  13034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13035. return
  13036. }
  13037. body, ioErr := ioutil.ReadAll(resp.Body)
  13038. if ioErr != nil {
  13039. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13041. return
  13042. }
  13043. var respJSON map[string]interface{}
  13044. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13045. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13047. return
  13048. }
  13049. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13050. result, _ := json.Marshal(respJSON)
  13051. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13052. utils.ErrorLog("解析失败:%v", err)
  13053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13054. return
  13055. }
  13056. res.ErrMsg = res10265.ErrMsg
  13057. res.Output = res10265.Output
  13058. res.InfRefmsgid = res10265.InfRefmsgid
  13059. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13060. res.Infcode = infocode
  13061. } else if miConfig.MdtrtareaAdmvs == "341203" {
  13062. psn_info, _ := service.GetPsnByPatientId(patient_id)
  13063. var api string
  13064. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  13065. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  13066. resp, requestErr := http.Get(api)
  13067. if requestErr != nil {
  13068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13069. return
  13070. }
  13071. body, ioErr := ioutil.ReadAll(resp.Body)
  13072. if ioErr != nil {
  13073. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13075. return
  13076. }
  13077. var respJSON map[string]interface{}
  13078. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13079. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13081. return
  13082. }
  13083. status := respJSON["data"].(map[string]interface{})["status"].(string)
  13084. if status == "0" {
  13085. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  13086. c.ServeSuccessJSON(map[string]interface{}{
  13087. "failed_code": -10,
  13088. "msg": err_msg,
  13089. })
  13090. return
  13091. }
  13092. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13093. result, _ := json.Marshal(respJSON)
  13094. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13095. utils.ErrorLog("解析失败:%v", err)
  13096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13097. return
  13098. }
  13099. } else if miConfig.MdtrtareaAdmvs == "340699" {
  13100. psn_info, _ := service.GetHisPatientByPatientId(patient_id)
  13101. var api string
  13102. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  13103. "&insuplc_admdvs=" + psn_info.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  13104. resp, requestErr := http.Get(api)
  13105. if requestErr != nil {
  13106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13107. return
  13108. }
  13109. body, ioErr := ioutil.ReadAll(resp.Body)
  13110. if ioErr != nil {
  13111. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13113. return
  13114. }
  13115. var respJSON map[string]interface{}
  13116. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13117. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13119. return
  13120. }
  13121. status := respJSON["data"].(map[string]interface{})["status"].(string)
  13122. if status == "0" {
  13123. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  13124. c.ServeSuccessJSON(map[string]interface{}{
  13125. "failed_code": -10,
  13126. "msg": err_msg,
  13127. })
  13128. return
  13129. }
  13130. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13131. result, _ := json.Marshal(respJSON)
  13132. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13133. utils.ErrorLog("解析失败:%v", err)
  13134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13135. return
  13136. }
  13137. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13138. p, _ := service.GetHisPatientById(patient_id)
  13139. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13140. var dat map[string]interface{}
  13141. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13142. fmt.Println(dat)
  13143. } else {
  13144. fmt.Println(err)
  13145. }
  13146. userJSONBytes, _ := json.Marshal(dat)
  13147. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13148. utils.ErrorLog("解析失败:%v", err)
  13149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13150. return
  13151. }
  13152. } else if miConfig.MdtrtareaAdmvs == "361025" {
  13153. p, _ := service.GetHisPatientById(patient_id)
  13154. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13155. var dat map[string]interface{}
  13156. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13157. fmt.Println(dat)
  13158. } else {
  13159. fmt.Println(err)
  13160. }
  13161. userJSONBytes, _ := json.Marshal(dat)
  13162. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13163. utils.ErrorLog("解析失败:%v", err)
  13164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13165. return
  13166. }
  13167. } else if miConfig.MdtrtareaAdmvs == "360100" {
  13168. p, _ := service.GetHisPatientById(patient_id)
  13169. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13170. var dat map[string]interface{}
  13171. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13172. fmt.Println(dat)
  13173. } else {
  13174. fmt.Println(err)
  13175. }
  13176. userJSONBytes, _ := json.Marshal(dat)
  13177. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13178. utils.ErrorLog("解析失败:%v", err)
  13179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13180. return
  13181. }
  13182. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13183. p, _ := service.GetHisPatientById(patient_id)
  13184. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13185. var dat map[string]interface{}
  13186. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13187. fmt.Println(dat)
  13188. } else {
  13189. fmt.Println(err)
  13190. }
  13191. userJSONBytes, _ := json.Marshal(dat)
  13192. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13193. utils.ErrorLog("解析失败:%v", err)
  13194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13195. return
  13196. }
  13197. } else if miConfig.MdtrtareaAdmvs == "420200" {
  13198. p, _ := service.GetHisPatientById(patient_id)
  13199. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  13200. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13201. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13202. resp, requestErr := http.Get(api)
  13203. if requestErr != nil {
  13204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13205. return
  13206. }
  13207. body, ioErr := ioutil.ReadAll(resp.Body)
  13208. if ioErr != nil {
  13209. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13211. return
  13212. }
  13213. var respJSON map[string]interface{}
  13214. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13215. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13217. return
  13218. }
  13219. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13220. result, _ := json.Marshal(respJSON)
  13221. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13222. utils.ErrorLog("解析失败:%v", err)
  13223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13224. return
  13225. }
  13226. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13227. p, _ := service.GetHisPatientById(patient_id)
  13228. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  13229. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13230. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13231. resp, requestErr := http.Get(api)
  13232. if requestErr != nil {
  13233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13234. return
  13235. }
  13236. body, ioErr := ioutil.ReadAll(resp.Body)
  13237. if ioErr != nil {
  13238. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13240. return
  13241. }
  13242. var respJSON map[string]interface{}
  13243. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13244. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13246. return
  13247. }
  13248. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13249. result, _ := json.Marshal(respJSON)
  13250. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13251. utils.ErrorLog("解析失败:%v", err)
  13252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13253. return
  13254. }
  13255. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13256. p, _ := service.GetHisPatientById(patient_id)
  13257. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  13258. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13259. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13260. resp, requestErr := http.Get(api)
  13261. if requestErr != nil {
  13262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13263. return
  13264. }
  13265. body, ioErr := ioutil.ReadAll(resp.Body)
  13266. if ioErr != nil {
  13267. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13269. return
  13270. }
  13271. var respJSON map[string]interface{}
  13272. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13273. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13275. return
  13276. }
  13277. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13278. result, _ := json.Marshal(respJSON)
  13279. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13280. utils.ErrorLog("解析失败:%v", err)
  13281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13282. return
  13283. }
  13284. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13285. p, _ := service.GetHisPatientById(patient_id)
  13286. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  13287. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13288. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13289. resp, requestErr := http.Get(api)
  13290. if requestErr != nil {
  13291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13292. return
  13293. }
  13294. body, ioErr := ioutil.ReadAll(resp.Body)
  13295. if ioErr != nil {
  13296. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13298. return
  13299. }
  13300. var respJSON map[string]interface{}
  13301. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13302. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13304. return
  13305. }
  13306. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13307. result, _ := json.Marshal(respJSON)
  13308. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13309. utils.ErrorLog("解析失败:%v", err)
  13310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13311. return
  13312. }
  13313. } else if miConfig.MdtrtareaAdmvs == "421300" {
  13314. p, _ := service.GetHisPatientById(patient_id)
  13315. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  13316. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13317. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13318. resp, requestErr := http.Get(api)
  13319. if requestErr != nil {
  13320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13321. return
  13322. }
  13323. body, ioErr := ioutil.ReadAll(resp.Body)
  13324. if ioErr != nil {
  13325. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13327. return
  13328. }
  13329. var respJSON map[string]interface{}
  13330. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13331. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13333. return
  13334. }
  13335. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13336. result, _ := json.Marshal(respJSON)
  13337. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13338. utils.ErrorLog("解析失败:%v", err)
  13339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13340. return
  13341. }
  13342. } else if miConfig.MdtrtareaAdmvs == "441799" {
  13343. p, _ := service.GetHisPatientById(patient_id)
  13344. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  13345. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13346. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13347. resp, requestErr := http.Get(api)
  13348. if requestErr != nil {
  13349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13350. return
  13351. }
  13352. body, ioErr := ioutil.ReadAll(resp.Body)
  13353. if ioErr != nil {
  13354. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13356. return
  13357. }
  13358. var respJSON map[string]interface{}
  13359. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13360. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13362. return
  13363. }
  13364. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13365. result, _ := json.Marshal(respJSON)
  13366. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13367. utils.ErrorLog("解析失败:%v", err)
  13368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13369. return
  13370. }
  13371. } else {
  13372. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  13373. var dat map[string]interface{}
  13374. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13375. fmt.Println(dat)
  13376. } else {
  13377. fmt.Println(err)
  13378. }
  13379. userJSONBytes, _ := json.Marshal(dat)
  13380. if miConfig.Code == "H15049901371" {
  13381. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  13382. utils.ErrorLog("解析失败:%v", err)
  13383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13384. return
  13385. }
  13386. res.InfRefmsgid = res10265.InfRefmsgid
  13387. res.Output = res10265.Output
  13388. res.ErrMsg = res10265.ErrMsg
  13389. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13390. res.Infcode = infocode
  13391. } else {
  13392. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13393. utils.ErrorLog("解析失败:%v", err)
  13394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13395. return
  13396. }
  13397. }
  13398. }
  13399. if res.Infcode == 0 {
  13400. c.ServeSuccessJSON(map[string]interface{}{
  13401. "result": res.Output.Result,
  13402. })
  13403. }
  13404. }
  13405. func (c *HisApiController) CheckInsutype() {
  13406. his_patient_id, _ := c.GetInt64("his_patient_id")
  13407. admin_user_id, _ := c.GetInt64("admin_user_id")
  13408. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13409. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  13410. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13411. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  13412. var dat map[string]interface{}
  13413. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13414. fmt.Println(dat)
  13415. } else {
  13416. fmt.Println(err)
  13417. }
  13418. userJSONBytes, _ := json.Marshal(dat)
  13419. var res Result90100
  13420. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13421. utils.ErrorLog("解析失败:%v", err)
  13422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13423. return
  13424. }
  13425. if res.Infcode != 0 {
  13426. c.ServeSuccessJSON(map[string]interface{}{
  13427. "failed_code": -10,
  13428. "msg": res.ErrMsg,
  13429. })
  13430. return
  13431. } else {
  13432. fmt.Println(res)
  13433. }
  13434. }
  13435. func (c *HisApiController) CheckCardPWD() {
  13436. card_pwd := c.GetString("card_pwd")
  13437. his_patient_id, _ := c.GetInt64("his_patient_id")
  13438. admin_user_id, _ := c.GetInt64("admin_user_id")
  13439. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13440. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13441. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  13442. psn, _ := service.GetPsnByPatientId(his.PatientId)
  13443. bas := strings.Split(psn.CardInfo, "|")
  13444. basNumber := bas[2]
  13445. if psn.InsuplcAdmdvs[:4] == "4403" {
  13446. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  13447. var dat map[string]interface{}
  13448. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13449. fmt.Println(dat)
  13450. } else {
  13451. fmt.Println(err)
  13452. }
  13453. userJSONBytes, _ := json.Marshal(dat)
  13454. var res Result90991
  13455. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13456. utils.ErrorLog("解析失败:%v", err)
  13457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13458. return
  13459. }
  13460. if res.Infcode != 0 {
  13461. c.ServeSuccessJSON(map[string]interface{}{
  13462. "failed_code": -10,
  13463. "msg": res.ErrMsg,
  13464. })
  13465. return
  13466. } else {
  13467. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  13468. var msg string
  13469. switch res.Output.Result.CardStat {
  13470. case "00":
  13471. msg = "未激活"
  13472. break
  13473. case "10":
  13474. msg = "激活"
  13475. break
  13476. case "20":
  13477. msg = "窗口挂失"
  13478. break
  13479. case "21":
  13480. msg = "电话挂失"
  13481. break
  13482. case "22":
  13483. msg = "单位网上申报挂失"
  13484. break
  13485. case "23":
  13486. msg = "保健办挂失"
  13487. break
  13488. case "24":
  13489. msg = "个人网上挂失"
  13490. break
  13491. case "25":
  13492. msg = "网上服务大厅挂失"
  13493. break
  13494. case "30":
  13495. msg = "注销"
  13496. break
  13497. case "40":
  13498. msg = "回收"
  13499. break
  13500. case "99":
  13501. msg = "制卡中(无效卡)"
  13502. break
  13503. }
  13504. c.ServeSuccessJSON(map[string]interface{}{
  13505. "failed_code": -10,
  13506. "msg": msg,
  13507. })
  13508. return
  13509. } else {
  13510. c.ServeSuccessJSON(map[string]interface{}{
  13511. "msg": "校验成功",
  13512. })
  13513. return
  13514. }
  13515. }
  13516. } else {
  13517. c.ServeSuccessJSON(map[string]interface{}{
  13518. "msg": "校验成功",
  13519. })
  13520. return
  13521. }
  13522. }
  13523. func (c *HisApiController) CheckCardPWDTwo() {
  13524. //card_pwd := c.GetString("card_pwd")
  13525. //his_patient_id, _ := c.GetInt64("his_patient_id")
  13526. admin_user_id, _ := c.GetInt64("admin_user_id")
  13527. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13528. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13529. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  13530. var dat map[string]interface{}
  13531. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13532. fmt.Println(dat)
  13533. } else {
  13534. fmt.Println(err)
  13535. }
  13536. userJSONBytes, _ := json.Marshal(dat)
  13537. var res Result90991
  13538. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13539. utils.ErrorLog("解析失败:%v", err)
  13540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13541. return
  13542. }
  13543. if res.Infcode != 0 {
  13544. c.ServeSuccessJSON(map[string]interface{}{
  13545. "failed_code": -10,
  13546. "msg": res.ErrMsg,
  13547. })
  13548. return
  13549. } else {
  13550. if res.Output.Result.SscnoCheckStat == "0" {
  13551. var msg string
  13552. switch res.Output.Result.CardStat {
  13553. case "00":
  13554. msg = "未激活"
  13555. break
  13556. case "10":
  13557. msg = "激活"
  13558. break
  13559. case "20":
  13560. msg = "窗口挂失"
  13561. break
  13562. case "21":
  13563. msg = "电话挂失"
  13564. break
  13565. case "22":
  13566. msg = "单位网上申报挂失"
  13567. break
  13568. case "23":
  13569. msg = "保健办挂失"
  13570. break
  13571. case "24":
  13572. msg = "个人网上挂失"
  13573. break
  13574. case "25":
  13575. msg = "网上服务大厅挂失"
  13576. break
  13577. case "30":
  13578. msg = "注销"
  13579. break
  13580. case "40":
  13581. msg = "回收"
  13582. break
  13583. case "99":
  13584. msg = "制卡中(无效卡)"
  13585. break
  13586. }
  13587. c.ServeSuccessJSON(map[string]interface{}{
  13588. "failed_code": -10,
  13589. "msg": msg,
  13590. })
  13591. return
  13592. } else {
  13593. c.ServeSuccessJSON(map[string]interface{}{
  13594. "msg": "校验成功",
  13595. })
  13596. return
  13597. }
  13598. }
  13599. }
  13600. type ELeCertData struct {
  13601. Data struct {
  13602. Extra string `json:"extra"`
  13603. IDNo string `json:"idNo"`
  13604. IDType string `json:"idType"`
  13605. EcToken string `json:"ecToken"`
  13606. InsuOrg string `json:"insuOrg"`
  13607. UserName string `json:"userName"`
  13608. EcIndexNo string `json:"ecIndexNo"`
  13609. Gender string `json:"gender"`
  13610. Birthday string `json:"birthday"`
  13611. Nationality string `json:"nationality"`
  13612. Email string `json:"email"`
  13613. } `json:"OutData"`
  13614. }
  13615. func (c *HisApiController) ReadCard() {
  13616. id_card_type, _ := c.GetInt64("id_card_type")
  13617. admin_user_id, _ := c.GetInt64("admin_user_id")
  13618. certificates, _ := c.GetInt64("certificates")
  13619. //
  13620. insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  13621. id_card_no := c.GetString("id_card_no")
  13622. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13623. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13624. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13625. switch id_card_type {
  13626. case 1:
  13627. if miConfig.MdtrtareaAdmvs == "421300" {
  13628. var res ResultTwo
  13629. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  13630. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13631. "&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)
  13632. resp, requestErr := http.Get(api)
  13633. if requestErr != nil {
  13634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13635. return
  13636. }
  13637. body, ioErr := ioutil.ReadAll(resp.Body)
  13638. if ioErr != nil {
  13639. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13641. return
  13642. }
  13643. var respJSON map[string]interface{}
  13644. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13645. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13647. return
  13648. }
  13649. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13650. result, _ := json.Marshal(respJSON)
  13651. fmt.Println("log")
  13652. fmt.Println(string(result))
  13653. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13654. utils.ErrorLog("解析失败:%v", err)
  13655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13656. return
  13657. }
  13658. if res.Infcode == 0 {
  13659. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13660. if err == gorm.ErrRecordNotFound {
  13661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13662. return
  13663. } else if err != nil {
  13664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13665. return
  13666. } else {
  13667. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13668. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13669. infoStr := string(Iinfos)
  13670. idetinfoStr := string(Idetinfos)
  13671. var rf []*ResultFive
  13672. json.Unmarshal([]byte(infoStr), &rf)
  13673. var insutypes []*ResultFive
  13674. var insutype string
  13675. var is390 int = 0
  13676. var is310 int = 0
  13677. for _, item := range rf {
  13678. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13679. insutypes = append(insutypes, item)
  13680. }
  13681. }
  13682. if len(insutypes) == 1 {
  13683. insutype = insutypes[0].Insutype
  13684. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13685. } else {
  13686. for _, i := range insutypes {
  13687. if i.Insutype == "390" {
  13688. is390 = 1
  13689. }
  13690. if i.Insutype == "310" {
  13691. is310 = 1
  13692. }
  13693. }
  13694. }
  13695. if is390 == 1 {
  13696. insutype = "390"
  13697. }
  13698. if is310 == 1 {
  13699. insutype = "310"
  13700. }
  13701. if len(insutypes) == 0 {
  13702. insutype = "390"
  13703. }
  13704. var insuplc_admdvs string
  13705. for _, item := range rf {
  13706. if item.Insutype == insutype {
  13707. insuplc_admdvs = item.InsuplcAdmdvs
  13708. }
  13709. }
  13710. if strings.Contains(insuplc_admdvs, "4213") {
  13711. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  13712. }
  13713. psn := &models.HisPsn{
  13714. PsnNo: res.Output.Baseinfo.PsnNo,
  13715. PatientId: patient.ID,
  13716. Certno: res.Output.Baseinfo.Certno,
  13717. Gend: res.Output.Baseinfo.Gend,
  13718. Naty: res.Output.Baseinfo.Naty,
  13719. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13720. PsnName: res.Output.Baseinfo.PsnName,
  13721. Idetinfo: idetinfoStr,
  13722. Insuinfo: infoStr,
  13723. InsuplcAdmdvs: insuplc_admdvs,
  13724. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13725. }
  13726. service.CreateHisPsn(psn)
  13727. c.ServeSuccessJSON(map[string]interface{}{
  13728. "patient": patient,
  13729. "number": res.Output.Baseinfo.Certno,
  13730. })
  13731. }
  13732. } else {
  13733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13734. return
  13735. }
  13736. } else if miConfig.MdtrtareaAdmvs == "420200" {
  13737. var res ResultTwo
  13738. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  13739. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13740. "&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)
  13741. resp, requestErr := http.Get(api)
  13742. if requestErr != nil {
  13743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13744. return
  13745. }
  13746. body, ioErr := ioutil.ReadAll(resp.Body)
  13747. if ioErr != nil {
  13748. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13750. return
  13751. }
  13752. var respJSON map[string]interface{}
  13753. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13754. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13756. return
  13757. }
  13758. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13759. result, _ := json.Marshal(respJSON)
  13760. fmt.Println("log")
  13761. fmt.Println(string(result))
  13762. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13763. utils.ErrorLog("解析失败:%v", err)
  13764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13765. return
  13766. }
  13767. if res.Infcode == 0 {
  13768. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13769. if err == gorm.ErrRecordNotFound {
  13770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13771. return
  13772. } else if err != nil {
  13773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13774. return
  13775. } else {
  13776. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13777. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13778. infoStr := string(Iinfos)
  13779. idetinfoStr := string(Idetinfos)
  13780. psn := &models.HisPsn{
  13781. PsnNo: res.Output.Baseinfo.PsnNo,
  13782. PatientId: patient.ID,
  13783. Certno: res.Output.Baseinfo.Certno,
  13784. Gend: res.Output.Baseinfo.Gend,
  13785. Naty: res.Output.Baseinfo.Naty,
  13786. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13787. PsnName: res.Output.Baseinfo.PsnName,
  13788. Idetinfo: idetinfoStr,
  13789. Insuinfo: infoStr,
  13790. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13791. }
  13792. service.CreateHisPsn(psn)
  13793. var rf []*ResultFive
  13794. json.Unmarshal([]byte(infoStr), &rf)
  13795. var insutypes []*ResultFive
  13796. var insutype string
  13797. var is390 int = 0
  13798. var is310 int = 0
  13799. for _, item := range rf {
  13800. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13801. insutypes = append(insutypes, item)
  13802. }
  13803. }
  13804. if len(insutypes) == 1 {
  13805. insutype = insutypes[0].Insutype
  13806. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13807. } else {
  13808. for _, i := range insutypes {
  13809. if i.Insutype == "390" {
  13810. is390 = 1
  13811. }
  13812. if i.Insutype == "310" {
  13813. is310 = 1
  13814. }
  13815. }
  13816. }
  13817. if is390 == 1 {
  13818. insutype = "390"
  13819. }
  13820. if is310 == 1 {
  13821. insutype = "310"
  13822. }
  13823. if len(insutypes) == 0 {
  13824. insutype = "310"
  13825. }
  13826. c.ServeSuccessJSON(map[string]interface{}{
  13827. "patient": patient,
  13828. "number": res.Output.Baseinfo.Certno,
  13829. "insutype": insutype,
  13830. })
  13831. }
  13832. } else {
  13833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13834. return
  13835. }
  13836. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13837. var res ResultTwo
  13838. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  13839. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13840. "&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)
  13841. resp, requestErr := http.Get(api)
  13842. if requestErr != nil {
  13843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13844. return
  13845. }
  13846. body, ioErr := ioutil.ReadAll(resp.Body)
  13847. if ioErr != nil {
  13848. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13850. return
  13851. }
  13852. var respJSON map[string]interface{}
  13853. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13854. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13856. return
  13857. }
  13858. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13859. result, _ := json.Marshal(respJSON)
  13860. fmt.Println("log")
  13861. fmt.Println(string(result))
  13862. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13863. utils.ErrorLog("解析失败:%v", err)
  13864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13865. return
  13866. }
  13867. if res.Infcode == 0 {
  13868. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13869. if err == gorm.ErrRecordNotFound {
  13870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13871. return
  13872. } else if err != nil {
  13873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13874. return
  13875. } else {
  13876. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13877. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13878. infoStr := string(Iinfos)
  13879. idetinfoStr := string(Idetinfos)
  13880. var rf []*ResultFive
  13881. json.Unmarshal([]byte(infoStr), &rf)
  13882. var insutypes []*ResultFive
  13883. var insutype string
  13884. var is390 int = 0
  13885. var is310 int = 0
  13886. for _, item := range rf {
  13887. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13888. insutypes = append(insutypes, item)
  13889. }
  13890. }
  13891. if len(insutypes) == 1 {
  13892. insutype = insutypes[0].Insutype
  13893. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13894. } else {
  13895. for _, i := range insutypes {
  13896. if i.Insutype == "390" {
  13897. is390 = 1
  13898. }
  13899. if i.Insutype == "310" {
  13900. is310 = 1
  13901. }
  13902. }
  13903. }
  13904. if is390 == 1 {
  13905. insutype = "390"
  13906. }
  13907. if is310 == 1 {
  13908. insutype = "310"
  13909. }
  13910. if len(insutypes) == 0 {
  13911. insutype = "390"
  13912. }
  13913. var insuplc_admdvs string
  13914. for _, item := range rf {
  13915. if item.Insutype == insutype {
  13916. insuplc_admdvs = item.InsuplcAdmdvs
  13917. }
  13918. }
  13919. psn := &models.HisPsn{
  13920. PsnNo: res.Output.Baseinfo.PsnNo,
  13921. PatientId: patient.ID,
  13922. Certno: res.Output.Baseinfo.Certno,
  13923. Gend: res.Output.Baseinfo.Gend,
  13924. Naty: res.Output.Baseinfo.Naty,
  13925. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13926. PsnName: res.Output.Baseinfo.PsnName,
  13927. Idetinfo: idetinfoStr,
  13928. Insuinfo: infoStr,
  13929. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13930. InsuplcAdmdvs: insuplc_admdvs,
  13931. }
  13932. service.CreateHisPsn(psn)
  13933. for _, item := range rf {
  13934. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13935. insutypes = append(insutypes, item)
  13936. }
  13937. }
  13938. if len(insutypes) == 1 {
  13939. insutype = insutypes[0].Insutype
  13940. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13941. } else {
  13942. for _, i := range insutypes {
  13943. if i.Insutype == "390" {
  13944. is390 = 1
  13945. }
  13946. if i.Insutype == "310" {
  13947. is310 = 1
  13948. }
  13949. }
  13950. }
  13951. if is390 == 1 {
  13952. insutype = "390"
  13953. }
  13954. if is310 == 1 {
  13955. insutype = "310"
  13956. }
  13957. if len(insutypes) == 0 {
  13958. insutype = "310"
  13959. }
  13960. c.ServeSuccessJSON(map[string]interface{}{
  13961. "patient": patient,
  13962. "number": res.Output.Baseinfo.Certno,
  13963. "insutype": insutype,
  13964. })
  13965. }
  13966. } else {
  13967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13968. return
  13969. }
  13970. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13971. var res ResultTwo
  13972. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  13973. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13974. "&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)
  13975. resp, requestErr := http.Get(api)
  13976. if requestErr != nil {
  13977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13978. return
  13979. }
  13980. body, ioErr := ioutil.ReadAll(resp.Body)
  13981. if ioErr != nil {
  13982. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13984. return
  13985. }
  13986. var respJSON map[string]interface{}
  13987. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13988. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13990. return
  13991. }
  13992. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13993. result, _ := json.Marshal(respJSON)
  13994. fmt.Println("log")
  13995. fmt.Println(string(result))
  13996. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13997. utils.ErrorLog("解析失败:%v", err)
  13998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13999. return
  14000. }
  14001. if res.Infcode == 0 {
  14002. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14003. if err == gorm.ErrRecordNotFound {
  14004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14005. return
  14006. } else if err != nil {
  14007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14008. return
  14009. } else {
  14010. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14011. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14012. infoStr := string(Iinfos)
  14013. idetinfoStr := string(Idetinfos)
  14014. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  14015. psn := &models.HisPsn{
  14016. PsnNo: res.Output.Baseinfo.PsnNo,
  14017. PatientId: patient.ID,
  14018. Certno: res.Output.Baseinfo.Certno,
  14019. Brdy: b,
  14020. Age: float64(age),
  14021. Gend: res.Output.Baseinfo.Gend,
  14022. Naty: res.Output.Baseinfo.Naty,
  14023. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14024. PsnName: res.Output.Baseinfo.PsnName,
  14025. Idetinfo: idetinfoStr,
  14026. Insuinfo: infoStr,
  14027. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14028. }
  14029. service.CreateHisPsn(psn)
  14030. var rf []*ResultFive
  14031. json.Unmarshal([]byte(infoStr), &rf)
  14032. var insutypes []*ResultFive
  14033. var insutype string
  14034. var is390 int = 0
  14035. var is310 int = 0
  14036. for _, item := range rf {
  14037. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14038. insutypes = append(insutypes, item)
  14039. }
  14040. }
  14041. if len(insutypes) == 1 {
  14042. insutype = insutypes[0].Insutype
  14043. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14044. } else {
  14045. for _, i := range insutypes {
  14046. if i.Insutype == "390" {
  14047. is390 = 1
  14048. }
  14049. if i.Insutype == "310" {
  14050. is310 = 1
  14051. }
  14052. }
  14053. }
  14054. if is390 == 1 {
  14055. insutype = "390"
  14056. }
  14057. if is310 == 1 {
  14058. insutype = "310"
  14059. }
  14060. if len(insutypes) == 0 {
  14061. insutype = "310"
  14062. }
  14063. c.ServeSuccessJSON(map[string]interface{}{
  14064. "patient": patient,
  14065. "number": res.Output.Baseinfo.Certno,
  14066. "insutype": insutype,
  14067. })
  14068. }
  14069. } else {
  14070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14071. return
  14072. }
  14073. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  14074. var api string
  14075. if miConfig.MdtrtareaAdmvs == "320830" {
  14076. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14077. "&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
  14078. fmt.Println(api)
  14079. } else if miConfig.MdtrtareaAdmvs == "320921" {
  14080. 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 +
  14081. "&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
  14082. fmt.Println(api)
  14083. } else {
  14084. 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 +
  14085. "&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)
  14086. }
  14087. resp, requestErr := http.Get(api)
  14088. if requestErr != nil {
  14089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14090. return
  14091. }
  14092. body, ioErr := ioutil.ReadAll(resp.Body)
  14093. if ioErr != nil {
  14094. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14096. return
  14097. }
  14098. var respJSON map[string]interface{}
  14099. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14100. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14102. return
  14103. }
  14104. var status string
  14105. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14106. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14107. //console.log()
  14108. fmt.Println("type===")
  14109. fmt.Println(card_type)
  14110. var token string
  14111. var res ResultTwo //1101结果
  14112. var res10265 ResultTwo10265 //1101结果
  14113. var card_info string //卡信息
  14114. var busi_card_info string
  14115. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14116. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14117. if status == "0" { //读卡成功
  14118. if card_type == "1" {
  14119. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14120. result, _ := json.Marshal(respJSON)
  14121. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14122. utils.ErrorLog("解析失败:%v", err)
  14123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14124. return
  14125. }
  14126. res.ErrMsg = res10265.ErrMsg
  14127. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14128. res.Infcode = infocode
  14129. res.Output = res10265.Output
  14130. res.InfRefmsgid = res10265.InfRefmsgid
  14131. } else {
  14132. //var card_info string //卡信息
  14133. //var busi_card_info string
  14134. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14135. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14136. //fmt.Println(card_info)
  14137. //fmt.Println(busi_card_info)
  14138. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14139. result, _ := json.Marshal(respJSON)
  14140. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14141. utils.ErrorLog("解析失败:%v", err)
  14142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14143. return
  14144. }
  14145. res.ErrMsg = res10265.ErrMsg
  14146. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14147. res.Infcode = infocode
  14148. res.Output = res10265.Output
  14149. res.InfRefmsgid = res10265.InfRefmsgid
  14150. }
  14151. if res.Infcode == 0 {
  14152. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14153. if err == gorm.ErrRecordNotFound {
  14154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14155. return
  14156. } else if err != nil {
  14157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14158. return
  14159. } else {
  14160. if card_type == "1" {
  14161. bas := strings.Split(card_info, "|")
  14162. basNumber := bas[2]
  14163. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14164. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14165. infoStr := string(Iinfos)
  14166. idetinfoStr := string(Idetinfos)
  14167. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  14168. psn := &models.HisPsn{
  14169. PsnNo: res.Output.Baseinfo.PsnNo,
  14170. PatientId: patient.ID,
  14171. Certno: res.Output.Baseinfo.Certno,
  14172. Brdy: b,
  14173. Age: float64(age),
  14174. Gend: res.Output.Baseinfo.Gend,
  14175. Naty: res.Output.Baseinfo.Naty,
  14176. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14177. PsnName: res.Output.Baseinfo.PsnName,
  14178. Idetinfo: idetinfoStr,
  14179. Insuinfo: infoStr,
  14180. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14181. CardInfo: card_info,
  14182. VerifyNumber: busi_card_info,
  14183. }
  14184. service.CreateHisPsn(psn)
  14185. var rf []*ResultFive
  14186. json.Unmarshal([]byte(infoStr), &rf)
  14187. var insutypes []*ResultFive
  14188. var insutype string
  14189. var is390 int = 0
  14190. var is310 int = 0
  14191. for _, item := range rf {
  14192. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14193. insutypes = append(insutypes, item)
  14194. }
  14195. }
  14196. if len(insutypes) == 1 {
  14197. insutype = insutypes[0].Insutype
  14198. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14199. } else {
  14200. for _, i := range insutypes {
  14201. if i.Insutype == "390" {
  14202. is390 = 1
  14203. }
  14204. if i.Insutype == "310" {
  14205. is310 = 1
  14206. }
  14207. }
  14208. }
  14209. if is390 == 1 {
  14210. insutype = "390"
  14211. }
  14212. if is310 == 1 {
  14213. insutype = "310"
  14214. }
  14215. if len(insutypes) == 0 {
  14216. insutype = "310"
  14217. }
  14218. c.ServeSuccessJSON(map[string]interface{}{
  14219. "patient": patient,
  14220. "number": basNumber,
  14221. "insutype": insutype,
  14222. })
  14223. } else {
  14224. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14225. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14226. infoStr := string(Iinfos)
  14227. idetinfoStr := string(Idetinfos)
  14228. psn := &models.HisPsn{
  14229. PsnNo: res.Output.Baseinfo.PsnNo,
  14230. PatientId: patient.ID,
  14231. Certno: res.Output.Baseinfo.Certno,
  14232. Gend: res.Output.Baseinfo.Gend,
  14233. Naty: res.Output.Baseinfo.Naty,
  14234. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14235. PsnName: res.Output.Baseinfo.PsnName,
  14236. Idetinfo: idetinfoStr,
  14237. Insuinfo: infoStr,
  14238. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14239. CardInfo: card_info,
  14240. VerifyNumber: token,
  14241. }
  14242. service.CreateHisPsn(psn)
  14243. c.ServeSuccessJSON(map[string]interface{}{
  14244. "patient": patient,
  14245. "number": token,
  14246. })
  14247. }
  14248. }
  14249. } else {
  14250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14251. return
  14252. }
  14253. } else { //读卡失败
  14254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14255. return
  14256. }
  14257. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14258. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  14259. cardnum = DeleteExtraSpaceTwo(cardnum)
  14260. cardCode = DeleteExtraSpaceTwo(cardCode)
  14261. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  14262. name = DeleteExtraSpaceTwo(name)
  14263. errmsg = DeleteExtraSpaceTwo(errmsg)
  14264. cardnum = Remove0000(cardnum)
  14265. cardCode = Remove0000(cardCode)
  14266. id_card_no = Remove0000(id_card_no)
  14267. name = Remove0000(name)
  14268. errmsg = Remove0000(errmsg)
  14269. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  14270. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  14271. //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)
  14272. //fmt.Println(result2)
  14273. //fmt.Println(requestLog2)
  14274. //fmt.Println(errMsgLog2)
  14275. 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)
  14276. saveLog(result, requestLog, "1101", "获取人员信息")
  14277. fmt.Println(errMsgLog)
  14278. if len(errMsgLog) > 0 {
  14279. } else {
  14280. var dat map[string]interface{}
  14281. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14282. fmt.Println(dat)
  14283. } else {
  14284. fmt.Println(err)
  14285. }
  14286. userJSONBytes, _ := json.Marshal(dat)
  14287. var res ResultTwo
  14288. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14289. utils.ErrorLog("解析失败:%v", err)
  14290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14291. return
  14292. }
  14293. res.ErrMsg = errMsgLog
  14294. if res.Infcode == 0 {
  14295. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  14296. if err == gorm.ErrRecordNotFound {
  14297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14298. return
  14299. } else if err != nil {
  14300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14301. return
  14302. } else {
  14303. fmt.Println(res)
  14304. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14305. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14306. infoStr := string(Iinfos)
  14307. idetinfoStr := string(Idetinfos)
  14308. var rf []*ResultFive
  14309. json.Unmarshal([]byte(infoStr), &rf)
  14310. var insutypes []*ResultFive
  14311. var insutype string
  14312. var is390 int = 0
  14313. var is310 int = 0
  14314. for _, item := range rf {
  14315. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14316. insutypes = append(insutypes, item)
  14317. }
  14318. }
  14319. if len(insutypes) == 1 {
  14320. insutype = insutypes[0].Insutype
  14321. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14322. } else {
  14323. for _, i := range insutypes {
  14324. if i.Insutype == "390" {
  14325. is390 = 1
  14326. }
  14327. if i.Insutype == "310" {
  14328. is310 = 1
  14329. }
  14330. }
  14331. }
  14332. if is390 == 1 {
  14333. insutype = "390"
  14334. }
  14335. if is310 == 1 {
  14336. insutype = "310"
  14337. }
  14338. if len(insutypes) == 0 {
  14339. insutype = "390"
  14340. }
  14341. var insuplc_admdvs string
  14342. for _, item := range rf {
  14343. if item.Insutype == insutype {
  14344. insuplc_admdvs = item.InsuplcAdmdvs
  14345. }
  14346. }
  14347. psn := &models.HisPsn{
  14348. PsnNo: res.Output.Baseinfo.PsnNo,
  14349. PatientId: patient.ID,
  14350. Certno: res.Output.Baseinfo.Certno,
  14351. Gend: res.Output.Baseinfo.Gend,
  14352. Naty: res.Output.Baseinfo.Naty,
  14353. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14354. PsnName: res.Output.Baseinfo.PsnName,
  14355. Idetinfo: idetinfoStr,
  14356. Insuinfo: infoStr,
  14357. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14358. CardInfo: basStr,
  14359. VerifyNumber: "",
  14360. InsuplcAdmdvs: insuplc_admdvs,
  14361. }
  14362. service.CreateHisPsn(psn)
  14363. c.ServeSuccessJSON(map[string]interface{}{
  14364. "patient": patient,
  14365. "number": cardnum,
  14366. "insutype": insutype,
  14367. })
  14368. }
  14369. } else {
  14370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14371. return
  14372. }
  14373. }
  14374. } else if miConfig.MdtrtareaAdmvs == "360302" {
  14375. fmt.Println(initFlag)
  14376. fmt.Println("initFlag")
  14377. if initFlag == 0 {
  14378. c.TestGetJiangXiBasBaseInit()
  14379. }
  14380. basStr := c.GetBasBaseInfo()
  14381. if len(basStr) == 0 {
  14382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14383. return
  14384. }
  14385. fmt.Println(basStr)
  14386. bas := strings.Split(basStr, "|")
  14387. basNumber := bas[1]
  14388. fmt.Println(basNumber)
  14389. card := bas[2]
  14390. card_sn := bas[3]
  14391. fmt.Println(card_sn)
  14392. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14393. 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)
  14394. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14395. var dat map[string]interface{}
  14396. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14397. fmt.Println(dat)
  14398. } else {
  14399. fmt.Println(err)
  14400. }
  14401. userJSONBytes, _ := json.Marshal(dat)
  14402. var res ResultTwo
  14403. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14404. utils.ErrorLog("解析失败:%v", err)
  14405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14406. return
  14407. }
  14408. if res.Infcode == 0 {
  14409. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14410. if err == gorm.ErrRecordNotFound {
  14411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14412. return
  14413. } else if err != nil {
  14414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14415. return
  14416. } else {
  14417. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14418. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14419. infoStr := string(Iinfos)
  14420. idetinfoStr := string(Idetinfos)
  14421. var rf []*ResultFive
  14422. json.Unmarshal([]byte(infoStr), &rf)
  14423. var insutypes []*ResultFive
  14424. var insutype string
  14425. var is390 int = 0
  14426. var is310 int = 0
  14427. var insuplc_admdvs string
  14428. for _, item := range rf {
  14429. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14430. insutypes = append(insutypes, item)
  14431. }
  14432. }
  14433. if len(insutypes) == 1 {
  14434. insutype = insutypes[0].Insutype
  14435. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14436. } else {
  14437. for _, i := range insutypes {
  14438. if i.Insutype == "390" {
  14439. is390 = 1
  14440. }
  14441. if i.Insutype == "310" {
  14442. is310 = 1
  14443. }
  14444. }
  14445. }
  14446. if is390 == 1 {
  14447. insutype = "390"
  14448. }
  14449. if is310 == 1 {
  14450. insutype = "310"
  14451. }
  14452. if len(insutypes) == 0 {
  14453. insutype = "310"
  14454. }
  14455. for _, item := range rf {
  14456. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14457. insuplc_admdvs = item.InsuplcAdmdvs
  14458. }
  14459. }
  14460. psn := &models.HisPsn{
  14461. PsnNo: res.Output.Baseinfo.PsnNo,
  14462. PatientId: patient.ID,
  14463. Certno: res.Output.Baseinfo.Certno,
  14464. Gend: res.Output.Baseinfo.Gend,
  14465. Naty: res.Output.Baseinfo.Naty,
  14466. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14467. PsnName: res.Output.Baseinfo.PsnName,
  14468. Idetinfo: idetinfoStr,
  14469. Insuinfo: infoStr,
  14470. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14471. CardInfo: basStr,
  14472. InsuplcAdmdvs: insuplc_admdvs,
  14473. VerifyNumber: "",
  14474. }
  14475. service.CreateHisPsn(psn)
  14476. c.ServeSuccessJSON(map[string]interface{}{
  14477. "patient": patient,
  14478. "number": basNumber,
  14479. "insutype": insutype,
  14480. })
  14481. }
  14482. } else {
  14483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14484. return
  14485. }
  14486. } else if miConfig.MdtrtareaAdmvs == "361025" {
  14487. basStr := c.GetBasBaseInfo22222()
  14488. fmt.Println(basStr)
  14489. if len(basStr) == 0 {
  14490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14491. return
  14492. }
  14493. fmt.Println(basStr)
  14494. bas := strings.Split(basStr, "|")
  14495. basNumber := bas[2] //卡号
  14496. card_sn := bas[3] //
  14497. id_card_No := bas[1] //卡号
  14498. fmt.Println(basNumber)
  14499. fmt.Println(card_sn)
  14500. fmt.Println(id_card_No)
  14501. var patient service.Patients
  14502. if len(id_card_No) == 0 {
  14503. patient, _ = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14504. } else {
  14505. patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14506. }
  14507. 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)
  14508. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14509. var dat map[string]interface{}
  14510. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14511. fmt.Println(dat)
  14512. } else {
  14513. fmt.Println(err)
  14514. }
  14515. userJSONBytes, _ := json.Marshal(dat)
  14516. var res ResultTwo
  14517. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14518. utils.ErrorLog("解析失败:%v", err)
  14519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14520. return
  14521. }
  14522. if res.Infcode == 0 {
  14523. var pateint2 service.Patients
  14524. var err error
  14525. if len(id_card_No) == 0 {
  14526. pateint2, err = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14527. } else {
  14528. pateint2, err = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14529. //patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14530. }
  14531. if err == gorm.ErrRecordNotFound {
  14532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14533. return
  14534. } else if err != nil {
  14535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14536. return
  14537. } else {
  14538. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14539. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14540. infoStr := string(Iinfos)
  14541. idetinfoStr := string(Idetinfos)
  14542. var rf []*ResultFive
  14543. json.Unmarshal([]byte(infoStr), &rf)
  14544. var insutypes []*ResultFive
  14545. var insutype string
  14546. var is390 int = 0
  14547. var is310 int = 0
  14548. var insuplc_admdvs string
  14549. for _, item := range rf {
  14550. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14551. insutypes = append(insutypes, item)
  14552. }
  14553. }
  14554. if len(insutypes) == 1 {
  14555. insutype = insutypes[0].Insutype
  14556. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14557. } else {
  14558. for _, i := range insutypes {
  14559. if i.Insutype == "390" {
  14560. is390 = 1
  14561. }
  14562. if i.Insutype == "310" {
  14563. is310 = 1
  14564. }
  14565. }
  14566. }
  14567. if is390 == 1 {
  14568. insutype = "390"
  14569. }
  14570. if is310 == 1 {
  14571. insutype = "310"
  14572. }
  14573. if len(insutypes) == 0 {
  14574. insutype = "310"
  14575. }
  14576. for _, item := range rf {
  14577. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14578. insuplc_admdvs = item.InsuplcAdmdvs
  14579. }
  14580. }
  14581. psn := &models.HisPsn{
  14582. PsnNo: res.Output.Baseinfo.PsnNo,
  14583. PatientId: pateint2.ID,
  14584. Certno: res.Output.Baseinfo.Certno,
  14585. Gend: res.Output.Baseinfo.Gend,
  14586. Naty: res.Output.Baseinfo.Naty,
  14587. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14588. PsnName: res.Output.Baseinfo.PsnName,
  14589. Idetinfo: idetinfoStr,
  14590. Insuinfo: infoStr,
  14591. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14592. CardInfo: basStr,
  14593. InsuplcAdmdvs: insuplc_admdvs,
  14594. VerifyNumber: "",
  14595. }
  14596. service.CreateHisPsn(psn)
  14597. c.ServeSuccessJSON(map[string]interface{}{
  14598. "patient": patient,
  14599. "number": basNumber,
  14600. "insutype": insutype,
  14601. })
  14602. }
  14603. } else {
  14604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14605. return
  14606. }
  14607. } else if miConfig.MdtrtareaAdmvs == "360100" {
  14608. fmt.Println(initFlag)
  14609. fmt.Println("initFlag")
  14610. if initFlag == 0 {
  14611. c.TestGetJiangXiBasBaseInittwo()
  14612. }
  14613. basStr := c.GetBasBaseInfo()
  14614. if len(basStr) == 0 {
  14615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14616. return
  14617. }
  14618. fmt.Println(basStr)
  14619. bas := strings.Split(basStr, "|")
  14620. basNumber := bas[1]
  14621. fmt.Println(basNumber)
  14622. card_sn := bas[3]
  14623. fmt.Println(card_sn)
  14624. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14625. 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)
  14626. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14627. var dat map[string]interface{}
  14628. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14629. fmt.Println(dat)
  14630. } else {
  14631. fmt.Println(err)
  14632. }
  14633. userJSONBytes, _ := json.Marshal(dat)
  14634. var res ResultTwo
  14635. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14636. utils.ErrorLog("解析失败:%v", err)
  14637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14638. return
  14639. }
  14640. if res.Infcode == 0 {
  14641. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14642. if err == gorm.ErrRecordNotFound {
  14643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14644. return
  14645. } else if err != nil {
  14646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14647. return
  14648. } else {
  14649. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14650. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14651. infoStr := string(Iinfos)
  14652. idetinfoStr := string(Idetinfos)
  14653. var rf []*ResultFive
  14654. json.Unmarshal([]byte(infoStr), &rf)
  14655. var insutypes []*ResultFive
  14656. var insutype string
  14657. var is390 int = 0
  14658. var is310 int = 0
  14659. var insuplc_admdvs string
  14660. for _, item := range rf {
  14661. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14662. insutypes = append(insutypes, item)
  14663. }
  14664. }
  14665. if len(insutypes) == 1 {
  14666. insutype = insutypes[0].Insutype
  14667. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14668. } else {
  14669. for _, i := range insutypes {
  14670. if i.Insutype == "390" {
  14671. is390 = 1
  14672. }
  14673. if i.Insutype == "310" {
  14674. is310 = 1
  14675. }
  14676. }
  14677. }
  14678. if is390 == 1 {
  14679. insutype = "390"
  14680. }
  14681. if is310 == 1 {
  14682. insutype = "310"
  14683. }
  14684. if len(insutypes) == 0 {
  14685. insutype = "310"
  14686. }
  14687. for _, item := range rf {
  14688. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14689. insuplc_admdvs = item.InsuplcAdmdvs
  14690. }
  14691. }
  14692. psn := &models.HisPsn{
  14693. PsnNo: res.Output.Baseinfo.PsnNo,
  14694. PatientId: patient.ID,
  14695. Certno: res.Output.Baseinfo.Certno,
  14696. Gend: res.Output.Baseinfo.Gend,
  14697. Naty: res.Output.Baseinfo.Naty,
  14698. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14699. PsnName: res.Output.Baseinfo.PsnName,
  14700. Idetinfo: idetinfoStr,
  14701. Insuinfo: infoStr,
  14702. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14703. CardInfo: basStr,
  14704. InsuplcAdmdvs: insuplc_admdvs,
  14705. VerifyNumber: "",
  14706. }
  14707. service.CreateHisPsn(psn)
  14708. c.ServeSuccessJSON(map[string]interface{}{
  14709. "patient": patient,
  14710. "number": basNumber,
  14711. "insutype": insutype,
  14712. })
  14713. }
  14714. } else {
  14715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14716. return
  14717. }
  14718. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14719. fmt.Println(initFlag)
  14720. fmt.Println("initFlag")
  14721. if initFlag == 0 {
  14722. c.TestGetHnBasBaseInit()
  14723. }
  14724. basStr := c.GetBasBaseInfo()
  14725. if len(basStr) == 0 {
  14726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14727. return
  14728. }
  14729. fmt.Println(basStr)
  14730. bas := strings.Split(basStr, "|")
  14731. basNumber := bas[1]
  14732. fmt.Println(basNumber)
  14733. card_sn := bas[3]
  14734. card_no := bas[2]
  14735. fmt.Println(card_sn)
  14736. name := bas[4]
  14737. name = ConvertToString(name, "gbk", "utf-8")
  14738. 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)
  14739. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14740. var dat map[string]interface{}
  14741. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14742. fmt.Println(dat)
  14743. } else {
  14744. fmt.Println(err)
  14745. }
  14746. userJSONBytes, _ := json.Marshal(dat)
  14747. var res ResultTwo
  14748. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14749. utils.ErrorLog("解析失败:%v", err)
  14750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14751. return
  14752. }
  14753. if res.Infcode == 0 {
  14754. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14755. if err == gorm.ErrRecordNotFound {
  14756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14757. return
  14758. } else if err != nil {
  14759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14760. return
  14761. } else {
  14762. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14763. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14764. infoStr := string(Iinfos)
  14765. idetinfoStr := string(Idetinfos)
  14766. psn := &models.HisPsn{
  14767. PsnNo: res.Output.Baseinfo.PsnNo,
  14768. PatientId: patient.ID,
  14769. Certno: res.Output.Baseinfo.Certno,
  14770. Gend: res.Output.Baseinfo.Gend,
  14771. Naty: res.Output.Baseinfo.Naty,
  14772. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14773. PsnName: res.Output.Baseinfo.PsnName,
  14774. Idetinfo: idetinfoStr,
  14775. Insuinfo: infoStr,
  14776. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14777. CardInfo: basStr,
  14778. VerifyNumber: "",
  14779. }
  14780. service.CreateHisPsn(psn)
  14781. var rf []*ResultFive
  14782. json.Unmarshal([]byte(infoStr), &rf)
  14783. var insutypes []*ResultFive
  14784. var insutype string
  14785. var is390 int = 0
  14786. var is310 int = 0
  14787. for _, item := range rf {
  14788. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14789. insutypes = append(insutypes, item)
  14790. }
  14791. }
  14792. if len(insutypes) == 1 {
  14793. insutype = insutypes[0].Insutype
  14794. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14795. } else {
  14796. for _, i := range insutypes {
  14797. if i.Insutype == "390" {
  14798. is390 = 1
  14799. }
  14800. if i.Insutype == "310" {
  14801. is310 = 1
  14802. }
  14803. }
  14804. }
  14805. if is390 == 1 {
  14806. insutype = "390"
  14807. }
  14808. if is310 == 1 {
  14809. insutype = "310"
  14810. }
  14811. if len(insutypes) == 0 {
  14812. insutype = "310"
  14813. }
  14814. c.ServeSuccessJSON(map[string]interface{}{
  14815. "patient": patient,
  14816. "number": basNumber,
  14817. "insutype": insutype,
  14818. })
  14819. }
  14820. } else {
  14821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14822. return
  14823. }
  14824. } else if miConfig.MdtrtareaAdmvs == "150404" {
  14825. var api string
  14826. 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 +
  14827. "&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
  14828. fmt.Println(api)
  14829. resp, requestErr := http.Get(api)
  14830. if requestErr != nil {
  14831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14832. return
  14833. }
  14834. body, ioErr := ioutil.ReadAll(resp.Body)
  14835. if ioErr != nil {
  14836. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14838. return
  14839. }
  14840. var respJSON map[string]interface{}
  14841. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14842. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14844. return
  14845. }
  14846. var res ResultTwo //1101结果
  14847. var res10265 ResultTwo10265 //1101结果
  14848. var card_info string //卡信息
  14849. token := respJSON["data"].(map[string]interface{})["token"].(string)
  14850. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14851. result, _ := json.Marshal(respJSON)
  14852. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14853. utils.ErrorLog("解析失败:%v", err)
  14854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14855. return
  14856. }
  14857. res.ErrMsg = res10265.ErrMsg
  14858. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14859. res.Infcode = infocode
  14860. res.Output = res10265.Output
  14861. res.InfRefmsgid = res10265.InfRefmsgid
  14862. if res.Infcode == 0 {
  14863. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14864. if err == gorm.ErrRecordNotFound {
  14865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14866. return
  14867. } else if err != nil {
  14868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14869. return
  14870. } else {
  14871. bas := strings.Split(card_info, "|")
  14872. basNumber := bas[2]
  14873. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14874. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14875. infoStr := string(Iinfos)
  14876. idetinfoStr := string(Idetinfos)
  14877. psn := &models.HisPsn{
  14878. PsnNo: res.Output.Baseinfo.PsnNo,
  14879. PatientId: patient.ID,
  14880. Certno: res.Output.Baseinfo.Certno,
  14881. Gend: res.Output.Baseinfo.Gend,
  14882. Naty: res.Output.Baseinfo.Naty,
  14883. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14884. PsnName: res.Output.Baseinfo.PsnName,
  14885. Idetinfo: idetinfoStr,
  14886. Insuinfo: infoStr,
  14887. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14888. CardInfo: card_info,
  14889. VerifyNumber: token,
  14890. }
  14891. service.CreateHisPsn(psn)
  14892. var rf []*ResultFive
  14893. json.Unmarshal([]byte(infoStr), &rf)
  14894. var insutypes []*ResultFive
  14895. var insutype string
  14896. var is390 int = 0
  14897. var is310 int = 0
  14898. for _, item := range rf {
  14899. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14900. insutypes = append(insutypes, item)
  14901. }
  14902. }
  14903. if len(insutypes) == 1 {
  14904. insutype = insutypes[0].Insutype
  14905. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14906. } else {
  14907. for _, i := range insutypes {
  14908. if i.Insutype == "390" {
  14909. is390 = 1
  14910. }
  14911. if i.Insutype == "310" {
  14912. is310 = 1
  14913. }
  14914. }
  14915. }
  14916. if is390 == 1 {
  14917. insutype = "390"
  14918. }
  14919. if is310 == 1 {
  14920. insutype = "310"
  14921. }
  14922. if len(insutypes) == 0 {
  14923. insutype = "310"
  14924. }
  14925. c.ServeSuccessJSON(map[string]interface{}{
  14926. "patient": patient,
  14927. "number": basNumber,
  14928. "insutype": insutype,
  14929. })
  14930. }
  14931. } else {
  14932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14933. return
  14934. }
  14935. } else if miConfig.MdtrtareaAdmvs == "450721" {
  14936. res := c.GetoleInfo()
  14937. if res.Infcode == 0 {
  14938. var result string
  14939. if res.Output.MdtrtCertType == "01" {
  14940. 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)
  14941. } else if res.Output.MdtrtCertType == "02" {
  14942. 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)
  14943. } else if res.Output.MdtrtCertType == "03" {
  14944. 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)
  14945. }
  14946. var dat map[string]interface{}
  14947. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14948. fmt.Println(dat)
  14949. } else {
  14950. fmt.Println(err)
  14951. }
  14952. userJSONBytes, _ := json.Marshal(dat)
  14953. var res2 ResultTwo
  14954. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14955. utils.ErrorLog("解析失败:%v", err)
  14956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14957. return
  14958. }
  14959. if res2.Infcode == 0 {
  14960. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14961. if err == gorm.ErrRecordNotFound {
  14962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14963. return
  14964. } else if err != nil {
  14965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14966. return
  14967. } else {
  14968. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14969. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14970. infoStr := string(Iinfos)
  14971. idetinfoStr := string(Idetinfos)
  14972. var rf []*ResultFive
  14973. json.Unmarshal([]byte(infoStr), &rf)
  14974. var insutypes []*ResultFive
  14975. var insutype string
  14976. var is390 int = 0
  14977. var is310 int = 0
  14978. //var insuplc_admdvs string
  14979. for _, item := range rf {
  14980. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14981. insutypes = append(insutypes, item)
  14982. }
  14983. }
  14984. if len(insutypes) == 1 {
  14985. insutype = insutypes[0].Insutype
  14986. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14987. } else {
  14988. for _, i := range insutypes {
  14989. if i.Insutype == "390" {
  14990. is390 = 1
  14991. }
  14992. if i.Insutype == "310" {
  14993. is310 = 1
  14994. }
  14995. }
  14996. }
  14997. if is390 == 1 {
  14998. insutype = "390"
  14999. }
  15000. if is310 == 1 {
  15001. insutype = "310"
  15002. }
  15003. if len(insutypes) == 0 {
  15004. insutype = "310"
  15005. }
  15006. psn := &models.HisPsn{
  15007. PsnNo: res2.Output.Baseinfo.PsnNo,
  15008. PatientId: patient.ID,
  15009. Certno: res2.Output.Baseinfo.Certno,
  15010. Gend: res2.Output.Baseinfo.Gend,
  15011. Naty: res2.Output.Baseinfo.Naty,
  15012. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  15013. PsnName: res2.Output.Baseinfo.PsnName,
  15014. Idetinfo: idetinfoStr,
  15015. Insuinfo: infoStr,
  15016. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15017. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  15018. VerifyNumber: res.Output.EcToken,
  15019. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  15020. }
  15021. if res.Output.MdtrtCertType == "01" {
  15022. psn.VerifyNumber = res.Output.EcToken
  15023. //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)
  15024. } else if res.Output.MdtrtCertType == "02" {
  15025. psn.VerifyNumber = res.Output.MdtrtCertNo
  15026. //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)
  15027. } else if res.Output.MdtrtCertType == "03" {
  15028. psn.VerifyNumber = res.Output.MdtrtCertNo
  15029. //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)
  15030. }
  15031. var balc float64
  15032. for _, item := range rf {
  15033. if item.Insutype == insutype {
  15034. balc = item.Balc
  15035. }
  15036. }
  15037. service.CreateHisPsn(psn)
  15038. c.ServeSuccessJSON(map[string]interface{}{
  15039. "patient": patient,
  15040. "number": res.Output.CardNo,
  15041. "insutype": insutype,
  15042. "blac": balc,
  15043. "desc": idetinfoStr,
  15044. })
  15045. }
  15046. } else {
  15047. c.ServeSuccessJSON(map[string]interface{}{
  15048. "failed_code": -10,
  15049. "msg": res2.ErrMsg,
  15050. })
  15051. }
  15052. } else {
  15053. c.ServeSuccessJSON(map[string]interface{}{
  15054. "failed_code": -10,
  15055. "msg": res.ErrMsg,
  15056. })
  15057. }
  15058. } else if miConfig.MdtrtareaAdmvs == "341203" {
  15059. var api string
  15060. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15061. "&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
  15062. fmt.Println(api)
  15063. resp, requestErr := http.Get(api)
  15064. if requestErr != nil {
  15065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15066. return
  15067. }
  15068. body, ioErr := ioutil.ReadAll(resp.Body)
  15069. if ioErr != nil {
  15070. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15072. return
  15073. }
  15074. var respJSON map[string]interface{}
  15075. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15076. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15078. return
  15079. }
  15080. var status string
  15081. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15082. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15083. //console.log()
  15084. fmt.Println("type===")
  15085. fmt.Println(card_type)
  15086. var token string
  15087. var res ResultTwo //1101结果
  15088. //var res10265 ResultTwoesultTwo10265 //1101结果
  15089. var card_info string //卡信息
  15090. var busi_card_info string
  15091. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15092. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15093. if status == "0" { //读卡成功
  15094. if card_type == "1" {
  15095. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15096. result, _ := json.Marshal(respJSON)
  15097. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15098. utils.ErrorLog("解析失败:%v", err)
  15099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15100. return
  15101. }
  15102. } else {
  15103. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15104. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15105. result, _ := json.Marshal(respJSON)
  15106. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15107. utils.ErrorLog("解析失败:%v", err)
  15108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15109. return
  15110. }
  15111. }
  15112. if res.Infcode == 0 {
  15113. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15114. if err == gorm.ErrRecordNotFound {
  15115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15116. return
  15117. } else if err != nil {
  15118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15119. return
  15120. } else {
  15121. if card_type == "1" {
  15122. bas := strings.Split(card_info, "|")
  15123. basNumber := bas[2]
  15124. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15125. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15126. infoStr := string(Iinfos)
  15127. idetinfoStr := string(Idetinfos)
  15128. psn := &models.HisPsn{
  15129. PsnNo: res.Output.Baseinfo.PsnNo,
  15130. PatientId: patient.ID,
  15131. Certno: res.Output.Baseinfo.Certno,
  15132. Gend: res.Output.Baseinfo.Gend,
  15133. Naty: res.Output.Baseinfo.Naty,
  15134. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15135. PsnName: res.Output.Baseinfo.PsnName,
  15136. Idetinfo: idetinfoStr,
  15137. Insuinfo: infoStr,
  15138. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15139. CardInfo: card_info,
  15140. VerifyNumber: busi_card_info,
  15141. }
  15142. service.CreateHisPsn(psn)
  15143. var rf []*ResultFive
  15144. json.Unmarshal([]byte(infoStr), &rf)
  15145. var insutypes []*ResultFive
  15146. var insutype string
  15147. var is390 int = 0
  15148. var is310 int = 0
  15149. for _, item := range rf {
  15150. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15151. insutypes = append(insutypes, item)
  15152. }
  15153. }
  15154. if len(insutypes) == 1 {
  15155. insutype = insutypes[0].Insutype
  15156. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15157. } else {
  15158. for _, i := range insutypes {
  15159. if i.Insutype == "390" {
  15160. is390 = 1
  15161. }
  15162. if i.Insutype == "310" {
  15163. is310 = 1
  15164. }
  15165. }
  15166. }
  15167. if is390 == 1 {
  15168. insutype = "390"
  15169. }
  15170. if is310 == 1 {
  15171. insutype = "310"
  15172. }
  15173. if len(insutypes) == 0 {
  15174. insutype = "310"
  15175. }
  15176. c.ServeSuccessJSON(map[string]interface{}{
  15177. "patient": patient,
  15178. "number": basNumber,
  15179. "insutype": insutype,
  15180. })
  15181. } else {
  15182. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15183. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15184. infoStr := string(Iinfos)
  15185. idetinfoStr := string(Idetinfos)
  15186. psn := &models.HisPsn{
  15187. PsnNo: res.Output.Baseinfo.PsnNo,
  15188. PatientId: patient.ID,
  15189. Certno: res.Output.Baseinfo.Certno,
  15190. Gend: res.Output.Baseinfo.Gend,
  15191. Naty: res.Output.Baseinfo.Naty,
  15192. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15193. PsnName: res.Output.Baseinfo.PsnName,
  15194. Idetinfo: idetinfoStr,
  15195. Insuinfo: infoStr,
  15196. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15197. CardInfo: card_info,
  15198. VerifyNumber: token,
  15199. }
  15200. service.CreateHisPsn(psn)
  15201. c.ServeSuccessJSON(map[string]interface{}{
  15202. "patient": patient,
  15203. "number": token,
  15204. })
  15205. }
  15206. }
  15207. } else {
  15208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15209. return
  15210. }
  15211. } else { //读卡失败
  15212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15213. return
  15214. }
  15215. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15216. var api string
  15217. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15218. "&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
  15219. fmt.Println(api)
  15220. resp, requestErr := http.Get(api)
  15221. if requestErr != nil {
  15222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15223. return
  15224. }
  15225. body, ioErr := ioutil.ReadAll(resp.Body)
  15226. if ioErr != nil {
  15227. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15229. return
  15230. }
  15231. var respJSON map[string]interface{}
  15232. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15233. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15235. return
  15236. }
  15237. var status string
  15238. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15239. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15240. //console.log()
  15241. fmt.Println("type===")
  15242. fmt.Println(card_type)
  15243. var token string
  15244. var res ResultTwo //1101结果
  15245. //var res10265 ResultTwoesultTwo10265 //1101结果
  15246. var card_info string //卡信息
  15247. //var busi_card_info string
  15248. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15249. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15250. if status == "0" { //读卡成功
  15251. if card_type == "1" {
  15252. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15253. result, _ := json.Marshal(respJSON)
  15254. fmt.Println(result)
  15255. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15256. utils.ErrorLog("解析失败:%v", err)
  15257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15258. return
  15259. }
  15260. fmt.Println(res)
  15261. } else {
  15262. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15263. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15264. result, _ := json.Marshal(respJSON)
  15265. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15266. utils.ErrorLog("解析失败:%v", err)
  15267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15268. return
  15269. }
  15270. }
  15271. if res.Infcode == 0 {
  15272. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15273. if err == gorm.ErrRecordNotFound {
  15274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15275. return
  15276. } else if err != nil {
  15277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15278. return
  15279. } else {
  15280. if card_type == "1" {
  15281. bas := strings.Split(card_info, "|")
  15282. basNumber := bas[2]
  15283. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15284. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15285. infoStr := string(Iinfos)
  15286. idetinfoStr := string(Idetinfos)
  15287. psn := &models.HisPsn{
  15288. PsnNo: res.Output.Baseinfo.PsnNo,
  15289. PatientId: patient.ID,
  15290. Certno: res.Output.Baseinfo.Certno,
  15291. Gend: res.Output.Baseinfo.Gend,
  15292. Naty: res.Output.Baseinfo.Naty,
  15293. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15294. PsnName: res.Output.Baseinfo.PsnName,
  15295. Idetinfo: idetinfoStr,
  15296. Insuinfo: infoStr,
  15297. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15298. CardInfo: card_info,
  15299. //VerifyNumber: busi_card_info,
  15300. }
  15301. service.CreateHisPsn(psn)
  15302. var rf []*ResultFive
  15303. json.Unmarshal([]byte(infoStr), &rf)
  15304. var insutypes []*ResultFive
  15305. var insutype string
  15306. var is390 int = 0
  15307. var is310 int = 0
  15308. for _, item := range rf {
  15309. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15310. insutypes = append(insutypes, item)
  15311. }
  15312. }
  15313. if len(insutypes) == 1 {
  15314. insutype = insutypes[0].Insutype
  15315. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15316. } else {
  15317. for _, i := range insutypes {
  15318. if i.Insutype == "390" {
  15319. is390 = 1
  15320. }
  15321. if i.Insutype == "310" {
  15322. is310 = 1
  15323. }
  15324. }
  15325. }
  15326. if is390 == 1 {
  15327. insutype = "390"
  15328. }
  15329. if is310 == 1 {
  15330. insutype = "310"
  15331. }
  15332. if len(insutypes) == 0 {
  15333. insutype = "310"
  15334. }
  15335. c.ServeSuccessJSON(map[string]interface{}{
  15336. "patient": patient,
  15337. "number": basNumber,
  15338. "insutype": insutype,
  15339. })
  15340. } else {
  15341. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15342. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15343. infoStr := string(Iinfos)
  15344. idetinfoStr := string(Idetinfos)
  15345. psn := &models.HisPsn{
  15346. PsnNo: res.Output.Baseinfo.PsnNo,
  15347. PatientId: patient.ID,
  15348. Certno: res.Output.Baseinfo.Certno,
  15349. Gend: res.Output.Baseinfo.Gend,
  15350. Naty: res.Output.Baseinfo.Naty,
  15351. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15352. PsnName: res.Output.Baseinfo.PsnName,
  15353. Idetinfo: idetinfoStr,
  15354. Insuinfo: infoStr,
  15355. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15356. CardInfo: card_info,
  15357. VerifyNumber: token,
  15358. }
  15359. service.CreateHisPsn(psn)
  15360. c.ServeSuccessJSON(map[string]interface{}{
  15361. "patient": patient,
  15362. "number": token,
  15363. })
  15364. }
  15365. }
  15366. } else {
  15367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15368. return
  15369. }
  15370. } else { //读卡失败
  15371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15372. return
  15373. }
  15374. } else {
  15375. if initFlag == 0 {
  15376. c.TestGetBasBaseInit()
  15377. }
  15378. basStr := c.GetBasBaseInfo()
  15379. if len(basStr) == 0 {
  15380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15381. return
  15382. }
  15383. fmt.Println(basStr)
  15384. bas := strings.Split(basStr, "|")
  15385. basNumber := bas[1]
  15386. fmt.Println(basNumber)
  15387. card_sn := bas[3]
  15388. fmt.Println(card_sn)
  15389. cardNumber := bas[2]
  15390. fmt.Println(cardNumber)
  15391. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  15392. var result string
  15393. if bas[0][:2] == "44" {
  15394. 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)
  15395. } else {
  15396. 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)
  15397. }
  15398. var dat map[string]interface{}
  15399. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15400. fmt.Println(dat)
  15401. } else {
  15402. fmt.Println(err)
  15403. }
  15404. userJSONBytes, _ := json.Marshal(dat)
  15405. var res ResultTwo
  15406. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15407. utils.ErrorLog("解析失败:%v", err)
  15408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15409. return
  15410. }
  15411. if res.Infcode == 0 {
  15412. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  15413. if err == gorm.ErrRecordNotFound {
  15414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15415. return
  15416. } else if err != nil {
  15417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15418. return
  15419. } else {
  15420. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15421. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15422. infoStr := string(Iinfos)
  15423. idetinfoStr := string(Idetinfos)
  15424. var rf []*ResultFive
  15425. json.Unmarshal([]byte(infoStr), &rf)
  15426. var insutypes []*ResultFive
  15427. var insutype string
  15428. var is390 int = 0
  15429. var is310 int = 0
  15430. var insuplc_admdvs string
  15431. for _, item := range rf {
  15432. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15433. insutypes = append(insutypes, item)
  15434. }
  15435. }
  15436. if len(insutypes) == 1 {
  15437. insutype = insutypes[0].Insutype
  15438. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15439. } else {
  15440. for _, i := range insutypes {
  15441. if i.Insutype == "390" {
  15442. is390 = 1
  15443. }
  15444. if i.Insutype == "310" {
  15445. is310 = 1
  15446. }
  15447. }
  15448. }
  15449. if is390 == 1 {
  15450. insutype = "390"
  15451. }
  15452. if is310 == 1 {
  15453. insutype = "310"
  15454. }
  15455. if len(insutypes) == 0 {
  15456. insutype = "310"
  15457. }
  15458. for _, item := range rf {
  15459. if item.Insutype == insutype {
  15460. insuplc_admdvs = item.InsuplcAdmdvs
  15461. }
  15462. }
  15463. psn := &models.HisPsn{
  15464. PsnNo: res.Output.Baseinfo.PsnNo,
  15465. PatientId: patient.ID,
  15466. Certno: res.Output.Baseinfo.Certno,
  15467. Gend: res.Output.Baseinfo.Gend,
  15468. Naty: res.Output.Baseinfo.Naty,
  15469. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15470. PsnName: res.Output.Baseinfo.PsnName,
  15471. Idetinfo: idetinfoStr,
  15472. Insuinfo: infoStr,
  15473. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15474. CardInfo: basStr,
  15475. VerifyNumber: "",
  15476. InsuplcAdmdvs: insuplc_admdvs,
  15477. }
  15478. service.CreateHisPsn(psn)
  15479. c.ServeSuccessJSON(map[string]interface{}{
  15480. "patient": patient,
  15481. "insutype": insutype,
  15482. "number": basNumber,
  15483. })
  15484. }
  15485. } else {
  15486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15487. return
  15488. }
  15489. break
  15490. }
  15491. case 2:
  15492. if miConfig.MdtrtareaAdmvs == "430800" {
  15493. if initFlag == 0 {
  15494. c.TestGetHnBasBaseInit()
  15495. }
  15496. SFZStr := c.GetSFZBaseInfo()
  15497. if len(SFZStr) == 0 {
  15498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15499. return
  15500. }
  15501. fmt.Println(SFZStr)
  15502. id_card_str := strings.Split(SFZStr, "^")
  15503. card_no := id_card_str[0]
  15504. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  15505. //name := id_card_str[1]
  15506. //name = ConvertToString(name, "gbk", "utf-8")
  15507. 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)
  15508. var dat map[string]interface{}
  15509. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15510. fmt.Println(dat)
  15511. } else {
  15512. fmt.Println(err)
  15513. }
  15514. userJSONBytes, _ := json.Marshal(dat)
  15515. var res ResultTwo
  15516. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15517. utils.ErrorLog("解析失败:%v", err)
  15518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15519. return
  15520. }
  15521. if res.Infcode == 0 {
  15522. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  15523. if err == gorm.ErrRecordNotFound {
  15524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15525. return
  15526. } else if err != nil {
  15527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15528. return
  15529. } else {
  15530. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15531. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15532. infoStr := string(Iinfos)
  15533. idetinfoStr := string(Idetinfos)
  15534. var rf []*ResultFive
  15535. json.Unmarshal([]byte(infoStr), &rf)
  15536. var insutypes []*ResultFive
  15537. var insutype string
  15538. var is390 int = 0
  15539. var is310 int = 0
  15540. for _, item := range rf {
  15541. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15542. insutypes = append(insutypes, item)
  15543. }
  15544. }
  15545. if len(insutypes) == 1 {
  15546. insutype = insutypes[0].Insutype
  15547. } else {
  15548. for _, i := range insutypes {
  15549. if i.Insutype == "390" {
  15550. is390 = 1
  15551. }
  15552. if i.Insutype == "310" {
  15553. is310 = 1
  15554. }
  15555. }
  15556. }
  15557. if is390 == 1 {
  15558. insutype = "390"
  15559. }
  15560. if is310 == 1 {
  15561. insutype = "310"
  15562. }
  15563. if len(insutypes) == 0 {
  15564. insutype = "310"
  15565. }
  15566. var InsuplcAdmdvs string
  15567. for _, item := range rf {
  15568. if item.Insutype == insutype {
  15569. InsuplcAdmdvs = item.InsuplcAdmdvs
  15570. }
  15571. }
  15572. psn := &models.HisPsn{
  15573. PsnNo: res.Output.Baseinfo.PsnNo,
  15574. PatientId: patient.ID,
  15575. Certno: res.Output.Baseinfo.Certno,
  15576. Gend: res.Output.Baseinfo.Gend,
  15577. Naty: res.Output.Baseinfo.Naty,
  15578. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15579. PsnName: res.Output.Baseinfo.PsnName,
  15580. Idetinfo: idetinfoStr,
  15581. Insuinfo: infoStr,
  15582. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15583. CardInfo: SFZStr,
  15584. VerifyNumber: "",
  15585. InsuplcAdmdvs: InsuplcAdmdvs,
  15586. }
  15587. service.CreateHisPsn(psn)
  15588. c.ServeSuccessJSON(map[string]interface{}{
  15589. "patient": patient,
  15590. "number": card_no,
  15591. "insutype": insutype,
  15592. })
  15593. }
  15594. } else {
  15595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15596. return
  15597. }
  15598. } else if miConfig.MdtrtareaAdmvs == "420200" {
  15599. var res ResultTwo
  15600. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  15601. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15602. "&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)
  15603. resp, requestErr := http.Get(api)
  15604. if requestErr != nil {
  15605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15606. return
  15607. }
  15608. body, ioErr := ioutil.ReadAll(resp.Body)
  15609. if ioErr != nil {
  15610. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15612. return
  15613. }
  15614. var respJSON map[string]interface{}
  15615. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15616. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15618. return
  15619. }
  15620. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15621. result, _ := json.Marshal(respJSON)
  15622. fmt.Println("log")
  15623. fmt.Println(string(result))
  15624. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15625. utils.ErrorLog("解析失败:%v", err)
  15626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15627. return
  15628. }
  15629. if res.Infcode == 0 {
  15630. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15631. if err == gorm.ErrRecordNotFound {
  15632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15633. return
  15634. } else if err != nil {
  15635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15636. return
  15637. } else {
  15638. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15639. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15640. infoStr := string(Iinfos)
  15641. idetinfoStr := string(Idetinfos)
  15642. psn := &models.HisPsn{
  15643. PsnNo: res.Output.Baseinfo.PsnNo,
  15644. PatientId: patient.ID,
  15645. Certno: res.Output.Baseinfo.Certno,
  15646. Gend: res.Output.Baseinfo.Gend,
  15647. Naty: res.Output.Baseinfo.Naty,
  15648. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15649. PsnName: res.Output.Baseinfo.PsnName,
  15650. Idetinfo: idetinfoStr,
  15651. Insuinfo: infoStr,
  15652. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15653. }
  15654. service.CreateHisPsn(psn)
  15655. c.ServeSuccessJSON(map[string]interface{}{
  15656. "patient": patient,
  15657. "number": res.Output.Baseinfo.Certno,
  15658. })
  15659. }
  15660. } else {
  15661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15662. return
  15663. }
  15664. } else if miConfig.MdtrtareaAdmvs == "421182" {
  15665. var res ResultTwo
  15666. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  15667. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15668. "&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)
  15669. resp, requestErr := http.Get(api)
  15670. if requestErr != nil {
  15671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15672. return
  15673. }
  15674. body, ioErr := ioutil.ReadAll(resp.Body)
  15675. if ioErr != nil {
  15676. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15678. return
  15679. }
  15680. var respJSON map[string]interface{}
  15681. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15682. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15684. return
  15685. }
  15686. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15687. result, _ := json.Marshal(respJSON)
  15688. fmt.Println("log")
  15689. fmt.Println(string(result))
  15690. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15691. utils.ErrorLog("解析失败:%v", err)
  15692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15693. return
  15694. }
  15695. if res.Infcode == 0 {
  15696. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15697. if err == gorm.ErrRecordNotFound {
  15698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15699. return
  15700. } else if err != nil {
  15701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15702. return
  15703. } else {
  15704. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15705. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15706. infoStr := string(Iinfos)
  15707. idetinfoStr := string(Idetinfos)
  15708. psn := &models.HisPsn{
  15709. PsnNo: res.Output.Baseinfo.PsnNo,
  15710. PatientId: patient.ID,
  15711. Certno: res.Output.Baseinfo.Certno,
  15712. Gend: res.Output.Baseinfo.Gend,
  15713. Naty: res.Output.Baseinfo.Naty,
  15714. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15715. PsnName: res.Output.Baseinfo.PsnName,
  15716. Idetinfo: idetinfoStr,
  15717. Insuinfo: infoStr,
  15718. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15719. }
  15720. service.CreateHisPsn(psn)
  15721. c.ServeSuccessJSON(map[string]interface{}{
  15722. "patient": patient,
  15723. "number": res.Output.Baseinfo.Certno,
  15724. })
  15725. }
  15726. } else {
  15727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15728. return
  15729. }
  15730. } else if miConfig.MdtrtareaAdmvs == "420902" {
  15731. var res ResultTwo
  15732. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  15733. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15734. "&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)
  15735. resp, requestErr := http.Get(api)
  15736. if requestErr != nil {
  15737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15738. return
  15739. }
  15740. body, ioErr := ioutil.ReadAll(resp.Body)
  15741. if ioErr != nil {
  15742. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15744. return
  15745. }
  15746. var respJSON map[string]interface{}
  15747. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15748. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15750. return
  15751. }
  15752. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15753. result, _ := json.Marshal(respJSON)
  15754. fmt.Println("log")
  15755. fmt.Println(string(result))
  15756. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15757. utils.ErrorLog("解析失败:%v", err)
  15758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15759. return
  15760. }
  15761. if res.Infcode == 0 {
  15762. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15763. if err == gorm.ErrRecordNotFound {
  15764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15765. return
  15766. } else if err != nil {
  15767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15768. return
  15769. } else {
  15770. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15771. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15772. infoStr := string(Iinfos)
  15773. idetinfoStr := string(Idetinfos)
  15774. var rf []*ResultFive
  15775. json.Unmarshal([]byte(infoStr), &rf)
  15776. var insutypes []*ResultFive
  15777. var insutype string
  15778. var is390 int = 0
  15779. var is310 int = 0
  15780. for _, item := range rf {
  15781. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  15782. insutypes = append(insutypes, item)
  15783. }
  15784. }
  15785. if len(insutypes) == 1 {
  15786. insutype = insutypes[0].Insutype
  15787. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15788. } else {
  15789. for _, i := range insutypes {
  15790. if i.Insutype == "390" {
  15791. is390 = 1
  15792. }
  15793. if i.Insutype == "310" {
  15794. is310 = 1
  15795. }
  15796. }
  15797. }
  15798. if is390 == 1 {
  15799. insutype = "390"
  15800. }
  15801. if is310 == 1 {
  15802. insutype = "310"
  15803. }
  15804. if len(insutypes) == 0 {
  15805. insutype = "390"
  15806. }
  15807. var insuplc_admdvs string
  15808. for _, item := range rf {
  15809. if item.Insutype == insutype {
  15810. insuplc_admdvs = item.InsuplcAdmdvs
  15811. }
  15812. }
  15813. psn := &models.HisPsn{
  15814. PsnNo: res.Output.Baseinfo.PsnNo,
  15815. PatientId: patient.ID,
  15816. Certno: res.Output.Baseinfo.Certno,
  15817. Gend: res.Output.Baseinfo.Gend,
  15818. Naty: res.Output.Baseinfo.Naty,
  15819. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15820. PsnName: res.Output.Baseinfo.PsnName,
  15821. Idetinfo: idetinfoStr,
  15822. Insuinfo: infoStr,
  15823. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15824. InsuplcAdmdvs: insuplc_admdvs,
  15825. }
  15826. service.CreateHisPsn(psn)
  15827. c.ServeSuccessJSON(map[string]interface{}{
  15828. "patient": patient,
  15829. "number": res.Output.Baseinfo.Certno,
  15830. })
  15831. }
  15832. } else {
  15833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15834. return
  15835. }
  15836. } else if miConfig.MdtrtareaAdmvs == "450721" {
  15837. res := c.GetoleInfo()
  15838. if res.Infcode == 0 {
  15839. var result string
  15840. if res.Output.MdtrtCertType == "01" {
  15841. 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)
  15842. } else if res.Output.MdtrtCertType == "02" {
  15843. 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)
  15844. } else if res.Output.MdtrtCertType == "03" {
  15845. 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)
  15846. }
  15847. var dat map[string]interface{}
  15848. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15849. fmt.Println(dat)
  15850. } else {
  15851. fmt.Println(err)
  15852. }
  15853. userJSONBytes, _ := json.Marshal(dat)
  15854. var res2 ResultTwo
  15855. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15856. utils.ErrorLog("解析失败:%v", err)
  15857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15858. return
  15859. }
  15860. if res2.Infcode == 0 {
  15861. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  15862. if err == gorm.ErrRecordNotFound {
  15863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15864. return
  15865. } else if err != nil {
  15866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15867. return
  15868. } else {
  15869. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  15870. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  15871. infoStr := string(Iinfos)
  15872. idetinfoStr := string(Idetinfos)
  15873. var rf []*ResultFive
  15874. json.Unmarshal([]byte(infoStr), &rf)
  15875. var insutypes []*ResultFive
  15876. var insutype string
  15877. var is390 int = 0
  15878. var is310 int = 0
  15879. //var insuplc_admdvs string
  15880. for _, item := range rf {
  15881. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15882. insutypes = append(insutypes, item)
  15883. }
  15884. }
  15885. if len(insutypes) == 1 {
  15886. insutype = insutypes[0].Insutype
  15887. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15888. } else {
  15889. for _, i := range insutypes {
  15890. if i.Insutype == "390" {
  15891. is390 = 1
  15892. }
  15893. if i.Insutype == "310" {
  15894. is310 = 1
  15895. }
  15896. }
  15897. }
  15898. if is390 == 1 {
  15899. insutype = "390"
  15900. }
  15901. if is310 == 1 {
  15902. insutype = "310"
  15903. }
  15904. if len(insutypes) == 0 {
  15905. insutype = "310"
  15906. }
  15907. psn := &models.HisPsn{
  15908. PsnNo: res2.Output.Baseinfo.PsnNo,
  15909. PatientId: patient.ID,
  15910. //Brdy: res2.Output.Baseinfo.Brdy,
  15911. Certno: res2.Output.Baseinfo.Certno,
  15912. Gend: res2.Output.Baseinfo.Gend,
  15913. Naty: res2.Output.Baseinfo.Naty,
  15914. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  15915. PsnName: res2.Output.Baseinfo.PsnName,
  15916. Idetinfo: idetinfoStr,
  15917. Insuinfo: infoStr,
  15918. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15919. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  15920. VerifyNumber: res.Output.EcToken,
  15921. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  15922. }
  15923. service.CreateHisPsn(psn)
  15924. var balc float64
  15925. for _, item := range rf {
  15926. if item.Insutype == insutype {
  15927. balc = item.Balc
  15928. }
  15929. }
  15930. c.ServeSuccessJSON(map[string]interface{}{
  15931. "patient": patient,
  15932. "number": res.Output.CardNo,
  15933. "insutype": insutype,
  15934. "blac": balc,
  15935. "desc": idetinfoStr,
  15936. })
  15937. }
  15938. } else {
  15939. c.ServeSuccessJSON(map[string]interface{}{
  15940. "failed_code": -10,
  15941. "msg": res2.ErrMsg,
  15942. })
  15943. }
  15944. } else {
  15945. c.ServeSuccessJSON(map[string]interface{}{
  15946. "failed_code": -10,
  15947. "msg": res.ErrMsg,
  15948. })
  15949. }
  15950. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15951. var insuplc_admdvs string
  15952. if len(patient.InsuplcAdmdvs) > 0 {
  15953. insuplc_admdvs = patient.InsuplcAdmdvs
  15954. } else {
  15955. if len(insuplc_admdvs_str) > 0 {
  15956. insuplc_admdvs = insuplc_admdvs_str
  15957. } else {
  15958. insuplc_admdvs = miConfig.InsuplcAdmdvs
  15959. }
  15960. }
  15961. //请求内网数据
  15962. api := miConfig.SecretKey + "ahyb/1101?url=" + miConfig.Url + "&cert_no=" + patient.IdCardNo +
  15963. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15964. "&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=" + ""
  15965. resp, requestErr := http.Get(api)
  15966. if requestErr != nil {
  15967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15968. return
  15969. }
  15970. body, ioErr := ioutil.ReadAll(resp.Body)
  15971. if ioErr != nil {
  15972. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15974. return
  15975. }
  15976. var respJSON map[string]interface{}
  15977. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15978. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15980. return
  15981. }
  15982. status := respJSON["data"].(map[string]interface{})["status"].(string)
  15983. if status == "0" {
  15984. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  15985. c.ServeSuccessJSON(map[string]interface{}{
  15986. "failed_code": -10,
  15987. "msg": err_msg,
  15988. })
  15989. return
  15990. }
  15991. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15992. var res ResultTwo
  15993. result, _ := json.Marshal(respJSON)
  15994. fmt.Println("log")
  15995. fmt.Println(string(result))
  15996. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15997. utils.ErrorLog("解析失败:%v", err)
  15998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15999. return
  16000. }
  16001. if res.Infcode == 0 {
  16002. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16003. if err == gorm.ErrRecordNotFound {
  16004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16005. return
  16006. } else if err != nil {
  16007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16008. return
  16009. } else {
  16010. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16011. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16012. infoStr := string(Iinfos)
  16013. idetinfoStr := string(Idetinfos)
  16014. psn := &models.HisPsn{
  16015. PsnNo: res.Output.Baseinfo.PsnNo,
  16016. PatientId: patient.ID,
  16017. Certno: res.Output.Baseinfo.Certno,
  16018. Gend: res.Output.Baseinfo.Gend,
  16019. Naty: res.Output.Baseinfo.Naty,
  16020. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16021. PsnName: res.Output.Baseinfo.PsnName,
  16022. Idetinfo: idetinfoStr,
  16023. Insuinfo: infoStr,
  16024. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16025. }
  16026. service.CreateHisPsn(psn)
  16027. var rf []*ResultFive
  16028. json.Unmarshal([]byte(infoStr), &rf)
  16029. var insutypes []*ResultFive
  16030. var is390 int = 0
  16031. var is310 int = 0
  16032. var insutype string
  16033. for _, item := range rf {
  16034. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16035. insutypes = append(insutypes, item)
  16036. }
  16037. }
  16038. if len(insutypes) == 1 {
  16039. insutype = insutypes[0].Insutype
  16040. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16041. } else {
  16042. for _, i := range insutypes {
  16043. if i.Insutype == "390" {
  16044. is390 = 1
  16045. }
  16046. if i.Insutype == "310" {
  16047. is310 = 1
  16048. }
  16049. }
  16050. }
  16051. if is390 == 1 {
  16052. insutype = "390"
  16053. }
  16054. if is310 == 1 {
  16055. insutype = "310"
  16056. }
  16057. if len(insutypes) == 0 {
  16058. insutype = "390"
  16059. }
  16060. c.ServeSuccessJSON(map[string]interface{}{
  16061. "patient": patient,
  16062. "insutype": insutype,
  16063. "number": res.Output.Baseinfo.Certno,
  16064. "info": res,
  16065. })
  16066. }
  16067. } else {
  16068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16069. return
  16070. }
  16071. } else {
  16072. SFZStr := c.GetSFZBaseInfo()
  16073. id_card_str := strings.Split(SFZStr, "^")
  16074. id_card_number := id_card_str[0]
  16075. card_sn := ""
  16076. 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)
  16077. var dat map[string]interface{}
  16078. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16079. fmt.Println(dat)
  16080. } else {
  16081. fmt.Println(err)
  16082. }
  16083. userJSONBytes, _ := json.Marshal(dat)
  16084. var res ResultTwo
  16085. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16086. utils.ErrorLog("解析失败:%v", err)
  16087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16088. return
  16089. }
  16090. if res.Infcode == 0 {
  16091. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  16092. if err == gorm.ErrRecordNotFound {
  16093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16094. return
  16095. } else if err != nil {
  16096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16097. return
  16098. } else {
  16099. c.ServeSuccessJSON(map[string]interface{}{
  16100. "patient": patient,
  16101. "number": id_card_number,
  16102. })
  16103. }
  16104. } else {
  16105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16106. return
  16107. }
  16108. }
  16109. break
  16110. case 3:
  16111. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  16112. var api string
  16113. if miConfig.MdtrtareaAdmvs == "320830" {
  16114. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16115. "&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
  16116. fmt.Println(api)
  16117. } else if miConfig.MdtrtareaAdmvs == "320921" {
  16118. 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 +
  16119. "&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
  16120. fmt.Println(api)
  16121. } else {
  16122. 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 +
  16123. "&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)
  16124. }
  16125. resp, requestErr := http.Get(api)
  16126. if requestErr != nil {
  16127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16128. return
  16129. }
  16130. body, ioErr := ioutil.ReadAll(resp.Body)
  16131. if ioErr != nil {
  16132. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16134. return
  16135. }
  16136. var respJSON map[string]interface{}
  16137. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16138. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16140. return
  16141. }
  16142. var status string
  16143. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16144. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16145. var token string
  16146. var res ResultTwo //1101结果
  16147. var res10265 ResultTwo10265 //1101结果
  16148. var card_info string //卡信息
  16149. var busi_card_info string
  16150. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16151. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16152. if status == "0" { //读卡成功
  16153. if card_type == "1" {
  16154. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16155. result, _ := json.Marshal(respJSON)
  16156. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16157. utils.ErrorLog("解析失败:%v", err)
  16158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16159. return
  16160. }
  16161. res.ErrMsg = res10265.ErrMsg
  16162. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16163. res.Infcode = infocode
  16164. res.Output = res10265.Output
  16165. res.InfRefmsgid = res10265.InfRefmsgid
  16166. } else {
  16167. //var card_info string //卡信息
  16168. //var busi_card_info string
  16169. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16170. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16171. //fmt.Println(card_info)
  16172. //fmt.Println(busi_card_info)
  16173. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16174. result, _ := json.Marshal(respJSON)
  16175. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16176. utils.ErrorLog("解析失败:%v", err)
  16177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16178. return
  16179. }
  16180. res.ErrMsg = res10265.ErrMsg
  16181. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16182. res.Infcode = infocode
  16183. res.Output = res10265.Output
  16184. res.InfRefmsgid = res10265.InfRefmsgid
  16185. }
  16186. if res.Infcode == 0 {
  16187. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16188. if err == gorm.ErrRecordNotFound {
  16189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16190. return
  16191. } else if err != nil {
  16192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16193. return
  16194. } else {
  16195. if card_type == "1" {
  16196. bas := strings.Split(card_info, "|")
  16197. basNumber := bas[2]
  16198. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16199. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16200. infoStr := string(Iinfos)
  16201. idetinfoStr := string(Idetinfos)
  16202. psn := &models.HisPsn{
  16203. PsnNo: res.Output.Baseinfo.PsnNo,
  16204. PatientId: patient.ID,
  16205. Certno: res.Output.Baseinfo.Certno,
  16206. //Brdy: res.Output.Baseinfo.Brdy,
  16207. Gend: res.Output.Baseinfo.Gend,
  16208. Naty: res.Output.Baseinfo.Naty,
  16209. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16210. PsnName: res.Output.Baseinfo.PsnName,
  16211. Idetinfo: idetinfoStr,
  16212. Insuinfo: infoStr,
  16213. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16214. CardInfo: card_info,
  16215. VerifyNumber: busi_card_info,
  16216. }
  16217. service.CreateHisPsn(psn)
  16218. c.ServeSuccessJSON(map[string]interface{}{
  16219. "patient": patient,
  16220. "number": basNumber,
  16221. })
  16222. } else {
  16223. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16224. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16225. infoStr := string(Iinfos)
  16226. idetinfoStr := string(Idetinfos)
  16227. psn := &models.HisPsn{
  16228. PsnNo: res.Output.Baseinfo.PsnNo,
  16229. PatientId: patient.ID,
  16230. Certno: res.Output.Baseinfo.Certno,
  16231. Gend: res.Output.Baseinfo.Gend,
  16232. Naty: res.Output.Baseinfo.Naty,
  16233. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16234. PsnName: res.Output.Baseinfo.PsnName,
  16235. Idetinfo: idetinfoStr,
  16236. Insuinfo: infoStr,
  16237. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16238. CardInfo: card_info,
  16239. VerifyNumber: token,
  16240. }
  16241. service.CreateHisPsn(psn)
  16242. var rf []*ResultFive
  16243. json.Unmarshal([]byte(infoStr), &rf)
  16244. var insutypes []*ResultFive
  16245. var insutype string
  16246. var is390 int = 0
  16247. var is310 int = 0
  16248. for _, item := range rf {
  16249. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16250. insutypes = append(insutypes, item)
  16251. }
  16252. }
  16253. if len(insutypes) == 1 {
  16254. insutype = insutypes[0].Insutype
  16255. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16256. } else {
  16257. for _, i := range insutypes {
  16258. if i.Insutype == "390" {
  16259. is390 = 1
  16260. }
  16261. if i.Insutype == "310" {
  16262. is310 = 1
  16263. }
  16264. }
  16265. }
  16266. if is390 == 1 {
  16267. insutype = "390"
  16268. }
  16269. if is310 == 1 {
  16270. insutype = "310"
  16271. }
  16272. if len(insutypes) == 0 {
  16273. insutype = "310"
  16274. }
  16275. c.ServeSuccessJSON(map[string]interface{}{
  16276. "patient": patient,
  16277. "number": token,
  16278. "insutype": insutype,
  16279. })
  16280. }
  16281. }
  16282. } else {
  16283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16284. return
  16285. }
  16286. } else { //读卡失败
  16287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16288. return
  16289. }
  16290. }
  16291. break
  16292. case 4:
  16293. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  16294. var api string
  16295. if miConfig.MdtrtareaAdmvs == "320830" {
  16296. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16297. "&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
  16298. fmt.Println(api)
  16299. } else if miConfig.MdtrtareaAdmvs == "320921" {
  16300. 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 +
  16301. "&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
  16302. fmt.Println(api)
  16303. } else {
  16304. 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 +
  16305. "&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)
  16306. }
  16307. resp, requestErr := http.Get(api)
  16308. if requestErr != nil {
  16309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16310. return
  16311. }
  16312. body, ioErr := ioutil.ReadAll(resp.Body)
  16313. if ioErr != nil {
  16314. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16316. return
  16317. }
  16318. var respJSON map[string]interface{}
  16319. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16320. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16322. return
  16323. }
  16324. var status string
  16325. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16326. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16327. var token string
  16328. var res ResultTwo //1101结果
  16329. var res10265 ResultTwo10265 //1101结果
  16330. if status == "0" { //读卡成功
  16331. var card_info string //卡信息
  16332. var busi_card_info string
  16333. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16334. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16335. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16336. fmt.Println(card_info)
  16337. fmt.Println(busi_card_info)
  16338. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16339. result, _ := json.Marshal(respJSON)
  16340. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16341. utils.ErrorLog("解析失败:%v", err)
  16342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16343. return
  16344. }
  16345. res.ErrMsg = res10265.ErrMsg
  16346. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16347. res.Infcode = infocode
  16348. res.Output = res10265.Output
  16349. res.InfRefmsgid = res10265.InfRefmsgid
  16350. if res.Infcode == 0 {
  16351. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16352. if err == gorm.ErrRecordNotFound {
  16353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16354. return
  16355. } else if err != nil {
  16356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16357. return
  16358. } else {
  16359. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16360. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16361. infoStr := string(Iinfos)
  16362. idetinfoStr := string(Idetinfos)
  16363. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  16364. psn := &models.HisPsn{
  16365. PsnNo: res.Output.Baseinfo.PsnNo,
  16366. PatientId: patient.ID,
  16367. Certno: res.Output.Baseinfo.Certno,
  16368. Brdy: b,
  16369. Age: float64(age),
  16370. //Brdy: res.Output.Baseinfo.Brdy,
  16371. Gend: res.Output.Baseinfo.Gend,
  16372. Naty: res.Output.Baseinfo.Naty,
  16373. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16374. PsnName: res.Output.Baseinfo.PsnName,
  16375. Idetinfo: idetinfoStr,
  16376. Insuinfo: infoStr,
  16377. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16378. CardInfo: card_info,
  16379. VerifyNumber: token,
  16380. }
  16381. var rf []*ResultFive
  16382. json.Unmarshal([]byte(infoStr), &rf)
  16383. var insutypes []*ResultFive
  16384. var insutype string
  16385. var is390 int = 0
  16386. var is310 int = 0
  16387. for _, item := range rf {
  16388. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16389. insutypes = append(insutypes, item)
  16390. }
  16391. }
  16392. if len(insutypes) == 1 {
  16393. insutype = insutypes[0].Insutype
  16394. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16395. } else {
  16396. for _, i := range insutypes {
  16397. if i.Insutype == "390" {
  16398. is390 = 1
  16399. }
  16400. if i.Insutype == "310" {
  16401. is310 = 1
  16402. }
  16403. }
  16404. }
  16405. if is390 == 1 {
  16406. insutype = "390"
  16407. }
  16408. if is310 == 1 {
  16409. insutype = "310"
  16410. }
  16411. if len(insutypes) == 0 {
  16412. insutype = "310"
  16413. }
  16414. service.CreateHisPsn(psn)
  16415. c.ServeSuccessJSON(map[string]interface{}{
  16416. "patient": patient,
  16417. "number": token,
  16418. "insutype": insutype,
  16419. })
  16420. }
  16421. } else {
  16422. c.ServeSuccessJSON(map[string]interface{}{
  16423. "failed_code": -10,
  16424. "msg": res.ErrMsg,
  16425. })
  16426. }
  16427. } else { //读卡失败
  16428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16429. return
  16430. }
  16431. } else if miConfig.MdtrtareaAdmvs == "341203" {
  16432. var api string
  16433. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16434. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  16435. resp, requestErr := http.Get(api)
  16436. if requestErr != nil {
  16437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16438. return
  16439. }
  16440. body, ioErr := ioutil.ReadAll(resp.Body)
  16441. if ioErr != nil {
  16442. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16444. return
  16445. }
  16446. var respJSON map[string]interface{}
  16447. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16448. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16450. return
  16451. }
  16452. var status string
  16453. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16454. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16455. var token string
  16456. var res ResultTwo //1101结果
  16457. if status == "1" { //读卡成功
  16458. var card_info string //卡信息
  16459. var busi_card_info string
  16460. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16461. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16462. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16463. fmt.Println(card_info)
  16464. fmt.Println(busi_card_info)
  16465. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16466. result, _ := json.Marshal(respJSON)
  16467. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16468. utils.ErrorLog("解析失败:%v", err)
  16469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16470. return
  16471. }
  16472. if res.Infcode == 0 {
  16473. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16474. if err == gorm.ErrRecordNotFound {
  16475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16476. return
  16477. } else if err != nil {
  16478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16479. return
  16480. } else {
  16481. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16482. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16483. infoStr := string(Iinfos)
  16484. idetinfoStr := string(Idetinfos)
  16485. psn := &models.HisPsn{
  16486. PsnNo: res.Output.Baseinfo.PsnNo,
  16487. PatientId: patient.ID,
  16488. Certno: res.Output.Baseinfo.Certno,
  16489. Gend: res.Output.Baseinfo.Gend,
  16490. Naty: res.Output.Baseinfo.Naty,
  16491. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16492. PsnName: res.Output.Baseinfo.PsnName,
  16493. Idetinfo: idetinfoStr,
  16494. Insuinfo: infoStr,
  16495. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16496. CardInfo: card_info,
  16497. VerifyNumber: token,
  16498. }
  16499. var rf []*ResultFive
  16500. json.Unmarshal([]byte(infoStr), &rf)
  16501. var insutypes []*ResultFive
  16502. var insutype string
  16503. var is390 int = 0
  16504. var is310 int = 0
  16505. for _, item := range rf {
  16506. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16507. insutypes = append(insutypes, item)
  16508. }
  16509. }
  16510. if len(insutypes) == 1 {
  16511. insutype = insutypes[0].Insutype
  16512. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16513. } else {
  16514. for _, i := range insutypes {
  16515. if i.Insutype == "390" {
  16516. is390 = 1
  16517. }
  16518. if i.Insutype == "310" {
  16519. is310 = 1
  16520. }
  16521. }
  16522. }
  16523. if is390 == 1 {
  16524. insutype = "390"
  16525. }
  16526. if is310 == 1 {
  16527. insutype = "310"
  16528. }
  16529. if len(insutypes) == 0 {
  16530. insutype = "310"
  16531. }
  16532. service.CreateHisPsn(psn)
  16533. c.ServeSuccessJSON(map[string]interface{}{
  16534. "patient": patient,
  16535. "number": token,
  16536. "insutype": insutype,
  16537. })
  16538. }
  16539. } else {
  16540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16541. return
  16542. }
  16543. } else { //读卡失败
  16544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16545. return
  16546. }
  16547. } else if miConfig.MdtrtareaAdmvs == "340699" {
  16548. var api string
  16549. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16550. "&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
  16551. resp, requestErr := http.Get(api)
  16552. if requestErr != nil {
  16553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16554. return
  16555. }
  16556. body, ioErr := ioutil.ReadAll(resp.Body)
  16557. if ioErr != nil {
  16558. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16560. return
  16561. }
  16562. var respJSON map[string]interface{}
  16563. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16564. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16566. return
  16567. }
  16568. var status string
  16569. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16570. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16571. var token string
  16572. var res ResultTwo //1101结果
  16573. if status == "1" { //读卡成功
  16574. var card_info string //卡信息
  16575. var busi_card_info string
  16576. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16577. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16578. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16579. fmt.Println(card_info)
  16580. fmt.Println(busi_card_info)
  16581. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16582. result, _ := json.Marshal(respJSON)
  16583. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16584. utils.ErrorLog("解析失败:%v", err)
  16585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16586. return
  16587. }
  16588. if res.Infcode == 0 {
  16589. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16590. if err == gorm.ErrRecordNotFound {
  16591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16592. return
  16593. } else if err != nil {
  16594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16595. return
  16596. } else {
  16597. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16598. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16599. infoStr := string(Iinfos)
  16600. idetinfoStr := string(Idetinfos)
  16601. psn := &models.HisPsn{
  16602. PsnNo: res.Output.Baseinfo.PsnNo,
  16603. PatientId: patient.ID,
  16604. Certno: res.Output.Baseinfo.Certno,
  16605. Gend: res.Output.Baseinfo.Gend,
  16606. Naty: res.Output.Baseinfo.Naty,
  16607. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16608. PsnName: res.Output.Baseinfo.PsnName,
  16609. Idetinfo: idetinfoStr,
  16610. Insuinfo: infoStr,
  16611. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16612. CardInfo: card_info,
  16613. VerifyNumber: token,
  16614. }
  16615. var rf []*ResultFive
  16616. json.Unmarshal([]byte(infoStr), &rf)
  16617. var insutypes []*ResultFive
  16618. var insutype string
  16619. var is390 int = 0
  16620. var is310 int = 0
  16621. for _, item := range rf {
  16622. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16623. insutypes = append(insutypes, item)
  16624. }
  16625. }
  16626. if len(insutypes) == 1 {
  16627. insutype = insutypes[0].Insutype
  16628. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16629. } else {
  16630. for _, i := range insutypes {
  16631. if i.Insutype == "390" {
  16632. is390 = 1
  16633. }
  16634. if i.Insutype == "310" {
  16635. is310 = 1
  16636. }
  16637. }
  16638. }
  16639. if is390 == 1 {
  16640. insutype = "390"
  16641. }
  16642. if is310 == 1 {
  16643. insutype = "310"
  16644. }
  16645. if len(insutypes) == 0 {
  16646. insutype = "390"
  16647. }
  16648. service.CreateHisPsn(psn)
  16649. c.ServeSuccessJSON(map[string]interface{}{
  16650. "patient": patient,
  16651. "number": token,
  16652. "insutype": insutype,
  16653. })
  16654. }
  16655. } else {
  16656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16657. return
  16658. }
  16659. } else { //读卡失败
  16660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16661. return
  16662. }
  16663. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16664. //idNo := c.GetString("idNo")
  16665. //userName := c.GetString("userName")
  16666. //ecToken := c.GetString("ecToken")
  16667. //insuOrg := c.GetString("insuOrg")
  16668. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  16669. utils.ErrorLog("解析失败:%v", json_result)
  16670. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16671. type ELeData struct {
  16672. Data struct {
  16673. IdNo string `json:"idNo"`
  16674. IdType string `json:"idType"`
  16675. UserName string `json:"userName"`
  16676. EcToken string `json:"ecToken"`
  16677. InsuOrg string `json:"insuOrg"`
  16678. Gender string `json:"gender"`
  16679. Birthday string `json:"birthday"`
  16680. Nationality string `json:"nationality"`
  16681. Email string `json:"email"`
  16682. Extra string `json:"extra"`
  16683. } `json:"data"`
  16684. Code int `json:"code"`
  16685. Message string `json:"message"`
  16686. }
  16687. var ele ELeData
  16688. err := json.Unmarshal([]byte(json_result), &ele)
  16689. if err != nil {
  16690. utils.ErrorLog("解析失败:%v", err)
  16691. }
  16692. token := ele.Data.EcToken
  16693. token = Remove0000(token)
  16694. 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)
  16695. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16696. var res ResultTwo
  16697. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16698. utils.ErrorLog("解析失败:%v", err)
  16699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16700. return
  16701. }
  16702. if res.Infcode == 0 {
  16703. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16704. if err == gorm.ErrRecordNotFound {
  16705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16706. return
  16707. } else if err != nil {
  16708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16709. return
  16710. } else {
  16711. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16712. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16713. infoStr := string(Iinfos)
  16714. idetinfoStr := string(Idetinfos)
  16715. psn := &models.HisPsn{
  16716. PsnNo: res.Output.Baseinfo.PsnNo,
  16717. PatientId: patient.ID,
  16718. Certno: res.Output.Baseinfo.Certno,
  16719. Gend: res.Output.Baseinfo.Gend,
  16720. Naty: res.Output.Baseinfo.Naty,
  16721. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16722. PsnName: res.Output.Baseinfo.PsnName,
  16723. Idetinfo: idetinfoStr,
  16724. Insuinfo: infoStr,
  16725. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16726. CardInfo: "",
  16727. Stage: "1",
  16728. VerifyNumber: token,
  16729. InsuplcAdmdvs: ele.Data.InsuOrg,
  16730. }
  16731. service.CreateHisPsn(psn)
  16732. var rf []*ResultFive
  16733. json.Unmarshal([]byte(infoStr), &rf)
  16734. var insutypes []*ResultFive
  16735. var insutype string
  16736. var is390 int = 0
  16737. var is310 int = 0
  16738. for _, item := range rf {
  16739. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16740. insutypes = append(insutypes, item)
  16741. }
  16742. }
  16743. if len(insutypes) == 1 {
  16744. insutype = insutypes[0].Insutype
  16745. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16746. } else {
  16747. for _, i := range insutypes {
  16748. if i.Insutype == "390" {
  16749. is390 = 1
  16750. }
  16751. if i.Insutype == "310" {
  16752. is310 = 1
  16753. }
  16754. }
  16755. }
  16756. if is390 == 1 {
  16757. insutype = "390"
  16758. }
  16759. if is310 == 1 {
  16760. insutype = "310"
  16761. }
  16762. if len(insutypes) == 0 {
  16763. insutype = "310"
  16764. }
  16765. c.ServeSuccessJSON(map[string]interface{}{
  16766. "patient": patient,
  16767. "number": token,
  16768. "insutype": insutype,
  16769. })
  16770. }
  16771. } else {
  16772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16773. return
  16774. }
  16775. } else if miConfig.MdtrtareaAdmvs == "360302" {
  16776. //if initFlag == 0 {
  16777. //c.TestGetJiangXiBasBaseInit()
  16778. //}
  16779. //if initEleFlag == 0 {
  16780. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16781. //}
  16782. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16783. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16784. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16785. type ELeData struct {
  16786. Data struct {
  16787. IdNo string `json:"idNo"`
  16788. IdType string `json:"idType"`
  16789. UserName string `json:"userName"`
  16790. EcToken string `json:"ecToken"`
  16791. InsuOrg string `json:"insuOrg"`
  16792. Gender string `json:"gender"`
  16793. Birthday string `json:"birthday"`
  16794. Nationality string `json:"nationality"`
  16795. Email string `json:"email"`
  16796. Extra string `json:"extra"`
  16797. } `json:"data"`
  16798. Code int `json:"code"`
  16799. Message string `json:"message"`
  16800. }
  16801. var ele ELeData
  16802. err := json.Unmarshal([]byte(result), &ele)
  16803. if err != nil {
  16804. utils.ErrorLog("解析失败:%v", err)
  16805. }
  16806. token := ele.Data.EcToken
  16807. token = Remove0000(token)
  16808. 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)
  16809. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16810. var res ResultTwo
  16811. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16812. utils.ErrorLog("解析失败:%v", err)
  16813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16814. return
  16815. }
  16816. if res.Infcode == 0 {
  16817. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16818. if err == gorm.ErrRecordNotFound {
  16819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16820. return
  16821. } else if err != nil {
  16822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16823. return
  16824. } else {
  16825. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16826. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16827. infoStr := string(Iinfos)
  16828. idetinfoStr := string(Idetinfos)
  16829. psn := &models.HisPsn{
  16830. PsnNo: res.Output.Baseinfo.PsnNo,
  16831. PatientId: patient.ID,
  16832. Certno: res.Output.Baseinfo.Certno,
  16833. Gend: res.Output.Baseinfo.Gend,
  16834. Naty: res.Output.Baseinfo.Naty,
  16835. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16836. PsnName: res.Output.Baseinfo.PsnName,
  16837. Idetinfo: idetinfoStr,
  16838. Insuinfo: infoStr,
  16839. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16840. CardInfo: "",
  16841. VerifyNumber: token,
  16842. InsuplcAdmdvs: ele.Data.InsuOrg,
  16843. }
  16844. service.CreateHisPsn(psn)
  16845. var rf []*ResultFive
  16846. json.Unmarshal([]byte(infoStr), &rf)
  16847. var insutypes []*ResultFive
  16848. var insutype string
  16849. var is390 int = 0
  16850. var is310 int = 0
  16851. for _, item := range rf {
  16852. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16853. insutypes = append(insutypes, item)
  16854. }
  16855. }
  16856. if len(insutypes) == 1 {
  16857. insutype = insutypes[0].Insutype
  16858. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16859. } else {
  16860. for _, i := range insutypes {
  16861. if i.Insutype == "390" {
  16862. is390 = 1
  16863. }
  16864. if i.Insutype == "310" {
  16865. is310 = 1
  16866. }
  16867. }
  16868. }
  16869. if is390 == 1 {
  16870. insutype = "390"
  16871. }
  16872. if is310 == 1 {
  16873. insutype = "310"
  16874. }
  16875. if len(insutypes) == 0 {
  16876. insutype = "310"
  16877. }
  16878. c.ServeSuccessJSON(map[string]interface{}{
  16879. "patient": patient,
  16880. "number": token,
  16881. "insutype": insutype,
  16882. })
  16883. }
  16884. } else {
  16885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16886. return
  16887. }
  16888. } else if miConfig.MdtrtareaAdmvs == "361025" {
  16889. //if initFlag == 0 {
  16890. //c.TestGetJiangXiBasBaseInit()
  16891. //}
  16892. //if initEleFlag == 0 {
  16893. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16894. //}
  16895. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16896. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16897. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16898. type ELeData struct {
  16899. Data struct {
  16900. IdNo string `json:"idNo"`
  16901. IdType string `json:"idType"`
  16902. UserName string `json:"userName"`
  16903. EcToken string `json:"ecToken"`
  16904. InsuOrg string `json:"insuOrg"`
  16905. Gender string `json:"gender"`
  16906. Birthday string `json:"birthday"`
  16907. Nationality string `json:"nationality"`
  16908. Email string `json:"email"`
  16909. Extra string `json:"extra"`
  16910. } `json:"data"`
  16911. Code int `json:"code"`
  16912. Message string `json:"message"`
  16913. }
  16914. var ele ELeData
  16915. err := json.Unmarshal([]byte(result), &ele)
  16916. if err != nil {
  16917. utils.ErrorLog("解析失败:%v", err)
  16918. }
  16919. token := ele.Data.EcToken
  16920. token = Remove0000(token)
  16921. 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)
  16922. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16923. var res ResultTwo
  16924. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16925. utils.ErrorLog("解析失败:%v", err)
  16926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16927. return
  16928. }
  16929. if res.Infcode == 0 {
  16930. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16931. if err == gorm.ErrRecordNotFound {
  16932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16933. return
  16934. } else if err != nil {
  16935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16936. return
  16937. } else {
  16938. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16939. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16940. infoStr := string(Iinfos)
  16941. idetinfoStr := string(Idetinfos)
  16942. psn := &models.HisPsn{
  16943. PsnNo: res.Output.Baseinfo.PsnNo,
  16944. PatientId: patient.ID,
  16945. Certno: res.Output.Baseinfo.Certno,
  16946. Gend: res.Output.Baseinfo.Gend,
  16947. Naty: res.Output.Baseinfo.Naty,
  16948. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16949. PsnName: res.Output.Baseinfo.PsnName,
  16950. Idetinfo: idetinfoStr,
  16951. Insuinfo: infoStr,
  16952. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16953. CardInfo: "",
  16954. VerifyNumber: token,
  16955. InsuplcAdmdvs: ele.Data.InsuOrg,
  16956. }
  16957. service.CreateHisPsn(psn)
  16958. var rf []*ResultFive
  16959. json.Unmarshal([]byte(infoStr), &rf)
  16960. var insutypes []*ResultFive
  16961. var insutype string
  16962. var is390 int = 0
  16963. var is310 int = 0
  16964. for _, item := range rf {
  16965. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16966. insutypes = append(insutypes, item)
  16967. }
  16968. }
  16969. if len(insutypes) == 1 {
  16970. insutype = insutypes[0].Insutype
  16971. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16972. } else {
  16973. for _, i := range insutypes {
  16974. if i.Insutype == "390" {
  16975. is390 = 1
  16976. }
  16977. if i.Insutype == "310" {
  16978. is310 = 1
  16979. }
  16980. }
  16981. }
  16982. if is390 == 1 {
  16983. insutype = "390"
  16984. }
  16985. if is310 == 1 {
  16986. insutype = "310"
  16987. }
  16988. if len(insutypes) == 0 {
  16989. insutype = "310"
  16990. }
  16991. c.ServeSuccessJSON(map[string]interface{}{
  16992. "patient": patient,
  16993. "number": token,
  16994. "insutype": insutype,
  16995. })
  16996. }
  16997. } else {
  16998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16999. return
  17000. }
  17001. } else if miConfig.MdtrtareaAdmvs == "360100" {
  17002. //if initFlag == 0 {
  17003. //c.TestGetJiangXiBasBaseInit()
  17004. //}
  17005. //if initEleFlag == 0 {
  17006. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  17007. //}
  17008. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  17009. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  17010. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  17011. type ELeData struct {
  17012. Data struct {
  17013. IdNo string `json:"idNo"`
  17014. IdType string `json:"idType"`
  17015. UserName string `json:"userName"`
  17016. EcToken string `json:"ecToken"`
  17017. InsuOrg string `json:"insuOrg"`
  17018. Gender string `json:"gender"`
  17019. Birthday string `json:"birthday"`
  17020. Nationality string `json:"nationality"`
  17021. Email string `json:"email"`
  17022. Extra string `json:"extra"`
  17023. } `json:"data"`
  17024. Code int `json:"code"`
  17025. Message string `json:"message"`
  17026. }
  17027. var ele ELeData
  17028. err := json.Unmarshal([]byte(result), &ele)
  17029. if err != nil {
  17030. utils.ErrorLog("解析失败:%v", err)
  17031. }
  17032. token := ele.Data.EcToken
  17033. token = Remove0000(token)
  17034. 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)
  17035. saveLog(result2, requestLog2, "1101", "获取人员信息")
  17036. var res ResultTwo
  17037. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17038. utils.ErrorLog("解析失败:%v", err)
  17039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17040. return
  17041. }
  17042. if res.Infcode == 0 {
  17043. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17044. if err == gorm.ErrRecordNotFound {
  17045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17046. return
  17047. } else if err != nil {
  17048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17049. return
  17050. } else {
  17051. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17052. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17053. infoStr := string(Iinfos)
  17054. idetinfoStr := string(Idetinfos)
  17055. psn := &models.HisPsn{
  17056. PsnNo: res.Output.Baseinfo.PsnNo,
  17057. PatientId: patient.ID,
  17058. Certno: res.Output.Baseinfo.Certno,
  17059. Gend: res.Output.Baseinfo.Gend,
  17060. Naty: res.Output.Baseinfo.Naty,
  17061. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17062. PsnName: res.Output.Baseinfo.PsnName,
  17063. Idetinfo: idetinfoStr,
  17064. Insuinfo: infoStr,
  17065. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17066. CardInfo: "",
  17067. VerifyNumber: token,
  17068. InsuplcAdmdvs: ele.Data.InsuOrg,
  17069. }
  17070. service.CreateHisPsn(psn)
  17071. var rf []*ResultFive
  17072. json.Unmarshal([]byte(infoStr), &rf)
  17073. var insutypes []*ResultFive
  17074. var insutype string
  17075. var is390 int = 0
  17076. var is310 int = 0
  17077. for _, item := range rf {
  17078. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17079. insutypes = append(insutypes, item)
  17080. }
  17081. }
  17082. if len(insutypes) == 1 {
  17083. insutype = insutypes[0].Insutype
  17084. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17085. } else {
  17086. for _, i := range insutypes {
  17087. if i.Insutype == "390" {
  17088. is390 = 1
  17089. }
  17090. if i.Insutype == "310" {
  17091. is310 = 1
  17092. }
  17093. }
  17094. }
  17095. if is390 == 1 {
  17096. insutype = "390"
  17097. }
  17098. if is310 == 1 {
  17099. insutype = "310"
  17100. }
  17101. if len(insutypes) == 0 {
  17102. insutype = "310"
  17103. }
  17104. c.ServeSuccessJSON(map[string]interface{}{
  17105. "patient": patient,
  17106. "number": token,
  17107. "insutype": insutype,
  17108. })
  17109. }
  17110. } else {
  17111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17112. return
  17113. }
  17114. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17115. //if initFlag == 0 {
  17116. c.TestGetJiangXiBasBaseInit()
  17117. //}
  17118. //if initEleFlag == 0 {
  17119. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  17120. //}
  17121. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  17122. type ELeData struct {
  17123. Data struct {
  17124. IdNo string `json:"idNo"`
  17125. IdType string `json:"idType"`
  17126. UserName string `json:"userName"`
  17127. EcToken string `json:"ecToken"`
  17128. InsuOrg string `json:"insuOrg"`
  17129. Gender string `json:"gender"`
  17130. Birthday string `json:"birthday"`
  17131. Nationality string `json:"nationality"`
  17132. Email string `json:"email"`
  17133. Extra string `json:"extra"`
  17134. } `json:"data"`
  17135. Code int `json:"code"`
  17136. Message string `json:"message"`
  17137. }
  17138. var ele ELeData
  17139. err := json.Unmarshal([]byte(json_result), &ele)
  17140. if err != nil {
  17141. utils.ErrorLog("解析失败:%v", err)
  17142. }
  17143. token := ele.Data.EcToken
  17144. token = Remove0000(token)
  17145. 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)
  17146. saveLog(result2, requestLog2, "1101", "获取人员信息")
  17147. var res ResultTwo
  17148. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17149. utils.ErrorLog("解析失败:%v", err)
  17150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17151. return
  17152. }
  17153. if res.Infcode == 0 {
  17154. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17155. if err == gorm.ErrRecordNotFound {
  17156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17157. return
  17158. } else if err != nil {
  17159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17160. return
  17161. } else {
  17162. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17163. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17164. infoStr := string(Iinfos)
  17165. idetinfoStr := string(Idetinfos)
  17166. psn := &models.HisPsn{
  17167. PsnNo: res.Output.Baseinfo.PsnNo,
  17168. PatientId: patient.ID,
  17169. Certno: res.Output.Baseinfo.Certno,
  17170. Gend: res.Output.Baseinfo.Gend,
  17171. Naty: res.Output.Baseinfo.Naty,
  17172. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17173. PsnName: res.Output.Baseinfo.PsnName,
  17174. Idetinfo: idetinfoStr,
  17175. Insuinfo: infoStr,
  17176. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17177. CardInfo: "",
  17178. VerifyNumber: token,
  17179. }
  17180. service.CreateHisPsn(psn)
  17181. var rf []*ResultFive
  17182. json.Unmarshal([]byte(infoStr), &rf)
  17183. var insutypes []*ResultFive
  17184. var insutype string
  17185. var is390 int = 0
  17186. var is310 int = 0
  17187. for _, item := range rf {
  17188. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17189. insutypes = append(insutypes, item)
  17190. }
  17191. }
  17192. if len(insutypes) == 1 {
  17193. insutype = insutypes[0].Insutype
  17194. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17195. } else {
  17196. for _, i := range insutypes {
  17197. if i.Insutype == "390" {
  17198. is390 = 1
  17199. }
  17200. if i.Insutype == "310" {
  17201. is310 = 1
  17202. }
  17203. }
  17204. }
  17205. if is390 == 1 {
  17206. insutype = "390"
  17207. }
  17208. if is310 == 1 {
  17209. insutype = "310"
  17210. }
  17211. if len(insutypes) == 0 {
  17212. insutype = "310"
  17213. }
  17214. c.ServeSuccessJSON(map[string]interface{}{
  17215. "patient": patient,
  17216. "number": token,
  17217. "insutype": insutype,
  17218. })
  17219. }
  17220. } else {
  17221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17222. return
  17223. }
  17224. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17225. type ELeData struct {
  17226. Code string `json:"code"`
  17227. Data struct {
  17228. Aac002 string `json:"aac002"`
  17229. Aaz500 string `json:"aaz500"`
  17230. ActCardNo string `json:"actCardNo"`
  17231. Bab520 string `json:"bab520"`
  17232. Bkz543 string `json:"bkz543"`
  17233. BusinessType string `json:"businessType"`
  17234. CertfCodg string `json:"certfCodg"`
  17235. EcIndexNo string `json:"ecIndexNo"`
  17236. EcToken string `json:"ecToken"`
  17237. ID0000 string `json:"id0000"`
  17238. IDNo string `json:"idNo"`
  17239. IDType string `json:"idType"`
  17240. Idcode string `json:"idcode"`
  17241. IdentityToken string `json:"identity_token"`
  17242. InsuOrg string `json:"insuOrg"`
  17243. OfficeID string `json:"officeId"`
  17244. OfficeName string `json:"officeName"`
  17245. OperatorID string `json:"operatorId"`
  17246. OperatorName string `json:"operatorName"`
  17247. OrgID string `json:"orgId"`
  17248. UserName string `json:"userName"`
  17249. } `json:"data"`
  17250. Infno interface{} `json:"infno"`
  17251. Message string `json:"message"`
  17252. OrgID string `json:"orgId"`
  17253. TransType string `json:"transType"`
  17254. }
  17255. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  17256. outPutInfo = Remove0000(outPutInfo)
  17257. if len(outPutInfo) > 0 {
  17258. var ele ELeData
  17259. err := json.Unmarshal([]byte(outPutInfo), &ele)
  17260. if err != nil {
  17261. utils.ErrorLog("解析失败:%v", err)
  17262. }
  17263. token := ele.Data.EcToken
  17264. fmt.Println(inputInfo)
  17265. fmt.Println(outPutInfo)
  17266. 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)
  17267. saveLog(result, requestLog, "1101", "获取人员信息")
  17268. var dat map[string]interface{}
  17269. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17270. fmt.Println(dat)
  17271. } else {
  17272. fmt.Println(err)
  17273. }
  17274. userJSONBytes, _ := json.Marshal(dat)
  17275. var res ResultTwo
  17276. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17277. utils.ErrorLog("解析失败:%v", err)
  17278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17279. return
  17280. }
  17281. res.ErrMsg = errMsgLog
  17282. if res.Infcode == 0 {
  17283. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  17284. if err == gorm.ErrRecordNotFound {
  17285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17286. return
  17287. } else if err != nil {
  17288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17289. return
  17290. } else {
  17291. fmt.Println(res)
  17292. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17293. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17294. infoStr := string(Iinfos)
  17295. idetinfoStr := string(Idetinfos)
  17296. psn := &models.HisPsn{
  17297. PsnNo: res.Output.Baseinfo.PsnNo,
  17298. PatientId: patient.ID,
  17299. Certno: res.Output.Baseinfo.Certno,
  17300. Gend: res.Output.Baseinfo.Gend,
  17301. Naty: res.Output.Baseinfo.Naty,
  17302. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17303. PsnName: res.Output.Baseinfo.PsnName,
  17304. Idetinfo: idetinfoStr,
  17305. Insuinfo: infoStr,
  17306. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17307. CardInfo: outPutInfo,
  17308. VerifyNumber: token,
  17309. InsuplcAdmdvs: ele.Data.InsuOrg,
  17310. }
  17311. service.CreateHisPsn(psn)
  17312. var rf []*ResultFive
  17313. json.Unmarshal([]byte(infoStr), &rf)
  17314. var insutypes []*ResultFive
  17315. var insutype string
  17316. var is390 int = 0
  17317. var is310 int = 0
  17318. for _, item := range rf {
  17319. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  17320. insutypes = append(insutypes, item)
  17321. }
  17322. }
  17323. if len(insutypes) == 1 {
  17324. insutype = insutypes[0].Insutype
  17325. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17326. } else {
  17327. for _, i := range insutypes {
  17328. if i.Insutype == "390" {
  17329. is390 = 1
  17330. }
  17331. if i.Insutype == "310" {
  17332. is310 = 1
  17333. }
  17334. }
  17335. }
  17336. if is390 == 1 {
  17337. insutype = "390"
  17338. }
  17339. if is310 == 1 {
  17340. insutype = "310"
  17341. }
  17342. if len(insutypes) == 0 {
  17343. insutype = "310"
  17344. }
  17345. c.ServeSuccessJSON(map[string]interface{}{
  17346. "patient": patient,
  17347. "number": token,
  17348. "insutype": insutype,
  17349. })
  17350. }
  17351. } else {
  17352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17353. return
  17354. }
  17355. }
  17356. } else if miConfig.MdtrtareaAdmvs == "150404" {
  17357. var api string
  17358. 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 +
  17359. "&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
  17360. resp, requestErr := http.Get(api)
  17361. if requestErr != nil {
  17362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17363. return
  17364. }
  17365. body, ioErr := ioutil.ReadAll(resp.Body)
  17366. if ioErr != nil {
  17367. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17369. return
  17370. }
  17371. var respJSON map[string]interface{}
  17372. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17373. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17375. return
  17376. }
  17377. var status string
  17378. status = respJSON["data"].(map[string]interface{})["status"].(string)
  17379. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  17380. var token string
  17381. var res ResultTwo //1101结果
  17382. var res10265 ResultTwo10265 //1101结果
  17383. if status == "0" { //读卡成功
  17384. var card_info string //卡信息
  17385. var busi_card_info string
  17386. token = respJSON["data"].(map[string]interface{})["token"].(string)
  17387. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  17388. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  17389. fmt.Println(card_info)
  17390. fmt.Println(busi_card_info)
  17391. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  17392. result, _ := json.Marshal(respJSON)
  17393. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17394. utils.ErrorLog("解析失败:%v", err)
  17395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17396. return
  17397. }
  17398. res.ErrMsg = res10265.ErrMsg
  17399. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  17400. res.Infcode = infocode
  17401. res.Output = res10265.Output
  17402. res.InfRefmsgid = res10265.InfRefmsgid
  17403. if res.Infcode == 0 {
  17404. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17405. if err == gorm.ErrRecordNotFound {
  17406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17407. return
  17408. } else if err != nil {
  17409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17410. return
  17411. } else {
  17412. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17413. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17414. infoStr := string(Iinfos)
  17415. idetinfoStr := string(Idetinfos)
  17416. psn := &models.HisPsn{
  17417. PsnNo: res.Output.Baseinfo.PsnNo,
  17418. PatientId: patient.ID,
  17419. Certno: res.Output.Baseinfo.Certno,
  17420. Gend: res.Output.Baseinfo.Gend,
  17421. Naty: res.Output.Baseinfo.Naty,
  17422. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17423. PsnName: res.Output.Baseinfo.PsnName,
  17424. Idetinfo: idetinfoStr,
  17425. Insuinfo: infoStr,
  17426. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17427. CardInfo: card_info,
  17428. VerifyNumber: token,
  17429. }
  17430. var rf []*ResultFive
  17431. json.Unmarshal([]byte(infoStr), &rf)
  17432. var insutypes []*ResultFive
  17433. var insutype string
  17434. var is390 int = 0
  17435. var is310 int = 0
  17436. for _, item := range rf {
  17437. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17438. insutypes = append(insutypes, item)
  17439. }
  17440. }
  17441. if len(insutypes) == 1 {
  17442. insutype = insutypes[0].Insutype
  17443. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17444. } else {
  17445. for _, i := range insutypes {
  17446. if i.Insutype == "390" {
  17447. is390 = 1
  17448. }
  17449. if i.Insutype == "310" {
  17450. is310 = 1
  17451. }
  17452. }
  17453. }
  17454. if is390 == 1 {
  17455. insutype = "390"
  17456. }
  17457. if is310 == 1 {
  17458. insutype = "310"
  17459. }
  17460. if len(insutypes) == 0 {
  17461. insutype = "310"
  17462. }
  17463. service.CreateHisPsn(psn)
  17464. c.ServeSuccessJSON(map[string]interface{}{
  17465. "patient": patient,
  17466. "number": token,
  17467. "insutype": insutype,
  17468. })
  17469. }
  17470. } else {
  17471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17472. return
  17473. }
  17474. } else { //读卡失败
  17475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17476. return
  17477. }
  17478. } else if miConfig.MdtrtareaAdmvs == "450721" {
  17479. res := c.GetoleInfo()
  17480. if res.Infcode == 0 {
  17481. var result string
  17482. if res.Output.MdtrtCertType == "01" {
  17483. 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)
  17484. } else if res.Output.MdtrtCertType == "02" {
  17485. 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)
  17486. } else if res.Output.MdtrtCertType == "03" {
  17487. 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)
  17488. }
  17489. var dat map[string]interface{}
  17490. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17491. fmt.Println(dat)
  17492. } else {
  17493. fmt.Println(err)
  17494. }
  17495. userJSONBytes, _ := json.Marshal(dat)
  17496. var res2 ResultTwo
  17497. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17498. utils.ErrorLog("解析失败:%v", err)
  17499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17500. return
  17501. }
  17502. if res2.Infcode == 0 {
  17503. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  17504. if err == gorm.ErrRecordNotFound {
  17505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17506. return
  17507. } else if err != nil {
  17508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17509. return
  17510. } else {
  17511. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  17512. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  17513. infoStr := string(Iinfos)
  17514. idetinfoStr := string(Idetinfos)
  17515. var rf []*ResultFive
  17516. json.Unmarshal([]byte(infoStr), &rf)
  17517. var insutypes []*ResultFive
  17518. var insutype string
  17519. var is390 int = 0
  17520. var is310 int = 0
  17521. //var insuplc_admdvs string
  17522. for _, item := range rf {
  17523. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17524. insutypes = append(insutypes, item)
  17525. }
  17526. }
  17527. if len(insutypes) == 1 {
  17528. insutype = insutypes[0].Insutype
  17529. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17530. } else {
  17531. for _, i := range insutypes {
  17532. if i.Insutype == "390" {
  17533. is390 = 1
  17534. }
  17535. if i.Insutype == "310" {
  17536. is310 = 1
  17537. }
  17538. }
  17539. }
  17540. if is390 == 1 {
  17541. insutype = "390"
  17542. }
  17543. if is310 == 1 {
  17544. insutype = "310"
  17545. }
  17546. if len(insutypes) == 0 {
  17547. insutype = "310"
  17548. }
  17549. psn := &models.HisPsn{
  17550. PsnNo: res2.Output.Baseinfo.PsnNo,
  17551. PatientId: patient.ID,
  17552. Certno: res2.Output.Baseinfo.Certno,
  17553. Gend: res2.Output.Baseinfo.Gend,
  17554. Naty: res2.Output.Baseinfo.Naty,
  17555. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  17556. PsnName: res2.Output.Baseinfo.PsnName,
  17557. Idetinfo: idetinfoStr,
  17558. Insuinfo: infoStr,
  17559. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17560. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  17561. VerifyNumber: res.Output.EcToken,
  17562. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  17563. }
  17564. if res.Output.MdtrtCertType == "01" {
  17565. psn.VerifyNumber = res.Output.EcToken
  17566. //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)
  17567. } else if res.Output.MdtrtCertType == "02" {
  17568. psn.VerifyNumber = res.Output.CardNo
  17569. //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)
  17570. } else if res.Output.MdtrtCertType == "03" {
  17571. psn.VerifyNumber = res.Output.MdtrtCertNo
  17572. //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)
  17573. }
  17574. service.CreateHisPsn(psn)
  17575. var balc float64
  17576. for _, item := range rf {
  17577. if item.Insutype == insutype {
  17578. balc = item.Balc
  17579. }
  17580. }
  17581. c.ServeSuccessJSON(map[string]interface{}{
  17582. "patient": patient,
  17583. "number": res.Output.CardNo,
  17584. "insutype": insutype,
  17585. "blac": balc,
  17586. "desc": idetinfoStr,
  17587. })
  17588. }
  17589. } else {
  17590. c.ServeSuccessJSON(map[string]interface{}{
  17591. "failed_code": -10,
  17592. "msg": res2.ErrMsg,
  17593. })
  17594. }
  17595. } else {
  17596. c.ServeSuccessJSON(map[string]interface{}{
  17597. "failed_code": -10,
  17598. "msg": res.ErrMsg,
  17599. })
  17600. }
  17601. } else if miConfig.MdtrtareaAdmvs == "420902" {
  17602. var res ResultTwo
  17603. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  17604. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  17605. "&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)
  17606. resp, requestErr := http.Get(api)
  17607. if requestErr != nil {
  17608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17609. return
  17610. }
  17611. body, ioErr := ioutil.ReadAll(resp.Body)
  17612. if ioErr != nil {
  17613. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17615. return
  17616. }
  17617. var respJSON map[string]interface{}
  17618. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17619. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17621. return
  17622. }
  17623. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17624. result, _ := json.Marshal(respJSON)
  17625. fmt.Println("log")
  17626. fmt.Println(string(result))
  17627. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17628. utils.ErrorLog("解析失败:%v", err)
  17629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17630. return
  17631. }
  17632. if res.Infcode == 0 {
  17633. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17634. if err == gorm.ErrRecordNotFound {
  17635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17636. return
  17637. } else if err != nil {
  17638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17639. return
  17640. } else {
  17641. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17642. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17643. infoStr := string(Iinfos)
  17644. idetinfoStr := string(Idetinfos)
  17645. var rf []*ResultFive
  17646. json.Unmarshal([]byte(infoStr), &rf)
  17647. var insutypes []*ResultFive
  17648. var insutype string
  17649. var is390 int = 0
  17650. var is310 int = 0
  17651. for _, item := range rf {
  17652. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  17653. insutypes = append(insutypes, item)
  17654. }
  17655. }
  17656. if len(insutypes) == 1 {
  17657. insutype = insutypes[0].Insutype
  17658. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17659. } else {
  17660. for _, i := range insutypes {
  17661. if i.Insutype == "390" {
  17662. is390 = 1
  17663. }
  17664. if i.Insutype == "310" {
  17665. is310 = 1
  17666. }
  17667. }
  17668. }
  17669. if is390 == 1 {
  17670. insutype = "390"
  17671. }
  17672. if is310 == 1 {
  17673. insutype = "310"
  17674. }
  17675. if len(insutypes) == 0 {
  17676. insutype = "390"
  17677. }
  17678. var insuplc_admdvs string
  17679. for _, item := range rf {
  17680. if item.Insutype == insutype {
  17681. insuplc_admdvs = item.InsuplcAdmdvs
  17682. }
  17683. }
  17684. psn := &models.HisPsn{
  17685. PsnNo: res.Output.Baseinfo.PsnNo,
  17686. PatientId: patient.ID,
  17687. Certno: res.Output.Baseinfo.Certno,
  17688. Gend: res.Output.Baseinfo.Gend,
  17689. Naty: res.Output.Baseinfo.Naty,
  17690. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17691. PsnName: res.Output.Baseinfo.PsnName,
  17692. Idetinfo: idetinfoStr,
  17693. Insuinfo: infoStr,
  17694. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17695. InsuplcAdmdvs: insuplc_admdvs,
  17696. }
  17697. service.CreateHisPsn(psn)
  17698. c.ServeSuccessJSON(map[string]interface{}{
  17699. "patient": patient,
  17700. "number": res.Output.Baseinfo.Certno,
  17701. })
  17702. }
  17703. } else {
  17704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17705. return
  17706. }
  17707. } else {
  17708. type ELeData struct {
  17709. Code string `json:"code"`
  17710. Data struct {
  17711. Aac002 string `json:"aac002"`
  17712. Aaz500 string `json:"aaz500"`
  17713. ActCardNo string `json:"actCardNo"`
  17714. Bab520 string `json:"bab520"`
  17715. Bkz543 string `json:"bkz543"`
  17716. BusinessType string `json:"businessType"`
  17717. CertfCodg string `json:"certfCodg"`
  17718. EcIndexNo string `json:"ecIndexNo"`
  17719. EcToken string `json:"ecToken"`
  17720. ID0000 string `json:"id0000"`
  17721. IDNo string `json:"idNo"`
  17722. IDType string `json:"idType"`
  17723. Idcode string `json:"idcode"`
  17724. IdentityToken string `json:"identity_token"`
  17725. InsuOrg string `json:"insuOrg"`
  17726. OfficeID string `json:"officeId"`
  17727. OfficeName string `json:"officeName"`
  17728. OperatorID string `json:"operatorId"`
  17729. OperatorName string `json:"operatorName"`
  17730. OrgID string `json:"orgId"`
  17731. UserName string `json:"userName"`
  17732. } `json:"data"`
  17733. Infno interface{} `json:"infno"`
  17734. Message string `json:"message"`
  17735. OrgID string `json:"orgId"`
  17736. TransType string `json:"transType"`
  17737. }
  17738. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  17739. fmt.Println(result)
  17740. outPutInfo := Remove0000(result)
  17741. fmt.Println(outPutInfo)
  17742. if len(outPutInfo) > 0 {
  17743. var ele ELeData
  17744. err := json.Unmarshal([]byte(outPutInfo), &ele)
  17745. if err != nil {
  17746. utils.ErrorLog("解析失败:%v", err)
  17747. }
  17748. token := ele.Data.EcToken
  17749. fmt.Println(outPutInfo)
  17750. 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)
  17751. saveLog(result, requestLog, "1101", "获取人员信息")
  17752. var dat map[string]interface{}
  17753. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17754. fmt.Println(dat)
  17755. } else {
  17756. fmt.Println(err)
  17757. }
  17758. userJSONBytes, _ := json.Marshal(dat)
  17759. var res ResultTwo
  17760. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17761. utils.ErrorLog("解析失败:%v", err)
  17762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17763. return
  17764. }
  17765. if res.Infcode == 0 {
  17766. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  17767. if err == gorm.ErrRecordNotFound {
  17768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17769. return
  17770. } else if err != nil {
  17771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17772. return
  17773. } else {
  17774. fmt.Println(res)
  17775. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17776. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17777. infoStr := string(Iinfos)
  17778. idetinfoStr := string(Idetinfos)
  17779. psn := &models.HisPsn{
  17780. PsnNo: res.Output.Baseinfo.PsnNo,
  17781. PatientId: patient.ID,
  17782. Certno: res.Output.Baseinfo.Certno,
  17783. Gend: res.Output.Baseinfo.Gend,
  17784. Naty: res.Output.Baseinfo.Naty,
  17785. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17786. PsnName: res.Output.Baseinfo.PsnName,
  17787. Idetinfo: idetinfoStr,
  17788. Insuinfo: infoStr,
  17789. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17790. CardInfo: outPutInfo,
  17791. VerifyNumber: token,
  17792. InsuplcAdmdvs: ele.Data.InsuOrg,
  17793. }
  17794. service.CreateHisPsn(psn)
  17795. var rf []*ResultFive
  17796. json.Unmarshal([]byte(infoStr), &rf)
  17797. var insutypes []*ResultFive
  17798. var insutype string
  17799. var is390 int = 0
  17800. var is310 int = 0
  17801. for _, item := range rf {
  17802. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17803. insutypes = append(insutypes, item)
  17804. }
  17805. }
  17806. if len(insutypes) == 1 {
  17807. insutype = insutypes[0].Insutype
  17808. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17809. } else {
  17810. for _, i := range insutypes {
  17811. if i.Insutype == "390" {
  17812. is390 = 1
  17813. }
  17814. if i.Insutype == "310" {
  17815. is310 = 1
  17816. }
  17817. }
  17818. }
  17819. if is390 == 1 {
  17820. insutype = "390"
  17821. }
  17822. if is310 == 1 {
  17823. insutype = "310"
  17824. }
  17825. if len(insutypes) == 0 {
  17826. insutype = "310"
  17827. }
  17828. c.ServeSuccessJSON(map[string]interface{}{
  17829. "patient": patient,
  17830. "number": token,
  17831. "insutype": insutype,
  17832. })
  17833. }
  17834. } else {
  17835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17836. return
  17837. }
  17838. }
  17839. //fmt.Println(result)
  17840. //
  17841. //if initFlag == 0 {
  17842. // c.TestGetBasBaseInit()
  17843. //}
  17844. //token := c.GetEleBaseInfo()
  17845. //
  17846. //token = Remove0000(token)
  17847. //
  17848. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  17849. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  17850. ////
  17851. //var res ResultTwo
  17852. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17853. // utils.ErrorLog("解析失败:%v", err)
  17854. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17855. // return
  17856. //}
  17857. //
  17858. //if res.Infcode == 0 {
  17859. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17860. // if err == gorm.ErrRecordNotFound {
  17861. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17862. // return
  17863. // } else if err != nil {
  17864. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17865. // return
  17866. //
  17867. // } else {
  17868. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17869. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17870. // infoStr := string(Iinfos)
  17871. // idetinfoStr := string(Idetinfos)
  17872. //
  17873. //
  17874. //
  17875. //
  17876. // var rf []*ResultFive
  17877. // json.Unmarshal([]byte(infoStr), &rf)
  17878. //
  17879. // var insutypes []*ResultFive
  17880. // var insutype string
  17881. // var is390 int = 0
  17882. // var is310 int = 0
  17883. // var insuplc_admdvs string
  17884. //
  17885. // for _, item := range rf {
  17886. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17887. // insutypes = append(insutypes, item)
  17888. // }
  17889. // }
  17890. //
  17891. // if len(insutypes) == 1 {
  17892. // insutype = insutypes[0].Insutype
  17893. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17894. // } else {
  17895. // for _, i := range insutypes {
  17896. // if i.Insutype == "390" {
  17897. // is390 = 1
  17898. // }
  17899. //
  17900. // if i.Insutype == "310" {
  17901. // is310 = 1
  17902. // }
  17903. // }
  17904. // }
  17905. // if is390 == 1 {
  17906. // insutype = "390"
  17907. // }
  17908. //
  17909. // if is310 == 1 {
  17910. // insutype = "310"
  17911. // }
  17912. // if len(insutypes) == 0 {
  17913. // insutype = "310"
  17914. // }
  17915. // for _, item := range rf {
  17916. // if item.Insutype == insutype {
  17917. // insuplc_admdvs = item.InsuplcAdmdvs
  17918. // }
  17919. // }
  17920. // psn := &models.HisPsn{
  17921. // PsnNo: res.Output.Baseinfo.PsnNo,
  17922. // Age: res.Output.Baseinfo.Age,
  17923. // PatientId: patient.ID,
  17924. // Certno: res.Output.Baseinfo.Certno,
  17925. // Brdy: res.Output.Baseinfo.Brdy,
  17926. // Gend: res.Output.Baseinfo.Gend,
  17927. // Naty: res.Output.Baseinfo.Naty,
  17928. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  17929. // PsnName: res.Output.Baseinfo.PsnName,
  17930. // Idetinfo: idetinfoStr,
  17931. // Insuinfo: infoStr,
  17932. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17933. // CardInfo: "",
  17934. // VerifyNumber: token,
  17935. // InsuplcAdmdvs: insuplc_admdvs,
  17936. // }
  17937. // service.CreateHisPsn(psn)
  17938. //
  17939. // c.ServeSuccessJSON(map[string]interface{}{
  17940. // "patient": patient,
  17941. // "number": token,
  17942. // })
  17943. // }
  17944. //} else {
  17945. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17946. // return
  17947. //}
  17948. }
  17949. break
  17950. case 5:
  17951. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  17952. var api string
  17953. if miConfig.MdtrtareaAdmvs == "320830" {
  17954. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  17955. "&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
  17956. fmt.Println(api)
  17957. } else if miConfig.MdtrtareaAdmvs == "320921" {
  17958. 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 +
  17959. "&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
  17960. fmt.Println(api)
  17961. } else {
  17962. 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 +
  17963. "&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)
  17964. }
  17965. resp, requestErr := http.Get(api)
  17966. if requestErr != nil {
  17967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17968. return
  17969. }
  17970. body, ioErr := ioutil.ReadAll(resp.Body)
  17971. if ioErr != nil {
  17972. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17974. return
  17975. }
  17976. var respJSON map[string]interface{}
  17977. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17978. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17980. return
  17981. }
  17982. var status string
  17983. status = respJSON["data"].(map[string]interface{})["status"].(string)
  17984. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  17985. var token string
  17986. var res ResultTwo //1101结果
  17987. var res10265 ResultTwo10265 //1101结果
  17988. if status == "0" { //读卡成功
  17989. var card_info string //卡信息
  17990. //var busi_card_info string
  17991. var auth_info string
  17992. token = respJSON["data"].(map[string]interface{})["token"].(string)
  17993. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  17994. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  17995. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  17996. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  17997. result, _ := json.Marshal(respJSON)
  17998. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17999. utils.ErrorLog("解析失败:%v", err)
  18000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18001. return
  18002. }
  18003. res.ErrMsg = res10265.ErrMsg
  18004. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  18005. res.Infcode = infocode
  18006. res.Output = res10265.Output
  18007. res.InfRefmsgid = res10265.InfRefmsgid
  18008. if res.Infcode == 0 {
  18009. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  18010. if err == gorm.ErrRecordNotFound {
  18011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  18012. return
  18013. } else if err != nil {
  18014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  18015. return
  18016. } else {
  18017. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  18018. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  18019. infoStr := string(Iinfos)
  18020. idetinfoStr := string(Idetinfos)
  18021. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  18022. psn := &models.HisPsn{
  18023. PsnNo: res.Output.Baseinfo.PsnNo,
  18024. PatientId: patient.ID,
  18025. Certno: res.Output.Baseinfo.Certno,
  18026. Gend: res.Output.Baseinfo.Gend,
  18027. Brdy: b,
  18028. Age: float64(age),
  18029. Naty: res.Output.Baseinfo.Naty,
  18030. PsnCertType: res.Output.Baseinfo.PsnCertType,
  18031. PsnName: res.Output.Baseinfo.PsnName,
  18032. Idetinfo: idetinfoStr,
  18033. Insuinfo: infoStr,
  18034. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18035. CardInfo: card_info,
  18036. VerifyNumber: token,
  18037. AuthInfo: auth_info,
  18038. }
  18039. var rf []*ResultFive
  18040. json.Unmarshal([]byte(infoStr), &rf)
  18041. var insutypes []*ResultFive
  18042. var insutype string
  18043. var is390 int = 0
  18044. var is310 int = 0
  18045. for _, item := range rf {
  18046. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  18047. insutypes = append(insutypes, item)
  18048. }
  18049. }
  18050. if len(insutypes) == 1 {
  18051. insutype = insutypes[0].Insutype
  18052. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  18053. } else {
  18054. for _, i := range insutypes {
  18055. if i.Insutype == "390" {
  18056. is390 = 1
  18057. }
  18058. if i.Insutype == "310" {
  18059. is310 = 1
  18060. }
  18061. }
  18062. }
  18063. if is390 == 1 {
  18064. insutype = "390"
  18065. }
  18066. if is310 == 1 {
  18067. insutype = "310"
  18068. }
  18069. if len(insutypes) == 0 {
  18070. insutype = "310"
  18071. }
  18072. service.CreateHisPsn(psn)
  18073. c.ServeSuccessJSON(map[string]interface{}{
  18074. "patient": patient,
  18075. "number": token,
  18076. "insutype": insutype,
  18077. })
  18078. }
  18079. } else {
  18080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18081. return
  18082. }
  18083. } else { //读卡失败
  18084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18085. return
  18086. }
  18087. }
  18088. break
  18089. }
  18090. }
  18091. var initFlag int64 = 0
  18092. var initEleFlag int64 = 0
  18093. func (c *HisApiController) TestGetBasBaseInit() {
  18094. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18095. Iinit := DllDef.MustFindProc("Init")
  18096. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18097. url := ""
  18098. if miConfig.InsuplcAdmdvs[:4] == "4403" {
  18099. url = "http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"
  18100. } else if miConfig.InsuplcAdmdvs[:4] == "4401" {
  18101. url = ""
  18102. } else {
  18103. url = "http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"
  18104. }
  18105. fmt.Println("SSCard的报错原因:", url)
  18106. fmt.Println("SSCard的报错原因:", miConfig.InsuplcAdmdvs)
  18107. ret, _, err := Iinit.Call(StrPtr(url), StrPtr(miConfig.InsuplcAdmdvs))
  18108. if ret != 0 {
  18109. fmt.Println("SSCard的报错原因:", err)
  18110. fmt.Println("SSCard的运算结果为:", ret)
  18111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18112. return
  18113. }
  18114. result := int(ret)
  18115. fmt.Println("SSCard的运算结果为1:", result)
  18116. initFlag = 1
  18117. return
  18118. }
  18119. func (c *HisApiController) HandleJiangXiReadCard() {
  18120. fmt.Println("~~~~~~")
  18121. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18122. admin_user_id, _ := c.GetInt64("admin_user_id")
  18123. id_card_type, _ := c.GetInt64("id_card_type")
  18124. //certificates, _ := c.GetInt64("certificates")
  18125. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18126. if initFlag == 0 {
  18127. c.TestGetJiangXiBasBaseInit()
  18128. }
  18129. basStr := c.GetBasBaseInfo()
  18130. if len(basStr) == 0 {
  18131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18132. return
  18133. }
  18134. fmt.Println(basStr)
  18135. bas := strings.Split(basStr, "|")
  18136. basNumber := bas[1]
  18137. fmt.Println(basNumber)
  18138. card_sn := bas[3]
  18139. fmt.Println(card_sn)
  18140. 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, "")
  18141. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  18142. var dat map[string]interface{}
  18143. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18144. fmt.Println(dat)
  18145. } else {
  18146. fmt.Println(err)
  18147. }
  18148. userJSONBytes, _ := json.Marshal(dat)
  18149. var res ResultTwo
  18150. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18151. utils.ErrorLog("解析失败:%v", err)
  18152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18153. return
  18154. }
  18155. if res.Infcode == 0 {
  18156. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  18157. if err == gorm.ErrRecordNotFound {
  18158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  18159. return
  18160. } else if err != nil {
  18161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  18162. return
  18163. } else {
  18164. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  18165. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  18166. infoStr := string(Iinfos)
  18167. idetinfoStr := string(Idetinfos)
  18168. psn := &models.HisPsn{
  18169. PsnNo: res.Output.Baseinfo.PsnNo,
  18170. PatientId: patient.ID,
  18171. Certno: res.Output.Baseinfo.Certno,
  18172. Gend: res.Output.Baseinfo.Gend,
  18173. Naty: res.Output.Baseinfo.Naty,
  18174. PsnCertType: res.Output.Baseinfo.PsnCertType,
  18175. PsnName: res.Output.Baseinfo.PsnName,
  18176. Idetinfo: idetinfoStr,
  18177. Insuinfo: infoStr,
  18178. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18179. CardInfo: basStr,
  18180. VerifyNumber: "",
  18181. }
  18182. service.CreateHisPsn(psn)
  18183. c.ServeSuccessJSON(map[string]interface{}{
  18184. "patient": patient,
  18185. "number": basNumber,
  18186. })
  18187. }
  18188. } else {
  18189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18190. return
  18191. }
  18192. }
  18193. func (c *HisApiController) TestGetHnBasBaseInit() {
  18194. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18195. Iinit := DllDef.MustFindProc("Init")
  18196. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18197. //http://10.77.211.236/CSB/hsa-fsi-1303
  18198. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  18199. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  18200. // 调用 Init 函数
  18201. 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"))))
  18202. //if ret != 0 {
  18203. fmt.Println("SSCard的报错原因:", err)
  18204. fmt.Println("SSCard的运算结果为:", ret)
  18205. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18206. // return
  18207. //}
  18208. result := int(ret)
  18209. fmt.Println("SSCard的运算结果为1:", result)
  18210. initFlag = 1
  18211. return
  18212. }
  18213. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  18214. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18215. Iinit := DllDef.MustFindProc("Init")
  18216. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18217. //http://10.77.211.236/CSB/hsa-fsi-1303
  18218. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360302"))
  18219. if ret != 0 {
  18220. fmt.Println("SSCard的报错原因:", err)
  18221. fmt.Println("SSCard的运算结果为:", ret)
  18222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18223. return
  18224. }
  18225. result := int(ret)
  18226. fmt.Println("SSCard的运算结果为1:", result)
  18227. initFlag = 1
  18228. return
  18229. }
  18230. func (c *HisApiController) TestGetJiangXiBasBaseInittwo() {
  18231. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18232. Iinit := DllDef.MustFindProc("Init")
  18233. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18234. //http://10.77.211.236/CSB/hsa-fsi-1303
  18235. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360100"))
  18236. if ret != 0 {
  18237. fmt.Println("SSCard的报错原因:", err)
  18238. fmt.Println("SSCard的运算结果为:", ret)
  18239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18240. return
  18241. }
  18242. result := int(ret)
  18243. fmt.Println("SSCard的运算结果为1:", result)
  18244. initFlag = 1
  18245. return
  18246. }
  18247. func (c *HisApiController) GetSFZBaseInfo() string {
  18248. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18249. readCard := DllDef.MustFindProc("ReadSFZ")
  18250. if readCard == nil {
  18251. fmt.Println("readcard is nil")
  18252. readCard = DllDef.MustFindProc("ReadSFZ")
  18253. }
  18254. str := make([]byte, 8096)
  18255. str1 := make([]byte, 8096)
  18256. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  18257. fmt.Println(r)
  18258. return Remove0000(string(str))
  18259. }
  18260. func (c *HisApiController) GetEleBaseInfo() string {
  18261. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18262. readCard := DllDef.MustFindProc("GetQRBase")
  18263. fmt.Println(readCard)
  18264. if readCard == nil {
  18265. fmt.Println("readcard is nil")
  18266. readCard = DllDef.MustFindProc("GetQRBase")
  18267. }
  18268. str := make([]byte, 1024)
  18269. str1 := make([]byte, 1024)
  18270. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  18271. fmt.Println(ret2)
  18272. fmt.Println(string(str1))
  18273. fmt.Println(string(str))
  18274. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18275. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18276. if ret2 != 0 {
  18277. return ""
  18278. }
  18279. return string(str)
  18280. }
  18281. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  18282. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18283. readCard := DllDef.MustFindProc("NationEcTrans")
  18284. fmt.Println(readCard)
  18285. fmt.Println("!!!!!")
  18286. pBusiCardInfo := make([]byte, 2048)
  18287. input := make(map[string]interface{})
  18288. inputData := make(map[string]interface{})
  18289. inputData["orgId"] = code
  18290. inputData["businessType"] = "01101"
  18291. inputData["operatorId"] = "1"
  18292. inputData["operatorName"] = "admin"
  18293. inputData["officeId"] = "001"
  18294. inputData["officeName"] = "血透室"
  18295. inputData["deviceType"] = ""
  18296. input["data"] = inputData
  18297. input["orgId"] = code
  18298. input["transType"] = "ec.query"
  18299. bytesData, _ := json.Marshal(input)
  18300. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  18301. fmt.Println(ret2)
  18302. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18303. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18304. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  18305. }
  18306. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  18307. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18308. readCard := DllDef.MustFindProc("NationEcTrans")
  18309. fmt.Println(readCard)
  18310. fmt.Println("!!!!!")
  18311. pBusiCardInfo := make([]byte, 2048)
  18312. input := make(map[string]interface{})
  18313. inputData := make(map[string]interface{})
  18314. inputData["orgId"] = code
  18315. inputData["businessType"] = "01101"
  18316. inputData["operatorId"] = "9"
  18317. inputData["operatorName"] = "admin"
  18318. inputData["officeId"] = "001"
  18319. inputData["officeName"] = "血透室"
  18320. inputData["deviceType"] = ""
  18321. input["data"] = inputData
  18322. input["orgId"] = code
  18323. input["transType"] = "ec.query"
  18324. bytesData, _ := json.Marshal(input)
  18325. 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])))
  18326. fmt.Println(ret2)
  18327. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18328. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18329. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  18330. }
  18331. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  18332. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18333. readCard := DllDef.MustFindProc("NationEcTrans")
  18334. fmt.Println(readCard)
  18335. fmt.Println("!!!!!")
  18336. pBusiCardInfo := make([]byte, 2048)
  18337. input := make(map[string]interface{})
  18338. inputData := make(map[string]interface{})
  18339. inputData["orgId"] = code
  18340. inputData["businessType"] = "01301"
  18341. inputData["operatorId"] = "9"
  18342. inputData["operatorName"] = "admin"
  18343. inputData["officeId"] = "001"
  18344. inputData["officeName"] = "血透室"
  18345. inputData["deviceType"] = ""
  18346. input["data"] = inputData
  18347. input["orgId"] = code
  18348. input["transType"] = "ec.query"
  18349. bytesData, _ := json.Marshal(input)
  18350. 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])))
  18351. fmt.Println(ret2)
  18352. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18353. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18354. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  18355. }
  18356. func GetJxEleBaseInfo(org_id int64) string {
  18357. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18358. readCard := DllDef.MustFindProc("NationEcTrans")
  18359. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18360. if readCard == nil {
  18361. fmt.Println("readcard is nil")
  18362. readCard = DllDef.MustFindProc("NationEcTrans")
  18363. }
  18364. str1 := make([]byte, 1024)
  18365. data := make(map[string]interface{})
  18366. inputData := make(map[string]interface{})
  18367. inputData["orgId"] = miConfig.Code
  18368. inputData["businessType"] = "01101"
  18369. inputData["operatorId"] = "test001"
  18370. inputData["operatorName"] = "cn"
  18371. inputData["officeId"] = "32760"
  18372. inputData["officeName"] = "waike"
  18373. inputData["deviceType"] = ""
  18374. data["data"] = inputData
  18375. data["transType"] = "ec.query"
  18376. data["extra "] = ""
  18377. data["orgId"] = miConfig.Code
  18378. bytesData, _ := json.Marshal(data)
  18379. //bytesData, _ := json.Marshal(data)
  18380. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18381. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18382. fmt.Println(ret2)
  18383. fmt.Println(string(str1))
  18384. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18385. if ret2 != 0 {
  18386. return ""
  18387. }
  18388. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18389. }
  18390. //func GetJxEleBaseInfoTWO(org_id int64) string {
  18391. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  18392. // readCard := DllDef.MustFindProc("NationEcTrans")
  18393. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18394. //
  18395. // if readCard == nil {
  18396. // fmt.Println("readcard is nil")
  18397. // readCard = DllDef.MustFindProc("NationEcTrans")
  18398. // }
  18399. // str1 := make([]byte, 1024)
  18400. //
  18401. // data := make(map[string]interface{})
  18402. //
  18403. // inputData := make(map[string]interface{})
  18404. // inputData["orgId"] = miConfig.Code
  18405. // inputData["businessType"] = "01101"
  18406. // inputData["operatorId"] = "test001"
  18407. // inputData["operatorName"] = "cn"
  18408. // inputData["officeId"] = "32760"
  18409. // inputData["officeName"] = "waike"
  18410. // inputData["deviceType"] = ""
  18411. //
  18412. // data["data"] = inputData
  18413. // data["transType"] = "ec.query"
  18414. // data["extra "] = ""
  18415. // data["orgId"] = miConfig.Code
  18416. // bytesData, _ := json.Marshal(data)
  18417. // //bytesData, _ := json.Marshal(data)
  18418. //
  18419. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18420. //
  18421. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18422. // fmt.Println(ret2)
  18423. // fmt.Println(string(str1))
  18424. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18425. //
  18426. // if ret2 != 0 {
  18427. // return ""
  18428. // }
  18429. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18430. //}
  18431. func GetJxEleBaseInitInfo(org_id int64) string {
  18432. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18433. readCard := DllDef.MustFindProc("NationEcTrans")
  18434. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18435. if readCard == nil {
  18436. fmt.Println("readcard is nil")
  18437. readCard = DllDef.MustFindProc("NationEcTrans")
  18438. }
  18439. str1 := make([]byte, 2048)
  18440. data := make(map[string]interface{})
  18441. inputData := make(map[string]interface{})
  18442. inputData["orgId"] = miConfig.Code
  18443. inputData["businessType"] = "01101"
  18444. inputData["operatorId"] = "1"
  18445. inputData["operatorName"] = "huangchuang"
  18446. inputData["officeId"] = "101"
  18447. inputData["officeName"] = "xuetou"
  18448. inputData["deviceType"] = ""
  18449. data["data"] = inputData
  18450. data["transType"] = "ec.query"
  18451. data["orgId"] = miConfig.Code
  18452. bytesData, _ := json.Marshal(data)
  18453. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18454. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18455. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  18456. fmt.Println(ret2)
  18457. fmt.Println(string(str1))
  18458. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18459. if ret2 != 0 {
  18460. return ""
  18461. }
  18462. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  18463. initEleFlag = 1
  18464. }
  18465. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18466. }
  18467. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  18468. // // 构建命令
  18469. // cmd := exec.Command("python", "b.py")
  18470. //
  18471. // // 执行命令并等待完成
  18472. // output, err := cmd.CombinedOutput()
  18473. // if err != nil {
  18474. // fmt.Println("Error executing Python script:", err)
  18475. // return
  18476. // }
  18477. //
  18478. // // 打印Python脚本的输出
  18479. // fmt.Println(string(output))
  18480. //}
  18481. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  18482. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  18483. readCard := DllDef.MustFindProc("gxyb_call")
  18484. if readCard == nil {
  18485. fmt.Println("readcard is nil")
  18486. readCard = DllDef.MustFindProc("gxyb_call")
  18487. }
  18488. str := make([]byte, 1024)
  18489. str1 := make([]byte, 1024)
  18490. //data := make(map[string]interface{})
  18491. currentTime := time.Now()
  18492. // 格式化时间为 "YYYYMMDDHH24MISS"
  18493. formattedTime := currentTime.Format("20060102150405")
  18494. inputData := make(map[string]interface{})
  18495. inputData2 := make(map[string]interface{})
  18496. inputData["transNo"] = "1401"
  18497. inputData["transType"] = "passwordCheck"
  18498. inputData["timestamp"] = formattedTime
  18499. inputData2["fixmedinsCode"] = code
  18500. inputData2["psnNo"] = ""
  18501. inputData["data"] = inputData2
  18502. jsonBytes, err := json.Marshal(inputData)
  18503. if err != nil {
  18504. fmt.Println("Error encoding map to JSON:", err)
  18505. }
  18506. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18507. fmt.Println(string(str1))
  18508. fmt.Println(string(str))
  18509. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18510. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18511. if ret2 != 0 {
  18512. return ""
  18513. }
  18514. return string(str)
  18515. }
  18516. func (c *HisApiController) GetoleInfo() Response {
  18517. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  18518. defer ole.CoUninitialize()
  18519. // Replace with the ProgID or CLSID of your COM object
  18520. progID := "YinHai.XJ.Actual.Interface.New"
  18521. // Create COM object
  18522. unknown, err := oleutil.CreateObject(progID)
  18523. if err != nil {
  18524. fmt.Println("Unable to create COM object:", err)
  18525. }
  18526. defer unknown.Release()
  18527. // Query for the IDispatch interface
  18528. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  18529. if err != nil {
  18530. fmt.Println("Unable to get IDispatch interface:", err)
  18531. }
  18532. defer dispatch.Release()
  18533. // Prepare parameters
  18534. transNo := "1401"
  18535. transType := "passwordCheck"
  18536. timestamp := time.Now().Unix()
  18537. fixmedinsCode := "H45072101171"
  18538. psnNo := ""
  18539. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  18540. result2 := ""
  18541. // Call COM object's method using the IDispatch interface
  18542. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  18543. fmt.Println(resulr)
  18544. fmt.Println(result2)
  18545. if err != nil {
  18546. fmt.Println("调用COM对象方法失败:", err)
  18547. }
  18548. var response Response
  18549. err2 := json.Unmarshal([]byte(result2), &response)
  18550. if err2 != nil {
  18551. fmt.Println("解析JSON失败:", err)
  18552. }
  18553. return response
  18554. }
  18555. func (c *HisApiController) GetBasBaseInfo() string {
  18556. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18557. readCard := DllDef.MustFindProc("ReadCardBas")
  18558. if readCard == nil {
  18559. fmt.Println("readcard is nil")
  18560. readCard = DllDef.MustFindProc("ReadCardBas")
  18561. }
  18562. str := make([]byte, 1024)
  18563. str1 := make([]byte, 1024)
  18564. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  18565. fmt.Println(string(str1))
  18566. fmt.Println(string(str))
  18567. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18568. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18569. if ret2 != 0 {
  18570. return ""
  18571. }
  18572. return string(str)
  18573. }
  18574. type Program struct {
  18575. FunctionID string `xml:"function_id"`
  18576. CardInfo string `xml:"cardinfo"`
  18577. User string `xml:"user"`
  18578. }
  18579. func (c *HisApiController) GetBasBaseInfo1111() string {
  18580. DllDef := syscall.MustLoadDLL("HealthyCarder.dll")
  18581. readCard := DllDef.MustFindProc("ReadSICardInfo")
  18582. readCard2 := DllDef.MustFindProc("ReadCardInfo")
  18583. if readCard == nil {
  18584. fmt.Println("readcard is nil")
  18585. readCard = DllDef.MustFindProc("ReadSICardInfo")
  18586. }
  18587. if readCard2 == nil {
  18588. fmt.Println("readcard is nil")
  18589. readCard2 = DllDef.MustFindProc("ReadCardInfo")
  18590. }
  18591. str := make([]byte, 1024)
  18592. str1 := make([]byte, 1024)
  18593. readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18594. str3 := make([]byte, 1024)
  18595. str4 := make([]byte, 1024)
  18596. readCard.Call((uintptr)(unsafe.Pointer(&str[3])), (uintptr)(unsafe.Pointer(&str1[4])))
  18597. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18598. //if err != nil {
  18599. // fmt.Println("Error opening file:", err)
  18600. //}
  18601. //defer file.Close()
  18602. //
  18603. //var lastProgram Program
  18604. //scanner := bufio.NewScanner(file)
  18605. //inProgram := false
  18606. //
  18607. //for scanner.Scan() {
  18608. // line := scanner.Text()
  18609. // if strings.Contains(line, "<program>") {
  18610. // inProgram = true
  18611. // programXML := "<program>"
  18612. // for scanner.Scan() {
  18613. // line = scanner.Text()
  18614. // programXML += line
  18615. // if strings.Contains(line, "</program>") {
  18616. // programXML += "</program>"
  18617. // break
  18618. // }
  18619. // }
  18620. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18621. // // 解析成功,更新最后的 Program
  18622. // }
  18623. // inProgram = false
  18624. // }
  18625. //}
  18626. //
  18627. // fmt.Println("Error reading file:", inProgram)
  18628. //
  18629. //if err := scanner.Err(); err != nil {
  18630. // fmt.Println("Error reading file:", err)
  18631. //}
  18632. // 输出最后一次的 Program
  18633. //fmt.Printf("最后一次的 <program>:\n")
  18634. //fmt.Printf("<program>\n")
  18635. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18636. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18637. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18638. //fmt.Printf("</program>\n")
  18639. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18640. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18641. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  18642. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  18643. return ConvertToString(string(str), "gbk", "utf-8")
  18644. }
  18645. func (c *HisApiController) GetBasBaseInfo22222() string {
  18646. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  18647. readCard := DllDef.MustFindProc("iReadCardUnclassifiedBas")
  18648. if readCard == nil {
  18649. fmt.Println("readcard is nil")
  18650. readCard = DllDef.MustFindProc("iReadCardUnclassifiedBas")
  18651. }
  18652. str := make([]byte, 1024)
  18653. str1 := make([]byte, 1024)
  18654. readCard.Call(uintptr(1), (uintptr)(unsafe.Pointer(&str1[0])))
  18655. //ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  18656. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18657. //if err != nil {
  18658. // fmt.Println("Error opening file:", err)
  18659. //}
  18660. //defer file.Close()
  18661. //
  18662. //var lastProgram Program
  18663. //scanner := bufio.NewScanner(file)
  18664. //inProgram := false
  18665. //
  18666. //for scanner.Scan() {
  18667. // line := scanner.Text()
  18668. // if strings.Contains(line, "<program>") {
  18669. // inProgram = true
  18670. // programXML := "<program>"
  18671. // for scanner.Scan() {
  18672. // line = scanner.Text()
  18673. // programXML += line
  18674. // if strings.Contains(line, "</program>") {
  18675. // programXML += "</program>"
  18676. // break
  18677. // }
  18678. // }
  18679. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18680. // // 解析成功,更新最后的 Program
  18681. // }
  18682. // inProgram = false
  18683. // }
  18684. //}
  18685. //
  18686. // fmt.Println("Error reading file:", inProgram)
  18687. //
  18688. //if err := scanner.Err(); err != nil {
  18689. // fmt.Println("Error reading file:", err)
  18690. //}
  18691. // 输出最后一次的 Program
  18692. //fmt.Printf("最后一次的 <program>:\n")
  18693. //fmt.Printf("<program>\n")
  18694. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18695. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18696. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18697. //fmt.Printf("</program>\n")
  18698. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18699. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18700. return ConvertToString(string(str1), "gbk", "utf-8")
  18701. }
  18702. func (c *HisApiController) GetahBasBaseInfo() string {
  18703. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  18704. readCard := DllDef.MustFindProc("iReadCardBas")
  18705. if readCard == nil {
  18706. fmt.Println("readcard is nil")
  18707. readCard = DllDef.MustFindProc("iReadCardBas")
  18708. }
  18709. //str := make([]byte, 1024)
  18710. str1 := make([]byte, 1024)
  18711. ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  18712. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18713. //if err != nil {
  18714. // fmt.Println("Error opening file:", err)
  18715. //}
  18716. //defer file.Close()
  18717. //
  18718. //var lastProgram Program
  18719. //scanner := bufio.NewScanner(file)
  18720. //inProgram := false
  18721. //
  18722. //for scanner.Scan() {
  18723. // line := scanner.Text()
  18724. // if strings.Contains(line, "<program>") {
  18725. // inProgram = true
  18726. // programXML := "<program>"
  18727. // for scanner.Scan() {
  18728. // line = scanner.Text()
  18729. // programXML += line
  18730. // if strings.Contains(line, "</program>") {
  18731. // programXML += "</program>"
  18732. // break
  18733. // }
  18734. // }
  18735. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18736. // // 解析成功,更新最后的 Program
  18737. // }
  18738. // inProgram = false
  18739. // }
  18740. //}
  18741. //
  18742. // fmt.Println("Error reading file:", inProgram)
  18743. //
  18744. //if err := scanner.Err(); err != nil {
  18745. // fmt.Println("Error reading file:", err)
  18746. //}
  18747. // 输出最后一次的 Program
  18748. //fmt.Printf("最后一次的 <program>:\n")
  18749. //fmt.Printf("<program>\n")
  18750. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18751. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18752. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18753. //fmt.Printf("</program>\n")
  18754. fmt.Println(string(str1))
  18755. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18756. if ret2 != 0 {
  18757. return ""
  18758. }
  18759. return string(str1)
  18760. }
  18761. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  18762. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  18763. readCard := DllDef.MustFindProc("read_cardinfo")
  18764. if readCard == nil {
  18765. fmt.Println("readcard is nil")
  18766. readCard = DllDef.MustFindProc("read_cardinfo")
  18767. }
  18768. str := make([]byte, 1024) //卡号
  18769. str1 := make([]byte, 1024) //卡识别码
  18770. str2 := make([]byte, 1024) //身份证号
  18771. str3 := make([]byte, 1024) //姓名
  18772. str4 := make([]byte, 1024) //错误信息
  18773. 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])))
  18774. fmt.Println(string(str1))
  18775. fmt.Println(string(str))
  18776. fmt.Println(string(str2))
  18777. fmt.Println(string(str3))
  18778. fmt.Println(string(str4))
  18779. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18780. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18781. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  18782. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  18783. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  18784. if ret2 != 0 {
  18785. return "", "", "", "", ""
  18786. }
  18787. return string(str), string(str1), string(str2), string(str3), string(str4)
  18788. }
  18789. type CustomFundPay struct {
  18790. FundPayType string `json:"fund_pay_type"`
  18791. FundPayamt float64 `json:"fund_payamt"`
  18792. InscpScpAmt float64 `json:"inscp_scp_amt"`
  18793. }
  18794. //func (c *HisApiController) GetBatchSettleList() {
  18795. // start_time_str := c.GetString("start_time")
  18796. // //end_time_str := c.GetString("end_time")
  18797. // admin_user_id, _ := c.GetInt64("admin_user_id")
  18798. //
  18799. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  18800. //
  18801. // for _, item := range orders {
  18802. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  18803. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18804. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18805. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18806. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18807. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18808. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18809. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18810. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18811. //
  18812. // if order.ID == 0 {
  18813. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  18814. // return
  18815. // }
  18816. //
  18817. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18818. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18819. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18820. // //fmt.Println(count)
  18821. // //var zero string
  18822. // //number := count + 1
  18823. // //if number >= 1000 {
  18824. // // zero = "0000" + strconv.FormatInt(number, 10)
  18825. // //} else if number >= 10000 {
  18826. // // zero = "000" + strconv.FormatInt(number, 10)
  18827. // //} else if number >= 100000 {
  18828. // // zero = "00" + strconv.FormatInt(number, 10)
  18829. // //} else if number >= 1000000 {
  18830. // // zero = "0" + strconv.FormatInt(number, 10)
  18831. // //} else {
  18832. // // zero = strconv.FormatInt(number, 10)
  18833. // //}
  18834. // //fmt.Println(zero)
  18835. //
  18836. // struct4101 := service.Struct4101{
  18837. // PsnNo: order.PsnNo,
  18838. // MdtrtId: order.MdtrtId,
  18839. // SetlId: order.SetlId,
  18840. // PsnName: order.PsnName,
  18841. // Gend: order.Gend,
  18842. // Brdy: his.Brdy,
  18843. // Age: his.Age,
  18844. // Naty: order.Naty,
  18845. // PatnCertType: "01",
  18846. // Certno: order.Certno,
  18847. // Prfs: "90",
  18848. // ConerName: roles[0].UserName,
  18849. // PatnRlts: "99",
  18850. // ConerAddr: miConfig.OrgName,
  18851. // ConerTel: admin.Mobile,
  18852. // HiType: order.Insutype,
  18853. // Insuplc: miConfig.InsuplcAdmdvs,
  18854. // MaindiagFlag: "1",
  18855. // BillCode: order.SetlId,
  18856. // BillNo: order.SetlId,
  18857. // BizSn: order.Number,
  18858. // PsnSelfPay: order.PsnPartAmt,
  18859. // PsnOwnPay: order.PsnPartAmt,
  18860. // AcctPay: order.AcctPay,
  18861. // PsnCashpay: order.PsnCashPay,
  18862. // HiPaymtd: "1",
  18863. // Hsorg: miConfig.InsuplcAdmdvs,
  18864. // HsorgOpter: miConfig.InsuplcAdmdvs,
  18865. // MedinsFillPsn: curRoles.UserName,
  18866. // MedinsFillDept: miConfig.OrgName,
  18867. // IptMedType: "2",
  18868. // }
  18869. // struct4101.SetlBegnDate = order.SetlTime
  18870. // struct4101.SetlEndDate = order.SetlTime
  18871. // time_arr := strings.Split(order.SetlTime, " ")
  18872. // struct4101.AdmTime = time_arr[0]
  18873. // struct4101.AdmEndTime = time_arr[0]
  18874. //
  18875. // var rf []CustomFundPay
  18876. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  18877. //
  18878. // var tempFunPays []service.CustomStruct
  18879. // for _, item := range rf {
  18880. // var tempFunPay service.CustomStruct
  18881. // tempFunPay.FundPayamt = item.FundPayamt
  18882. // tempFunPay.FundPayType = item.FundPayType
  18883. // tempFunPays = append(tempFunPays, tempFunPay)
  18884. // }
  18885. // struct4101.CustomStruct = tempFunPays
  18886. //
  18887. // var tempDiaginfos []service.DiaginfoStructTwo
  18888. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18889. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18890. //
  18891. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18892. // var config []*models.HisXtDiagnoseConfig
  18893. // for _, item := range diagnosis_ids {
  18894. // id, _ := strconv.ParseInt(item, 10, 64)
  18895. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  18896. // config = append(config, &diagnosisConfig)
  18897. // }
  18898. //
  18899. // for index, item := range config {
  18900. // if index == 0 {
  18901. // var tempDiaginfo service.DiaginfoStructTwo
  18902. // tempDiaginfo.DiagCode = item.CountryCode
  18903. // tempDiaginfo.DiagName = item.CountryContentName
  18904. // tempDiaginfo.DiagType = "1"
  18905. // tempDiaginfo.MaindiagFlag = "1"
  18906. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18907. // } else {
  18908. // var tempDiaginfo service.DiaginfoStructTwo
  18909. // tempDiaginfo.DiagCode = item.CountryCode
  18910. // tempDiaginfo.DiagName = item.CountryContentName
  18911. // tempDiaginfo.DiagType = "1"
  18912. // tempDiaginfo.MaindiagFlag = "0"
  18913. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18914. // }
  18915. // }
  18916. // struct4101.Diseinfo = tempDiaginfos
  18917. //
  18918. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  18919. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18920. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18921. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18922. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18923. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18924. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18925. //
  18926. // var iteminfo service.IteminfoStruct
  18927. //
  18928. // var bedCostTotal float64 = 0 //床位总费
  18929. // var bedCostSelfTotal float64 = 0 //床位自费
  18930. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18931. //
  18932. // var operationCostTotal float64 = 0 //手术费
  18933. // var operationCostSelfTotal float64 = 0 //手术费
  18934. // var operationCostPartSelfTotal float64 = 0 //手术费
  18935. //
  18936. // var otherCostTotal float64 = 0 //其他费用
  18937. // var otherCostSelfTotal float64 = 0 //其他费用
  18938. // var otherCostPartSelfTotal float64 = 0 //其他费用
  18939. //
  18940. // var materialCostTotal float64 = 0 //材料费
  18941. // var materialCostSelfTotal float64 = 0 //材料费
  18942. // var materialCostPartSelfTotal float64 = 0 //材料费
  18943. //
  18944. // var westernMedicineCostTotal float64 = 0 //西药费
  18945. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  18946. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18947. //
  18948. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18949. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18950. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18951. //
  18952. // var checkCostTotal float64 = 0 //检查费
  18953. // var checkCostSelfTotal float64 = 0 //检查费
  18954. // var checkCostPartSelfTotal float64 = 0 //检查费
  18955. //
  18956. // var laboratoryCostTotal float64 = 0 //化验费
  18957. // var laboratoryCostSelfTotal float64 = 0 //化验费
  18958. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18959. //
  18960. // var treatCostTotal float64 = 0 //治疗费用
  18961. // var treatCostSelfTotal float64 = 0 //治疗费用
  18962. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  18963. //
  18964. // decimal.DivisionPrecision = 2
  18965. //
  18966. // var bed_fulamt_ownpay_amt float64 = 0
  18967. // var operation_fulamt_ownpay_amt float64 = 0
  18968. // var other_fulamt_ownpay_amt float64 = 0
  18969. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  18970. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18971. // var check_fulamt_ownpay_amt float64 = 0
  18972. // var material_fulamt_ownpay_amt float64 = 0
  18973. // var laboratory_fulamt_ownpay_amt float64 = 0
  18974. // var treat_fulamt_ownpay_amt float64 = 0
  18975. //
  18976. // var bed_claa_sunmfee float64 = 0
  18977. // var bed_clab_amt float64 = 0
  18978. // var bed_other_amt float64 = 0
  18979. //
  18980. // var operation_claa_sunmfee float64 = 0
  18981. // var operation_clab_amt float64 = 0
  18982. // var operation_other_amt float64 = 0
  18983. //
  18984. // var other_claa_sunmfee float64 = 0
  18985. // var other_clab_amt float64 = 0
  18986. // var other_other_amt float64 = 0
  18987. //
  18988. // var westernMedicine_claa_sunmfee float64 = 0
  18989. // var westernMedicine_clab_amt float64 = 0
  18990. // var westernMedicine_other_amt float64 = 0
  18991. //
  18992. // var chineseTraditional_claa_sunmfee float64 = 0
  18993. // var chineseTraditional_clab_amt float64 = 0
  18994. // var chineseTraditional_other_amt float64 = 0
  18995. //
  18996. // var check_claa_sunmfee float64 = 0
  18997. // var check_clab_amt float64 = 0
  18998. // var check_other_amt float64 = 0
  18999. //
  19000. // var material_claa_sunmfee float64 = 0
  19001. // var material_clab_amt float64 = 0
  19002. // var material_other_amt float64 = 0
  19003. //
  19004. // var laboratory_claa_sunmfee float64 = 0
  19005. // var laboratory_clab_amt float64 = 0
  19006. // var laboratory_other_amt float64 = 0
  19007. //
  19008. // var treat_claa_sunmfee float64 = 0
  19009. // var treat_clab_amt float64 = 0
  19010. // var treat_other_amt float64 = 0
  19011. //
  19012. // for _, item := range order.HisOrderInfo {
  19013. // if item.MedChrgitmType == "01" { //床位费
  19014. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19015. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19016. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19017. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19018. // if item.ChrgitmLv == "1" {
  19019. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19020. // }
  19021. // if item.ChrgitmLv == "2" {
  19022. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19023. //
  19024. // }
  19025. // if item.ChrgitmLv == "3" {
  19026. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19027. // }
  19028. //
  19029. // }
  19030. //
  19031. // if item.MedChrgitmType == "03" { //检查费
  19032. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19033. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19034. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19035. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19036. // if item.ChrgitmLv == "1" {
  19037. //
  19038. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19039. //
  19040. // }
  19041. // if item.ChrgitmLv == "2" {
  19042. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19043. //
  19044. // }
  19045. // if item.ChrgitmLv == "3" {
  19046. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19047. // }
  19048. // }
  19049. //
  19050. // if item.MedChrgitmType == "04" { //化验费
  19051. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19052. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19053. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19054. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19055. // if item.ChrgitmLv == "1" {
  19056. //
  19057. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19058. //
  19059. // }
  19060. // if item.ChrgitmLv == "2" {
  19061. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19062. //
  19063. // }
  19064. // if item.ChrgitmLv == "3" {
  19065. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19066. // }
  19067. // }
  19068. //
  19069. // if item.MedChrgitmType == "05" { //治疗费
  19070. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19071. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19072. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19073. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19074. // if item.ChrgitmLv == "1" {
  19075. //
  19076. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19077. //
  19078. // }
  19079. // if item.ChrgitmLv == "2" {
  19080. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19081. //
  19082. // }
  19083. // if item.ChrgitmLv == "3" {
  19084. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19085. // }
  19086. // }
  19087. //
  19088. // if item.MedChrgitmType == "06" { //手术费
  19089. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19090. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19091. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19092. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19093. //
  19094. // if item.ChrgitmLv == "1" {
  19095. //
  19096. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19097. //
  19098. // }
  19099. // if item.ChrgitmLv == "2" {
  19100. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19101. //
  19102. // }
  19103. // if item.ChrgitmLv == "3" {
  19104. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19105. // }
  19106. // }
  19107. //
  19108. // if item.MedChrgitmType == "08" { //材料费
  19109. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19110. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19111. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19112. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19113. // if item.ChrgitmLv == "1" {
  19114. //
  19115. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19116. //
  19117. // }
  19118. // if item.ChrgitmLv == "2" {
  19119. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19120. //
  19121. // }
  19122. // if item.ChrgitmLv == "3" {
  19123. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19124. // }
  19125. // }
  19126. //
  19127. // if item.MedChrgitmType == "09" { //西药费
  19128. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19129. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19130. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19131. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19132. // if item.ChrgitmLv == "1" {
  19133. //
  19134. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19135. //
  19136. // }
  19137. // if item.ChrgitmLv == "2" {
  19138. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19139. //
  19140. // }
  19141. // if item.ChrgitmLv == "3" {
  19142. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19143. // }
  19144. // }
  19145. //
  19146. // if item.MedChrgitmType == "11" { //中成费
  19147. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19148. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19149. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19150. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19151. // if item.ChrgitmLv == "1" {
  19152. //
  19153. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19154. //
  19155. // }
  19156. // if item.ChrgitmLv == "2" {
  19157. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19158. //
  19159. // }
  19160. // if item.ChrgitmLv == "3" {
  19161. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19162. // }
  19163. // }
  19164. //
  19165. // if item.MedChrgitmType == "14" { //其他费
  19166. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19167. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19168. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19169. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19170. // if item.ChrgitmLv == "1" {
  19171. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19172. //
  19173. // }
  19174. // if item.ChrgitmLv == "2" {
  19175. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19176. //
  19177. // }
  19178. // if item.ChrgitmLv == "3" {
  19179. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19180. // }
  19181. // }
  19182. //
  19183. // }
  19184. //
  19185. // var iteminfoStructs []service.IteminfoStruct
  19186. //
  19187. // if bedCostTotal != 0 {
  19188. // iteminfo.MedChrgitm = "01"
  19189. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19190. // iteminfo.Amt = bedCostTotal
  19191. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  19192. // iteminfo.ClabAmt = bed_clab_amt
  19193. // iteminfo.OthAmt = bed_other_amt
  19194. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19195. // }
  19196. //
  19197. // if checkCostTotal != 0 {
  19198. // iteminfo.MedChrgitm = "03"
  19199. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19200. // iteminfo.Amt = checkCostTotal
  19201. // iteminfo.ClaaSumfee = check_claa_sunmfee
  19202. // iteminfo.ClabAmt = check_clab_amt
  19203. // iteminfo.OthAmt = check_other_amt
  19204. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19205. //
  19206. // }
  19207. //
  19208. // if laboratoryCostTotal != 0 {
  19209. // iteminfo.MedChrgitm = "04"
  19210. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19211. // iteminfo.Amt = laboratoryCostTotal
  19212. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19213. // iteminfo.ClabAmt = laboratory_clab_amt
  19214. // iteminfo.OthAmt = laboratory_other_amt
  19215. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19216. //
  19217. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19218. //
  19219. // }
  19220. //
  19221. // if treatCostTotal != 0 {
  19222. // iteminfo.MedChrgitm = "05"
  19223. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19224. // iteminfo.Amt = treatCostTotal
  19225. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  19226. // iteminfo.ClabAmt = treat_clab_amt
  19227. // iteminfo.OthAmt = treat_other_amt
  19228. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19229. // //(struct4101.IteminfoStruct, iteminfo)
  19230. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19231. // }
  19232. //
  19233. // if operationCostTotal != 0 {
  19234. // iteminfo.MedChrgitm = "06"
  19235. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19236. // iteminfo.Amt = operationCostTotal
  19237. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  19238. // iteminfo.ClabAmt = operation_clab_amt
  19239. // iteminfo.OthAmt = operation_other_amt
  19240. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19241. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19242. // }
  19243. //
  19244. // if materialCostTotal != 0 {
  19245. // iteminfo.MedChrgitm = "08"
  19246. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19247. // iteminfo.Amt = materialCostTotal
  19248. // iteminfo.ClaaSumfee = material_claa_sunmfee
  19249. // iteminfo.ClabAmt = material_clab_amt
  19250. // iteminfo.OthAmt = material_other_amt
  19251. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19252. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19253. // }
  19254. //
  19255. // if westernMedicineCostTotal != 0 {
  19256. // iteminfo.MedChrgitm = "09"
  19257. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19258. // iteminfo.Amt = westernMedicineCostTotal
  19259. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19260. // iteminfo.ClabAmt = westernMedicine_clab_amt
  19261. // iteminfo.OthAmt = westernMedicine_other_amt
  19262. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19263. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19264. //
  19265. // }
  19266. // if chineseTraditionalMedicineCostTotal != 0 {
  19267. // iteminfo.MedChrgitm = "11"
  19268. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19269. // iteminfo.Amt = westernMedicineCostTotal
  19270. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19271. // iteminfo.ClabAmt = westernMedicine_clab_amt
  19272. // iteminfo.OthAmt = westernMedicine_other_amt
  19273. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19274. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19275. //
  19276. // }
  19277. // if otherCostTotal != 0 {
  19278. // iteminfo.MedChrgitm = "14"
  19279. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19280. // iteminfo.Amt = otherCostTotal
  19281. // iteminfo.ClaaSumfee = other_claa_sunmfee
  19282. // iteminfo.ClabAmt = other_clab_amt
  19283. // iteminfo.OthAmt = other_other_amt
  19284. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19285. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19286. //
  19287. // }
  19288. // struct4101.IteminfoStruct = iteminfoStructs
  19289. // struct4101.Ntly = "中国"
  19290. // struct4101.AdmCaty = "A03.06"
  19291. //
  19292. // struct4101.DoctorName = doctor.UserName
  19293. // struct4101.DoctorCode = doctor.DoctorNumber
  19294. //
  19295. // var res ResultSeventeen
  19296. //
  19297. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19298. // struct4101.BillCode = order.Number
  19299. // struct4101.BillNo = order.SetlId
  19300. // var resOther ResultSeventeenOther
  19301. // var pp models.PublicParams
  19302. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19303. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19304. // pp.FixmedinsName = miConfig.OrgName
  19305. // pp.FixmedinsCode = miConfig.Code
  19306. // pp.RequestUrl = miConfig.Url
  19307. // pp.Cainfo = miConfig.Cainfo
  19308. // pp.SecretKey = miConfig.SecretKey
  19309. // pp.AccessKey = miConfig.AccessKey
  19310. // pp.OpterName = curRoles.UserName
  19311. //
  19312. // client := &http.Client{}
  19313. // var req *http.Request
  19314. // data := make(map[string]interface{})
  19315. // data["struct4101"] = struct4101
  19316. // data["pp"] = pp
  19317. // bytesData, _ := json.Marshal(data)
  19318. // if miConfig.MdtrtareaAdmvs == "320921" {
  19319. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19320. // } else {
  19321. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19322. // }
  19323. // resp, _ := client.Do(req)
  19324. // defer resp.Body.Close()
  19325. // body, ioErr := ioutil.ReadAll(resp.Body)
  19326. // if ioErr != nil {
  19327. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19328. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19329. // return
  19330. // }
  19331. // var respJSON map[string]interface{}
  19332. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19333. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19334. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19335. // return
  19336. // }
  19337. //
  19338. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19339. // userJSONBytes, _ := json.Marshal(respJSON)
  19340. // fmt.Println("log")
  19341. // fmt.Println(string(userJSONBytes))
  19342. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19343. // utils.ErrorLog("解析失败:%v", err)
  19344. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19345. // return
  19346. // }
  19347. // res.InfRefmsgid = resOther.InfRefmsgid
  19348. // res.Output = resOther.Output
  19349. // res.ErrMsg = resOther.ErrMsg
  19350. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19351. // res.Infcode = infocode
  19352. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  19353. //
  19354. // var pp models.PublicParams
  19355. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19356. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19357. // pp.FixmedinsName = miConfig.OrgName
  19358. // pp.FixmedinsCode = miConfig.Code
  19359. // pp.RequestUrl = miConfig.Url
  19360. // pp.Cainfo = miConfig.Cainfo
  19361. // pp.SecretKey = miConfig.SecretKey
  19362. // pp.AccessKey = miConfig.AccessKey
  19363. // pp.OpterName = curRoles.UserName
  19364. // result, _ := service.Jxyb4101(struct4101, pp)
  19365. // var dat map[string]interface{}
  19366. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19367. // fmt.Println(dat)
  19368. // } else {
  19369. // fmt.Println(err)
  19370. // }
  19371. // userJSONBytes, _ := json.Marshal(dat)
  19372. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19373. // utils.ErrorLog("解析失败:%v", err)
  19374. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19375. // return
  19376. // }
  19377. //
  19378. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  19379. // var pp models.PublicParams
  19380. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19381. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19382. // pp.FixmedinsName = miConfig.OrgName
  19383. // pp.FixmedinsCode = miConfig.Code
  19384. // pp.RequestUrl = miConfig.Url
  19385. // pp.Cainfo = miConfig.Cainfo
  19386. // pp.SecretKey = miConfig.SecretKey
  19387. // pp.AccessKey = miConfig.AccessKey
  19388. // pp.OpterName = curRoles.UserName
  19389. // result, _ := service.Hnyb4101(struct4101, pp)
  19390. // var dat map[string]interface{}
  19391. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19392. // fmt.Println(dat)
  19393. // } else {
  19394. // fmt.Println(err)
  19395. // }
  19396. // userJSONBytes, _ := json.Marshal(dat)
  19397. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19398. // utils.ErrorLog("解析失败:%v", err)
  19399. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19400. // return
  19401. // }
  19402. //
  19403. // } else if miConfig.MdtrtareaAdmvs == "150404" {
  19404. // var resOther ResultSeventeenOther
  19405. //
  19406. // var pp models.PublicParams
  19407. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19408. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19409. // pp.FixmedinsName = miConfig.OrgName
  19410. // pp.FixmedinsCode = miConfig.Code
  19411. // pp.RequestUrl = miConfig.Url
  19412. // pp.Cainfo = miConfig.Cainfo
  19413. // pp.SecretKey = miConfig.SecretKey
  19414. // pp.AccessKey = miConfig.AccessKey
  19415. // pp.OpterName = curRoles.UserName
  19416. // client := &http.Client{}
  19417. // var req *http.Request
  19418. // data := make(map[string]interface{})
  19419. // data["struct4101"] = struct4101
  19420. // data["pp"] = pp
  19421. // bytesData, _ := json.Marshal(data)
  19422. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19423. // resp, _ := client.Do(req)
  19424. // defer resp.Body.Close()
  19425. // body, ioErr := ioutil.ReadAll(resp.Body)
  19426. // if ioErr != nil {
  19427. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19428. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19429. // return
  19430. // }
  19431. // var respJSON map[string]interface{}
  19432. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19433. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19434. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19435. // return
  19436. // }
  19437. //
  19438. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19439. // userJSONBytes, _ := json.Marshal(respJSON)
  19440. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19441. // utils.ErrorLog("解析失败:%v", err)
  19442. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19443. // return
  19444. // }
  19445. // res.InfRefmsgid = resOther.InfRefmsgid
  19446. // res.Output = resOther.Output
  19447. // res.ErrMsg = resOther.ErrMsg
  19448. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19449. // res.Infcode = infocode
  19450. //
  19451. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  19452. // var pp models.PublicParams
  19453. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19454. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19455. // pp.FixmedinsName = miConfig.OrgName
  19456. // pp.FixmedinsCode = miConfig.Code
  19457. // pp.RequestUrl = miConfig.Url
  19458. // pp.Cainfo = miConfig.Cainfo
  19459. // pp.SecretKey = miConfig.SecretKey
  19460. // pp.AccessKey = miConfig.AccessKey
  19461. // pp.OpterName = curRoles.UserName
  19462. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19463. // fmt.Println(requestLog)
  19464. // fmt.Println(errMsgLog)
  19465. //
  19466. // saveLog(result, requestLog, "4101a", "上传清单")
  19467. //
  19468. // var dat map[string]interface{}
  19469. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19470. // fmt.Println(dat)
  19471. // } else {
  19472. // fmt.Println(err)
  19473. // }
  19474. // userJSONBytes, _ := json.Marshal(dat)
  19475. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19476. // utils.ErrorLog("解析失败:%v", err)
  19477. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19478. // return
  19479. // }
  19480. //
  19481. // } else {
  19482. //
  19483. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  19484. // var dat map[string]interface{}
  19485. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19486. // fmt.Println(dat)
  19487. // } else {
  19488. // fmt.Println(err)
  19489. // }
  19490. // userJSONBytes, _ := json.Marshal(dat)
  19491. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19492. // utils.ErrorLog("解析失败:%v", err)
  19493. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19494. // return
  19495. // }
  19496. // }
  19497. //
  19498. // if res.Infcode != 0 {
  19499. // adminUser := c.GetAdminUserInfo()
  19500. // errlog := &models.HisOrderError{
  19501. // UserOrgId: adminUser.CurrentOrgId,
  19502. // Ctime: time.Now().Unix(),
  19503. // Mtime: time.Now().Unix(),
  19504. // ErrMsg: res.ErrMsg,
  19505. // Status: 1,
  19506. // PatientId: order.ID,
  19507. // Stage: 10265,
  19508. // }
  19509. // service.CreateErrMsgLog(errlog)
  19510. // continue
  19511. // } else {
  19512. // //order.FaPiaoNumber = zero
  19513. // //order.FaPiaoCode = last_order.FaPiaoCode
  19514. // //service.UpdateOrder(order)
  19515. // hisFundSettleListResult := &models.HisFundSettleListResult{
  19516. // Number: res.Output.SetlListId,
  19517. // Status: 1,
  19518. // Ctime: time.Now().Unix(),
  19519. // Mtime: time.Now().Unix(),
  19520. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19521. // IsUpload: 1,
  19522. // OrderId: order.ID,
  19523. // }
  19524. // service.CreateUploadRecord(hisFundSettleListResult)
  19525. // c.ServeSuccessJSON(map[string]interface{}{
  19526. // "msg": "上传成功",
  19527. // "result": hisFundSettleListResult,
  19528. // })
  19529. // continue
  19530. // }
  19531. // }
  19532. //}
  19533. func (c *HisApiController) GetbatchSettleList() {
  19534. //order_id, _ := c.GetInt64("order_id")
  19535. admin_user_id, _ := c.GetInt64("admin_user_id")
  19536. start_date := c.GetString("start_date")
  19537. end_date := c.GetString("end_date")
  19538. orders, _ := service.GetAllHisOrderTwo10485(start_date,end_date)
  19539. for _, item := range orders {
  19540. order, _ := service.GetHisOrderByIDTwo(item.ID)
  19541. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19542. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  19543. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19544. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19545. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19546. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19547. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  19548. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  19549. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19550. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19551. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19552. //fmt.Println(count)
  19553. //var zero string
  19554. //number := count + 1
  19555. //if number >= 1000 {
  19556. // zero = "0000" + strconv.FormatInt(number, 10)
  19557. //} else if number >= 10000 {
  19558. // zero = "000" + strconv.FormatInt(number, 10)
  19559. //} else if number >= 100000 {
  19560. // zero = "00" + strconv.FormatInt(number, 10)
  19561. //} else if number >= 1000000 {
  19562. // zero = "0" + strconv.FormatInt(number, 10)
  19563. //} else {
  19564. // zero = strconv.FormatInt(number, 10)
  19565. //}
  19566. //fmt.Println(zero)
  19567. struct4101 := service.Struct4101{
  19568. PsnNo: order.PsnNo,
  19569. MdtrtId: order.MdtrtId,
  19570. SetlId: order.SetlId,
  19571. PsnName: order.PsnName,
  19572. Gend: order.Gend,
  19573. Brdy: his.Brdy,
  19574. Age: his.Age,
  19575. Naty: order.Naty,
  19576. PatnCertType: "01",
  19577. Certno: order.Certno,
  19578. Prfs: "90",
  19579. ConerName: roles[0].UserName,
  19580. PatnRlts: "99",
  19581. ConerAddr: miConfig.OrgName,
  19582. ConerTel: admin.Mobile,
  19583. HiType: order.Insutype,
  19584. Insuplc: miConfig.InsuplcAdmdvs,
  19585. MaindiagFlag: "1",
  19586. BillCode: order.SetlId,
  19587. BillNo: order.SetlId,
  19588. BizSn: order.Number,
  19589. PsnSelfPay: order.PsnPartAmt,
  19590. PsnOwnPay: order.PsnPartAmt,
  19591. AcctPay: order.AcctPay,
  19592. PsnCashpay: order.PsnCashPay,
  19593. HiPaymtd: "1",
  19594. Hsorg: miConfig.InsuplcAdmdvs,
  19595. HsorgOpter: miConfig.InsuplcAdmdvs,
  19596. MedinsFillPsn: curRoles.UserName,
  19597. MedinsFillDept: miConfig.OrgName,
  19598. IptMedType: "2",
  19599. }
  19600. struct4101.SetlBegnDate = order.SetlTime
  19601. struct4101.SetlEndDate = order.SetlTime
  19602. time_arr := strings.Split(order.SetlTime, " ")
  19603. struct4101.AdmTime = time_arr[0]
  19604. struct4101.AdmEndTime = time_arr[0]
  19605. //var rf []CustomFundPay
  19606. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19607. //
  19608. //var tempFunPays []service.CustomStruct
  19609. //for _, item := range rf {
  19610. // var tempFunPay service.CustomStruct
  19611. // tempFunPay.FundPayamt = item.FundPayamt
  19612. // tempFunPay.FundPayType = item.FundPayType
  19613. // tempFunPays = append(tempFunPays, tempFunPay)
  19614. //}
  19615. //struct4101.CustomStruct = tempFunPays
  19616. var tempDiaginfos []service.DiaginfoStructTwo
  19617. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19618. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19619. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  19620. var config []*models.HisXtDiagnoseConfig
  19621. for _, item := range diagnosis_ids {
  19622. id, _ := strconv.ParseInt(item, 10, 64)
  19623. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19624. config = append(config, &diagnosisConfig)
  19625. }
  19626. for index, item := range config {
  19627. if index == 0 {
  19628. var tempDiaginfo service.DiaginfoStructTwo
  19629. tempDiaginfo.DiagCode = item.CountryCode
  19630. tempDiaginfo.DiagName = item.CountryContentName
  19631. tempDiaginfo.DiagType = "1"
  19632. tempDiaginfo.MaindiagFlag = "1"
  19633. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19634. } else {
  19635. var tempDiaginfo service.DiaginfoStructTwo
  19636. tempDiaginfo.DiagCode = item.CountryCode
  19637. tempDiaginfo.DiagName = item.CountryContentName
  19638. tempDiaginfo.DiagType = "1"
  19639. tempDiaginfo.MaindiagFlag = "0"
  19640. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19641. }
  19642. }
  19643. struct4101.Diseinfo = tempDiaginfos
  19644. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19645. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19646. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19647. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  19648. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  19649. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19650. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19651. var iteminfo service.IteminfoStruct
  19652. var bedCostTotal float64 = 0 //床位总费
  19653. var bedCostSelfTotal float64 = 0 //床位自费
  19654. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19655. var operationCostTotal float64 = 0 //手术费
  19656. var operationCostSelfTotal float64 = 0 //手术费
  19657. var operationCostPartSelfTotal float64 = 0 //手术费
  19658. var otherCostTotal float64 = 0 //其他费用
  19659. var otherCostSelfTotal float64 = 0 //其他费用
  19660. var otherCostPartSelfTotal float64 = 0 //其他费用
  19661. var materialCostTotal float64 = 0 //材料费
  19662. var materialCostSelfTotal float64 = 0 //材料费
  19663. var materialCostPartSelfTotal float64 = 0 //材料费
  19664. var westernMedicineCostTotal float64 = 0 //西药费
  19665. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19666. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19667. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19668. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19669. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19670. var checkCostTotal float64 = 0 //检查费
  19671. var checkCostSelfTotal float64 = 0 //检查费
  19672. var checkCostPartSelfTotal float64 = 0 //检查费
  19673. var laboratoryCostTotal float64 = 0 //化验费
  19674. var laboratoryCostSelfTotal float64 = 0 //化验费
  19675. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19676. var treatCostTotal float64 = 0 //治疗费用
  19677. var treatCostSelfTotal float64 = 0 //治疗费用
  19678. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19679. decimal.DivisionPrecision = 2
  19680. var bed_fulamt_ownpay_amt float64 = 0
  19681. var operation_fulamt_ownpay_amt float64 = 0
  19682. var other_fulamt_ownpay_amt float64 = 0
  19683. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19684. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19685. var check_fulamt_ownpay_amt float64 = 0
  19686. var material_fulamt_ownpay_amt float64 = 0
  19687. var laboratory_fulamt_ownpay_amt float64 = 0
  19688. var treat_fulamt_ownpay_amt float64 = 0
  19689. var bed_claa_sunmfee float64 = 0
  19690. var bed_clab_amt float64 = 0
  19691. var bed_other_amt float64 = 0
  19692. var operation_claa_sunmfee float64 = 0
  19693. var operation_clab_amt float64 = 0
  19694. var operation_other_amt float64 = 0
  19695. var other_claa_sunmfee float64 = 0
  19696. var other_clab_amt float64 = 0
  19697. var other_other_amt float64 = 0
  19698. var westernMedicine_claa_sunmfee float64 = 0
  19699. var westernMedicine_clab_amt float64 = 0
  19700. var westernMedicine_other_amt float64 = 0
  19701. var chineseTraditional_claa_sunmfee float64 = 0
  19702. var chineseTraditional_clab_amt float64 = 0
  19703. var chineseTraditional_other_amt float64 = 0
  19704. var check_claa_sunmfee float64 = 0
  19705. var check_clab_amt float64 = 0
  19706. var check_other_amt float64 = 0
  19707. var material_claa_sunmfee float64 = 0
  19708. var material_clab_amt float64 = 0
  19709. var material_other_amt float64 = 0
  19710. var laboratory_claa_sunmfee float64 = 0
  19711. var laboratory_clab_amt float64 = 0
  19712. var laboratory_other_amt float64 = 0
  19713. var treat_claa_sunmfee float64 = 0
  19714. var treat_clab_amt float64 = 0
  19715. var treat_other_amt float64 = 0
  19716. for _, item := range order.HisOrderInfo {
  19717. if item.MedChrgitmType == "01" { //床位费
  19718. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19719. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19720. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19721. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19722. if item.ChrgitmLv == "1" {
  19723. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19724. }
  19725. if item.ChrgitmLv == "2" {
  19726. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19727. }
  19728. if item.ChrgitmLv == "3" {
  19729. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19730. }
  19731. }
  19732. if item.MedChrgitmType == "03" { //检查费
  19733. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19734. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19735. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19736. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19737. if item.ChrgitmLv == "1" {
  19738. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19739. }
  19740. if item.ChrgitmLv == "2" {
  19741. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19742. }
  19743. if item.ChrgitmLv == "3" {
  19744. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19745. }
  19746. }
  19747. if item.MedChrgitmType == "04" { //化验费
  19748. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19749. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19750. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19751. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19752. if item.ChrgitmLv == "1" {
  19753. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19754. }
  19755. if item.ChrgitmLv == "2" {
  19756. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19757. }
  19758. if item.ChrgitmLv == "3" {
  19759. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19760. }
  19761. }
  19762. if item.MedChrgitmType == "05" { //治疗费
  19763. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19764. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19765. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19766. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19767. if item.ChrgitmLv == "1" {
  19768. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19769. }
  19770. if item.ChrgitmLv == "2" {
  19771. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19772. }
  19773. if item.ChrgitmLv == "3" {
  19774. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19775. }
  19776. }
  19777. if item.MedChrgitmType == "06" { //手术费
  19778. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19779. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19780. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19781. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19782. if item.ChrgitmLv == "1" {
  19783. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19784. }
  19785. if item.ChrgitmLv == "2" {
  19786. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19787. }
  19788. if item.ChrgitmLv == "3" {
  19789. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19790. }
  19791. }
  19792. if item.MedChrgitmType == "08" { //材料费
  19793. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19794. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19795. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19796. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19797. if item.ChrgitmLv == "1" {
  19798. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19799. }
  19800. if item.ChrgitmLv == "2" {
  19801. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19802. }
  19803. if item.ChrgitmLv == "3" {
  19804. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19805. }
  19806. }
  19807. if item.MedChrgitmType == "09" { //西药费
  19808. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19809. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19810. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19811. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19812. if item.ChrgitmLv == "1" {
  19813. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19814. }
  19815. if item.ChrgitmLv == "2" {
  19816. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19817. }
  19818. if item.ChrgitmLv == "3" {
  19819. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19820. }
  19821. }
  19822. if item.MedChrgitmType == "11" { //中成费
  19823. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19824. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19825. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19826. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19827. if item.ChrgitmLv == "1" {
  19828. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19829. }
  19830. if item.ChrgitmLv == "2" {
  19831. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19832. }
  19833. if item.ChrgitmLv == "3" {
  19834. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19835. }
  19836. }
  19837. if item.MedChrgitmType == "14" { //其他费
  19838. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19839. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19840. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19841. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19842. if item.ChrgitmLv == "1" {
  19843. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19844. }
  19845. if item.ChrgitmLv == "2" {
  19846. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19847. }
  19848. if item.ChrgitmLv == "3" {
  19849. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19850. }
  19851. }
  19852. }
  19853. var iteminfoStructs []service.IteminfoStruct
  19854. if bedCostTotal != 0 {
  19855. iteminfo.MedChrgitm = "01"
  19856. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19857. iteminfo.Amt = bedCostTotal
  19858. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19859. iteminfo.ClabAmt = bed_clab_amt
  19860. iteminfo.OthAmt = bed_other_amt
  19861. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19862. }
  19863. if checkCostTotal != 0 {
  19864. iteminfo.MedChrgitm = "03"
  19865. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19866. iteminfo.Amt = checkCostTotal
  19867. iteminfo.ClaaSumfee = check_claa_sunmfee
  19868. iteminfo.ClabAmt = check_clab_amt
  19869. iteminfo.OthAmt = check_other_amt
  19870. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19871. }
  19872. if laboratoryCostTotal != 0 {
  19873. iteminfo.MedChrgitm = "04"
  19874. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19875. iteminfo.Amt = laboratoryCostTotal
  19876. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19877. iteminfo.ClabAmt = laboratory_clab_amt
  19878. iteminfo.OthAmt = laboratory_other_amt
  19879. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19880. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19881. }
  19882. if treatCostTotal != 0 {
  19883. iteminfo.MedChrgitm = "05"
  19884. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19885. iteminfo.Amt = treatCostTotal
  19886. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19887. iteminfo.ClabAmt = treat_clab_amt
  19888. iteminfo.OthAmt = treat_other_amt
  19889. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19890. //(struct4101.IteminfoStruct, iteminfo)
  19891. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19892. }
  19893. if operationCostTotal != 0 {
  19894. iteminfo.MedChrgitm = "06"
  19895. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19896. iteminfo.Amt = operationCostTotal
  19897. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19898. iteminfo.ClabAmt = operation_clab_amt
  19899. iteminfo.OthAmt = operation_other_amt
  19900. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19901. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19902. }
  19903. if materialCostTotal != 0 {
  19904. iteminfo.MedChrgitm = "08"
  19905. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19906. iteminfo.Amt = materialCostTotal
  19907. iteminfo.ClaaSumfee = material_claa_sunmfee
  19908. iteminfo.ClabAmt = material_clab_amt
  19909. iteminfo.OthAmt = material_other_amt
  19910. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19911. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19912. }
  19913. if westernMedicineCostTotal != 0 {
  19914. iteminfo.MedChrgitm = "09"
  19915. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19916. iteminfo.Amt = westernMedicineCostTotal
  19917. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19918. iteminfo.ClabAmt = westernMedicine_clab_amt
  19919. iteminfo.OthAmt = westernMedicine_other_amt
  19920. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19921. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19922. }
  19923. if chineseTraditionalMedicineCostTotal != 0 {
  19924. iteminfo.MedChrgitm = "11"
  19925. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19926. iteminfo.Amt = westernMedicineCostTotal
  19927. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19928. iteminfo.ClabAmt = westernMedicine_clab_amt
  19929. iteminfo.OthAmt = westernMedicine_other_amt
  19930. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19931. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19932. }
  19933. if otherCostTotal != 0 {
  19934. iteminfo.MedChrgitm = "14"
  19935. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19936. iteminfo.Amt = otherCostTotal
  19937. iteminfo.ClaaSumfee = other_claa_sunmfee
  19938. iteminfo.ClabAmt = other_clab_amt
  19939. iteminfo.OthAmt = other_other_amt
  19940. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19941. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19942. }
  19943. struct4101.IteminfoStruct = iteminfoStructs
  19944. struct4101.Ntly = "中国"
  19945. struct4101.AdmCaty = "A03.06"
  19946. struct4101.DoctorName = doctor.UserName
  19947. struct4101.DoctorCode = doctor.DoctorNumber
  19948. var res ResultSeventeen
  19949. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  19950. struct4101.BillCode = order.Number
  19951. struct4101.BillNo = order.SetlId
  19952. var resOther ResultSeventeenOther
  19953. var pp models.PublicParams
  19954. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19955. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19956. pp.FixmedinsName = miConfig.OrgName
  19957. pp.FixmedinsCode = miConfig.Code
  19958. pp.RequestUrl = miConfig.Url
  19959. pp.Cainfo = miConfig.Cainfo
  19960. pp.SecretKey = miConfig.SecretKey
  19961. pp.AccessKey = miConfig.AccessKey
  19962. pp.OpterName = curRoles.UserName
  19963. client := &http.Client{}
  19964. var req *http.Request
  19965. data := make(map[string]interface{})
  19966. data["struct4101"] = struct4101
  19967. data["pp"] = pp
  19968. bytesData, _ := json.Marshal(data)
  19969. if miConfig.MdtrtareaAdmvs == "320830" {
  19970. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/4101", bytes.NewReader(bytesData))
  19971. } else if miConfig.MdtrtareaAdmvs == "320921" {
  19972. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19973. } else {
  19974. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19975. }
  19976. resp, _ := client.Do(req)
  19977. defer resp.Body.Close()
  19978. body, ioErr := ioutil.ReadAll(resp.Body)
  19979. if ioErr != nil {
  19980. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19982. return
  19983. }
  19984. var respJSON map[string]interface{}
  19985. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19986. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19988. return
  19989. }
  19990. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19991. userJSONBytes, _ := json.Marshal(respJSON)
  19992. fmt.Println("log")
  19993. fmt.Println(string(userJSONBytes))
  19994. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19995. utils.ErrorLog("解析失败:%v", err)
  19996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19997. return
  19998. }
  19999. res.InfRefmsgid = resOther.InfRefmsgid
  20000. res.Output = resOther.Output
  20001. res.ErrMsg = resOther.ErrMsg
  20002. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20003. res.Infcode = infocode
  20004. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20005. var pp models.PublicParams
  20006. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20007. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20008. pp.FixmedinsName = miConfig.OrgName
  20009. pp.FixmedinsCode = miConfig.Code
  20010. pp.RequestUrl = miConfig.Url
  20011. pp.Cainfo = miConfig.Cainfo
  20012. pp.SecretKey = miConfig.SecretKey
  20013. pp.AccessKey = miConfig.AccessKey
  20014. pp.OpterName = curRoles.UserName
  20015. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  20016. result, _ := service.Jxyb4101(struct4101, pp)
  20017. var dat map[string]interface{}
  20018. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20019. fmt.Println(dat)
  20020. } else {
  20021. fmt.Println(err)
  20022. }
  20023. userJSONBytes, _ := json.Marshal(dat)
  20024. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20025. utils.ErrorLog("解析失败:%v", err)
  20026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20027. return
  20028. }
  20029. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20030. var pp models.PublicParams
  20031. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20032. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20033. pp.FixmedinsName = miConfig.OrgName
  20034. pp.FixmedinsCode = miConfig.Code
  20035. pp.RequestUrl = miConfig.Url
  20036. pp.Cainfo = miConfig.Cainfo
  20037. pp.SecretKey = miConfig.SecretKey
  20038. pp.AccessKey = miConfig.AccessKey
  20039. pp.OpterName = curRoles.UserName
  20040. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  20041. result, _ := service.Jxyb4101(struct4101, pp)
  20042. var dat map[string]interface{}
  20043. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20044. fmt.Println(dat)
  20045. } else {
  20046. fmt.Println(err)
  20047. }
  20048. userJSONBytes, _ := json.Marshal(dat)
  20049. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20050. utils.ErrorLog("解析失败:%v", err)
  20051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20052. return
  20053. }
  20054. } else if miConfig.MdtrtareaAdmvs == "360100" {
  20055. var pp models.PublicParams
  20056. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20057. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20058. pp.FixmedinsName = miConfig.OrgName
  20059. pp.FixmedinsCode = miConfig.Code
  20060. pp.RequestUrl = miConfig.Url
  20061. pp.Cainfo = miConfig.Cainfo
  20062. pp.SecretKey = miConfig.SecretKey
  20063. pp.AccessKey = miConfig.AccessKey
  20064. pp.OpterName = curRoles.UserName
  20065. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  20066. result, _ := service.Jxyb4101(struct4101, pp)
  20067. var dat map[string]interface{}
  20068. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20069. fmt.Println(dat)
  20070. } else {
  20071. fmt.Println(err)
  20072. }
  20073. userJSONBytes, _ := json.Marshal(dat)
  20074. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20075. utils.ErrorLog("解析失败:%v", err)
  20076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20077. return
  20078. }
  20079. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20080. var pp models.PublicParams
  20081. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20082. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20083. pp.FixmedinsName = miConfig.OrgName
  20084. pp.FixmedinsCode = miConfig.Code
  20085. pp.RequestUrl = miConfig.Url
  20086. pp.Cainfo = miConfig.Cainfo
  20087. pp.SecretKey = miConfig.SecretKey
  20088. pp.AccessKey = miConfig.AccessKey
  20089. pp.OpterName = curRoles.UserName
  20090. result, _ := service.Hnyb4101(struct4101, pp)
  20091. var dat map[string]interface{}
  20092. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20093. fmt.Println(dat)
  20094. } else {
  20095. fmt.Println(err)
  20096. }
  20097. userJSONBytes, _ := json.Marshal(dat)
  20098. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20099. utils.ErrorLog("解析失败:%v", err)
  20100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20101. return
  20102. }
  20103. } else if miConfig.MdtrtareaAdmvs == "150404" {
  20104. var resOther ResultSeventeenOther
  20105. var pp models.PublicParams
  20106. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20107. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20108. pp.FixmedinsName = miConfig.OrgName
  20109. pp.FixmedinsCode = miConfig.Code
  20110. pp.RequestUrl = miConfig.Url
  20111. pp.Cainfo = miConfig.Cainfo
  20112. pp.SecretKey = miConfig.SecretKey
  20113. pp.AccessKey = miConfig.AccessKey
  20114. pp.OpterName = curRoles.UserName
  20115. client := &http.Client{}
  20116. var req *http.Request
  20117. data := make(map[string]interface{})
  20118. data["struct4101"] = struct4101
  20119. data["pp"] = pp
  20120. bytesData, _ := json.Marshal(data)
  20121. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20122. resp, _ := client.Do(req)
  20123. defer resp.Body.Close()
  20124. body, ioErr := ioutil.ReadAll(resp.Body)
  20125. if ioErr != nil {
  20126. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20128. return
  20129. }
  20130. var respJSON map[string]interface{}
  20131. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20132. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20134. return
  20135. }
  20136. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20137. userJSONBytes, _ := json.Marshal(respJSON)
  20138. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20139. utils.ErrorLog("解析失败:%v", err)
  20140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20141. return
  20142. }
  20143. res.InfRefmsgid = resOther.InfRefmsgid
  20144. res.Output = resOther.Output
  20145. res.ErrMsg = resOther.ErrMsg
  20146. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20147. res.Infcode = infocode
  20148. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20149. var pp models.PublicParams
  20150. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20151. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20152. pp.FixmedinsName = miConfig.OrgName
  20153. pp.FixmedinsCode = miConfig.Code
  20154. pp.RequestUrl = miConfig.Url
  20155. pp.Cainfo = miConfig.Cainfo
  20156. pp.SecretKey = miConfig.SecretKey
  20157. pp.AccessKey = miConfig.AccessKey
  20158. pp.OpterName = curRoles.UserName
  20159. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  20160. fmt.Println(requestLog)
  20161. fmt.Println(errMsgLog)
  20162. saveLog(result, requestLog, "4101a", "上传清单")
  20163. var dat map[string]interface{}
  20164. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20165. fmt.Println(dat)
  20166. } else {
  20167. fmt.Println(err)
  20168. }
  20169. userJSONBytes, _ := json.Marshal(dat)
  20170. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20171. utils.ErrorLog("解析失败:%v", err)
  20172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20173. return
  20174. }
  20175. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20176. var pp models.PublicParams
  20177. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20178. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20179. pp.FixmedinsName = miConfig.OrgName
  20180. pp.FixmedinsCode = miConfig.Code
  20181. pp.RequestUrl = miConfig.Url
  20182. pp.Cainfo = miConfig.Cainfo
  20183. pp.SecretKey = miConfig.SecretKey
  20184. pp.AccessKey = miConfig.AccessKey
  20185. pp.OpterName = curRoles.UserName
  20186. client := &http.Client{}
  20187. var req *http.Request
  20188. data := make(map[string]interface{})
  20189. data["struct4101"] = struct4101
  20190. data["pp"] = pp
  20191. bytesData, _ := json.Marshal(data)
  20192. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  20193. resp, _ := client.Do(req)
  20194. defer resp.Body.Close()
  20195. body, ioErr := ioutil.ReadAll(resp.Body)
  20196. if ioErr != nil {
  20197. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20199. return
  20200. }
  20201. var respJSON map[string]interface{}
  20202. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20203. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20205. return
  20206. }
  20207. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20208. userJSONBytes, _ := json.Marshal(respJSON)
  20209. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20210. utils.ErrorLog("解析失败:%v", err)
  20211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20212. return
  20213. }
  20214. } else {
  20215. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20216. var dat map[string]interface{}
  20217. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20218. fmt.Println(dat)
  20219. } else {
  20220. fmt.Println(err)
  20221. }
  20222. userJSONBytes, _ := json.Marshal(dat)
  20223. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20224. utils.ErrorLog("解析失败:%v", err)
  20225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20226. return
  20227. }
  20228. }
  20229. if res.Infcode != 0 {
  20230. errlog := &models.HisOrderError{
  20231. UserOrgId: order.UserOrgId,
  20232. Ctime: time.Now().Unix(),
  20233. Mtime: time.Now().Unix(),
  20234. ErrMsg: res.ErrMsg + "解析失败",
  20235. Status: 1,
  20236. PatientId: order.ID,
  20237. Stage: 10485,
  20238. }
  20239. service.CreateErrMsgLog(errlog)
  20240. continue
  20241. //c.ServeSuccessJSON(map[string]interface{}{
  20242. // "failed_code": -10,
  20243. // "msg": res.ErrMsg,
  20244. //})
  20245. } else {
  20246. //order.FaPiaoNumber = zero
  20247. //order.FaPiaoCode = last_order.FaPiaoCode
  20248. //service.UpdateOrder(order)
  20249. hisFundSettleListResult := &models.HisFundSettleListResult{
  20250. Number: res.Output.SetlListId,
  20251. Status: 1,
  20252. Ctime: time.Now().Unix(),
  20253. Mtime: time.Now().Unix(),
  20254. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20255. IsUpload: 1,
  20256. OrderId: order.ID,
  20257. }
  20258. service.CreateUploadRecord(hisFundSettleListResult)
  20259. continue
  20260. }
  20261. }
  20262. }
  20263. func (c *HisApiController) GetSettleList() {
  20264. order_id, _ := c.GetInt64("order_id")
  20265. admin_user_id, _ := c.GetInt64("admin_user_id")
  20266. order, _ := service.GetHisOrderByIDTwo(order_id)
  20267. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20268. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  20269. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20270. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  20271. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20272. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20273. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  20274. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  20275. if order.ID == 0 {
  20276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20277. return
  20278. }
  20279. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  20280. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  20281. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  20282. //fmt.Println(count)
  20283. //var zero string
  20284. //number := count + 1
  20285. //if number >= 1000 {
  20286. // zero = "0000" + strconv.FormatInt(number, 10)
  20287. //} else if number >= 10000 {
  20288. // zero = "000" + strconv.FormatInt(number, 10)
  20289. //} else if number >= 100000 {
  20290. // zero = "00" + strconv.FormatInt(number, 10)
  20291. //} else if number >= 1000000 {
  20292. // zero = "0" + strconv.FormatInt(number, 10)
  20293. //} else {
  20294. // zero = strconv.FormatInt(number, 10)
  20295. //}
  20296. //fmt.Println(zero)
  20297. struct4101 := service.Struct4101{
  20298. PsnNo: order.PsnNo,
  20299. MdtrtId: order.MdtrtId,
  20300. SetlId: order.SetlId,
  20301. PsnName: order.PsnName,
  20302. Gend: order.Gend,
  20303. Brdy: his.Brdy,
  20304. Age: his.Age,
  20305. Naty: order.Naty,
  20306. PatnCertType: "01",
  20307. Certno: order.Certno,
  20308. Prfs: "90",
  20309. ConerName: roles[0].UserName,
  20310. PatnRlts: "99",
  20311. ConerAddr: miConfig.OrgName,
  20312. ConerTel: admin.Mobile,
  20313. HiType: order.Insutype,
  20314. Insuplc: miConfig.InsuplcAdmdvs,
  20315. MaindiagFlag: "1",
  20316. BillCode: order.SetlId,
  20317. BillNo: order.SetlId,
  20318. BizSn: order.Number,
  20319. PsnSelfPay: order.PsnPartAmt,
  20320. PsnOwnPay: order.PsnPartAmt,
  20321. AcctPay: order.AcctPay,
  20322. PsnCashpay: order.PsnCashPay,
  20323. HiPaymtd: "1",
  20324. Hsorg: miConfig.InsuplcAdmdvs,
  20325. HsorgOpter: miConfig.InsuplcAdmdvs,
  20326. MedinsFillPsn: curRoles.UserName,
  20327. MedinsFillDept: miConfig.OrgName,
  20328. IptMedType: "2",
  20329. }
  20330. struct4101.SetlBegnDate = order.SetlTime
  20331. struct4101.SetlEndDate = order.SetlTime
  20332. time_arr := strings.Split(order.SetlTime, " ")
  20333. struct4101.AdmTime = time_arr[0]
  20334. struct4101.AdmEndTime = time_arr[0]
  20335. //
  20336. //var rf []CustomFundPay
  20337. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  20338. //
  20339. //var tempFunPays []service.CustomStruct
  20340. //for _, item := range rf {
  20341. // var tempFunPay service.CustomStruct
  20342. // tempFunPay.FundPayamt = item.FundPayamt
  20343. // tempFunPay.FundPayType = item.FundPayType
  20344. // tempFunPays = append(tempFunPays, tempFunPay)
  20345. //}
  20346. //struct4101.CustomStruct = tempFunPays
  20347. var tempDiaginfos []service.DiaginfoStructTwo
  20348. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20349. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20350. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  20351. var config []*models.HisXtDiagnoseConfig
  20352. for _, item := range diagnosis_ids {
  20353. id, _ := strconv.ParseInt(item, 10, 64)
  20354. diagnosisConfig, _ := service.FindDiagnoseById(id)
  20355. config = append(config, &diagnosisConfig)
  20356. }
  20357. if miConfig.Code == "H15049901371" {
  20358. //for _, item := range config {
  20359. // if item.ID == 138 {
  20360. diagnosisConfig, _ := service.FindDiagnoseById(138)
  20361. var tempDiaginfo service.DiaginfoStructTwo
  20362. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  20363. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  20364. tempDiaginfo.DiagType = "1"
  20365. tempDiaginfo.MaindiagFlag = "1"
  20366. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20367. //}
  20368. //}
  20369. for _, item := range config {
  20370. if item.ID != 138 {
  20371. var tempDiaginfo service.DiaginfoStructTwo
  20372. tempDiaginfo.DiagCode = item.CountryCode
  20373. tempDiaginfo.DiagName = item.CountryContentName
  20374. tempDiaginfo.DiagType = "1"
  20375. tempDiaginfo.MaindiagFlag = "0"
  20376. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20377. }
  20378. }
  20379. } else {
  20380. for index, item := range config {
  20381. if index == 0 {
  20382. var tempDiaginfo service.DiaginfoStructTwo
  20383. tempDiaginfo.DiagCode = item.CountryCode
  20384. tempDiaginfo.DiagName = item.CountryContentName
  20385. tempDiaginfo.DiagType = "1"
  20386. tempDiaginfo.MaindiagFlag = "1"
  20387. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20388. } else {
  20389. var tempDiaginfo service.DiaginfoStructTwo
  20390. tempDiaginfo.DiagCode = item.CountryCode
  20391. tempDiaginfo.DiagName = item.CountryContentName
  20392. tempDiaginfo.DiagType = "1"
  20393. tempDiaginfo.MaindiagFlag = "0"
  20394. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20395. }
  20396. }
  20397. }
  20398. struct4101.Diseinfo = tempDiaginfos
  20399. sickConfigTwo, _ := service.FindSickById(his.SickType)
  20400. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20401. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20402. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  20403. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  20404. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20405. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20406. var iteminfo service.IteminfoStruct
  20407. var bedCostTotal float64 = 0 //床位总费
  20408. var bedCostSelfTotal float64 = 0 //床位自费
  20409. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20410. var operationCostTotal float64 = 0 //手术费
  20411. var operationCostSelfTotal float64 = 0 //手术费
  20412. var operationCostPartSelfTotal float64 = 0 //手术费
  20413. var otherCostTotal float64 = 0 //其他费用
  20414. var otherCostSelfTotal float64 = 0 //其他费用
  20415. var otherCostPartSelfTotal float64 = 0 //其他费用
  20416. var materialCostTotal float64 = 0 //材料费
  20417. var materialCostSelfTotal float64 = 0 //材料费
  20418. var materialCostPartSelfTotal float64 = 0 //材料费
  20419. var westernMedicineCostTotal float64 = 0 //西药费
  20420. var westernMedicineCostSelfTotal float64 = 0 //西药费
  20421. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20422. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20423. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20424. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20425. var checkCostTotal float64 = 0 //检查费
  20426. var checkCostSelfTotal float64 = 0 //检查费
  20427. var checkCostPartSelfTotal float64 = 0 //检查费
  20428. var laboratoryCostTotal float64 = 0 //化验费
  20429. var laboratoryCostSelfTotal float64 = 0 //化验费
  20430. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20431. var treatCostTotal float64 = 0 //治疗费用
  20432. var treatCostSelfTotal float64 = 0 //治疗费用
  20433. var treatCostPartSelfTotal float64 = 0 //治疗费用
  20434. decimal.DivisionPrecision = 2
  20435. var bed_fulamt_ownpay_amt float64 = 0
  20436. var operation_fulamt_ownpay_amt float64 = 0
  20437. var other_fulamt_ownpay_amt float64 = 0
  20438. var westernMedicine_fulamt_ownpay_amt float64 = 0
  20439. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20440. var check_fulamt_ownpay_amt float64 = 0
  20441. var material_fulamt_ownpay_amt float64 = 0
  20442. var laboratory_fulamt_ownpay_amt float64 = 0
  20443. var treat_fulamt_ownpay_amt float64 = 0
  20444. var bed_claa_sunmfee float64 = 0
  20445. var bed_clab_amt float64 = 0
  20446. var bed_other_amt float64 = 0
  20447. var operation_claa_sunmfee float64 = 0
  20448. var operation_clab_amt float64 = 0
  20449. var operation_other_amt float64 = 0
  20450. var other_claa_sunmfee float64 = 0
  20451. var other_clab_amt float64 = 0
  20452. var other_other_amt float64 = 0
  20453. var westernMedicine_claa_sunmfee float64 = 0
  20454. var westernMedicine_clab_amt float64 = 0
  20455. var westernMedicine_other_amt float64 = 0
  20456. var chineseTraditional_claa_sunmfee float64 = 0
  20457. var chineseTraditional_clab_amt float64 = 0
  20458. var chineseTraditional_other_amt float64 = 0
  20459. var check_claa_sunmfee float64 = 0
  20460. var check_clab_amt float64 = 0
  20461. var check_other_amt float64 = 0
  20462. var material_claa_sunmfee float64 = 0
  20463. var material_clab_amt float64 = 0
  20464. var material_other_amt float64 = 0
  20465. var laboratory_claa_sunmfee float64 = 0
  20466. var laboratory_clab_amt float64 = 0
  20467. var laboratory_other_amt float64 = 0
  20468. var treat_claa_sunmfee float64 = 0
  20469. var treat_clab_amt float64 = 0
  20470. var treat_other_amt float64 = 0
  20471. for _, item := range order.HisOrderInfo {
  20472. if item.MedChrgitmType == "01" { //床位费
  20473. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20474. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20475. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20476. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20477. if item.ChrgitmLv == "1" {
  20478. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20479. }
  20480. if item.ChrgitmLv == "2" {
  20481. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20482. }
  20483. if item.ChrgitmLv == "3" {
  20484. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20485. }
  20486. }
  20487. if item.MedChrgitmType == "03" { //检查费
  20488. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20489. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20490. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20491. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20492. if item.ChrgitmLv == "1" {
  20493. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20494. }
  20495. if item.ChrgitmLv == "2" {
  20496. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20497. }
  20498. if item.ChrgitmLv == "3" {
  20499. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20500. }
  20501. }
  20502. if item.MedChrgitmType == "04" { //化验费
  20503. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20504. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20505. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20506. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20507. if item.ChrgitmLv == "1" {
  20508. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20509. }
  20510. if item.ChrgitmLv == "2" {
  20511. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20512. }
  20513. if item.ChrgitmLv == "3" {
  20514. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20515. }
  20516. }
  20517. if item.MedChrgitmType == "05" { //治疗费
  20518. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20519. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20520. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20521. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20522. if item.ChrgitmLv == "1" {
  20523. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20524. }
  20525. if item.ChrgitmLv == "2" {
  20526. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20527. }
  20528. if item.ChrgitmLv == "3" {
  20529. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20530. }
  20531. }
  20532. if item.MedChrgitmType == "06" { //手术费
  20533. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20534. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20535. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20536. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20537. if item.ChrgitmLv == "1" {
  20538. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20539. }
  20540. if item.ChrgitmLv == "2" {
  20541. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20542. }
  20543. if item.ChrgitmLv == "3" {
  20544. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20545. }
  20546. }
  20547. if item.MedChrgitmType == "08" { //材料费
  20548. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20549. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20550. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20551. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20552. if item.ChrgitmLv == "1" {
  20553. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20554. }
  20555. if item.ChrgitmLv == "2" {
  20556. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20557. }
  20558. if item.ChrgitmLv == "3" {
  20559. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20560. }
  20561. }
  20562. if item.MedChrgitmType == "09" { //西药费
  20563. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20564. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20565. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20566. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20567. if item.ChrgitmLv == "1" {
  20568. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20569. }
  20570. if item.ChrgitmLv == "2" {
  20571. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20572. }
  20573. if item.ChrgitmLv == "3" {
  20574. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20575. }
  20576. }
  20577. if item.MedChrgitmType == "11" { //中成费
  20578. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20579. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20580. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20581. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20582. if item.ChrgitmLv == "1" {
  20583. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20584. }
  20585. if item.ChrgitmLv == "2" {
  20586. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20587. }
  20588. if item.ChrgitmLv == "3" {
  20589. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20590. }
  20591. }
  20592. if item.MedChrgitmType == "14" { //其他费
  20593. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20594. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20595. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20596. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20597. if item.ChrgitmLv == "1" {
  20598. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20599. }
  20600. if item.ChrgitmLv == "2" {
  20601. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20602. }
  20603. if item.ChrgitmLv == "3" {
  20604. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20605. }
  20606. }
  20607. }
  20608. var iteminfoStructs []service.IteminfoStruct
  20609. if bedCostTotal != 0 {
  20610. iteminfo.MedChrgitm = "01"
  20611. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20612. iteminfo.Amt = bedCostTotal
  20613. iteminfo.ClaaSumfee = bed_claa_sunmfee
  20614. iteminfo.ClabAmt = bed_clab_amt
  20615. iteminfo.OthAmt = bed_other_amt
  20616. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20617. }
  20618. if checkCostTotal != 0 {
  20619. iteminfo.MedChrgitm = "03"
  20620. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20621. iteminfo.Amt = checkCostTotal
  20622. iteminfo.ClaaSumfee = check_claa_sunmfee
  20623. iteminfo.ClabAmt = check_clab_amt
  20624. iteminfo.OthAmt = check_other_amt
  20625. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20626. }
  20627. if laboratoryCostTotal != 0 {
  20628. iteminfo.MedChrgitm = "04"
  20629. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20630. iteminfo.Amt = laboratoryCostTotal
  20631. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20632. iteminfo.ClabAmt = laboratory_clab_amt
  20633. iteminfo.OthAmt = laboratory_other_amt
  20634. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20635. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20636. }
  20637. if treatCostTotal != 0 {
  20638. iteminfo.MedChrgitm = "05"
  20639. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20640. iteminfo.Amt = treatCostTotal
  20641. iteminfo.ClaaSumfee = treat_claa_sunmfee
  20642. iteminfo.ClabAmt = treat_clab_amt
  20643. iteminfo.OthAmt = treat_other_amt
  20644. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20645. //(struct4101.IteminfoStruct, iteminfo)
  20646. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20647. }
  20648. if operationCostTotal != 0 {
  20649. iteminfo.MedChrgitm = "06"
  20650. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20651. iteminfo.Amt = operationCostTotal
  20652. iteminfo.ClaaSumfee = operation_claa_sunmfee
  20653. iteminfo.ClabAmt = operation_clab_amt
  20654. iteminfo.OthAmt = operation_other_amt
  20655. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20656. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20657. }
  20658. if materialCostTotal != 0 {
  20659. iteminfo.MedChrgitm = "08"
  20660. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20661. iteminfo.Amt = materialCostTotal
  20662. iteminfo.ClaaSumfee = material_claa_sunmfee
  20663. iteminfo.ClabAmt = material_clab_amt
  20664. iteminfo.OthAmt = material_other_amt
  20665. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20666. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20667. }
  20668. if westernMedicineCostTotal != 0 {
  20669. iteminfo.MedChrgitm = "09"
  20670. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20671. iteminfo.Amt = westernMedicineCostTotal
  20672. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20673. iteminfo.ClabAmt = westernMedicine_clab_amt
  20674. iteminfo.OthAmt = westernMedicine_other_amt
  20675. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20676. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20677. }
  20678. if chineseTraditionalMedicineCostTotal != 0 {
  20679. iteminfo.MedChrgitm = "11"
  20680. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20681. iteminfo.Amt = westernMedicineCostTotal
  20682. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20683. iteminfo.ClabAmt = westernMedicine_clab_amt
  20684. iteminfo.OthAmt = westernMedicine_other_amt
  20685. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20686. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20687. }
  20688. if otherCostTotal != 0 {
  20689. iteminfo.MedChrgitm = "14"
  20690. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20691. iteminfo.Amt = otherCostTotal
  20692. iteminfo.ClaaSumfee = other_claa_sunmfee
  20693. iteminfo.ClabAmt = other_clab_amt
  20694. iteminfo.OthAmt = other_other_amt
  20695. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20696. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20697. }
  20698. struct4101.IteminfoStruct = iteminfoStructs
  20699. struct4101.Ntly = "中国"
  20700. struct4101.AdmCaty = "A03.06"
  20701. struct4101.DoctorName = doctor.UserName
  20702. struct4101.DoctorCode = doctor.DoctorNumber
  20703. var res ResultSeventeen
  20704. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  20705. struct4101.BillCode = order.Number
  20706. struct4101.BillNo = order.SetlId
  20707. var resOther ResultSeventeenOther
  20708. var pp models.PublicParams
  20709. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20710. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20711. pp.FixmedinsName = miConfig.OrgName
  20712. pp.FixmedinsCode = miConfig.Code
  20713. pp.RequestUrl = miConfig.Url
  20714. pp.Cainfo = miConfig.Cainfo
  20715. pp.SecretKey = miConfig.SecretKey
  20716. pp.AccessKey = miConfig.AccessKey
  20717. pp.OpterName = curRoles.UserName
  20718. client := &http.Client{}
  20719. var req *http.Request
  20720. data := make(map[string]interface{})
  20721. data["struct4101"] = struct4101
  20722. data["pp"] = pp
  20723. bytesData, _ := json.Marshal(data)
  20724. if miConfig.MdtrtareaAdmvs == "320830" {
  20725. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/4101", bytes.NewReader(bytesData))
  20726. } else if miConfig.MdtrtareaAdmvs == "320921" {
  20727. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  20728. } else {
  20729. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  20730. }
  20731. resp, _ := client.Do(req)
  20732. defer resp.Body.Close()
  20733. body, ioErr := ioutil.ReadAll(resp.Body)
  20734. if ioErr != nil {
  20735. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20737. return
  20738. }
  20739. var respJSON map[string]interface{}
  20740. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20741. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20743. return
  20744. }
  20745. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  20746. userJSONBytes, _ := json.Marshal(respJSON)
  20747. fmt.Println("log")
  20748. fmt.Println(string(userJSONBytes))
  20749. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20750. utils.ErrorLog("解析失败:%v", err)
  20751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20752. return
  20753. }
  20754. res.InfRefmsgid = resOther.InfRefmsgid
  20755. res.Output = resOther.Output
  20756. res.ErrMsg = resOther.ErrMsg
  20757. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20758. res.Infcode = infocode
  20759. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20760. var pp models.PublicParams
  20761. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20762. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20763. pp.FixmedinsName = miConfig.OrgName
  20764. pp.FixmedinsCode = miConfig.Code
  20765. pp.RequestUrl = miConfig.Url
  20766. pp.Cainfo = miConfig.Cainfo
  20767. pp.SecretKey = miConfig.SecretKey
  20768. pp.AccessKey = miConfig.AccessKey
  20769. pp.OpterName = curRoles.UserName
  20770. result, _ := service.Jxyb4101(struct4101, pp)
  20771. var dat map[string]interface{}
  20772. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20773. fmt.Println(dat)
  20774. } else {
  20775. fmt.Println(err)
  20776. }
  20777. userJSONBytes, _ := json.Marshal(dat)
  20778. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20779. utils.ErrorLog("解析失败:%v", err)
  20780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20781. return
  20782. }
  20783. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20784. var pp models.PublicParams
  20785. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20786. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20787. pp.FixmedinsName = miConfig.OrgName
  20788. pp.FixmedinsCode = miConfig.Code
  20789. pp.RequestUrl = miConfig.Url
  20790. pp.Cainfo = miConfig.Cainfo
  20791. pp.SecretKey = miConfig.SecretKey
  20792. pp.AccessKey = miConfig.AccessKey
  20793. pp.OpterName = curRoles.UserName
  20794. result, _ := service.Jxyb4101(struct4101, pp)
  20795. var dat map[string]interface{}
  20796. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20797. fmt.Println(dat)
  20798. } else {
  20799. fmt.Println(err)
  20800. }
  20801. userJSONBytes, _ := json.Marshal(dat)
  20802. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20803. utils.ErrorLog("解析失败:%v", err)
  20804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20805. return
  20806. }
  20807. } else if miConfig.MdtrtareaAdmvs == "360100" {
  20808. var pp models.PublicParams
  20809. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20810. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20811. pp.FixmedinsName = miConfig.OrgName
  20812. pp.FixmedinsCode = miConfig.Code
  20813. pp.RequestUrl = miConfig.Url
  20814. pp.Cainfo = miConfig.Cainfo
  20815. pp.SecretKey = miConfig.SecretKey
  20816. pp.AccessKey = miConfig.AccessKey
  20817. pp.OpterName = curRoles.UserName
  20818. result, _ := service.Jxyb4101(struct4101, pp)
  20819. var dat map[string]interface{}
  20820. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20821. fmt.Println(dat)
  20822. } else {
  20823. fmt.Println(err)
  20824. }
  20825. userJSONBytes, _ := json.Marshal(dat)
  20826. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20827. utils.ErrorLog("解析失败:%v", err)
  20828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20829. return
  20830. }
  20831. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20832. var pp models.PublicParams
  20833. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20834. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20835. pp.FixmedinsName = miConfig.OrgName
  20836. pp.FixmedinsCode = miConfig.Code
  20837. pp.RequestUrl = miConfig.Url
  20838. pp.Cainfo = miConfig.Cainfo
  20839. pp.SecretKey = miConfig.SecretKey
  20840. pp.AccessKey = miConfig.AccessKey
  20841. pp.OpterName = curRoles.UserName
  20842. result, _ := service.Hnyb4101(struct4101, pp)
  20843. var dat map[string]interface{}
  20844. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20845. fmt.Println(dat)
  20846. } else {
  20847. fmt.Println(err)
  20848. }
  20849. userJSONBytes, _ := json.Marshal(dat)
  20850. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20851. utils.ErrorLog("解析失败:%v", err)
  20852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20853. return
  20854. }
  20855. } else if miConfig.MdtrtareaAdmvs == "150404" {
  20856. var resOther ResultSeventeenOther
  20857. var pp models.PublicParams
  20858. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20859. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20860. pp.FixmedinsName = miConfig.OrgName
  20861. pp.FixmedinsCode = miConfig.Code
  20862. pp.RequestUrl = miConfig.Url
  20863. pp.Cainfo = miConfig.Cainfo
  20864. pp.SecretKey = miConfig.SecretKey
  20865. pp.AccessKey = miConfig.AccessKey
  20866. pp.OpterName = curRoles.UserName
  20867. client := &http.Client{}
  20868. var req *http.Request
  20869. data := make(map[string]interface{})
  20870. data["struct4101"] = struct4101
  20871. data["pp"] = pp
  20872. bytesData, _ := json.Marshal(data)
  20873. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20874. resp, _ := client.Do(req)
  20875. defer resp.Body.Close()
  20876. body, ioErr := ioutil.ReadAll(resp.Body)
  20877. if ioErr != nil {
  20878. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20880. return
  20881. }
  20882. var respJSON map[string]interface{}
  20883. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20884. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20886. return
  20887. }
  20888. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20889. userJSONBytes, _ := json.Marshal(respJSON)
  20890. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20891. utils.ErrorLog("解析失败:%v", err)
  20892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20893. return
  20894. }
  20895. res.InfRefmsgid = resOther.InfRefmsgid
  20896. res.Output = resOther.Output
  20897. res.ErrMsg = resOther.ErrMsg
  20898. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20899. res.Infcode = infocode
  20900. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20901. var pp models.PublicParams
  20902. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20903. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20904. pp.FixmedinsName = miConfig.OrgName
  20905. pp.FixmedinsCode = miConfig.Code
  20906. pp.RequestUrl = miConfig.Url
  20907. pp.Cainfo = miConfig.Cainfo
  20908. pp.SecretKey = miConfig.SecretKey
  20909. pp.AccessKey = miConfig.AccessKey
  20910. pp.OpterName = curRoles.UserName
  20911. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  20912. fmt.Println(requestLog)
  20913. fmt.Println(errMsgLog)
  20914. saveLog(result, requestLog, "4101a", "上传清单")
  20915. var dat map[string]interface{}
  20916. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20917. fmt.Println(dat)
  20918. } else {
  20919. fmt.Println(err)
  20920. }
  20921. userJSONBytes, _ := json.Marshal(dat)
  20922. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20923. utils.ErrorLog("解析失败:%v", err)
  20924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20925. return
  20926. }
  20927. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20928. var pp models.PublicParams
  20929. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20930. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20931. pp.FixmedinsName = miConfig.OrgName
  20932. pp.FixmedinsCode = miConfig.Code
  20933. pp.RequestUrl = miConfig.Url
  20934. pp.Cainfo = miConfig.Cainfo
  20935. pp.SecretKey = miConfig.SecretKey
  20936. pp.AccessKey = miConfig.AccessKey
  20937. pp.OpterName = curRoles.UserName
  20938. client := &http.Client{}
  20939. var req *http.Request
  20940. data := make(map[string]interface{})
  20941. data["struct4101"] = struct4101
  20942. data["pp"] = pp
  20943. bytesData, _ := json.Marshal(data)
  20944. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  20945. resp, _ := client.Do(req)
  20946. defer resp.Body.Close()
  20947. body, ioErr := ioutil.ReadAll(resp.Body)
  20948. if ioErr != nil {
  20949. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20951. return
  20952. }
  20953. var respJSON map[string]interface{}
  20954. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20955. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20957. return
  20958. }
  20959. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20960. userJSONBytes, _ := json.Marshal(respJSON)
  20961. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20962. utils.ErrorLog("解析失败:%v", err)
  20963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20964. return
  20965. }
  20966. } else {
  20967. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20968. var dat map[string]interface{}
  20969. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20970. fmt.Println(dat)
  20971. } else {
  20972. fmt.Println(err)
  20973. }
  20974. userJSONBytes, _ := json.Marshal(dat)
  20975. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20976. utils.ErrorLog("解析失败:%v", err)
  20977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20978. return
  20979. }
  20980. }
  20981. if res.Infcode != 0 {
  20982. c.ServeSuccessJSON(map[string]interface{}{
  20983. "failed_code": -10,
  20984. "msg": res.ErrMsg,
  20985. })
  20986. return
  20987. } else {
  20988. //order.FaPiaoNumber = zero
  20989. //order.FaPiaoCode = last_order.FaPiaoCode
  20990. //service.UpdateOrder(order)
  20991. hisFundSettleListResult := &models.HisFundSettleListResult{
  20992. Number: res.Output.SetlListId,
  20993. Status: 1,
  20994. Ctime: time.Now().Unix(),
  20995. Mtime: time.Now().Unix(),
  20996. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20997. IsUpload: 1,
  20998. OrderId: order_id,
  20999. }
  21000. service.CreateUploadRecord(hisFundSettleListResult)
  21001. c.ServeSuccessJSON(map[string]interface{}{
  21002. "msg": "上传成功",
  21003. "result": hisFundSettleListResult,
  21004. })
  21005. return
  21006. }
  21007. }
  21008. func (c *HisApiController) GetSettleListHospital() {
  21009. order_id, _ := c.GetInt64("order_id")
  21010. admin_user_id, _ := c.GetInt64("admin_user_id")
  21011. order, _ := service.GetHisOrderByIDTwo(order_id)
  21012. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  21013. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  21014. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  21015. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  21016. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  21017. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  21018. if order.ID == 0 {
  21019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  21020. return
  21021. }
  21022. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  21023. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  21024. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  21025. fmt.Println(count)
  21026. var zero string
  21027. number := count + 1
  21028. if number >= 1000 {
  21029. zero = "0000" + strconv.FormatInt(number, 10)
  21030. } else if number >= 10000 {
  21031. zero = "000" + strconv.FormatInt(number, 10)
  21032. } else if number >= 100000 {
  21033. zero = "00" + strconv.FormatInt(number, 10)
  21034. } else if number >= 1000000 {
  21035. zero = "0" + strconv.FormatInt(number, 10)
  21036. } else {
  21037. zero = strconv.FormatInt(number, 10)
  21038. }
  21039. fmt.Println(zero)
  21040. struct4101 := service.Struct4101{
  21041. PsnNo: order.PsnNo,
  21042. MdtrtId: order.MdtrtId,
  21043. SetlId: order.SetlId,
  21044. PsnName: order.PsnName,
  21045. Gend: order.Gend,
  21046. Brdy: his.Brdy,
  21047. Age: int64(order.Age),
  21048. Naty: order.Naty,
  21049. PatnCertType: "01",
  21050. Certno: order.Certno,
  21051. Prfs: "90",
  21052. ConerName: roles[0].UserName,
  21053. PatnRlts: "99",
  21054. ConerAddr: miConfig.OrgName,
  21055. ConerTel: admin.Mobile,
  21056. HiType: order.Insutype,
  21057. Insuplc: miConfig.InsuplcAdmdvs,
  21058. MaindiagFlag: "1",
  21059. BillCode: order.SetlId,
  21060. BillNo: order.SetlId,
  21061. BizSn: order.Number,
  21062. PsnSelfPay: order.PsnPartAmt,
  21063. PsnOwnPay: order.PsnPartAmt,
  21064. AcctPay: order.AcctPay,
  21065. PsnCashpay: order.PsnCashPay,
  21066. HiPaymtd: "1",
  21067. Hsorg: miConfig.InsuplcAdmdvs,
  21068. HsorgOpter: miConfig.InsuplcAdmdvs,
  21069. MedinsFillPsn: curRoles.UserName,
  21070. MedinsFillDept: depart.Name,
  21071. IptMedType: "2",
  21072. AdmTime: his.InHosptialTime,
  21073. AdmEndTime: his.OutHosptialTime,
  21074. }
  21075. struct4101.SetlBegnDate = order.SetlTime
  21076. struct4101.SetlEndDate = order.SetlTime
  21077. //var rf []CustomFundPay
  21078. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  21079. //
  21080. //var tempFunPays []service.CustomStruct
  21081. //for _, item := range rf {
  21082. // var tempFunPay service.CustomStruct
  21083. // tempFunPay.FundPayamt = item.FundPayamt
  21084. // tempFunPay.FundPayType = item.FundPayType
  21085. // tempFunPays = append(tempFunPays, tempFunPay)
  21086. //}
  21087. //struct4101.CustomStruct = tempFunPays
  21088. var tempDiaginfos []service.DiaginfoStructTwo
  21089. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  21090. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  21091. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  21092. //for _, item := range infos {
  21093. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  21094. //}
  21095. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  21096. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  21097. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  21098. fmt.Println(diagnosis_ids_arr)
  21099. if order.UserOrgId == 10210 {
  21100. var diagnosis_ids_arr_two []int64
  21101. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  21102. var config []*models.HisXtDiagnoseConfig
  21103. for _, id := range diagnosis_ids_arr_two {
  21104. //id, _ := strconv.ParseInt(item, 10, 64)
  21105. diagnosisConfig, _ := service.FindDiagnoseById(id)
  21106. if diagnosisConfig.ID > 0 {
  21107. config = append(config, &diagnosisConfig)
  21108. }
  21109. }
  21110. for index, item := range config {
  21111. if item.ID > 0 {
  21112. if index == 0 {
  21113. var tempDiaginfo service.DiaginfoStructTwo
  21114. tempDiaginfo.DiagCode = item.CountryCode
  21115. tempDiaginfo.DiagName = item.CountryContentName
  21116. tempDiaginfo.DiagType = "1"
  21117. tempDiaginfo.MaindiagFlag = "1"
  21118. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21119. } else {
  21120. var tempDiaginfo service.DiaginfoStructTwo
  21121. tempDiaginfo.DiagCode = item.CountryCode
  21122. tempDiaginfo.DiagName = item.CountryContentName
  21123. tempDiaginfo.DiagType = "1"
  21124. tempDiaginfo.MaindiagFlag = "0"
  21125. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21126. }
  21127. }
  21128. }
  21129. struct4101.Diseinfo = tempDiaginfos
  21130. } else {
  21131. var config []*models.HisXtDiagnoseConfig
  21132. for _, item := range diagnosis_ids_arr {
  21133. id, _ := strconv.ParseInt(item, 10, 64)
  21134. diagnosisConfig, _ := service.FindDiagnoseById(id)
  21135. if diagnosisConfig.ID > 0 {
  21136. config = append(config, &diagnosisConfig)
  21137. }
  21138. }
  21139. for index, item := range config {
  21140. if item.ID > 0 {
  21141. if index == 0 {
  21142. var tempDiaginfo service.DiaginfoStructTwo
  21143. tempDiaginfo.DiagCode = item.CountryCode
  21144. tempDiaginfo.DiagName = item.CountryContentName
  21145. tempDiaginfo.DiagType = "1"
  21146. tempDiaginfo.MaindiagFlag = "1"
  21147. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21148. } else {
  21149. var tempDiaginfo service.DiaginfoStructTwo
  21150. tempDiaginfo.DiagCode = item.CountryCode
  21151. tempDiaginfo.DiagName = item.CountryContentName
  21152. tempDiaginfo.DiagType = "1"
  21153. tempDiaginfo.MaindiagFlag = "0"
  21154. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21155. }
  21156. }
  21157. }
  21158. struct4101.Diseinfo = tempDiaginfos
  21159. }
  21160. sickConfigTwo, _ := service.FindSickById(his.SickType)
  21161. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  21162. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  21163. tempOpspdiseinfo2.OprnOprtCode = ""
  21164. tempOpspdiseinfo2.OprnOprtName = ""
  21165. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  21166. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  21167. var iteminfo service.IteminfoStruct
  21168. var bedCostTotal float64 = 0 //床位总费
  21169. var bedCostSelfTotal float64 = 0 //床位自费
  21170. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  21171. var operationCostTotal float64 = 0 //手术费
  21172. var operationCostSelfTotal float64 = 0 //手术费
  21173. var operationCostPartSelfTotal float64 = 0 //手术费
  21174. var otherCostTotal float64 = 0 //其他费用
  21175. var otherCostSelfTotal float64 = 0 //其他费用
  21176. var otherCostPartSelfTotal float64 = 0 //其他费用
  21177. var materialCostTotal float64 = 0 //材料费
  21178. var materialCostSelfTotal float64 = 0 //材料费
  21179. var materialCostPartSelfTotal float64 = 0 //材料费
  21180. var westernMedicineCostTotal float64 = 0 //西药费
  21181. var westernMedicineCostSelfTotal float64 = 0 //西药费
  21182. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  21183. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  21184. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  21185. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  21186. var checkCostTotal float64 = 0 //检查费
  21187. var checkCostSelfTotal float64 = 0 //检查费
  21188. var checkCostPartSelfTotal float64 = 0 //检查费
  21189. var laboratoryCostTotal float64 = 0 //化验费
  21190. var laboratoryCostSelfTotal float64 = 0 //化验费
  21191. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  21192. var treatCostTotal float64 = 0 //治疗费用
  21193. var treatCostSelfTotal float64 = 0 //治疗费用
  21194. var treatCostPartSelfTotal float64 = 0 //治疗费用
  21195. decimal.DivisionPrecision = 2
  21196. var bed_fulamt_ownpay_amt float64 = 0
  21197. var operation_fulamt_ownpay_amt float64 = 0
  21198. var other_fulamt_ownpay_amt float64 = 0
  21199. var westernMedicine_fulamt_ownpay_amt float64 = 0
  21200. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  21201. var check_fulamt_ownpay_amt float64 = 0
  21202. var material_fulamt_ownpay_amt float64 = 0
  21203. var laboratory_fulamt_ownpay_amt float64 = 0
  21204. var treat_fulamt_ownpay_amt float64 = 0
  21205. var bed_claa_sunmfee float64 = 0
  21206. var bed_clab_amt float64 = 0
  21207. var bed_other_amt float64 = 0
  21208. var operation_claa_sunmfee float64 = 0
  21209. var operation_clab_amt float64 = 0
  21210. var operation_other_amt float64 = 0
  21211. var other_claa_sunmfee float64 = 0
  21212. var other_clab_amt float64 = 0
  21213. var other_other_amt float64 = 0
  21214. var westernMedicine_claa_sunmfee float64 = 0
  21215. var westernMedicine_clab_amt float64 = 0
  21216. var westernMedicine_other_amt float64 = 0
  21217. var chineseTraditional_claa_sunmfee float64 = 0
  21218. var chineseTraditional_clab_amt float64 = 0
  21219. var chineseTraditional_other_amt float64 = 0
  21220. var check_claa_sunmfee float64 = 0
  21221. var check_clab_amt float64 = 0
  21222. var check_other_amt float64 = 0
  21223. var material_claa_sunmfee float64 = 0
  21224. var material_clab_amt float64 = 0
  21225. var material_other_amt float64 = 0
  21226. var laboratory_claa_sunmfee float64 = 0
  21227. var laboratory_clab_amt float64 = 0
  21228. var laboratory_other_amt float64 = 0
  21229. var treat_claa_sunmfee float64 = 0
  21230. var treat_clab_amt float64 = 0
  21231. var treat_other_amt float64 = 0
  21232. for _, item := range order.HisOrderInfo {
  21233. if item.MedChrgitmType == "01" { //床位费
  21234. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21235. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21236. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21237. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21238. if item.ChrgitmLv == "1" {
  21239. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21240. }
  21241. if item.ChrgitmLv == "2" {
  21242. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21243. }
  21244. if item.ChrgitmLv == "3" {
  21245. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21246. }
  21247. }
  21248. if item.MedChrgitmType == "03" { //检查费
  21249. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21250. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21251. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21252. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21253. if item.ChrgitmLv == "1" {
  21254. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21255. }
  21256. if item.ChrgitmLv == "2" {
  21257. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21258. }
  21259. if item.ChrgitmLv == "3" {
  21260. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21261. }
  21262. }
  21263. if item.MedChrgitmType == "04" { //化验费
  21264. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21265. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21266. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21267. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21268. if item.ChrgitmLv == "1" {
  21269. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21270. }
  21271. if item.ChrgitmLv == "2" {
  21272. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21273. }
  21274. if item.ChrgitmLv == "3" {
  21275. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21276. }
  21277. }
  21278. if item.MedChrgitmType == "05" { //治疗费
  21279. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21280. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21281. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21282. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21283. if item.ChrgitmLv == "1" {
  21284. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21285. }
  21286. if item.ChrgitmLv == "2" {
  21287. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21288. }
  21289. if item.ChrgitmLv == "3" {
  21290. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21291. }
  21292. }
  21293. if item.MedChrgitmType == "06" { //手术费
  21294. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21295. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21296. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21297. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21298. if item.ChrgitmLv == "1" {
  21299. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21300. }
  21301. if item.ChrgitmLv == "2" {
  21302. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21303. }
  21304. if item.ChrgitmLv == "3" {
  21305. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21306. }
  21307. }
  21308. if item.MedChrgitmType == "08" { //材料费
  21309. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21310. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21311. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21312. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21313. if item.ChrgitmLv == "1" {
  21314. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21315. }
  21316. if item.ChrgitmLv == "2" {
  21317. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21318. }
  21319. if item.ChrgitmLv == "3" {
  21320. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21321. }
  21322. }
  21323. if item.MedChrgitmType == "09" { //西药费
  21324. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21325. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21326. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21327. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21328. if item.ChrgitmLv == "1" {
  21329. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21330. }
  21331. if item.ChrgitmLv == "2" {
  21332. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21333. }
  21334. if item.ChrgitmLv == "3" {
  21335. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21336. }
  21337. }
  21338. if item.MedChrgitmType == "11" { //中成费
  21339. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21340. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21341. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21342. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21343. if item.ChrgitmLv == "1" {
  21344. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21345. }
  21346. if item.ChrgitmLv == "2" {
  21347. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21348. }
  21349. if item.ChrgitmLv == "3" {
  21350. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21351. }
  21352. }
  21353. if item.MedChrgitmType == "14" { //其他费
  21354. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21355. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21356. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21357. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21358. if item.ChrgitmLv == "1" {
  21359. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21360. }
  21361. if item.ChrgitmLv == "2" {
  21362. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21363. }
  21364. if item.ChrgitmLv == "3" {
  21365. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21366. }
  21367. }
  21368. }
  21369. var iteminfoStructs []service.IteminfoStruct
  21370. if bedCostTotal != 0 {
  21371. iteminfo.MedChrgitm = "01"
  21372. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21373. iteminfo.Amt = bedCostTotal
  21374. iteminfo.ClaaSumfee = bed_claa_sunmfee
  21375. iteminfo.ClabAmt = bed_clab_amt
  21376. iteminfo.OthAmt = bed_other_amt
  21377. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21378. }
  21379. if checkCostTotal != 0 {
  21380. iteminfo.MedChrgitm = "03"
  21381. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  21382. iteminfo.Amt = checkCostTotal
  21383. iteminfo.ClaaSumfee = check_claa_sunmfee
  21384. iteminfo.ClabAmt = check_clab_amt
  21385. iteminfo.OthAmt = check_other_amt
  21386. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21387. }
  21388. if laboratoryCostTotal != 0 {
  21389. iteminfo.MedChrgitm = "04"
  21390. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  21391. iteminfo.Amt = laboratoryCostTotal
  21392. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  21393. iteminfo.ClabAmt = laboratory_clab_amt
  21394. iteminfo.OthAmt = laboratory_other_amt
  21395. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21396. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21397. }
  21398. if treatCostTotal != 0 {
  21399. iteminfo.MedChrgitm = "05"
  21400. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  21401. iteminfo.Amt = treatCostTotal
  21402. iteminfo.ClaaSumfee = treat_claa_sunmfee
  21403. iteminfo.ClabAmt = treat_clab_amt
  21404. iteminfo.OthAmt = treat_other_amt
  21405. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21406. //(struct4101.IteminfoStruct, iteminfo)
  21407. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21408. }
  21409. if operationCostTotal != 0 {
  21410. iteminfo.MedChrgitm = "06"
  21411. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21412. iteminfo.Amt = operationCostTotal
  21413. iteminfo.ClaaSumfee = operation_claa_sunmfee
  21414. iteminfo.ClabAmt = operation_clab_amt
  21415. iteminfo.OthAmt = operation_other_amt
  21416. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21417. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21418. }
  21419. if materialCostTotal != 0 {
  21420. iteminfo.MedChrgitm = "08"
  21421. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  21422. iteminfo.Amt = materialCostTotal
  21423. iteminfo.ClaaSumfee = material_claa_sunmfee
  21424. iteminfo.ClabAmt = material_clab_amt
  21425. iteminfo.OthAmt = material_other_amt
  21426. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21427. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21428. }
  21429. if westernMedicineCostTotal != 0 {
  21430. iteminfo.MedChrgitm = "09"
  21431. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21432. iteminfo.Amt = westernMedicineCostTotal
  21433. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21434. iteminfo.ClabAmt = westernMedicine_clab_amt
  21435. iteminfo.OthAmt = westernMedicine_other_amt
  21436. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21437. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21438. }
  21439. if chineseTraditionalMedicineCostTotal != 0 {
  21440. iteminfo.MedChrgitm = "11"
  21441. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21442. iteminfo.Amt = westernMedicineCostTotal
  21443. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21444. iteminfo.ClabAmt = westernMedicine_clab_amt
  21445. iteminfo.OthAmt = westernMedicine_other_amt
  21446. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21447. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21448. }
  21449. if otherCostTotal != 0 {
  21450. iteminfo.MedChrgitm = "14"
  21451. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  21452. iteminfo.Amt = otherCostTotal
  21453. iteminfo.ClaaSumfee = other_claa_sunmfee
  21454. iteminfo.ClabAmt = other_clab_amt
  21455. iteminfo.OthAmt = other_other_amt
  21456. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21457. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21458. }
  21459. struct4101.IteminfoStruct = iteminfoStructs
  21460. struct4101.Ntly = "中国"
  21461. struct4101.AdmCaty = "A03.06"
  21462. var resOther ResultSeventeenOther
  21463. var res ResultSeventeen
  21464. if miConfig.MdtrtareaAdmvs == "150404" {
  21465. var pp models.PublicParams
  21466. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  21467. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21468. pp.FixmedinsName = miConfig.OrgName
  21469. pp.FixmedinsCode = miConfig.Code
  21470. pp.RequestUrl = miConfig.Url
  21471. pp.Cainfo = miConfig.Cainfo
  21472. pp.SecretKey = miConfig.SecretKey
  21473. pp.AccessKey = miConfig.AccessKey
  21474. pp.OpterName = curRoles.UserName
  21475. client := &http.Client{}
  21476. var req *http.Request
  21477. data := make(map[string]interface{})
  21478. data["struct4101"] = struct4101
  21479. data["pp"] = pp
  21480. bytesData, _ := json.Marshal(data)
  21481. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  21482. resp, _ := client.Do(req)
  21483. defer resp.Body.Close()
  21484. body, ioErr := ioutil.ReadAll(resp.Body)
  21485. if ioErr != nil {
  21486. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21488. return
  21489. }
  21490. var respJSON map[string]interface{}
  21491. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21492. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21494. return
  21495. }
  21496. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21497. userJSONBytes, _ := json.Marshal(respJSON)
  21498. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  21499. utils.ErrorLog("解析失败:%v", err)
  21500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21501. return
  21502. }
  21503. res.InfRefmsgid = resOther.InfRefmsgid
  21504. res.Output = resOther.Output
  21505. res.ErrMsg = resOther.ErrMsg
  21506. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  21507. res.Infcode = infocode
  21508. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21509. var pp models.PublicParams
  21510. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21511. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21512. pp.FixmedinsName = miConfig.OrgName
  21513. pp.FixmedinsCode = miConfig.Code
  21514. pp.RequestUrl = miConfig.Url
  21515. pp.Cainfo = miConfig.Cainfo
  21516. pp.SecretKey = miConfig.SecretKey
  21517. pp.AccessKey = miConfig.AccessKey
  21518. pp.OpterName = curRoles.UserName
  21519. result, _ := service.Jxyb4101(struct4101, pp)
  21520. var dat map[string]interface{}
  21521. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21522. fmt.Println(dat)
  21523. } else {
  21524. fmt.Println(err)
  21525. }
  21526. userJSONBytes, _ := json.Marshal(dat)
  21527. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21528. utils.ErrorLog("解析失败:%v", err)
  21529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21530. return
  21531. }
  21532. } else if miConfig.MdtrtareaAdmvs == "361025" {
  21533. var pp models.PublicParams
  21534. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21535. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21536. pp.FixmedinsName = miConfig.OrgName
  21537. pp.FixmedinsCode = miConfig.Code
  21538. pp.RequestUrl = miConfig.Url
  21539. pp.Cainfo = miConfig.Cainfo
  21540. pp.SecretKey = miConfig.SecretKey
  21541. pp.AccessKey = miConfig.AccessKey
  21542. pp.OpterName = curRoles.UserName
  21543. result, _ := service.Jxyb4101(struct4101, pp)
  21544. var dat map[string]interface{}
  21545. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21546. fmt.Println(dat)
  21547. } else {
  21548. fmt.Println(err)
  21549. }
  21550. userJSONBytes, _ := json.Marshal(dat)
  21551. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21552. utils.ErrorLog("解析失败:%v", err)
  21553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21554. return
  21555. }
  21556. } else if miConfig.MdtrtareaAdmvs == "360100" {
  21557. var pp models.PublicParams
  21558. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21559. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21560. pp.FixmedinsName = miConfig.OrgName
  21561. pp.FixmedinsCode = miConfig.Code
  21562. pp.RequestUrl = miConfig.Url
  21563. pp.Cainfo = miConfig.Cainfo
  21564. pp.SecretKey = miConfig.SecretKey
  21565. pp.AccessKey = miConfig.AccessKey
  21566. pp.OpterName = curRoles.UserName
  21567. result, _ := service.Jxyb4101(struct4101, pp)
  21568. var dat map[string]interface{}
  21569. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21570. fmt.Println(dat)
  21571. } else {
  21572. fmt.Println(err)
  21573. }
  21574. userJSONBytes, _ := json.Marshal(dat)
  21575. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21576. utils.ErrorLog("解析失败:%v", err)
  21577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21578. return
  21579. }
  21580. } else {
  21581. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  21582. var dat map[string]interface{}
  21583. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21584. fmt.Println(dat)
  21585. } else {
  21586. fmt.Println(err)
  21587. }
  21588. userJSONBytes, _ := json.Marshal(dat)
  21589. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21590. utils.ErrorLog("解析失败:%v", err)
  21591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21592. return
  21593. }
  21594. }
  21595. if res.Infcode != 0 {
  21596. c.ServeSuccessJSON(map[string]interface{}{
  21597. "failed_code": -10,
  21598. "msg": res.ErrMsg,
  21599. })
  21600. return
  21601. } else {
  21602. if miConfig.MdtrtareaAdmvs != "150404" {
  21603. order.FaPiaoNumber = zero
  21604. order.FaPiaoCode = last_order.FaPiaoCode
  21605. service.UpdateOrder(order)
  21606. }
  21607. hisFundSettleListResult := &models.HisFundSettleListResult{
  21608. Number: res.Output.SetlListId,
  21609. Status: 1,
  21610. Ctime: time.Now().Unix(),
  21611. Mtime: time.Now().Unix(),
  21612. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21613. IsUpload: 1,
  21614. OrderId: order_id,
  21615. }
  21616. service.CreateUploadRecord(hisFundSettleListResult)
  21617. c.ServeSuccessJSON(map[string]interface{}{
  21618. "msg": "上传成功",
  21619. "result": hisFundSettleListResult,
  21620. })
  21621. return
  21622. }
  21623. }
  21624. //func (c *HisApiController) GetBatchSettleList() {
  21625. // orders, _ := service.GetAllHisOrder(10106)
  21626. // for _, item := range orders {
  21627. // order_id := item.ID
  21628. // order, _ := service.GetHisOrderByIDTwo(order_id)
  21629. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  21630. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  21631. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  21632. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  21633. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  21634. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  21635. //
  21636. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  21637. //
  21638. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  21639. //
  21640. // if order.ID == 0 {
  21641. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  21642. // return
  21643. // }
  21644. // if his.BalanceAccountsType == 2 {
  21645. // continue
  21646. // }
  21647. // struct4101 := service.Struct4101{
  21648. // PsnNo: order.PsnNo,
  21649. // MdtrtId: order.MdtrtId,
  21650. // SetlId: order.SetlId,
  21651. // PsnName: order.PsnName,
  21652. // Gend: order.Gend,
  21653. // Brdy: his.Brdy,
  21654. // Age: his.Age,
  21655. // Naty: order.Naty,
  21656. // PatnCertType: "01",
  21657. // Certno: order.Certno,
  21658. // Prfs: "90",
  21659. // ConerName: roles[0].UserName,
  21660. // PatnRlts: "99",
  21661. // ConerAddr: miConfig.OrgName,
  21662. // ConerTel: admin.Mobile,
  21663. // HiType: order.Insutype,
  21664. // Insuplc: his.InsuplcAdmdvs,
  21665. // MaindiagFlag: "1",
  21666. // BillCode: order.SetlId,
  21667. // BillNo: order.SetlId,
  21668. // BizSn: order.Number,
  21669. // PsnSelfPay: order.PsnPartAmt,
  21670. // PsnOwnPay: order.PsnPartAmt,
  21671. // AcctPay: order.AcctPay,
  21672. // PsnCashpay: order.PsnCashPay,
  21673. // HiPaymtd: "1",
  21674. // Hsorg: his.InsuplcAdmdvs,
  21675. // HsorgOpter: his.InsuplcAdmdvs,
  21676. // MedinsFillPsn: curRoles.UserName,
  21677. // MedinsFillDept: depart.Name,
  21678. // IptMedType: "2",
  21679. // }
  21680. // struct4101.SetlBegnDate = order.SetlTime
  21681. // struct4101.SetlEndDate = order.SetlTime
  21682. // //if order.SettleType == 1 {
  21683. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  21684. // // dateStr := t.Format("2006-01-02")
  21685. // // struct4101.SetlBegnDate = dateStr
  21686. // // struct4101.SetlEndDate = dateStr
  21687. // //} else {
  21688. // // t := time.Unix(int64(order.SettleStartTime), 0)
  21689. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  21690. // // dateStartStr := t.Format("2006-01-02")
  21691. // // dateEndStr := t2.Format("2006-01-02")
  21692. // // struct4101.SetlBegnDate = dateStartStr
  21693. // // struct4101.SetlEndDate = dateEndStr
  21694. // //}
  21695. //
  21696. // var rf []CustomFundPay
  21697. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  21698. //
  21699. // var tempFunPays []service.CustomStruct
  21700. // var tempFunPay610100 service.CustomStruct
  21701. //
  21702. // for _, item := range rf {
  21703. // if item.FundPayType == "610100" {
  21704. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  21705. // tempFunPay610100.FundPayType = item.FundPayType
  21706. // } else {
  21707. // var tempFunPay service.CustomStruct
  21708. // tempFunPay.FundPayamt = item.FundPayamt
  21709. // tempFunPay.FundPayType = item.FundPayType
  21710. // tempFunPays = append(tempFunPays, tempFunPay)
  21711. // }
  21712. // }
  21713. // tempFunPays = append(tempFunPays, tempFunPay610100)
  21714. // struct4101.CustomStruct = tempFunPays
  21715. //
  21716. // var tempDiaginfos []service.DiaginfoStructTwo
  21717. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  21718. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  21719. //
  21720. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  21721. // var config []*models.HisXtDiagnoseConfig
  21722. // for _, item := range diagnosis_ids {
  21723. // id, _ := strconv.ParseInt(item, 10, 64)
  21724. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  21725. // config = append(config, &diagnosisConfig)
  21726. // }
  21727. //
  21728. // for index, item := range config {
  21729. // if index == 0 {
  21730. // var tempDiaginfo service.DiaginfoStructTwo
  21731. // tempDiaginfo.DiagCode = item.CountryCode
  21732. // tempDiaginfo.DiagName = item.CountryContentName
  21733. // tempDiaginfo.DiagType = "1"
  21734. // tempDiaginfo.MaindiagFlag = "1"
  21735. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21736. // } else {
  21737. //
  21738. // var tempDiaginfo service.DiaginfoStructTwo
  21739. // tempDiaginfo.DiagCode = item.CountryCode
  21740. // tempDiaginfo.DiagName = item.CountryContentName
  21741. // tempDiaginfo.DiagType = "2"
  21742. // tempDiaginfo.MaindiagFlag = "0"
  21743. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21744. // }
  21745. // }
  21746. // struct4101.Diseinfo = tempDiaginfos
  21747. //
  21748. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  21749. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  21750. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  21751. // tempOpspdiseinfo2.OprnOprtCode = ""
  21752. // tempOpspdiseinfo2.OprnOprtName = ""
  21753. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  21754. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  21755. //
  21756. // var iteminfo service.IteminfoStruct
  21757. //
  21758. // var bedCostTotal float64 = 0 //床位总费
  21759. // var bedCostSelfTotal float64 = 0 //床位自费
  21760. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  21761. //
  21762. // var examineCostTotal float64 = 0 //诊查总费
  21763. // var examineCostSelfTotal float64 = 0 //诊查自费
  21764. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  21765. //
  21766. // var nursingCostTotal float64 = 0 //护理总费
  21767. // var nursingCostSelfTotal float64 = 0 //护理自费
  21768. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  21769. //
  21770. // var chineseMedicineCostTotal float64 = 0 //中成药
  21771. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  21772. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  21773. //
  21774. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  21775. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  21776. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  21777. //
  21778. // var registerCostTotal float64 = 0 //一般诊疗费
  21779. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  21780. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  21781. //
  21782. // var operationCostTotal float64 = 0 //手术费
  21783. // var operationCostSelfTotal float64 = 0 //手术费
  21784. // var operationCostPartSelfTotal float64 = 0 //手术费
  21785. //
  21786. // var otherCostTotal float64 = 0 //其他费用
  21787. // var otherCostSelfTotal float64 = 0 //其他费用
  21788. // var otherCostPartSelfTotal float64 = 0 //其他费用
  21789. //
  21790. // var materialCostTotal float64 = 0 //材料费
  21791. // var materialCostSelfTotal float64 = 0 //材料费
  21792. // var materialCostPartSelfTotal float64 = 0 //材料费
  21793. //
  21794. // var westernMedicineCostTotal float64 = 0 //西药费
  21795. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  21796. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  21797. //
  21798. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  21799. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  21800. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  21801. //
  21802. // var checkCostTotal float64 = 0 //检查费
  21803. // var checkCostSelfTotal float64 = 0 //检查费
  21804. // var checkCostPartSelfTotal float64 = 0 //检查费
  21805. //
  21806. // var laboratoryCostTotal float64 = 0 //化验费
  21807. // var laboratoryCostSelfTotal float64 = 0 //化验费
  21808. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  21809. //
  21810. // var treatCostTotal float64 = 0 //治疗费用
  21811. // var treatCostSelfTotal float64 = 0 //治疗费用
  21812. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  21813. //
  21814. // decimal.DivisionPrecision = 2
  21815. //
  21816. // var bed_fulamt_ownpay_amt float64 = 0
  21817. //
  21818. // var examine_fulamt_ownpay_amt float64 = 0
  21819. //
  21820. // var nursing_fulamt_ownpay_amt float64 = 0
  21821. //
  21822. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  21823. //
  21824. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  21825. //
  21826. // var register_fulamt_ownpay_amt float64 = 0
  21827. //
  21828. // var operation_fulamt_ownpay_amt float64 = 0
  21829. // var other_fulamt_ownpay_amt float64 = 0
  21830. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  21831. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  21832. // var check_fulamt_ownpay_amt float64 = 0
  21833. // var material_fulamt_ownpay_amt float64 = 0
  21834. // var laboratory_fulamt_ownpay_amt float64 = 0
  21835. // var treat_fulamt_ownpay_amt float64 = 0
  21836. //
  21837. // var bed_claa_sunmfee float64 = 0
  21838. // var bed_clab_amt float64 = 0
  21839. // var bed_other_amt float64 = 0
  21840. //
  21841. // var examine_claa_sunmfee float64 = 0
  21842. // var examine_clab_amt float64 = 0
  21843. // var examine_other_amt float64 = 0
  21844. //
  21845. // var nursing_claa_sunmfee float64 = 0
  21846. // var nursing_clab_amt float64 = 0
  21847. // var nursing_other_amt float64 = 0
  21848. //
  21849. // var chinese_medicine_claa_sunmfee float64 = 0
  21850. // var chinese_medicine_clab_amt float64 = 0
  21851. // var chinese_medicine_other_amt float64 = 0
  21852. //
  21853. // var commonly_treatment_claa_sunmfee float64 = 0
  21854. // var commonly_treatment_clab_amt float64 = 0
  21855. // var commonly_treatment_other_amt float64 = 0
  21856. //
  21857. // var operation_claa_sunmfee float64 = 0
  21858. // var operation_clab_amt float64 = 0
  21859. // var operation_other_amt float64 = 0
  21860. //
  21861. // var other_claa_sunmfee float64 = 0
  21862. // var other_clab_amt float64 = 0
  21863. // var other_other_amt float64 = 0
  21864. //
  21865. // var westernMedicine_claa_sunmfee float64 = 0
  21866. // var westernMedicine_clab_amt float64 = 0
  21867. // var westernMedicine_other_amt float64 = 0
  21868. //
  21869. // var chineseTraditional_claa_sunmfee float64 = 0
  21870. // var chineseTraditional_clab_amt float64 = 0
  21871. // var chineseTraditional_other_amt float64 = 0
  21872. //
  21873. // var check_claa_sunmfee float64 = 0
  21874. // var check_clab_amt float64 = 0
  21875. // var check_other_amt float64 = 0
  21876. //
  21877. // var material_claa_sunmfee float64 = 0
  21878. // var material_clab_amt float64 = 0
  21879. // var material_other_amt float64 = 0
  21880. //
  21881. // var laboratory_claa_sunmfee float64 = 0
  21882. // var laboratory_clab_amt float64 = 0
  21883. // var laboratory_other_amt float64 = 0
  21884. //
  21885. // var treat_claa_sunmfee float64 = 0
  21886. // var treat_clab_amt float64 = 0
  21887. // var treat_other_amt float64 = 0
  21888. //
  21889. // var register_claa_sunmfee float64 = 0
  21890. // var register_clab_amt float64 = 0
  21891. // var register_other_amt float64 = 0
  21892. //
  21893. // for _, item := range order.HisOrderInfo {
  21894. // if item.MedChrgitmType == "01" { //床位费
  21895. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21896. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21897. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21898. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21899. // if item.ChrgitmLv == "1" {
  21900. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21901. // }
  21902. // if item.ChrgitmLv == "2" {
  21903. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21904. //
  21905. // }
  21906. // if item.ChrgitmLv == "3" {
  21907. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21908. // }
  21909. //
  21910. // }
  21911. //
  21912. // if item.MedChrgitmType == "02" { //诊查
  21913. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21914. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21915. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21916. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21917. // if item.ChrgitmLv == "1" {
  21918. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21919. // }
  21920. // if item.ChrgitmLv == "2" {
  21921. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21922. //
  21923. // }
  21924. // if item.ChrgitmLv == "3" {
  21925. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21926. // }
  21927. //
  21928. // }
  21929. //
  21930. // if item.MedChrgitmType == "03" { //检查费
  21931. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21932. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21933. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21934. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21935. // if item.ChrgitmLv == "1" {
  21936. //
  21937. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21938. //
  21939. // }
  21940. // if item.ChrgitmLv == "2" {
  21941. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21942. //
  21943. // }
  21944. // if item.ChrgitmLv == "3" {
  21945. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21946. // }
  21947. // }
  21948. //
  21949. // if item.MedChrgitmType == "04" { //化验费
  21950. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21951. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21952. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21953. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21954. // if item.ChrgitmLv == "1" {
  21955. //
  21956. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21957. //
  21958. // }
  21959. // if item.ChrgitmLv == "2" {
  21960. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21961. //
  21962. // }
  21963. // if item.ChrgitmLv == "3" {
  21964. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21965. // }
  21966. // }
  21967. //
  21968. // if item.MedChrgitmType == "05" { //治疗费
  21969. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21970. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21971. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21972. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21973. // if item.ChrgitmLv == "1" {
  21974. //
  21975. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21976. //
  21977. // }
  21978. // if item.ChrgitmLv == "2" {
  21979. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21980. //
  21981. // }
  21982. // if item.ChrgitmLv == "3" {
  21983. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21984. // }
  21985. // }
  21986. //
  21987. // if item.MedChrgitmType == "06" { //手术费
  21988. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21989. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21990. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21991. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21992. //
  21993. // if item.ChrgitmLv == "1" {
  21994. //
  21995. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21996. //
  21997. // }
  21998. // if item.ChrgitmLv == "2" {
  21999. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22000. //
  22001. // }
  22002. // if item.ChrgitmLv == "3" {
  22003. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22004. // }
  22005. // }
  22006. //
  22007. // if item.MedChrgitmType == "07" { //手术费
  22008. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22009. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22010. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22011. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22012. //
  22013. // if item.ChrgitmLv == "1" {
  22014. //
  22015. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22016. //
  22017. // }
  22018. // if item.ChrgitmLv == "2" {
  22019. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22020. //
  22021. // }
  22022. // if item.ChrgitmLv == "3" {
  22023. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22024. // }
  22025. // }
  22026. //
  22027. // if item.MedChrgitmType == "08" { //材料费
  22028. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22029. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22030. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22031. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22032. // if item.ChrgitmLv == "1" {
  22033. //
  22034. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22035. //
  22036. // }
  22037. // if item.ChrgitmLv == "2" {
  22038. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22039. //
  22040. // }
  22041. // if item.ChrgitmLv == "3" {
  22042. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22043. // }
  22044. // }
  22045. // if item.MedChrgitmType == "09" { //西药费
  22046. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22047. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22048. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22049. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22050. // if item.ChrgitmLv == "1" {
  22051. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22052. // }
  22053. // if item.ChrgitmLv == "2" {
  22054. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22055. // }
  22056. // if item.ChrgitmLv == "3" {
  22057. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22058. // }
  22059. // }
  22060. // if item.MedChrgitmType == "10" { //中药饮片
  22061. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22062. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22063. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22064. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22065. // if item.ChrgitmLv == "1" {
  22066. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22067. // }
  22068. // if item.ChrgitmLv == "2" {
  22069. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22070. // }
  22071. // if item.ChrgitmLv == "3" {
  22072. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22073. // }
  22074. // }
  22075. //
  22076. // if item.MedChrgitmType == "11" { //中成费
  22077. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22078. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22079. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22080. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22081. // if item.ChrgitmLv == "1" {
  22082. //
  22083. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22084. //
  22085. // }
  22086. // if item.ChrgitmLv == "2" {
  22087. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22088. //
  22089. // }
  22090. // if item.ChrgitmLv == "3" {
  22091. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22092. // }
  22093. // }
  22094. //
  22095. // if item.MedChrgitmType == "12" { //中成费
  22096. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22097. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22098. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22099. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22100. // if item.ChrgitmLv == "1" {
  22101. //
  22102. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22103. //
  22104. // }
  22105. // if item.ChrgitmLv == "2" {
  22106. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22107. //
  22108. // }
  22109. // if item.ChrgitmLv == "3" {
  22110. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22111. // }
  22112. // }
  22113. //
  22114. // if item.MedChrgitmType == "13" { //中成费
  22115. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22116. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22117. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22118. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22119. // if item.ChrgitmLv == "1" {
  22120. //
  22121. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22122. //
  22123. // }
  22124. // if item.ChrgitmLv == "2" {
  22125. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22126. //
  22127. // }
  22128. // if item.ChrgitmLv == "3" {
  22129. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22130. // }
  22131. // }
  22132. //
  22133. // if item.MedChrgitmType == "14" { //其他费
  22134. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22135. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22136. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22137. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22138. // if item.ChrgitmLv == "1" {
  22139. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22140. //
  22141. // }
  22142. // if item.ChrgitmLv == "2" {
  22143. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22144. //
  22145. // }
  22146. // if item.ChrgitmLv == "3" {
  22147. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22148. // }
  22149. // }
  22150. //
  22151. // }
  22152. //
  22153. // var iteminfoStructs []service.IteminfoStruct
  22154. //
  22155. // if bedCostTotal != 0 {
  22156. // iteminfo.MedChrgitm = "01"
  22157. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  22158. // iteminfo.Amt = bedCostTotal
  22159. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  22160. // iteminfo.ClabAmt = bed_clab_amt
  22161. // iteminfo.OthAmt = bed_other_amt
  22162. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22163. // }
  22164. //
  22165. // if examineCostTotal != 0 {
  22166. // iteminfo.MedChrgitm = "02"
  22167. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  22168. // iteminfo.Amt = examineCostTotal
  22169. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  22170. // iteminfo.ClabAmt = examine_clab_amt
  22171. // iteminfo.OthAmt = examine_other_amt
  22172. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22173. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22174. // }
  22175. //
  22176. // if checkCostTotal != 0 {
  22177. // iteminfo.MedChrgitm = "03"
  22178. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  22179. // iteminfo.Amt = checkCostTotal
  22180. // iteminfo.ClaaSumfee = check_claa_sunmfee
  22181. // iteminfo.ClabAmt = check_clab_amt
  22182. // iteminfo.OthAmt = check_other_amt
  22183. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22184. //
  22185. // }
  22186. //
  22187. // if laboratoryCostTotal != 0 {
  22188. // iteminfo.MedChrgitm = "04"
  22189. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  22190. // iteminfo.Amt = laboratoryCostTotal
  22191. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  22192. // iteminfo.ClabAmt = laboratory_clab_amt
  22193. // iteminfo.OthAmt = laboratory_other_amt
  22194. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22195. //
  22196. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22197. //
  22198. // }
  22199. //
  22200. // if treatCostTotal != 0 {
  22201. // iteminfo.MedChrgitm = "05"
  22202. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  22203. // iteminfo.Amt = treatCostTotal
  22204. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  22205. // iteminfo.ClabAmt = treat_clab_amt
  22206. // iteminfo.OthAmt = treat_other_amt
  22207. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22208. // //(struct4101.IteminfoStruct, iteminfo)
  22209. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22210. // }
  22211. //
  22212. // if operationCostTotal != 0 {
  22213. // iteminfo.MedChrgitm = "06"
  22214. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  22215. // iteminfo.Amt = operationCostTotal
  22216. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  22217. // iteminfo.ClabAmt = operation_clab_amt
  22218. // iteminfo.OthAmt = operation_other_amt
  22219. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22220. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22221. // }
  22222. //
  22223. // if nursingCostTotal != 0 {
  22224. // iteminfo.MedChrgitm = "07"
  22225. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  22226. // iteminfo.Amt = nursingCostTotal
  22227. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  22228. // iteminfo.ClabAmt = nursing_clab_amt
  22229. // iteminfo.OthAmt = nursing_other_amt
  22230. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22231. // }
  22232. //
  22233. // if materialCostTotal != 0 {
  22234. // iteminfo.MedChrgitm = "08"
  22235. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  22236. // iteminfo.Amt = materialCostTotal
  22237. // iteminfo.ClaaSumfee = material_claa_sunmfee
  22238. // iteminfo.ClabAmt = material_clab_amt
  22239. // iteminfo.OthAmt = material_other_amt
  22240. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22241. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22242. // }
  22243. //
  22244. // if westernMedicineCostTotal != 0 {
  22245. // iteminfo.MedChrgitm = "09"
  22246. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  22247. // iteminfo.Amt = westernMedicineCostTotal
  22248. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  22249. // iteminfo.ClabAmt = westernMedicine_clab_amt
  22250. // iteminfo.OthAmt = westernMedicine_other_amt
  22251. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22252. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22253. //
  22254. // }
  22255. //
  22256. // if chineseMedicineCostTotal != 0 {
  22257. // iteminfo.MedChrgitm = "10"
  22258. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  22259. // iteminfo.Amt = chineseMedicineCostTotal
  22260. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  22261. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  22262. // iteminfo.OthAmt = chinese_medicine_other_amt
  22263. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22264. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22265. //
  22266. // }
  22267. //
  22268. // if chineseTraditionalMedicineCostTotal != 0 {
  22269. // iteminfo.MedChrgitm = "11"
  22270. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  22271. // iteminfo.Amt = westernMedicineCostTotal
  22272. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  22273. // iteminfo.ClabAmt = westernMedicine_clab_amt
  22274. // iteminfo.OthAmt = westernMedicine_other_amt
  22275. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22276. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22277. //
  22278. // }
  22279. //
  22280. // if commonlyTreatmentCostTotal != 0 {
  22281. // iteminfo.MedChrgitm = "12"
  22282. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  22283. // iteminfo.Amt = commonlyTreatmentCostTotal
  22284. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  22285. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  22286. // iteminfo.OthAmt = commonly_treatment_other_amt
  22287. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22288. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22289. //
  22290. // }
  22291. //
  22292. // if registerCostTotal != 0 {
  22293. // iteminfo.MedChrgitm = "13"
  22294. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  22295. // iteminfo.Amt = registerCostTotal
  22296. // iteminfo.ClaaSumfee = register_claa_sunmfee
  22297. // iteminfo.ClabAmt = register_clab_amt
  22298. // iteminfo.OthAmt = register_other_amt
  22299. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22300. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22301. //
  22302. // }
  22303. //
  22304. // if otherCostTotal != 0 {
  22305. // iteminfo.MedChrgitm = "14"
  22306. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  22307. // iteminfo.Amt = otherCostTotal
  22308. // iteminfo.ClaaSumfee = other_claa_sunmfee
  22309. // iteminfo.ClabAmt = other_clab_amt
  22310. // iteminfo.OthAmt = other_other_amt
  22311. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22312. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22313. //
  22314. // }
  22315. // struct4101.IteminfoStruct = iteminfoStructs
  22316. // time_arr := strings.Split(order.SetlTime, " ")
  22317. // struct4101.AdmTime = time_arr[0]
  22318. // struct4101.AdmEndTime = time_arr[0]
  22319. //
  22320. // struct4101.DoctorName = doctor.UserName
  22321. // struct4101.DoctorCode = doctor.DoctorNumber
  22322. //
  22323. // struct4101.Ntly = "中国"
  22324. // struct4101.AdmCaty = "A03.06"
  22325. // var res ResultSeventeen
  22326. // if miConfig.MdtrtareaAdmvs == "421300" {
  22327. // data := make(map[string]interface{})
  22328. // data["struct4101"] = struct4101
  22329. // data["secret_key"] = miConfig.SecretKey
  22330. // data["org_name"] = miConfig.OrgName
  22331. // data["opera"] = curRoles.UserName
  22332. // data["code"] = miConfig.Code
  22333. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  22334. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22335. //
  22336. // client := &http.Client{}
  22337. // bytesData, _ := json.Marshal(data)
  22338. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  22339. // resp, _ := client.Do(req)
  22340. // defer resp.Body.Close()
  22341. // body, ioErr := ioutil.ReadAll(resp.Body)
  22342. // if ioErr != nil {
  22343. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22344. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22345. // return
  22346. // }
  22347. // var respJSON map[string]interface{}
  22348. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22349. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22350. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22351. // return
  22352. // }
  22353. //
  22354. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22355. // userJSONBytes, _ := json.Marshal(respJSON)
  22356. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22357. // utils.ErrorLog("解析失败:%v", err)
  22358. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22359. // adminUser := c.GetAdminUserInfo()
  22360. // errlog := &models.HisOrderError{
  22361. // UserOrgId: adminUser.CurrentOrgId,
  22362. // Ctime: time.Now().Unix(),
  22363. // Mtime: time.Now().Unix(),
  22364. // ErrMsg: res.ErrMsg + "解析失败",
  22365. // Status: 1,
  22366. // PatientId: order_id,
  22367. // Stage: 10088,
  22368. // }
  22369. // service.CreateErrMsgLog(errlog)
  22370. // continue
  22371. // }
  22372. //
  22373. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  22374. // data := make(map[string]interface{})
  22375. // data["struct4101"] = struct4101
  22376. // data["secret_key"] = miConfig.SecretKey
  22377. // data["org_name"] = miConfig.OrgName
  22378. // data["opera"] = curRoles.UserName
  22379. // data["code"] = miConfig.Code
  22380. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  22381. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22382. //
  22383. // client := &http.Client{}
  22384. // bytesData, _ := json.Marshal(data)
  22385. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  22386. // resp, _ := client.Do(req)
  22387. // defer resp.Body.Close()
  22388. // body, ioErr := ioutil.ReadAll(resp.Body)
  22389. // if ioErr != nil {
  22390. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22391. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22392. // return
  22393. // }
  22394. // var respJSON map[string]interface{}
  22395. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22396. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22397. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22398. // return
  22399. // }
  22400. //
  22401. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22402. // userJSONBytes, _ := json.Marshal(respJSON)
  22403. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22404. // utils.ErrorLog("解析失败:%v", err)
  22405. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22406. // adminUser := c.GetAdminUserInfo()
  22407. // errlog := &models.HisOrderError{
  22408. // UserOrgId: adminUser.CurrentOrgId,
  22409. // Ctime: time.Now().Unix(),
  22410. // Mtime: time.Now().Unix(),
  22411. // ErrMsg: res.ErrMsg + "解析失败",
  22412. // Status: 1,
  22413. // PatientId: order_id,
  22414. // Stage: 10088,
  22415. // }
  22416. // service.CreateErrMsgLog(errlog)
  22417. // continue
  22418. // }
  22419. //
  22420. // } else {
  22421. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  22422. // fmt.Println(result)
  22423. //
  22424. // var dat map[string]interface{}
  22425. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22426. // fmt.Println(dat)
  22427. // } else {
  22428. // fmt.Println(err)
  22429. // }
  22430. // userJSONBytes, _ := json.Marshal(dat)
  22431. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22432. // utils.ErrorLog("解析失败:%v", err)
  22433. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22434. // adminUser := c.GetAdminUserInfo()
  22435. // errlog := &models.HisOrderError{
  22436. // UserOrgId: adminUser.CurrentOrgId,
  22437. // Ctime: time.Now().Unix(),
  22438. // Mtime: time.Now().Unix(),
  22439. // ErrMsg: res.ErrMsg + "解析失败",
  22440. // Status: 1,
  22441. // PatientId: order_id,
  22442. // Stage: 10106,
  22443. // }
  22444. // service.CreateErrMsgLog(errlog)
  22445. // continue
  22446. // }
  22447. // }
  22448. //
  22449. // if res.Infcode != 0 {
  22450. // adminUser := c.GetAdminUserInfo()
  22451. // errlog := &models.HisOrderError{
  22452. // UserOrgId: adminUser.CurrentOrgId,
  22453. // Ctime: time.Now().Unix(),
  22454. // Mtime: time.Now().Unix(),
  22455. // ErrMsg: res.ErrMsg,
  22456. // Status: 1,
  22457. // PatientId: order_id,
  22458. // Stage: 10106,
  22459. // }
  22460. // service.CreateErrMsgLog(errlog)
  22461. // continue
  22462. // } else {
  22463. // hisFundSettleListResult := &models.HisFundSettleListResult{
  22464. // Number: res.Output.SetlListId,
  22465. // Status: 1,
  22466. // Ctime: time.Now().Unix(),
  22467. // Mtime: time.Now().Unix(),
  22468. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  22469. // IsUpload: 1,
  22470. // OrderId: order_id,
  22471. // }
  22472. // service.CreateUploadRecord(hisFundSettleListResult)
  22473. // continue
  22474. // }
  22475. // }
  22476. //}
  22477. func (c *HisApiController) GetOrgInfo() {
  22478. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  22479. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  22480. }
  22481. func (c *HisApiController) GetHisPatientInfo() {
  22482. medical_insurance_card := c.GetString("medical_insurance_card")
  22483. id_card_type, _ := c.GetInt64("id_card_type")
  22484. id_card := c.GetString("id_card")
  22485. adminInfo := c.GetAdminUserInfo()
  22486. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  22487. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  22488. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  22489. IdCardNo := ""
  22490. if id_card_type == 1 {
  22491. IdCardNo = medical_insurance_card
  22492. } else if id_card_type == 2 {
  22493. IdCardNo = id_card
  22494. }
  22495. if config.IsOpen == 1 {
  22496. 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
  22497. resp, requestErr := http.Get(api)
  22498. if requestErr != nil {
  22499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22500. return
  22501. }
  22502. defer resp.Body.Close()
  22503. body, ioErr := ioutil.ReadAll(resp.Body)
  22504. if ioErr != nil {
  22505. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22507. return
  22508. }
  22509. var respJSON map[string]interface{}
  22510. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22511. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22513. return
  22514. }
  22515. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22516. userJSONBytes, _ := json.Marshal(userJSON)
  22517. var res ResultTwo
  22518. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22519. utils.ErrorLog("解析失败:%v", err)
  22520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22521. return
  22522. }
  22523. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  22524. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  22525. infoStr := string(Iinfos)
  22526. idetinfoStr := string(Idetinfos)
  22527. if res.Infcode == 0 {
  22528. his := models.VMHisPatient{
  22529. Status: 1,
  22530. Ctime: time.Now().Unix(),
  22531. Mtime: time.Now().Unix(),
  22532. PsnNo: res.Output.Baseinfo.PsnNo,
  22533. PsnCertType: res.Output.Baseinfo.PsnCertType,
  22534. Certno: res.Output.Baseinfo.Certno,
  22535. PsnName: res.Output.Baseinfo.PsnName,
  22536. Gend: res.Output.Baseinfo.Gend,
  22537. Naty: res.Output.Baseinfo.Naty,
  22538. Iinfo: infoStr,
  22539. Idetinfo: idetinfoStr,
  22540. UserOrgId: adminInfo.CurrentOrgId,
  22541. IsReturn: 1,
  22542. IdCardType: id_card_type,
  22543. }
  22544. c.ServeSuccessJSON(map[string]interface{}{
  22545. "info": his,
  22546. })
  22547. } else {
  22548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  22549. return
  22550. }
  22551. }
  22552. }
  22553. //func GetBasBaseInfo() (jsonStr string, err error) {
  22554. //
  22555. // handle := syscall.NewLazyDLL("SSCard.dll")
  22556. // add := handle.NewProc("ReadCardBas")
  22557. // str := make([]byte, 1024)
  22558. // str1 := make([]byte, 1024)
  22559. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  22560. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  22561. //
  22562. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  22563. //
  22564. // fmt.Println("> Add(4,5)的结果为:", ret)
  22565. // handle.Release()
  22566. //
  22567. // return "", nil
  22568. //
  22569. //}
  22570. //func GetQRBaseInfo() (jsonStr string, err error) {
  22571. // handle := syscall.LoadDLL("SSCard.dll")
  22572. // ReadCardBas := handle.FindProc("GetQRBase")
  22573. //
  22574. // str := make([]byte, 256)
  22575. // str1 := make([]byte, 256)
  22576. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  22577. //
  22578. // fmt.Println(string(str))
  22579. // fmt.Println(r)
  22580. // return string(str), nil
  22581. //}
  22582. //func CardInit() int {
  22583. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  22584. // add := DllTestDef.MustFindProc("Init")
  22585. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  22586. // if err != nil {
  22587. // fmt.Println("SSCard的运算结果为:", ret)
  22588. // }
  22589. // result := int(ret)
  22590. // return result
  22591. //}
  22592. //func CardInit() int {
  22593. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  22594. // if err != nil {
  22595. // fmt.Println("SSCard的运算结果为:", ret)
  22596. // }
  22597. // fmt.Println(err)
  22598. // result := int(ret)
  22599. // return result
  22600. //}
  22601. func IntPtr(n int) uintptr {
  22602. return uintptr(n)
  22603. }
  22604. func StrPtr(s string) uintptr {
  22605. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  22606. }
  22607. type Result2001 struct {
  22608. Cainfo interface{} `json:"cainfo"`
  22609. ErrMsg string `json:"err_msg"`
  22610. InfRefmsgid string `json:"inf_refmsgid"`
  22611. Infcode int64 `json:"infcode"`
  22612. Output struct {
  22613. Trtinfo struct {
  22614. PsnNo string `json:"psn_no"`
  22615. TrtChkType string `json:"trt_chk_type"`
  22616. FundPayType string `json:"fund_pay_type"`
  22617. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  22618. Begndate string `json:"begndate"`
  22619. Enddate string `json:"enddate"`
  22620. TrtChkRslt string `json:"trt_chk_rslt"`
  22621. } `json:"trtinfo"`
  22622. } `json:"output"`
  22623. RefmsgTime string `json:"refmsg_time"`
  22624. RespondTime string `json:"respond_time"`
  22625. Signtype interface{} `json:"signtype"`
  22626. WarnMsg interface{} `json:"warn_msg"`
  22627. }
  22628. type Result2001Org10265 struct {
  22629. Cainfo interface{} `json:"cainfo"`
  22630. ErrMsg string `json:"err_msg"`
  22631. InfRefmsgid string `json:"inf_refmsgid"`
  22632. Infcode string `json:"infcode"`
  22633. Output struct {
  22634. Trtinfo struct {
  22635. PsnNo string `json:"psn_no"`
  22636. TrtChkType string `json:"trt_chk_type"`
  22637. FundPayType string `json:"fund_pay_type"`
  22638. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  22639. Begndate string `json:"begndate"`
  22640. Enddate string `json:"enddate"`
  22641. TrtChkRslt string `json:"trt_chk_rslt"`
  22642. } `json:"trtinfo"`
  22643. } `json:"output"`
  22644. RefmsgTime string `json:"refmsg_time"`
  22645. RespondTime string `json:"respond_time"`
  22646. Signtype interface{} `json:"signtype"`
  22647. WarnMsg interface{} `json:"warn_msg"`
  22648. }
  22649. type ResultTwo struct {
  22650. ErrMsg string `json:"err_msg"`
  22651. InfRefmsgid string `json:"inf_refmsgid"`
  22652. Infcode int64 `json:"infcode"`
  22653. Output struct {
  22654. Baseinfo struct {
  22655. //Brdy string `json:"brdy"`
  22656. Certno string `json:"certno"`
  22657. Gend string `json:"gend"`
  22658. Naty string `json:"naty"`
  22659. PsnCertType string `json:"psn_cert_type"`
  22660. PsnName string `json:"psn_name"`
  22661. PsnNo string `json:"psn_no"`
  22662. } `json:"baseinfo"`
  22663. Idetinfo []interface{} `json:"idetinfo"`
  22664. Iinfo []struct {
  22665. Balc float64 `json:"balc"`
  22666. CvlservFlag string `json:"cvlserv_flag"`
  22667. EmpName string `json:"emp_name"`
  22668. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22669. Insutype string `json:"insutype"`
  22670. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22671. //PausInsuDate string `json:"paus_insu_date"`
  22672. //PsnInsuDate string `json:"psn_insu_date"`
  22673. PsnInsuStas string `json:"psn_insu_stas"`
  22674. PsnType string `json:"psn_type"`
  22675. } `json:"insuinfo"`
  22676. } `json:"output"`
  22677. RefmsgTime string `json:"refmsg_time"`
  22678. RespondTime string `json:"respond_time"`
  22679. Signtype interface{} `json:"signtype"`
  22680. WarnInfo interface{} `json:"warn_info"`
  22681. }
  22682. type ResultTwo10265 struct {
  22683. ErrMsg string `json:"err_msg"`
  22684. InfRefmsgid string `json:"inf_refmsgid"`
  22685. Infcode string `json:"infcode"`
  22686. Output struct {
  22687. Baseinfo struct {
  22688. //Brdy string `json:"brdy"`
  22689. Certno string `json:"certno"`
  22690. Gend string `json:"gend"`
  22691. Naty string `json:"naty"`
  22692. PsnCertType string `json:"psn_cert_type"`
  22693. PsnName string `json:"psn_name"`
  22694. PsnNo string `json:"psn_no"`
  22695. } `json:"baseinfo"`
  22696. Idetinfo []interface{} `json:"idetinfo"`
  22697. Iinfo []struct {
  22698. Balc float64 `json:"balc"`
  22699. CvlservFlag string `json:"cvlserv_flag"`
  22700. EmpName string `json:"emp_name"`
  22701. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22702. Insutype string `json:"insutype"`
  22703. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22704. PsnInsuStas string `json:"psn_insu_stas"`
  22705. PsnType string `json:"psn_type"`
  22706. } `json:"insuinfo"`
  22707. } `json:"output"`
  22708. RefmsgTime string `json:"refmsg_time"`
  22709. RespondTime string `json:"respond_time"`
  22710. Signtype interface{} `json:"signtype"`
  22711. WarnInfo interface{} `json:"warn_info"`
  22712. }
  22713. type ResultThree struct {
  22714. Cainfo interface{} `json:"cainfo"`
  22715. ErrMsg string `json:"err_msg"`
  22716. InfRefmsgid string `json:"inf_refmsgid"`
  22717. Infcode int64 `json:"infcode"`
  22718. Output struct {
  22719. Data struct {
  22720. IptOtpNo string `json:"ipt_otp_no"`
  22721. MdtrtID string `json:"mdtrt_id"`
  22722. PsnNo string `json:"psn_no"`
  22723. } `json:"data"`
  22724. } `json:"output"`
  22725. RefmsgTime string `json:"refmsg_time"`
  22726. RespondTime string `json:"respond_time"`
  22727. Signtype interface{} `json:"signtype"`
  22728. WarnMsg interface{} `json:"warn_msg"`
  22729. }
  22730. type ResultThree10265 struct {
  22731. Cainfo interface{} `json:"cainfo"`
  22732. ErrMsg string `json:"err_msg"`
  22733. InfRefmsgid string `json:"inf_refmsgid"`
  22734. Infcode string `json:"infcode"`
  22735. Output struct {
  22736. Data struct {
  22737. IptOtpNo string `json:"ipt_otp_no"`
  22738. MdtrtID string `json:"mdtrt_id"`
  22739. PsnNo string `json:"psn_no"`
  22740. } `json:"data"`
  22741. } `json:"output"`
  22742. RefmsgTime string `json:"refmsg_time"`
  22743. RespondTime string `json:"respond_time"`
  22744. Signtype interface{} `json:"signtype"`
  22745. WarnMsg interface{} `json:"warn_msg"`
  22746. }
  22747. type ResultFour struct {
  22748. Cainfo string `json:"cainfo"`
  22749. ErrMsg string `json:"err_msg"`
  22750. InfRefmsgid string `json:"inf_refmsgid"`
  22751. Infcode int64 `json:"infcode"`
  22752. Output struct {
  22753. Result []struct {
  22754. BasMednFlag string `json:"bas_medn_flag"`
  22755. ChldMedcFlag string `json:"chld_medc_flag"`
  22756. ChrgitmLv string `json:"chrgitm_lv"`
  22757. Cnt float64 `json:"cnt"`
  22758. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  22759. DrtReimFlag string `json:"drt_reim_flag"`
  22760. FeedetlSn string `json:"feedetl_sn"`
  22761. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22762. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  22763. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22764. ListSpItemFlag string `json:"list_sp_item_flag"`
  22765. LmtUsedFlag string `json:"lmt_used_flag"`
  22766. MedChrgitmType string `json:"med_chrgitm_type"`
  22767. Memo string `json:"memo"`
  22768. OverlmtAmt float64 `json:"overlmt_amt"`
  22769. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22770. Pric float64 `json:"pric"`
  22771. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  22772. SelfpayProp float64 `json:"selfpay_prop"`
  22773. } `json:"result"`
  22774. } `json:"output"`
  22775. RefmsgTime string `json:"refmsg_time"`
  22776. RespondTime string `json:"respond_time"`
  22777. Signtype string `json:"signtype"`
  22778. WarnMsg string `json:"warn_msg"`
  22779. }
  22780. type ResultFour10265 struct {
  22781. Cainfo string `json:"cainfo"`
  22782. ErrMsg string `json:"err_msg"`
  22783. InfRefmsgid string `json:"inf_refmsgid"`
  22784. Infcode string `json:"infcode"`
  22785. Output struct {
  22786. Result []struct {
  22787. BasMednFlag string `json:"bas_medn_flag"`
  22788. ChldMedcFlag string `json:"chld_medc_flag"`
  22789. ChrgitmLv string `json:"chrgitm_lv"`
  22790. Cnt float64 `json:"cnt"`
  22791. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  22792. DrtReimFlag string `json:"drt_reim_flag"`
  22793. FeedetlSn string `json:"feedetl_sn"`
  22794. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22795. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  22796. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22797. ListSpItemFlag string `json:"list_sp_item_flag"`
  22798. LmtUsedFlag string `json:"lmt_used_flag"`
  22799. MedChrgitmType string `json:"med_chrgitm_type"`
  22800. Memo string `json:"memo"`
  22801. OverlmtAmt float64 `json:"overlmt_amt"`
  22802. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22803. Pric float64 `json:"pric"`
  22804. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  22805. SelfpayProp float64 `json:"selfpay_prop"`
  22806. } `json:"result"`
  22807. } `json:"output"`
  22808. RefmsgTime string `json:"refmsg_time"`
  22809. RespondTime string `json:"respond_time"`
  22810. Signtype string `json:"signtype"`
  22811. WarnMsg string `json:"warn_msg"`
  22812. }
  22813. type ResultMemo struct {
  22814. InsuAdmdvs string `json:"insuAdmdvs"`
  22815. }
  22816. // [{"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}]
  22817. type ResultIDInfo struct {
  22818. Begntime string `json:"begntime"`
  22819. Endtime string `json:"endtime"`
  22820. Memo string `json:"memo"`
  22821. }
  22822. type ResultFive struct {
  22823. Balc float64 `json:"balc"`
  22824. CvlservFlag string `json:"cvlserv_flag"`
  22825. EmpName string `json:"emp_name"`
  22826. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22827. Insutype string `json:"insutype"`
  22828. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22829. PausInsuDate string `json:"paus_insu_date"`
  22830. PsnInsuDate string `json:"psn_insu_date"`
  22831. PsnInsuStas string `json:"psn_insu_stas"`
  22832. PsnType string `json:"psn_type"`
  22833. }
  22834. type ResultSix struct {
  22835. Cainfo interface{} `json:"cainfo"`
  22836. ErrMsg string `json:"err_msg"`
  22837. InfRefmsgid string `json:"inf_refmsgid"`
  22838. Infcode int64 `json:"infcode"`
  22839. Output struct {
  22840. } `json:"output"`
  22841. RefmsgTime string `json:"refmsg_time"`
  22842. RespondTime string `json:"respond_time"`
  22843. Signtype interface{} `json:"signtype"`
  22844. WarnMsg interface{} `json:"warn_msg"`
  22845. }
  22846. type ResultSix3103 struct {
  22847. Cainfo interface{} `json:"cainfo"`
  22848. ErrMsg string `json:"err_msg"`
  22849. InfRefmsgid string `json:"inf_refmsgid"`
  22850. Infcode int64 `json:"infcode"`
  22851. RefmsgTime string `json:"refmsg_time"`
  22852. RespondTime string `json:"respond_time"`
  22853. Signtype interface{} `json:"signtype"`
  22854. WarnMsg interface{} `json:"warn_msg"`
  22855. }
  22856. type FJ3507Result struct {
  22857. Cainfo interface{} `json:"cainfo"`
  22858. ErrMsg string `json:"err_msg"`
  22859. InfRefmsgid string `json:"inf_refmsgid"`
  22860. Infcode int64 `json:"infcode"`
  22861. Output struct {
  22862. retRslt string `json:"retRslt"`
  22863. msgRslt string `json:"msgRslt"`
  22864. } `json:"output"`
  22865. RefmsgTime string `json:"refmsg_time"`
  22866. RespondTime string `json:"respond_time"`
  22867. Signtype interface{} `json:"signtype"`
  22868. WarnMsg interface{} `json:"warn_msg"`
  22869. }
  22870. type FJ3507ResultFor10188 struct {
  22871. Cainfo interface{} `json:"cainfo"`
  22872. ErrMsg string `json:"err_msg"`
  22873. InfRefmsgid string `json:"inf_refmsgid"`
  22874. Infcode string `json:"infcode"`
  22875. RefmsgTime string `json:"refmsg_time"`
  22876. RespondTime string `json:"respond_time"`
  22877. Signtype interface{} `json:"signtype"`
  22878. WarnMsg interface{} `json:"warn_msg"`
  22879. }
  22880. type Result2406 struct {
  22881. Cainfo interface{} `json:"cainfo"`
  22882. ErrMsg string `json:"err_msg"`
  22883. InfRefmsgid string `json:"inf_refmsgid"`
  22884. Infcode int64 `json:"infcode"`
  22885. Output struct {
  22886. Result struct {
  22887. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  22888. } `json:"result"`
  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 GZResultSix struct {
  22896. Cainfo interface{} `json:"cainfo"`
  22897. ErrMsg string `json:"err_msg"`
  22898. InfRefmsgid string `json:"inf_refmsgid"`
  22899. Infcode int64 `json:"infcode"`
  22900. Output string `json:"output"`
  22901. RefmsgTime string `json:"refmsg_time"`
  22902. RespondTime string `json:"respond_time"`
  22903. Signtype interface{} `json:"signtype"`
  22904. WarnMsg interface{} `json:"warn_msg"`
  22905. }
  22906. type ResultSix10265 struct {
  22907. Cainfo interface{} `json:"cainfo"`
  22908. ErrMsg string `json:"err_msg"`
  22909. InfRefmsgid string `json:"inf_refmsgid"`
  22910. Infcode string `json:"infcode"`
  22911. Output struct {
  22912. } `json:"output"`
  22913. RefmsgTime string `json:"refmsg_time"`
  22914. RespondTime string `json:"respond_time"`
  22915. Signtype interface{} `json:"signtype"`
  22916. WarnMsg interface{} `json:"warn_msg"`
  22917. }
  22918. type ResultSeven struct {
  22919. Cainfo string `json:"cainfo"`
  22920. ErrMsg string `json:"err_msg"`
  22921. InfRefmsgid string `json:"inf_refmsgid"`
  22922. Infcode int64 `json:"infcode"`
  22923. Output struct {
  22924. Setlinfo struct {
  22925. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22926. AcctPay float64 `json:"acct_pay"`
  22927. ActPayDedc float64 `json:"act_pay_dedc"`
  22928. Age float64 `json:"age"`
  22929. Balc float64 `json:"balc"`
  22930. Certno string `json:"certno"`
  22931. ClrOptins string `json:"clr_optins"`
  22932. ClrType string `json:"clr_type"`
  22933. ClrWay string `json:"clr_way"`
  22934. CvlservFlag string `json:"cvlserv_flag"`
  22935. CvlservPay float64 `json:"cvlserv_pay"`
  22936. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22937. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22938. Gend string `json:"gend"`
  22939. HifesPay float64 `json:"hifes_pay"`
  22940. HifmiPay float64 `json:"hifmi_pay"`
  22941. HifpPay float64 `json:"hifp_pay"`
  22942. HospPartAmt float64 `json:"hosp_part_amt"`
  22943. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22944. Insutype string `json:"insutype"`
  22945. MafPay float64 `json:"maf_pay"`
  22946. MdtrtCertType string `json:"mdtrt_cert_type"`
  22947. HifobPay float64 `json:"hifob_pay"`
  22948. MdtrtID string `json:"mdtrt_id"`
  22949. MedType string `json:"med_type"`
  22950. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22951. MedinsSetlID string `json:"medins_setl_id"`
  22952. Naty string `json:"naty"`
  22953. OthPay float64 `json:"oth_pay"`
  22954. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22955. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22956. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22957. PsnCashPay float64 `json:"psn_cash_pay"`
  22958. PsnCertType string `json:"psn_cert_type"`
  22959. PsnName string `json:"psn_name"`
  22960. PsnNo string `json:"psn_no"`
  22961. PsnPartAmt float64 `json:"psn_part_amt"`
  22962. PsnType string `json:"psn_type"`
  22963. SetlID string `json:"setl_id"`
  22964. SetlTime string `json:"setl_time"`
  22965. } `json:"setlinfo"`
  22966. Setldetail interface{} `json:"setldetail"`
  22967. } `json:"output"`
  22968. RefmsgTime string `json:"refmsg_time"`
  22969. RespondTime string `json:"respond_time"`
  22970. Signtype interface{} `json:"signtype"`
  22971. WarnMsg interface{} `json:"warn_msg"`
  22972. }
  22973. type ResultSeven10633 struct {
  22974. Cainfo string `json:"cainfo"`
  22975. ErrMsg string `json:"err_msg"`
  22976. InfRefmsgid string `json:"inf_refmsgid"`
  22977. Infcode int64 `json:"infcode"`
  22978. Output struct {
  22979. Setlinfo struct {
  22980. AcctPay float64 `json:"acct_pay"`
  22981. ActPayDedc float64 `json:"act_pay_dedc"`
  22982. Age float64 `json:"age"`
  22983. Balc float64 `json:"balc"`
  22984. Certno string `json:"certno"`
  22985. ClrOptins string `json:"clr_optins"`
  22986. ClrType string `json:"clr_type"`
  22987. ClrWay string `json:"clr_way"`
  22988. CvlservFlag string `json:"cvlserv_flag"`
  22989. CvlservPay float64 `json:"cvlserv_pay"`
  22990. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22991. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22992. Gend string `json:"gend"`
  22993. HifesPay float64 `json:"hifes_pay"`
  22994. HifmiPay float64 `json:"hifmi_pay"`
  22995. HifpPay float64 `json:"hifp_pay"`
  22996. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22997. Insutype string `json:"insutype"`
  22998. MafPay float64 `json:"maf_pay"`
  22999. MdtrtCertType string `json:"mdtrt_cert_type"`
  23000. HifobPay float64 `json:"hifob_pay"`
  23001. MdtrtID string `json:"mdtrt_id"`
  23002. MedType string `json:"med_type"`
  23003. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23004. MedinsSetlID string `json:"medins_setl_id"`
  23005. Naty string `json:"naty"`
  23006. OthPay float64 `json:"oth_pay"`
  23007. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23008. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23009. PsnCashPay float64 `json:"psn_cash_pay"`
  23010. PsnCertType string `json:"psn_cert_type"`
  23011. PsnName string `json:"psn_name"`
  23012. PsnNo string `json:"psn_no"`
  23013. PsnPartAmt float64 `json:"psn_part_amt"`
  23014. PsnType string `json:"psn_type"`
  23015. SetlID string `json:"setl_id"`
  23016. SetlTime string `json:"setl_time"`
  23017. } `json:"setlinfo"`
  23018. Setldetail interface{} `json:"setldetail"`
  23019. } `json:"output"`
  23020. RefmsgTime string `json:"refmsg_time"`
  23021. RespondTime string `json:"respond_time"`
  23022. Signtype interface{} `json:"signtype"`
  23023. WarnMsg interface{} `json:"warn_msg"`
  23024. }
  23025. type ResultSevenAH struct {
  23026. Cainfo string `json:"cainfo"`
  23027. ErrMsg string `json:"err_msg"`
  23028. InfRefmsgid string `json:"inf_refmsgid"`
  23029. Infcode int64 `json:"infcode"`
  23030. Output struct {
  23031. Setlinfo struct {
  23032. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23033. AcctPay float64 `json:"acct_pay"`
  23034. ActPayDedc float64 `json:"act_pay_dedc"`
  23035. Age float64 `json:"age"`
  23036. Balc float64 `json:"balc"`
  23037. Certno string `json:"certno"`
  23038. ClrOptins string `json:"clr_optins"`
  23039. ClrType string `json:"clr_type"`
  23040. ClrWay string `json:"clr_way"`
  23041. CvlservFlag string `json:"cvlserv_flag"`
  23042. CvlservPay float64 `json:"cvlserv_pay"`
  23043. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23044. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23045. Gend string `json:"gend"`
  23046. HifesPay float64 `json:"hifes_pay"`
  23047. HifmiPay float64 `json:"hifmi_pay"`
  23048. HifpPay float64 `json:"hifp_pay"`
  23049. HospPartAmt float64 `json:"hosp_part_amt"`
  23050. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23051. Insutype string `json:"insutype"`
  23052. MafPay float64 `json:"maf_pay"`
  23053. MdtrtCertType string `json:"mdtrt_cert_type"`
  23054. HifobPay float64 `json:"hifob_pay"`
  23055. MdtrtID string `json:"mdtrt_id"`
  23056. MedType string `json:"med_type"`
  23057. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23058. MedinsSetlID string `json:"medins_setl_id"`
  23059. Naty string `json:"naty"`
  23060. OthPay float64 `json:"oth_pay"`
  23061. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23062. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23063. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23064. PsnCashPay float64 `json:"psn_cash_pay"`
  23065. PsnCertType string `json:"psn_cert_type"`
  23066. PsnName string `json:"psn_name"`
  23067. PsnNo string `json:"psn_no"`
  23068. PsnPartAmt float64 `json:"psn_part_amt"`
  23069. PsnType string `json:"psn_type"`
  23070. SetlID string `json:"setl_id"`
  23071. SetlTime int64 `json:"setl_time"`
  23072. } `json:"setlinfo"`
  23073. Setldetail interface{} `json:"setldetail"`
  23074. } `json:"output"`
  23075. RefmsgTime string `json:"refmsg_time"`
  23076. RespondTime string `json:"respond_time"`
  23077. Signtype interface{} `json:"signtype"`
  23078. WarnMsg interface{} `json:"warn_msg"`
  23079. }
  23080. type ResultSeven10265 struct {
  23081. Cainfo string `json:"cainfo"`
  23082. ErrMsg string `json:"err_msg"`
  23083. InfRefmsgid string `json:"inf_refmsgid"`
  23084. Infcode string `json:"infcode"`
  23085. Output struct {
  23086. Setlinfo struct {
  23087. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23088. AcctPay float64 `json:"acct_pay"`
  23089. ActPayDedc float64 `json:"act_pay_dedc"`
  23090. Age float64 `json:"age"`
  23091. Balc float64 `json:"balc"`
  23092. Certno string `json:"certno"`
  23093. ClrOptins string `json:"clr_optins"`
  23094. ClrType string `json:"clr_type"`
  23095. ClrWay string `json:"clr_way"`
  23096. CvlservFlag string `json:"cvlserv_flag"`
  23097. CvlservPay float64 `json:"cvlserv_pay"`
  23098. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23099. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23100. Gend string `json:"gend"`
  23101. HifesPay float64 `json:"hifes_pay"`
  23102. HifmiPay float64 `json:"hifmi_pay"`
  23103. HifpPay float64 `json:"hifp_pay"`
  23104. HospPartAmt float64 `json:"hosp_part_amt"`
  23105. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23106. Insutype string `json:"insutype"`
  23107. MafPay float64 `json:"maf_pay"`
  23108. MdtrtCertType string `json:"mdtrt_cert_type"`
  23109. HifobPay float64 `json:"hifob_pay"`
  23110. MdtrtID string `json:"mdtrt_id"`
  23111. MedType string `json:"med_type"`
  23112. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23113. MedinsSetlID string `json:"medins_setl_id"`
  23114. Naty string `json:"naty"`
  23115. OthPay float64 `json:"oth_pay"`
  23116. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23117. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23118. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23119. PsnCashPay float64 `json:"psn_cash_pay"`
  23120. PsnCertType string `json:"psn_cert_type"`
  23121. PsnName string `json:"psn_name"`
  23122. PsnNo string `json:"psn_no"`
  23123. PsnPartAmt float64 `json:"psn_part_amt"`
  23124. PsnType string `json:"psn_type"`
  23125. SetlID string `json:"setl_id"`
  23126. SetlTime string `json:"setl_time"`
  23127. } `json:"setlinfo"`
  23128. Setldetail interface{} `json:"setldetail"`
  23129. } `json:"output"`
  23130. RefmsgTime string `json:"refmsg_time"`
  23131. RespondTime string `json:"respond_time"`
  23132. Signtype interface{} `json:"signtype"`
  23133. WarnMsg interface{} `json:"warn_msg"`
  23134. }
  23135. type ResultSeven10265Two struct {
  23136. Cainfo string `json:"cainfo"`
  23137. ErrMsg string `json:"err_msg"`
  23138. InfRefmsgid string `json:"inf_refmsgid"`
  23139. Infcode string `json:"infcode"`
  23140. Output struct {
  23141. Setlinfo struct {
  23142. AcctMulaidPay string `json:"acct_mulaid_pay"`
  23143. AcctPay float64 `json:"acct_pay"`
  23144. ActPayDedc float64 `json:"act_pay_dedc"`
  23145. Age float64 `json:"age"`
  23146. Balc float64 `json:"balc"`
  23147. Certno string `json:"certno"`
  23148. ClrOptins string `json:"clr_optins"`
  23149. ClrType string `json:"clr_type"`
  23150. ClrWay string `json:"clr_way"`
  23151. CvlservFlag string `json:"cvlserv_flag"`
  23152. CvlservPay float64 `json:"cvlserv_pay"`
  23153. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23154. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23155. Gend string `json:"gend"`
  23156. HifesPay float64 `json:"hifes_pay"`
  23157. HifmiPay float64 `json:"hifmi_pay"`
  23158. HifpPay float64 `json:"hifp_pay"`
  23159. HospPartAmt string `json:"hosp_part_amt"`
  23160. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23161. Insutype string `json:"insutype"`
  23162. MafPay float64 `json:"maf_pay"`
  23163. MdtrtCertType string `json:"mdtrt_cert_type"`
  23164. HifobPay float64 `json:"hifob_pay"`
  23165. MdtrtID string `json:"mdtrt_id"`
  23166. MedType string `json:"med_type"`
  23167. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23168. MedinsSetlID string `json:"medins_setl_id"`
  23169. Naty string `json:"naty"`
  23170. OthPay float64 `json:"oth_pay"`
  23171. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23172. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  23173. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23174. PsnCashPay float64 `json:"psn_cash_pay"`
  23175. PsnCertType string `json:"psn_cert_type"`
  23176. PsnName string `json:"psn_name"`
  23177. PsnNo string `json:"psn_no"`
  23178. PsnPartAmt float64 `json:"psn_part_amt"`
  23179. PsnType string `json:"psn_type"`
  23180. SetlID string `json:"setl_id"`
  23181. SetlTime string `json:"setl_time"`
  23182. } `json:"setlinfo"`
  23183. Setldetail interface{} `json:"setldetail"`
  23184. } `json:"output"`
  23185. RefmsgTime string `json:"refmsg_time"`
  23186. RespondTime string `json:"respond_time"`
  23187. Signtype interface{} `json:"signtype"`
  23188. WarnMsg interface{} `json:"warn_msg"`
  23189. }
  23190. type ResultSeven10633Two struct {
  23191. Cainfo string `json:"cainfo"`
  23192. ErrMsg string `json:"err_msg"`
  23193. InfRefmsgid string `json:"inf_refmsgid"`
  23194. Infcode string `json:"infcode"`
  23195. Output struct {
  23196. Setlinfo struct {
  23197. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23198. AcctPay float64 `json:"acct_pay"`
  23199. ActPayDedc float64 `json:"act_pay_dedc"`
  23200. Age float64 `json:"age"`
  23201. Balc float64 `json:"balc"`
  23202. Certno string `json:"certno"`
  23203. ClrOptins string `json:"clr_optins"`
  23204. ClrType string `json:"clr_type"`
  23205. ClrWay string `json:"clr_way"`
  23206. CvlservFlag string `json:"cvlserv_flag"`
  23207. CvlservPay float64 `json:"cvlserv_pay"`
  23208. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23209. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23210. Gend string `json:"gend"`
  23211. HifesPay float64 `json:"hifes_pay"`
  23212. HifmiPay float64 `json:"hifmi_pay"`
  23213. HifpPay float64 `json:"hifp_pay"`
  23214. HospPartAmt float64 `json:"hosp_part_amt"`
  23215. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23216. Insutype string `json:"insutype"`
  23217. MafPay float64 `json:"maf_pay"`
  23218. MdtrtCertType string `json:"mdtrt_cert_type"`
  23219. HifobPay float64 `json:"hifob_pay"`
  23220. MdtrtID string `json:"mdtrt_id"`
  23221. MedType string `json:"med_type"`
  23222. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23223. MedinsSetlID string `json:"medins_setl_id"`
  23224. Naty string `json:"naty"`
  23225. OthPay float64 `json:"oth_pay"`
  23226. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23227. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23228. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23229. PsnCashPay float64 `json:"psn_cash_pay"`
  23230. PsnCertType string `json:"psn_cert_type"`
  23231. PsnName string `json:"psn_name"`
  23232. PsnNo string `json:"psn_no"`
  23233. PsnPartAmt float64 `json:"psn_part_amt"`
  23234. PsnType string `json:"psn_type"`
  23235. SetlID string `json:"setl_id"`
  23236. SetlTime string `json:"setl_time"`
  23237. } `json:"setlinfo"`
  23238. Setldetail interface{} `json:"setldetail"`
  23239. } `json:"output"`
  23240. RefmsgTime string `json:"refmsg_time"`
  23241. RespondTime string `json:"respond_time"`
  23242. Signtype interface{} `json:"signtype"`
  23243. WarnMsg interface{} `json:"warn_msg"`
  23244. }
  23245. type FlexibleFloat float64
  23246. func (f *FlexibleFloat) UnmarshalJSON(data []byte) error {
  23247. var v interface{}
  23248. if err := json.Unmarshal(data, &v); err != nil {
  23249. return err
  23250. }
  23251. switch value := v.(type) {
  23252. case float64:
  23253. *f = FlexibleFloat(value)
  23254. case string:
  23255. if value == "" {
  23256. *f = 0 // 空字符串默认0
  23257. } else {
  23258. num, err := strconv.ParseFloat(value, 64)
  23259. if err != nil {
  23260. return fmt.Errorf("无法解析字符串为浮点数: %v", err)
  23261. }
  23262. *f = FlexibleFloat(num)
  23263. }
  23264. default:
  23265. return fmt.Errorf("不支持的字段类型: %T", value)
  23266. }
  23267. return nil
  23268. }
  23269. type ResultSeven10633Three struct {
  23270. Cainfo string `json:"cainfo"`
  23271. ErrMsg string `json:"err_msg"`
  23272. InfRefmsgid string `json:"inf_refmsgid"`
  23273. Infcode string `json:"infcode"`
  23274. Output struct {
  23275. Setlinfo struct {
  23276. AcctPay float64 `json:"acct_pay"`
  23277. ActPayDedc float64 `json:"act_pay_dedc"`
  23278. Age float64 `json:"age"`
  23279. Balc float64 `json:"balc"`
  23280. Certno string `json:"certno"`
  23281. ClrOptins string `json:"clr_optins"`
  23282. ClrType string `json:"clr_type"`
  23283. ClrWay string `json:"clr_way"`
  23284. CvlservFlag string `json:"cvlserv_flag"`
  23285. CvlservPay float64 `json:"cvlserv_pay"`
  23286. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23287. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23288. Gend string `json:"gend"`
  23289. HifesPay float64 `json:"hifes_pay"`
  23290. HifmiPay float64 `json:"hifmi_pay"`
  23291. HifpPay float64 `json:"hifp_pay"`
  23292. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23293. Insutype string `json:"insutype"`
  23294. MafPay float64 `json:"maf_pay"`
  23295. MdtrtCertType string `json:"mdtrt_cert_type"`
  23296. HifobPay float64 `json:"hifob_pay"`
  23297. MdtrtID string `json:"mdtrt_id"`
  23298. MedType string `json:"med_type"`
  23299. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23300. MedinsSetlID string `json:"medins_setl_id"`
  23301. Naty string `json:"naty"`
  23302. OthPay float64 `json:"oth_pay"`
  23303. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23304. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23305. PsnCashPay float64 `json:"psn_cash_pay"`
  23306. PsnCertType string `json:"psn_cert_type"`
  23307. PsnName string `json:"psn_name"`
  23308. PsnNo string `json:"psn_no"`
  23309. PsnPartAmt float64 `json:"psn_part_amt"`
  23310. PsnType string `json:"psn_type"`
  23311. SetlID string `json:"setl_id"`
  23312. SetlTime string `json:"setl_time"`
  23313. } `json:"setlinfo"`
  23314. Setldetail interface{} `json:"setldetail"`
  23315. } `json:"output"`
  23316. RefmsgTime string `json:"refmsg_time"`
  23317. RespondTime string `json:"respond_time"`
  23318. Signtype interface{} `json:"signtype"`
  23319. WarnMsg interface{} `json:"warn_msg"`
  23320. }
  23321. type GZResultSeven10265Two struct {
  23322. Cainfo string `json:"cainfo"`
  23323. ErrMsg string `json:"err_msg"`
  23324. InfRefmsgid string `json:"inf_refmsgid"`
  23325. Infcode int64 `json:"infcode"`
  23326. Output struct {
  23327. Setlinfo struct {
  23328. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23329. AcctPay float64 `json:"acct_pay"`
  23330. ActPayDedc float64 `json:"act_pay_dedc"`
  23331. Age float64 `json:"age"`
  23332. Balc float64 `json:"balc"`
  23333. Certno string `json:"certno"`
  23334. ClrOptins string `json:"clr_optins"`
  23335. ClrType string `json:"clr_type"`
  23336. ClrWay string `json:"clr_way"`
  23337. CvlservFlag string `json:"cvlserv_flag"`
  23338. CvlservPay float64 `json:"cvlserv_pay"`
  23339. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23340. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23341. Gend string `json:"gend"`
  23342. HifesPay float64 `json:"hifes_pay"`
  23343. HifmiPay float64 `json:"hifmi_pay"`
  23344. HifpPay float64 `json:"hifp_pay"`
  23345. HospPartAmt float64 `json:"hosp_part_amt"`
  23346. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23347. Insutype string `json:"insutype"`
  23348. MafPay float64 `json:"maf_pay"`
  23349. MdtrtCertType string `json:"mdtrt_cert_type"`
  23350. HifobPay float64 `json:"hifob_pay"`
  23351. MdtrtID string `json:"mdtrt_id"`
  23352. MedType string `json:"med_type"`
  23353. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23354. MedinsSetlID string `json:"medins_setl_id"`
  23355. Naty string `json:"naty"`
  23356. OthPay float64 `json:"oth_pay"`
  23357. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23358. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  23359. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23360. PsnCashPay float64 `json:"psn_cash_pay"`
  23361. PsnCertType string `json:"psn_cert_type"`
  23362. PsnName string `json:"psn_name"`
  23363. PsnNo string `json:"psn_no"`
  23364. PsnPartAmt float64 `json:"psn_part_amt"`
  23365. PsnType string `json:"psn_type"`
  23366. SetlID string `json:"setl_id"`
  23367. SetlTime string `json:"setl_time"`
  23368. } `json:"setlinfo"`
  23369. Setldetail interface{} `json:"setldetail"`
  23370. } `json:"output"`
  23371. RefmsgTime string `json:"refmsg_time"`
  23372. RespondTime string `json:"respond_time"`
  23373. Signtype interface{} `json:"signtype"`
  23374. WarnMsg interface{} `json:"warn_msg"`
  23375. }
  23376. type ResultEight struct {
  23377. Cainfo string `json:"cainfo"`
  23378. ErrMsg string `json:"err_msg"`
  23379. InfRefmsgid string `json:"inf_refmsgid"`
  23380. Infcode int64 `json:"infcode"`
  23381. Output struct {
  23382. Stmtinfo struct {
  23383. SetlOptins string `json:"setl_optins"`
  23384. StmtRslt string `json:"stmt_rslt"`
  23385. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  23386. } `json:"stmtinfo"`
  23387. } `json:"output"`
  23388. RefmsgTime string `json:"refmsg_time"`
  23389. RespondTime string `json:"respond_time"`
  23390. Signtype interface{} `json:"signtype"`
  23391. WarnMsg interface{} `json:"warn_msg"`
  23392. }
  23393. type ResultEightFor10188 struct {
  23394. Cainfo string `json:"cainfo"`
  23395. ErrMsg string `json:"err_msg"`
  23396. InfRefmsgid string `json:"inf_refmsgid"`
  23397. Infcode string `json:"infcode"`
  23398. Output struct {
  23399. Stmtinfo struct {
  23400. SetlOptins string `json:"setl_optins"`
  23401. StmtRslt string `json:"stmt_rslt"`
  23402. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  23403. } `json:"stmtinfo"`
  23404. } `json:"output"`
  23405. RefmsgTime string `json:"refmsg_time"`
  23406. RespondTime string `json:"respond_time"`
  23407. Signtype interface{} `json:"signtype"`
  23408. WarnMsg interface{} `json:"warn_msg"`
  23409. }
  23410. type ResultNine struct {
  23411. Cainfo string `json:"cainfo"`
  23412. ErrMsg string `json:"err_msg"`
  23413. InfRefmsgid string `json:"inf_refmsgid"`
  23414. Infcode int64 `json:"infcode"`
  23415. Output struct {
  23416. FileQuryNo string `json:"file_qury_no"`
  23417. } `json:"output"`
  23418. RefmsgTime string `json:"refmsg_time"`
  23419. RespondTime string `json:"respond_time"`
  23420. Signtype interface{} `json:"signtype"`
  23421. WarnMsg interface{} `json:"warn_msg"`
  23422. }
  23423. type ResultTen struct {
  23424. Cainfo string `json:"cainfo"`
  23425. ErrMsg string `json:"err_msg"`
  23426. InfRefmsgid string `json:"inf_refmsgid"`
  23427. Infcode int64 `json:"infcode"`
  23428. Output struct {
  23429. Fileinfo struct {
  23430. DldEndtime string `json:"dld_endtime"`
  23431. FileQuryNo string `json:"file_qury_no"`
  23432. Filename string `json:"filename"`
  23433. } `json:"fileinfo"`
  23434. } `json:"output"`
  23435. RefmsgTime string `json:"refmsg_time"`
  23436. RespondTime string `json:"respond_time"`
  23437. Signtype interface{} `json:"signtype"`
  23438. WarnMsg interface{} `json:"warn_msg"`
  23439. }
  23440. type Result5262 struct {
  23441. ErrMsg string `json:"err_msg"`
  23442. InfRefmsgid string `json:"inf_refmsgid"`
  23443. Infcode int64 `json:"infcode"`
  23444. Output struct {
  23445. PageInfo struct {
  23446. Size int `json:"size"`
  23447. RecordCounts int `json:"record_counts"`
  23448. } `json:"page_info"`
  23449. Idetinfo []interface{} `json:"idetinfo"`
  23450. Result []struct {
  23451. SetlID string `json:"setl_id"`
  23452. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  23453. MdtrtID string `json:"mdtrt_id"`
  23454. InitSetlID string `json:"init_setl_id,omitempty"`
  23455. PsnNo string `json:"psn_no"`
  23456. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  23457. PsnName string `json:"psn_name"`
  23458. PsnCertType string `json:"psn_cert_type"`
  23459. Certno string `json:"certno"`
  23460. Gend string `json:"gend,omitempty"`
  23461. Naty string `json:"naty,omitempty"`
  23462. Brdy string `json:"brdy,omitempty"`
  23463. Age float64 `json:"age,omitempty"`
  23464. Insutype string `json:"insutype,omitempty"`
  23465. PsnType string `json:"psn_type"`
  23466. CvlservFlag string `json:"cvlserv_flag"`
  23467. CvlservLv string `json:"cvlserv_lv,omitempty"`
  23468. SpPsnType string `json:"sp_psn_type,omitempty"`
  23469. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  23470. ClctGrde string `json:"clct_grde,omitempty"`
  23471. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  23472. NwbFlag string `json:"nwb_flag,omitempty"`
  23473. InsuAdmdvs string `json:"insu_admdvs"`
  23474. EmpNo string `json:"emp_no,omitempty"`
  23475. EmpName string `json:"emp_name,omitempty"`
  23476. EmpType string `json:"emp_type,omitempty"`
  23477. EconType string `json:"econ_type,omitempty"`
  23478. AfilIndu string `json:"afil_indu,omitempty"`
  23479. AfilRlts string `json:"afil_rlts,omitempty"`
  23480. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  23481. PayLoc string `json:"pay_loc,omitempty"`
  23482. FixmedinsCode string `json:"fixmedins_code"`
  23483. FixmedinsName string `json:"fixmedins_name"`
  23484. HospLv string `json:"hosp_lv,omitempty"`
  23485. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  23486. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  23487. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  23488. Begndate string `json:"begndate"`
  23489. Enddate string `json:"enddate"`
  23490. SetlTime string `json:"setl_time"`
  23491. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  23492. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  23493. MedType string `json:"med_type"`
  23494. SetlType string `json:"setl_type,omitempty"`
  23495. ClrType string `json:"clr_type,omitempty"`
  23496. ClrWay string `json:"clr_way,omitempty"`
  23497. PsnSetlway string `json:"psn_setlway,omitempty"`
  23498. ClrOptins string `json:"clr_optins,omitempty"`
  23499. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  23500. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  23501. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  23502. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  23503. InscpAmt float64 `json:"inscp_amt,omitempty"`
  23504. DedcStd float64 `json:"dedc_std,omitempty"`
  23505. CrtDedc float64 `json:"crt_dedc,omitempty"`
  23506. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  23507. HifpPay float64 `json:"hifp_pay,omitempty"`
  23508. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  23509. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  23510. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  23511. HifesPay float64 `json:"hifes_pay,omitempty"`
  23512. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  23513. HifobPay float64 `json:"hifob_pay,omitempty"`
  23514. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  23515. MafPay float64 `json:"maf_pay,omitempty"`
  23516. OthfundPay float64 `json:"othfund_pay,omitempty"`
  23517. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  23518. PsnPay float64 `json:"psn_pay,omitempty"`
  23519. AcctPay float64 `json:"acct_pay,omitempty"`
  23520. CashPayamt float64 `json:"cash_payamt,omitempty"`
  23521. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  23522. Balc float64 `json:"balc,omitempty"`
  23523. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  23524. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  23525. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  23526. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  23527. Year string `json:"year,omitempty"`
  23528. DiseNo string `json:"dise_no,omitempty"`
  23529. DiseName string `json:"dise_name,omitempty"`
  23530. Invono string `json:"invono,omitempty"`
  23531. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  23532. ValiFlag string `json:"vali_flag,omitempty"`
  23533. Memo string `json:"memo,omitempty"`
  23534. Rid string `json:"rid"`
  23535. UpdtTime string `json:"updt_time,omitempty"`
  23536. CrterID string `json:"crter_id,omitempty"`
  23537. CrterName string `json:"crter_name,omitempty"`
  23538. CrteTime string `json:"crte_time,omitempty"`
  23539. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  23540. OpterID string `json:"opter_id,omitempty"`
  23541. OpterName string `json:"opter_name,omitempty"`
  23542. OptTime string `json:"opt_time,omitempty"`
  23543. OptinsNo string `json:"optins_no,omitempty"`
  23544. PoolareaNo string `json:"poolarea_no,omitempty"`
  23545. } `json:"result"`
  23546. } `json:"output"`
  23547. RefmsgTime string `json:"refmsg_time"`
  23548. RespondTime string `json:"respond_time"`
  23549. Signtype interface{} `json:"signtype"`
  23550. WarnInfo interface{} `json:"warn_info"`
  23551. }
  23552. type Result5267 struct {
  23553. ErrMsg string `json:"err_msg"`
  23554. InfRefmsgid string `json:"inf_refmsgid"`
  23555. Infcode int64 `json:"infcode"`
  23556. Output struct {
  23557. PageInfo struct {
  23558. Size int `json:"size"`
  23559. RecordCounts int `json:"record_counts"`
  23560. } `json:"pageinfo"`
  23561. Result []struct {
  23562. SetlID string `json:"setl_id"`
  23563. ClrOptins string `json:"clr_optins"`
  23564. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  23565. MdtrtID string `json:"mdtrt_id"`
  23566. InitSetlID string `json:"init_setl_id,omitempty"`
  23567. PsnNo string `json:"psn_no"`
  23568. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  23569. PsnName string `json:"psn_name"`
  23570. PsnCertType string `json:"psn_cert_type"`
  23571. Certno string `json:"certno"`
  23572. Gend string `json:"gend,omitempty"`
  23573. Naty string `json:"naty,omitempty"`
  23574. Brdy string `json:"brdy,omitempty"`
  23575. Age float64 `json:"age,omitempty"`
  23576. Insutype string `json:"insutype,omitempty"`
  23577. PsnType string `json:"psn_type"`
  23578. CvlservFlag string `json:"cvlserv_flag"`
  23579. CvlservLv string `json:"cvlserv_lv,omitempty"`
  23580. SpPsnType string `json:"sp_psn_type,omitempty"`
  23581. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  23582. ClctGrde string `json:"clct_grde,omitempty"`
  23583. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  23584. NwbFlag string `json:"nwb_flag,omitempty"`
  23585. InsuAdmdvs string `json:"insu_admdvs"`
  23586. EmpNo string `json:"emp_no,omitempty"`
  23587. EmpName string `json:"emp_name,omitempty"`
  23588. EmpType string `json:"emp_type,omitempty"`
  23589. EconType string `json:"econ_type,omitempty"`
  23590. AfilIndu string `json:"afil_indu,omitempty"`
  23591. AfilRlts string `json:"afil_rlts,omitempty"`
  23592. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  23593. PayLoc string `json:"pay_loc,omitempty"`
  23594. FixmedinsCode string `json:"fixmedins_code"`
  23595. FixmedinsName string `json:"fixmedins_name"`
  23596. HospLv string `json:"hosp_lv,omitempty"`
  23597. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  23598. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  23599. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  23600. Begndate string `json:"begndate,omitempty"`
  23601. Enddate string `json:"enddate,omitempty"`
  23602. SetlTime string `json:"setl_time,omitempty"`
  23603. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  23604. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  23605. MedType string `json:"med_type"`
  23606. SetlType string `json:"setl_type,omitempty"`
  23607. ClrType string `json:"clr_type,omitempty"`
  23608. ClrWay string `json:"clr_way,omitempty"`
  23609. PsnSetlway string `json:"psn_setlway,omitempty"`
  23610. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  23611. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  23612. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  23613. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  23614. InscpAmt float64 `json:"inscp_amt,omitempty"`
  23615. DedcStd float64 `json:"dedc_std,omitempty"`
  23616. CrtDedc float64 `json:"crt_dedc,omitempty"`
  23617. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  23618. HifpPay float64 `json:"hifp_pay,omitempty"`
  23619. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  23620. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  23621. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  23622. HifesPay float64 `json:"hifes_pay,omitempty"`
  23623. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  23624. HifobPay float64 `json:"hifob_pay,omitempty"`
  23625. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  23626. MafPay float64 `json:"maf_pay,omitempty"`
  23627. OthfundPay float64 `json:"othfund_pay,omitempty"`
  23628. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  23629. PsnPay float64 `json:"psn_pay,omitempty"`
  23630. AcctPay float64 `json:"acct_pay,omitempty"`
  23631. CashPayamt float64 `json:"cash_payamt,omitempty"`
  23632. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  23633. Balc float64 `json:"balc,omitempty"`
  23634. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  23635. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  23636. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  23637. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  23638. Year string `json:"year,omitempty"`
  23639. DiseNo string `json:"dise_no,omitempty"`
  23640. DiseName string `json:"dise_name,omitempty"`
  23641. Invono string `json:"invono,omitempty"`
  23642. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  23643. Memo string `json:"memo,omitempty"`
  23644. UpdtTime string `json:"updt_time,omitempty"`
  23645. OpterID string `json:"opter_id,omitempty"`
  23646. OpterName string `json:"opter_name,omitempty"`
  23647. OptTime string `json:"opt_time,omitempty"`
  23648. OptinsNo string `json:"optins_no,omitempty"`
  23649. PoolareaNo string `json:"poolarea_no,omitempty"`
  23650. } `json:"result"`
  23651. } `json:"output"`
  23652. RefmsgTime string `json:"refmsg_time"`
  23653. RespondTime string `json:"respond_time"`
  23654. Signtype interface{} `json:"signtype"`
  23655. WarnInfo interface{} `json:"warn_info"`
  23656. }
  23657. // type Autogenerated struct {
  23658. // Output struct {
  23659. // Setlinfo struct {
  23660. // SetlTime string `json:"setl_time"`
  23661. // CvlservPay float64 `json:"cvlserv_pay"`
  23662. // Year string `json:"year"`
  23663. // MedType string `json:"med_type"`
  23664. // PsnPay float64 `json:"psn_pay"`
  23665. // OpterID string `json:"opter_id"`
  23666. // Begndate string `json:"begndate"`
  23667. // FlxempeFlag string `json:"flxempe_flag"`
  23668. // HifmiPay float64 `json:"hifmi_pay"`
  23669. // PsnNo string `json:"psn_no"`
  23670. // ActPayDedc float64 `json:"act_pay_dedc"`
  23671. // MedinsSetlID interface{} `json:"medins_setl_id"`
  23672. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23673. // ClrWay string `json:"clr_way"`
  23674. // OthPay float64 `json:"oth_pay"`
  23675. // Gend string `json:"gend"`
  23676. // MdtrtID string `json:"mdtrt_id"`
  23677. // AcctPay float64 `json:"acct_pay"`
  23678. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  23679. // Insutype string `json:"insutype"`
  23680. // Invono interface{} `json:"invono"`
  23681. // Enddate string `json:"enddate"`
  23682. // CashPayamt float64 `json:"cash_payamt"`
  23683. // PsnType string `json:"psn_type"`
  23684. // FixmedinsName string `json:"fixmedins_name"`
  23685. // HifpPay float64 `json:"hifp_pay"`
  23686. // NewFlag interface{} `json:"new_flag"`
  23687. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23688. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  23689. // PayLoc string `json:"pay_loc"`
  23690. // ClrType string `json:"clr_type"`
  23691. // RefdSetlFlag string `json:"refd_setl_flag"`
  23692. // CvlservFlag string `json:"cvlserv_flag"`
  23693. // EmpName string `json:"emp_name"`
  23694. // Brdy string `json:"brdy"`
  23695. // Naty string `json:"naty"`
  23696. // Certno string `json:"certno"`
  23697. // DiseCode string `json:"dise_code"`
  23698. // FixmedinsCode string `json:"fixmedins_code"`
  23699. // DedcHospLv string `json:"dedc_hosp_lv"`
  23700. // OpterName string `json:"opter_name"`
  23701. // Balc float64 `json:"balc"`
  23702. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23703. // PsnCertType string `json:"psn_cert_type"`
  23704. // HifobPay float64 `json:"hifob_pay"`
  23705. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  23706. // HifesPay float64 `json:"hifes_pay"`
  23707. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23708. // OptTime string `json:"opt_time"`
  23709. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23710. // SetlID string `json:"setl_id"`
  23711. // MafPay float64 `json:"maf_pay"`
  23712. // PsnName string `json:"psn_name"`
  23713. // InsuOptins interface{} `json:"insu_optins"`
  23714. // PrefFundPay interface{} `json:"pref_fund_pay"`
  23715. // ClrOptins string `json:"clr_optins"`
  23716. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23717. // DiseName string `json:"dise_name"`
  23718. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23719. // Age float64 `json:"age"`
  23720. // DtrtCertType string `json:"dtrt_cert_type"`
  23721. // HospLv string `json:"hosp_lv"`
  23722. // } `json:"setlinfo"`
  23723. // Setldetail []struct {
  23724. // FundPayType string `json:"fund_pay_type"`
  23725. // FundPayamt float64 `json:"fund_payamt"`
  23726. // SetlProcInfo interface{} `json:"setl_proc_info"`
  23727. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  23728. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  23729. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  23730. // PrefFundPay interface{} `json:"pref_fund_pay"`
  23731. // } `json:"setldetail"`
  23732. // } `json:"output"`
  23733. // Infcode int `json:"infcode"`
  23734. // WarnMsg interface{} `json:"warn_msg"`
  23735. // Cainfo interface{} `json:"cainfo"`
  23736. // ErrMsg interface{} `json:"err_msg"`
  23737. // RefmsgTime string `json:"refmsg_time"`
  23738. // Signtype interface{} `json:"signtype"`
  23739. // RespondTime string `json:"respond_time"`
  23740. // InfRefmsgid string `json:"inf_refmsgid"`
  23741. // }
  23742. type Result002 struct {
  23743. Cainfo interface{} `json:"cainfo"`
  23744. ErrMsg string `json:"err_msg"`
  23745. InfRefmsgid string `json:"inf_refmsgid"`
  23746. Infcode int64 `json:"infcode"`
  23747. Output struct {
  23748. RxFile string `json:"rx_file"`
  23749. SignDigest string `json:"sign_digest"`
  23750. SignCertSn string `json:"sign_cert_sn"`
  23751. SignCertDn string `json:"sign_cert_dn"`
  23752. } `json:"output"`
  23753. RefmsgTime string `json:"refmsg_time"`
  23754. RespondTime string `json:"respond_time"`
  23755. Signtype interface{} `json:"signtype"`
  23756. WarnMsg interface{} `json:"warn_msg"`
  23757. }
  23758. type AhResult002 struct {
  23759. RxFile string `json:"rxFile"`
  23760. SignDigest string `json:"signDigest"`
  23761. SignCertSn string `json:"signCertSn"`
  23762. SignCertDn string `json:"signCertDn"`
  23763. }
  23764. type Result003 struct {
  23765. Cainfo interface{} `json:"cainfo"`
  23766. ErrMsg string `json:"err_msg"`
  23767. InfRefmsgid string `json:"inf_refmsgid"`
  23768. Infcode int64 `json:"infcode"`
  23769. Output struct {
  23770. HiRxno string `json:"hi_rxno"`
  23771. RxStasCodg string `json:"rx_stas_codg"`
  23772. RxStasName string `json:"rx_stas_name"`
  23773. } `json:"output"`
  23774. RefmsgTime string `json:"refmsg_time"`
  23775. RespondTime string `json:"respond_time"`
  23776. Signtype interface{} `json:"signtype"`
  23777. WarnMsg interface{} `json:"warn_msg"`
  23778. }
  23779. type AHResult003 struct {
  23780. HiRxno string `json:"hiRxno"`
  23781. RxStasCodg string `json:"rxStasCodg"`
  23782. RxStasName string `json:"rxStasName"`
  23783. }
  23784. type ResultEleven struct {
  23785. Cainfo string `json:"cainfo"`
  23786. ErrMsg string `json:"err_msg"`
  23787. InfRefmsgid string `json:"inf_refmsgid"`
  23788. Infcode int64 `json:"infcode"`
  23789. Output struct {
  23790. Setlinfo struct {
  23791. SetlTime string `json:"setl_time"`
  23792. CvlservPay float64 `json:"cvlserv_pay"`
  23793. Year string `json:"year"`
  23794. MedType string `json:"med_type"`
  23795. PsnPay float64 `json:"psn_pay"`
  23796. OpterID string `json:"opter_id"`
  23797. Begndate string `json:"begndate"`
  23798. FlxempeFlag string `json:"flxempe_flag"`
  23799. HifmiPay float64 `json:"hifmi_pay"`
  23800. PsnNo string `json:"psn_no"`
  23801. ActPayDedc float64 `json:"act_pay_dedc"`
  23802. MedinsSetlID interface{} `json:"medins_setl_id"`
  23803. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23804. ClrWay string `json:"clr_way"`
  23805. OthPay float64 `json:"oth_pay"`
  23806. Gend string `json:"gend"`
  23807. MdtrtID string `json:"mdtrt_id"`
  23808. AcctPay float64 `json:"acct_pay"`
  23809. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23810. Insutype string `json:"insutype"`
  23811. Invono interface{} `json:"invono"`
  23812. Enddate string `json:"enddate"`
  23813. CashPayamt float64 `json:"cash_payamt"`
  23814. PsnType string `json:"psn_type"`
  23815. FixmedinsName string `json:"fixmedins_name"`
  23816. HifpPay float64 `json:"hifp_pay"`
  23817. NewFlag interface{} `json:"new_flag"`
  23818. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23819. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23820. PayLoc string `json:"pay_loc"`
  23821. ClrType string `json:"clr_type"`
  23822. RefdSetlFlag string `json:"refd_setl_flag"`
  23823. CvlservFlag string `json:"cvlserv_flag"`
  23824. EmpName string `json:"emp_name"`
  23825. Brdy string `json:"brdy"`
  23826. Naty string `json:"naty"`
  23827. Certno string `json:"certno"`
  23828. DiseCode string `json:"dise_code"`
  23829. FixmedinsCode string `json:"fixmedins_code"`
  23830. DedcHospLv string `json:"dedc_hosp_lv"`
  23831. OpterName string `json:"opter_name"`
  23832. Balc float64 `json:"balc"`
  23833. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23834. PsnCertType string `json:"psn_cert_type"`
  23835. HifobPay float64 `json:"hifob_pay"`
  23836. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23837. HifesPay float64 `json:"hifes_pay"`
  23838. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23839. OptTime string `json:"opt_time"`
  23840. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23841. SetlID string `json:"setl_id"`
  23842. MafPay float64 `json:"maf_pay"`
  23843. PsnName string `json:"psn_name"`
  23844. InsuOptins interface{} `json:"insu_optins"`
  23845. PrefFundPay interface{} `json:"pref_fund_pay"`
  23846. ClrOptins string `json:"clr_optins"`
  23847. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23848. DiseName string `json:"dise_name"`
  23849. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23850. Age float64 `json:"age"`
  23851. DtrtCertType string `json:"dtrt_cert_type"`
  23852. HospLv string `json:"hosp_lv"`
  23853. PsnCashPay float64 `json:"psn_cash_pay"`
  23854. } `json:"setlinfo"`
  23855. } `json:"output"`
  23856. RefmsgTime string `json:"refmsg_time"`
  23857. RespondTime string `json:"respond_time"`
  23858. Signtype interface{} `json:"signtype"`
  23859. WarnMsg interface{} `json:"warn_msg"`
  23860. }
  23861. type ResultElevenah struct {
  23862. Cainfo string `json:"cainfo"`
  23863. ErrMsg string `json:"err_msg"`
  23864. InfRefmsgid string `json:"inf_refmsgid"`
  23865. Infcode int64 `json:"infcode"`
  23866. Output struct {
  23867. Setlinfo struct {
  23868. SetlTime int64 `json:"setl_time"`
  23869. CvlservPay float64 `json:"cvlserv_pay"`
  23870. Year string `json:"year"`
  23871. MedType string `json:"med_type"`
  23872. PsnPay float64 `json:"psn_pay"`
  23873. OpterID string `json:"opter_id"`
  23874. Begndate int64 `json:"begndate"`
  23875. FlxempeFlag string `json:"flxempe_flag"`
  23876. HifmiPay float64 `json:"hifmi_pay"`
  23877. PsnNo string `json:"psn_no"`
  23878. ActPayDedc float64 `json:"act_pay_dedc"`
  23879. MedinsSetlID interface{} `json:"medins_setl_id"`
  23880. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23881. ClrWay string `json:"clr_way"`
  23882. OthPay float64 `json:"oth_pay"`
  23883. Gend string `json:"gend"`
  23884. MdtrtID string `json:"mdtrt_id"`
  23885. AcctPay float64 `json:"acct_pay"`
  23886. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23887. Insutype string `json:"insutype"`
  23888. Invono interface{} `json:"invono"`
  23889. Enddate int64 `json:"enddate"`
  23890. CashPayamt float64 `json:"cash_payamt"`
  23891. PsnType string `json:"psn_type"`
  23892. FixmedinsName string `json:"fixmedins_name"`
  23893. HifpPay float64 `json:"hifp_pay"`
  23894. NewFlag interface{} `json:"new_flag"`
  23895. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23896. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23897. PayLoc string `json:"pay_loc"`
  23898. ClrType string `json:"clr_type"`
  23899. RefdSetlFlag string `json:"refd_setl_flag"`
  23900. CvlservFlag string `json:"cvlserv_flag"`
  23901. EmpName string `json:"emp_name"`
  23902. Brdy int64 `json:"brdy"`
  23903. Naty string `json:"naty"`
  23904. Certno string `json:"certno"`
  23905. DiseCode string `json:"dise_code"`
  23906. FixmedinsCode string `json:"fixmedins_code"`
  23907. DedcHospLv string `json:"dedc_hosp_lv"`
  23908. OpterName string `json:"opter_name"`
  23909. Balc float64 `json:"balc"`
  23910. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23911. PsnCertType string `json:"psn_cert_type"`
  23912. HifobPay float64 `json:"hifob_pay"`
  23913. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23914. HifesPay float64 `json:"hifes_pay"`
  23915. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23916. OptTime int64 `json:"opt_time"`
  23917. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23918. SetlID string `json:"setl_id"`
  23919. MafPay float64 `json:"maf_pay"`
  23920. PsnName string `json:"psn_name"`
  23921. InsuOptins interface{} `json:"insu_optins"`
  23922. PrefFundPay interface{} `json:"pref_fund_pay"`
  23923. ClrOptins string `json:"clr_optins"`
  23924. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23925. DiseName string `json:"dise_name"`
  23926. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23927. Age float64 `json:"age"`
  23928. DtrtCertType string `json:"dtrt_cert_type"`
  23929. HospLv string `json:"hosp_lv"`
  23930. PsnCashPay float64 `json:"psn_cash_pay"`
  23931. } `json:"setlinfo"`
  23932. } `json:"output"`
  23933. RefmsgTime string `json:"refmsg_time"`
  23934. RespondTime string `json:"respond_time"`
  23935. Signtype interface{} `json:"signtype"`
  23936. WarnMsg interface{} `json:"warn_msg"`
  23937. }
  23938. type ResultEleven10265 struct {
  23939. Cainfo string `json:"cainfo"`
  23940. ErrMsg string `json:"err_msg"`
  23941. InfRefmsgid string `json:"inf_refmsgid"`
  23942. Infcode string `json:"infcode"`
  23943. Output struct {
  23944. Setlinfo struct {
  23945. SetlTime string `json:"setl_time"`
  23946. CvlservPay float64 `json:"cvlserv_pay"`
  23947. Year string `json:"year"`
  23948. MedType string `json:"med_type"`
  23949. PsnPay float64 `json:"psn_pay"`
  23950. OpterID string `json:"opter_id"`
  23951. Begndate string `json:"begndate"`
  23952. FlxempeFlag string `json:"flxempe_flag"`
  23953. HifmiPay float64 `json:"hifmi_pay"`
  23954. PsnNo string `json:"psn_no"`
  23955. ActPayDedc float64 `json:"act_pay_dedc"`
  23956. MedinsSetlID interface{} `json:"medins_setl_id"`
  23957. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23958. ClrWay string `json:"clr_way"`
  23959. OthPay float64 `json:"oth_pay"`
  23960. Gend string `json:"gend"`
  23961. MdtrtID string `json:"mdtrt_id"`
  23962. AcctPay float64 `json:"acct_pay"`
  23963. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23964. Insutype string `json:"insutype"`
  23965. Invono interface{} `json:"invono"`
  23966. Enddate string `json:"enddate"`
  23967. CashPayamt float64 `json:"cash_payamt"`
  23968. PsnType string `json:"psn_type"`
  23969. FixmedinsName string `json:"fixmedins_name"`
  23970. HifpPay float64 `json:"hifp_pay"`
  23971. NewFlag interface{} `json:"new_flag"`
  23972. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23973. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23974. PayLoc string `json:"pay_loc"`
  23975. ClrType string `json:"clr_type"`
  23976. RefdSetlFlag string `json:"refd_setl_flag"`
  23977. CvlservFlag string `json:"cvlserv_flag"`
  23978. EmpName string `json:"emp_name"`
  23979. Brdy string `json:"brdy"`
  23980. Naty string `json:"naty"`
  23981. Certno string `json:"certno"`
  23982. DiseCode string `json:"dise_code"`
  23983. FixmedinsCode string `json:"fixmedins_code"`
  23984. DedcHospLv string `json:"dedc_hosp_lv"`
  23985. OpterName string `json:"opter_name"`
  23986. Balc float64 `json:"balc"`
  23987. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23988. PsnCertType string `json:"psn_cert_type"`
  23989. HifobPay float64 `json:"hifob_pay"`
  23990. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23991. HifesPay float64 `json:"hifes_pay"`
  23992. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23993. OptTime string `json:"opt_time"`
  23994. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23995. SetlID string `json:"setl_id"`
  23996. MafPay float64 `json:"maf_pay"`
  23997. PsnName string `json:"psn_name"`
  23998. InsuOptins interface{} `json:"insu_optins"`
  23999. PrefFundPay interface{} `json:"pref_fund_pay"`
  24000. ClrOptins string `json:"clr_optins"`
  24001. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  24002. DiseName string `json:"dise_name"`
  24003. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  24004. Age float64 `json:"age"`
  24005. DtrtCertType string `json:"dtrt_cert_type"`
  24006. HospLv string `json:"hosp_lv"`
  24007. PsnCashPay float64 `json:"psn_cash_pay"`
  24008. } `json:"setlinfo"`
  24009. } `json:"output"`
  24010. RefmsgTime string `json:"refmsg_time"`
  24011. RespondTime string `json:"respond_time"`
  24012. Signtype interface{} `json:"signtype"`
  24013. WarnMsg interface{} `json:"warn_msg"`
  24014. }
  24015. type ResultTwelve struct {
  24016. Cainfo string `json:"cainfo"`
  24017. ErrMsg string `json:"err_msg"`
  24018. InfRefmsgid string `json:"inf_refmsgid"`
  24019. Infcode int64 `json:"infcode"`
  24020. Output struct {
  24021. MdtrtId string `json:"mdtrt_id"`
  24022. ChrgBchno string `json:"chrg_bchno"`
  24023. PsnNo string `json:"psn_no"`
  24024. } `json:"output"`
  24025. RefmsgTime string `json:"refmsg_time"`
  24026. RespondTime string `json:"respond_time"`
  24027. Signtype interface{} `json:"signtype"`
  24028. WarnMsg interface{} `json:"warn_msg"`
  24029. }
  24030. type ResultThirteen struct {
  24031. ErrMsg string `json:"err_msg"`
  24032. InfRefmsgid string `json:"inf_refmsgid"`
  24033. Infcode int64 `json:"infcode"`
  24034. Output struct {
  24035. Result struct {
  24036. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  24037. } `json:"result"`
  24038. } `json:"output"`
  24039. RefmsgTime string `json:"refmsg_time"`
  24040. RespondTime string `json:"respond_time"`
  24041. Signtype interface{} `json:"signtype"`
  24042. WarnInfo interface{} `json:"warn_info"`
  24043. }
  24044. type ResultThirteen10265 struct {
  24045. ErrMsg string `json:"err_msg"`
  24046. InfRefmsgid string `json:"inf_refmsgid"`
  24047. Infcode string `json:"infcode"`
  24048. Output struct {
  24049. Result struct {
  24050. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  24051. } `json:"result"`
  24052. } `json:"output"`
  24053. RefmsgTime string `json:"refmsg_time"`
  24054. RespondTime string `json:"respond_time"`
  24055. Signtype interface{} `json:"signtype"`
  24056. WarnInfo interface{} `json:"warn_info"`
  24057. }
  24058. type ResultFourteen struct {
  24059. ErrMsg string `json:"err_msg"`
  24060. InfRefmsgid string `json:"inf_refmsgid"`
  24061. Infcode int64 `json:"infcode"`
  24062. Output struct {
  24063. } `json:"output"`
  24064. RefmsgTime string `json:"refmsg_time"`
  24065. RespondTime string `json:"respond_time"`
  24066. Signtype interface{} `json:"signtype"`
  24067. WarnInfo interface{} `json:"warn_info"`
  24068. }
  24069. type ResultCFYLJG001 struct {
  24070. ErrMsg string `json:"err_msg"`
  24071. InfRefmsgid string `json:"inf_refmsgid"`
  24072. Infcode int64 `json:"infcode"`
  24073. Output struct {
  24074. RxTraceCode string `json:"rx_trace_code"`
  24075. HiRxno string `json:"hi_rxno"`
  24076. } `json:"output"`
  24077. RefmsgTime string `json:"refmsg_time"`
  24078. RespondTime string `json:"respond_time"`
  24079. Signtype interface{} `json:"signtype"`
  24080. WarnInfo interface{} `json:"warn_info"`
  24081. }
  24082. type ResultCFYLJG001AH struct {
  24083. RxTraceCode string `json:"rxTraceCode"`
  24084. HiRxno string `json:"hiRxno"`
  24085. }
  24086. type ResultCFYLJG007 struct {
  24087. ErrMsg string `json:"err_msg"`
  24088. InfRefmsgid string `json:"inf_refmsgid"`
  24089. Infcode int64 `json:"infcode"`
  24090. Output struct {
  24091. HiRxno string `json:"hi_rxno"`
  24092. RxStasName string `json:"rx_stas_name"`
  24093. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  24094. Seltdelts []interface{} `json:"seltdelts"`
  24095. RxUsedStasName string `json:"rx_used_stas_name"`
  24096. RxStasCodg string `json:"rx_stas_codg"`
  24097. } `json:"output"`
  24098. RefmsgTime string `json:"refmsg_time"`
  24099. RespondTime string `json:"respond_time"`
  24100. Signtype interface{} `json:"signtype"`
  24101. WarnInfo interface{} `json:"warn_info"`
  24102. }
  24103. type ResultCFYLJG002 struct {
  24104. ErrMsg string `json:"err_msg"`
  24105. InfRefmsgid string `json:"inf_refmsgid"`
  24106. Infcode int64 `json:"infcode"`
  24107. Output struct {
  24108. RxFile string `json:"rx_file"`
  24109. SignDigest string `json:"sign_digest"`
  24110. SignCertSn string `json:"sign_cert_sn"`
  24111. SignCertDn string `json:"sign_cert_dn"`
  24112. } `json:"output"`
  24113. RefmsgTime string `json:"refmsg_time"`
  24114. RespondTime string `json:"respond_time"`
  24115. Signtype interface{} `json:"signtype"`
  24116. WarnInfo interface{} `json:"warn_info"`
  24117. }
  24118. type ResultCFYLJG003 struct {
  24119. ErrMsg string `json:"err_msg"`
  24120. InfRefmsgid string `json:"inf_refmsgid"`
  24121. Infcode int64 `json:"infcode"`
  24122. Output struct {
  24123. HiRxno string `json:"hi_rxno"`
  24124. RxStasCodg string `json:"rx_stas_codg"`
  24125. RxStasName string `json:"rx_stas_name"`
  24126. } `json:"output"`
  24127. RefmsgTime string `json:"refmsg_time"`
  24128. RespondTime string `json:"respond_time"`
  24129. Signtype interface{} `json:"signtype"`
  24130. WarnInfo interface{} `json:"warn_info"`
  24131. }
  24132. type ResultCFYLJG004 struct {
  24133. ErrMsg string `json:"err_msg"`
  24134. InfRefmsgid string `json:"inf_refmsgid"`
  24135. Infcode int64 `json:"infcode"`
  24136. Output struct {
  24137. HiRxno string `json:"hi_rxno"`
  24138. RxStasCodg string `json:"rx_stas_codg"`
  24139. RxStasName string `json:"rx_stas_name"`
  24140. } `json:"output"`
  24141. RefmsgTime string `json:"refmsg_time"`
  24142. RespondTime string `json:"respond_time"`
  24143. Signtype interface{} `json:"signtype"`
  24144. WarnInfo interface{} `json:"warn_info"`
  24145. }
  24146. type ResultCFYLJG008 struct {
  24147. ErrMsg string `json:"err_msg"`
  24148. InfRefmsgid string `json:"inf_refmsgid"`
  24149. Infcode int64 `json:"infcode"`
  24150. Output struct {
  24151. PoolareaNo string `json:"poolareaNo"`
  24152. AdmdvsName string `json:"admdvsName"`
  24153. Count string `json:"count"`
  24154. } `json:"output"`
  24155. RefmsgTime string `json:"refmsg_time"`
  24156. RespondTime string `json:"respond_time"`
  24157. Signtype interface{} `json:"signtype"`
  24158. WarnInfo interface{} `json:"warn_info"`
  24159. }
  24160. type ResultCFYLJG005 struct {
  24161. ErrMsg string `json:"err_msg"`
  24162. InfRefmsgid string `json:"inf_refmsgid"`
  24163. Infcode int64 `json:"infcode"`
  24164. Output struct {
  24165. HiRxNo string `json:"hi_rxno"`
  24166. FixMedinsCode string `json:"fixmedins_code"`
  24167. FixMedinsName string `json:"fixmedins_name"`
  24168. RxStasCodg string `json:"rx_stas_codg"`
  24169. RxStasName string `json:"rx_stas_name"`
  24170. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  24171. RxUserdStasName string `json:"rx_userd_stas_name"`
  24172. PrscTime string `json:"prsc_time"`
  24173. RxDrugCnt float64 `json:"rx_drug_cnt"`
  24174. RxUsedWayCodg string `json:"rx_used_way_codg"`
  24175. RxUsedWayName string `json:"rx_used_way_name"`
  24176. RxFrquCodg string `json:"rx_frqu_codg"`
  24177. RxFrquName string `json:"rx_frqu_name"`
  24178. RxDosunt string `json:"rx_dosunt"`
  24179. RxDoscnt float64 `json:"rx_doscnt"`
  24180. RxDrordDscr string `json:"rx_drord_dscr"`
  24181. ValiDays int64 `json:"vali_days"`
  24182. ValiEndTime string `json:"vali_end_time"`
  24183. ReptFlag string `json:"rept_flag"`
  24184. MaxReptCnt int64 `json:"max_rept_cnt"`
  24185. ReptdCnt int64 `json:"reptd_cnt"`
  24186. MinInrvDays int64 `json:"min_inrv_days"`
  24187. RxTypeCode string `json:"rx_type_code"`
  24188. RxTypeName string `json:"rx_type_name"`
  24189. LongRxFlag string `json:"long_rx_flag"`
  24190. RxDetlList []struct {
  24191. MedListCodg string `json:"med_list_codg"`
  24192. MedinsListCodg string `json:"medins_list_codg"`
  24193. HospPrepFlag string `json:"hosp_prep_flag"`
  24194. RxItemTypeCode string `json:"rx_item_type_code"`
  24195. RxItemTypeName string `json:"rx_item_type_name"`
  24196. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  24197. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  24198. TcmHerbFoote string `json:"tcmherb_foote"`
  24199. MednTypeCode string `json:"medn_type_code"`
  24200. MednTypeName string `json:"medn_type_name"`
  24201. MainMedcFlag string `json:"main_medc_flag"`
  24202. UrgtFlag string `json:"urgt_flag"`
  24203. BasMednFlag string `json:"bas_medn_flag"`
  24204. ImpDrugFlag string `json:"imp_drug_flag"`
  24205. ProdBarc string `json:"prod_barc"`
  24206. DrugProdname string `json:"drug_prodname"`
  24207. GennameCodg string `json:"genname_codg"`
  24208. DrugGenname string `json:"drug_genname"`
  24209. DrugDosform string `json:"drug_dosform"`
  24210. DrugSpec string `json:"drug_spec"`
  24211. PrdrName string `json:"prdr_name"`
  24212. MedcWayCodg string `json:"medc_way_codg"`
  24213. MedcWayDscr string `json:"medc_way_dscr"`
  24214. MedcBegntime string `json:"medc_begntime"`
  24215. MedcEndtime string `json:"medc_endtime"`
  24216. MedcDays float64 `json:"medc_days"`
  24217. DrugPric float64 `json:"drug_pric"`
  24218. DrugSumamt float64 `json:"drug_sumamt"`
  24219. DrugCnt float64 `json:"drug_cnt"`
  24220. DrugDosunt string `json:"drug_dosunt"`
  24221. SinDoscnt float64 `json:"sin_doscnt"`
  24222. SinDosunt string `json:"sin_dosunt"`
  24223. UsedFrquCodg string `json:"used_frqu_codg"`
  24224. UsedFrquName string `json:"used_frqu_name"`
  24225. DrugTotlcnt string `json:"drug_totlcnt"`
  24226. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  24227. DiseCodg string `json:"dise_codg"`
  24228. HospApprFlag string `json:"hosp_appr_flag"`
  24229. } `json:"rx_detl_list"`
  24230. RxOtpinfo struct {
  24231. MedType string `json:"med_type"`
  24232. IptOtpNo string `json:"ipt_otp_no"`
  24233. OtpIptFlag string `json:"otp_ipt_flag"`
  24234. PatnName string `json:"patn_name"`
  24235. PatnAge float64 `json:"patn_age"`
  24236. PatnHgt float64 `json:"patn_hgt"`
  24237. PatnWt float64 `json:"patn_wt"`
  24238. Gend string `json:"gend"`
  24239. GesoVal float64 `json:"geso_val"`
  24240. NwbFlag string `json:"nwb_flag"`
  24241. NwbAge string `json:"nwb_age"`
  24242. SuckPrdFlag string `json:"suck_prd_flag"`
  24243. AlgsHis string `json:"algs_his"`
  24244. Insutype string `json:"insutype"`
  24245. PrscDeptName string `json:"prsc_dept_name"`
  24246. PrscDrName string `json:"prsc_dr_name"`
  24247. PharName string `json:"phar_name"`
  24248. PharChkTime string `json:"phar_chk_time"`
  24249. MdtrtTime string `json:"mdtrt_time"`
  24250. DiseCodg string `json:"dise_codg"`
  24251. DiseName string `json:"dise_name"`
  24252. SpDiseFlag string `json:"sp_dise_flag"`
  24253. MaindiagCode string `json:"maindiag_code"`
  24254. MaindiagName string `json:"maindiag_name"`
  24255. DiseCondDscr string `json:"dise_cond_dscr"`
  24256. FstdiagFlag string `json:"fstdiag_flag"`
  24257. } `json:"rx_otpinfo"`
  24258. RxDiseList []struct {
  24259. DiagType string `json:"diag_type"`
  24260. MaindiagFlag string `json:"maindiag_flag"`
  24261. DiagSrtNo string `json:"diag_srt_no"`
  24262. DiagCode string `json:"diag_code"`
  24263. DiagName string `json:"diag_name"`
  24264. DiagDept string `json:"diag_dept"`
  24265. DiagDrNo string `json:"diag_dr_no"`
  24266. DiagDrName string `json:"diag_dr_name"`
  24267. DiagTime string `json:"diag_time"`
  24268. TcmDiseCode string `json:"tcm_dise_code"`
  24269. TcmDiseName string `json:"tcm_dise_name"`
  24270. TcmSympCode string `json:"tcmsymp_code"`
  24271. TcmSymp string `json:"tcmsymp"`
  24272. } `json:"rx_dise_list"`
  24273. } `json:"output"`
  24274. RefmsgTime string `json:"refmsg_time"`
  24275. RespondTime string `json:"respond_time"`
  24276. Signtype interface{} `json:"signtype"`
  24277. WarnInfo interface{} `json:"warn_info"`
  24278. }
  24279. type ResultCFYLJG006 struct {
  24280. ErrMsg string `json:"err_msg"`
  24281. InfRefmsgid string `json:"inf_refmsgid"`
  24282. Infcode int64 `json:"infcode"`
  24283. Output struct {
  24284. HiRxNo string `json:"hi_rxno"`
  24285. PharCode string `json:"phar_code"`
  24286. PharName string `json:"phar_name"`
  24287. RxChkOpnn string `json:"rx_chk_opnn"`
  24288. RxChkTime string `json:"rx_chk_time"`
  24289. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  24290. RxChkStasName string `json:"rx_chk_stas_name"`
  24291. RxStasCodg string `json:"rx_stas_codg"`
  24292. RxStasName string `json:"rx_stas_name"`
  24293. } `json:"output"`
  24294. RefmsgTime string `json:"refmsg_time"`
  24295. RespondTime string `json:"respond_time"`
  24296. Signtype interface{} `json:"signtype"`
  24297. WarnInfo interface{} `json:"warn_info"`
  24298. }
  24299. type ResultFourteen10265 struct {
  24300. ErrMsg string `json:"err_msg"`
  24301. InfRefmsgid string `json:"inf_refmsgid"`
  24302. Infcode string `json:"infcode"`
  24303. Output struct {
  24304. } `json:"output"`
  24305. RefmsgTime string `json:"refmsg_time"`
  24306. RespondTime string `json:"respond_time"`
  24307. Signtype interface{} `json:"signtype"`
  24308. WarnInfo interface{} `json:"warn_info"`
  24309. }
  24310. type ResultSixteen struct {
  24311. Cainfo string `json:"cainfo"`
  24312. ErrMsg string `json:"err_msg"`
  24313. InfRefmsgid string `json:"inf_refmsgid"`
  24314. Infcode int64 `json:"infcode"`
  24315. Output struct {
  24316. Setlinfo struct {
  24317. MdtrtID string `json:"mdtrt_id"`
  24318. SetlID string `json:"setl_id"`
  24319. ClrOptins string `json:"clr_optins"`
  24320. SetlTime string `json:"setl_time"`
  24321. MedfeeSumamt float64 `json:"medfee_sumamt"`
  24322. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  24323. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  24324. PreselfpayAmt float64 `json:"preselfpay_amt"`
  24325. InscpScpAmt float64 `json:"inscp_scp_amt"`
  24326. ActPayDedc float64 `json:"act_pay_dedc"`
  24327. HifpPay float64 `json:"hifp_pay"`
  24328. PoolPropSe float64 `json:"pool_prop_selfpay"`
  24329. Lfpay float64 `json:"selfpay"`
  24330. CvlservPay float64 `json:"cvlserv_pay"`
  24331. HifesPay float64 `json:"hifes_pay"`
  24332. HifmiPay float64 `json:"hifmi_pay"`
  24333. HifobPay float64 `json:"hifob_pay"`
  24334. MafPay float64 `json:"maf_pay"`
  24335. OthPay float64 `json:"oth_pay"`
  24336. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  24337. PsnPartAmt float64 `json:"psn_part_amt"`
  24338. AcctPay float64 `json:"acct_pay"`
  24339. Balc float64 `json:"balc"`
  24340. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  24341. HospPartAmt float64 `json:"hosp_part_amt"`
  24342. MedinsSetlID string `json:"medins_setl_id"`
  24343. PdnCashPay string `json:"pdn_cash_pay"`
  24344. } `json:"setlinfo"`
  24345. } `json:"output"`
  24346. RefmsgTime string `json:"refmsg_time"`
  24347. RespondTime string `json:"respond_time"`
  24348. Signtype interface{} `json:"signtype"`
  24349. WarnMsg interface{} `json:"warn_msg"`
  24350. }
  24351. type ResultSixteen10265 struct {
  24352. Cainfo string `json:"cainfo"`
  24353. ErrMsg string `json:"err_msg"`
  24354. InfRefmsgid string `json:"inf_refmsgid"`
  24355. Infcode string `json:"infcode"`
  24356. Output struct {
  24357. Setlinfo struct {
  24358. MdtrtID string `json:"mdtrt_id"`
  24359. SetlID string `json:"setl_id"`
  24360. ClrOptins string `json:"clr_optins"`
  24361. SetlTime string `json:"setl_time"`
  24362. MedfeeSumamt float64 `json:"medfee_sumamt"`
  24363. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  24364. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  24365. PreselfpayAmt float64 `json:"preselfpay_amt"`
  24366. InscpScpAmt float64 `json:"inscp_scp_amt"`
  24367. ActPayDedc float64 `json:"act_pay_dedc"`
  24368. HifpPay float64 `json:"hifp_pay"`
  24369. PoolPropSe float64 `json:"pool_prop_selfpay"`
  24370. Lfpay float64 `json:"selfpay"`
  24371. CvlservPay float64 `json:"cvlserv_pay"`
  24372. HifesPay float64 `json:"hifes_pay"`
  24373. HifmiPay float64 `json:"hifmi_pay"`
  24374. HifobPay float64 `json:"hifob_pay"`
  24375. MafPay float64 `json:"maf_pay"`
  24376. OthPay float64 `json:"oth_pay"`
  24377. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  24378. PsnPartAmt float64 `json:"psn_part_amt"`
  24379. AcctPay float64 `json:"acct_pay"`
  24380. Balc float64 `json:"balc"`
  24381. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  24382. HospPartAmt float64 `json:"hosp_part_amt"`
  24383. MedinsSetlID string `json:"medins_setl_id"`
  24384. PdnCashPay string `json:"pdn_cash_pay"`
  24385. } `json:"setlinfo"`
  24386. } `json:"output"`
  24387. RefmsgTime string `json:"refmsg_time"`
  24388. RespondTime string `json:"respond_time"`
  24389. Signtype interface{} `json:"signtype"`
  24390. WarnMsg interface{} `json:"warn_msg"`
  24391. }
  24392. type ResultSixteen10265Two struct {
  24393. Cainfo string `json:"cainfo"`
  24394. ErrMsg string `json:"err_msg"`
  24395. InfRefmsgid string `json:"inf_refmsgid"`
  24396. Infcode string `json:"infcode"`
  24397. Output struct {
  24398. Setlinfo interface{} `json:"setlinfo"`
  24399. } `json:"output"`
  24400. RefmsgTime string `json:"refmsg_time"`
  24401. RespondTime string `json:"respond_time"`
  24402. Signtype interface{} `json:"signtype"`
  24403. WarnMsg interface{} `json:"warn_msg"`
  24404. }
  24405. type ResultgzSixteen10265Two struct {
  24406. Cainfo string `json:"cainfo"`
  24407. ErrMsg string `json:"err_msg"`
  24408. InfRefmsgid string `json:"inf_refmsgid"`
  24409. Infcode int64 `json:"infcode"`
  24410. Output struct {
  24411. Setlinfo interface{} `json:"setlinfo"`
  24412. } `json:"output"`
  24413. RefmsgTime string `json:"refmsg_time"`
  24414. RespondTime string `json:"respond_time"`
  24415. Signtype interface{} `json:"signtype"`
  24416. WarnMsg interface{} `json:"warn_msg"`
  24417. }
  24418. type ResultSeventeen struct {
  24419. ErrMsg string `json:"err_msg"`
  24420. InfRefmsgid string `json:"inf_refmsgid"`
  24421. Infcode int64 `json:"infcode"`
  24422. Output struct {
  24423. SetlListId string `json:"setl_list_id"`
  24424. } `json:"output"`
  24425. RefmsgTime string `json:"refmsg_time"`
  24426. RespondTime string `json:"respond_time"`
  24427. Signtype string `json:"signtype"`
  24428. WarnInfo string `json:"warn_info"`
  24429. }
  24430. type ResultSeventeenOther struct {
  24431. ErrMsg string `json:"err_msg"`
  24432. InfRefmsgid string `json:"inf_refmsgid"`
  24433. Infcode string `json:"infcode"`
  24434. Output struct {
  24435. SetlListId string `json:"setl_list_id"`
  24436. } `json:"output"`
  24437. RefmsgTime string `json:"refmsg_time"`
  24438. RespondTime string `json:"respond_time"`
  24439. Signtype string `json:"signtype"`
  24440. WarnInfo string `json:"warn_info"`
  24441. }
  24442. type Result90991 struct {
  24443. ErrMsg string `json:"err_msg"`
  24444. InfRefmsgid string `json:"inf_refmsgid"`
  24445. Infcode int64 `json:"infcode"`
  24446. Output struct {
  24447. Result struct {
  24448. PsnNo string `json:"psn_no"`
  24449. CardStat string `json:"card_stat"`
  24450. Certno string `json:"certno"`
  24451. PsnName string `json:"psn_name"`
  24452. CheckStat string `json:"check_stat"`
  24453. SscnoCheckStat string `json:"sscno_check_stat"`
  24454. } `json:"result"`
  24455. } `json:"output"`
  24456. RefmsgTime string `json:"refmsg_time"`
  24457. RespondTime string `json:"respond_time"`
  24458. Signtype interface{} `json:"signtype"`
  24459. WarnInfo interface{} `json:"warn_info"`
  24460. }
  24461. type Result90100 struct {
  24462. ErrMsg string `json:"err_msg"`
  24463. InfRefmsgid string `json:"inf_refmsgid"`
  24464. Infcode int64 `json:"infcode"`
  24465. Output struct {
  24466. PoolareaNo string `json:"poolarea_no"`
  24467. PoolareaNoName string `json:"poolarea_no_name"`
  24468. Insutype string `json:"insutype"`
  24469. InsutypeName string `json:"insutype_name"`
  24470. ClctType string `json:"clct_type"`
  24471. ClctTypeName string `json:"clct_type_name"`
  24472. ClctFlag string `json:"clct_flag"`
  24473. ClctFlagName string `json:"clct_flag_name"`
  24474. AccrymBegn string `json:"accrym_begn"`
  24475. AccrymEnd string `json:"accrym_end"`
  24476. ClctTime string `json:"clct_time"`
  24477. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  24478. } `json:"output"`
  24479. RefmsgTime string `json:"refmsg_time"`
  24480. RespondTime string `json:"respond_time"`
  24481. Signtype interface{} `json:"signtype"`
  24482. WarnInfo interface{} `json:"warn_info"`
  24483. }
  24484. type Custom struct {
  24485. DetItemFeeSumamt string
  24486. Cut string
  24487. FeedetlSn string
  24488. Price string
  24489. MedListCodg string
  24490. Type int64
  24491. AdviceId int64
  24492. ProjectId int64
  24493. ItemId int64
  24494. }
  24495. type Result5301 struct {
  24496. ErrMsg string `json:"err_msg"`
  24497. InfRefmsgid string `json:"inf_refmsgid"`
  24498. Infcode int64 `json:"infcode"`
  24499. Output struct {
  24500. Result []struct {
  24501. OpspDiseCode string `json:"opsp_dise_code"`
  24502. OpspDiseName string `json:"opsp_dise_name"`
  24503. Begndate string `json:"begndate"`
  24504. Enddate string `json:"enddate"`
  24505. } `json:"feedetail"`
  24506. } `json:"output"`
  24507. RefmsgTime string `json:"refmsg_time"`
  24508. RespondTime string `json:"respond_time"`
  24509. Signtype interface{} `json:"signtype"`
  24510. WarnInfo interface{} `json:"warn_info"`
  24511. }
  24512. type Result5301For10265 struct {
  24513. ErrMsg string `json:"err_msg"`
  24514. InfRefmsgid string `json:"inf_refmsgid"`
  24515. Infcode string `json:"infcode"`
  24516. Output struct {
  24517. Result []struct {
  24518. OpspDiseCode string `json:"opsp_dise_code"`
  24519. OpspDiseName string `json:"opsp_dise_name"`
  24520. Begndate string `json:"begndate"`
  24521. Enddate string `json:"enddate"`
  24522. } `json:"feedetail"`
  24523. } `json:"output"`
  24524. RefmsgTime string `json:"refmsg_time"`
  24525. RespondTime string `json:"respond_time"`
  24526. Signtype interface{} `json:"signtype"`
  24527. WarnInfo interface{} `json:"warn_info"`
  24528. }
  24529. //获取个人信息----挂号-----上传就诊信息
  24530. func (c *HisApiController) GetRegisterInfo() {
  24531. id, _ := c.GetInt64("id")
  24532. record_time := c.GetString("record_time")
  24533. settlementValue, _ := c.GetInt64("settlement_value")
  24534. medical_insurance_card := c.GetString("medical_insurance_card")
  24535. name := c.GetString("name")
  24536. id_card_type, _ := c.GetInt64("id_card_type")
  24537. certificates, _ := c.GetInt64("certificates")
  24538. medical_care, _ := c.GetInt64("medical_care")
  24539. birthday := c.GetString("birthday")
  24540. id_card := c.GetString("id_card")
  24541. register_type, _ := c.GetInt64("register")
  24542. doctor, _ := c.GetInt64("doctor")
  24543. department, _ := c.GetInt64("department")
  24544. gender, _ := c.GetInt64("sex")
  24545. registration_fee, _ := c.GetFloat("registration_fee")
  24546. medical_expenses, _ := c.GetFloat("medical_expenses")
  24547. social_type, _ := c.GetInt64("social_type")
  24548. admin_user_id, _ := c.GetInt64("admin_user_id")
  24549. insuplc_admdvs := c.GetString("insuplc_admdvs")
  24550. insuplc_admdvs_tt := c.GetString("insuplc_admdvs")
  24551. mdtrt_type := c.GetString("mdtrt_type")
  24552. if id_card_type == 5 {
  24553. id_card_type = 4
  24554. }
  24555. timeLayout := "2006-01-02"
  24556. loc, _ := time.LoadLocation("Local")
  24557. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  24558. birthUnix := birthdays.Unix()
  24559. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24560. if err != nil {
  24561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24562. return
  24563. }
  24564. recordDateTime := theTime.Unix()
  24565. adminInfo := c.GetAdminUserInfo()
  24566. var patient service.Patients
  24567. if id == 0 {
  24568. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  24569. } else {
  24570. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  24571. }
  24572. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  24573. if patientPrescription.ID == 0 {
  24574. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  24575. }
  24576. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  24577. if patient.ID == 0 {
  24578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  24579. return
  24580. }
  24581. if len(patient.IdCardNo) == 0 {
  24582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  24583. return
  24584. }
  24585. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  24586. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  24587. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  24588. //就诊结算未完成,不能进行二次挂号
  24589. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  24590. if len(his) >= 1 {
  24591. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  24592. if len(his) >= 1 && order.ID == 0 {
  24593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  24594. return
  24595. }
  24596. }
  24597. var aaaa string
  24598. //var register_log string
  24599. if config.IsOpen == 1 {
  24600. var res ResultTwo
  24601. var res10265 ResultTwo10265
  24602. var PsnNo string
  24603. var PsnCertType string
  24604. var Certno string
  24605. var PsnName string
  24606. var Gend string
  24607. var Naty string
  24608. var Brdy string
  24609. var Age float64
  24610. var infoStr string
  24611. var idetinfoStr string
  24612. var infocode int64
  24613. var verify_number string
  24614. fmt.Println(verify_number)
  24615. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  24616. psn_info, _ := service.GetPsnByPatientId(id)
  24617. PsnNo = psn_info.PsnNo
  24618. PsnCertType = psn_info.PsnCertType
  24619. Certno = psn_info.Certno
  24620. PsnName = psn_info.PsnName
  24621. Gend = psn_info.Gend
  24622. Naty = psn_info.Naty
  24623. Brdy = psn_info.Brdy
  24624. Age = psn_info.Age
  24625. infoStr = psn_info.Insuinfo
  24626. idetinfoStr = psn_info.Idetinfo
  24627. infocode = 0
  24628. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  24629. psn_info, _ := service.GetPsnByPatientId(id)
  24630. PsnNo = psn_info.PsnNo
  24631. PsnCertType = psn_info.PsnCertType
  24632. Certno = psn_info.Certno
  24633. PsnName = psn_info.PsnName
  24634. Gend = psn_info.Gend
  24635. Naty = psn_info.Naty
  24636. Brdy = psn_info.Brdy
  24637. Age = psn_info.Age
  24638. infoStr = psn_info.Insuinfo
  24639. idetinfoStr = psn_info.Idetinfo
  24640. infocode = 0
  24641. verify_number = psn_info.VerifyNumber
  24642. } else if miConfig.MdtrtareaAdmvs == "150404" {
  24643. if id_card_type == 2 {
  24644. //请求内网数据
  24645. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  24646. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24647. "&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
  24648. resp, requestErr := http.Get(api)
  24649. if requestErr != nil {
  24650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24651. return
  24652. }
  24653. body, ioErr := ioutil.ReadAll(resp.Body)
  24654. if ioErr != nil {
  24655. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24657. return
  24658. }
  24659. var respJSON map[string]interface{}
  24660. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24661. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24663. return
  24664. }
  24665. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24666. result_byte, _ := json.Marshal(respJSON)
  24667. result := string(result_byte)
  24668. var dat map[string]interface{}
  24669. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24670. fmt.Println(dat)
  24671. } else {
  24672. fmt.Println(err)
  24673. }
  24674. userJSONBytes, _ := json.Marshal(dat)
  24675. var res ResultTwo
  24676. var resTwo10265 ResultTwo10265
  24677. if miConfig.Code == "H15049901371" {
  24678. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  24679. utils.ErrorLog("解析失败:%v", err)
  24680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24681. return
  24682. }
  24683. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  24684. res.Infcode = Infcode
  24685. res.ErrMsg = resTwo10265.ErrMsg
  24686. res.Output = resTwo10265.Output
  24687. res.InfRefmsgid = resTwo10265.InfRefmsgid
  24688. res.RespondTime = resTwo10265.RespondTime
  24689. res.WarnInfo = resTwo10265.WarnInfo
  24690. } else {
  24691. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24692. utils.ErrorLog("解析失败:%v", err)
  24693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24694. return
  24695. }
  24696. }
  24697. //var insutypes []string
  24698. //var insutype string
  24699. //var is390 int = 0
  24700. //var is310 int = 0
  24701. //for _, item := range res.Output.Iinfo {
  24702. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24703. // insutypes = append(insutypes, item.Insutype)
  24704. // }
  24705. //}
  24706. //if len(insutypes) == 1 {
  24707. // insutype = insutypes[0]
  24708. //} else {
  24709. // for _, i := range insutypes {
  24710. // if i == "390" {
  24711. // is390 = 1
  24712. // }
  24713. //
  24714. // if i == "310" {
  24715. // is310 = 1
  24716. // }
  24717. // }
  24718. //}
  24719. //if is390 == 1 {
  24720. // insutype = "390"
  24721. //}
  24722. //if is310 == 1 {
  24723. // insutype = "310"
  24724. //}
  24725. //if len(insutypes) == 0 {
  24726. // insutype = "310"
  24727. //}
  24728. PsnNo = res.Output.Baseinfo.PsnNo
  24729. PsnCertType = res.Output.Baseinfo.PsnCertType
  24730. Certno = res.Output.Baseinfo.Certno
  24731. PsnName = res.Output.Baseinfo.PsnName
  24732. Gend = res.Output.Baseinfo.Gend
  24733. Naty = res.Output.Baseinfo.Naty
  24734. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24735. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24736. infoStr = string(Iinfos)
  24737. idetinfoStr = string(Idetinfos)
  24738. infocode = res.Infcode
  24739. //infocode = 0
  24740. //verify_number = psn_info.VerifyNumber
  24741. } else {
  24742. psn_info, _ := service.GetPsnByPatientId(id)
  24743. PsnNo = psn_info.PsnNo
  24744. PsnCertType = psn_info.PsnCertType
  24745. Certno = psn_info.Certno
  24746. PsnName = psn_info.PsnName
  24747. Gend = psn_info.Gend
  24748. Naty = psn_info.Naty
  24749. Brdy = psn_info.Brdy
  24750. Age = psn_info.Age
  24751. infoStr = psn_info.Insuinfo
  24752. idetinfoStr = psn_info.Idetinfo
  24753. infocode = 0
  24754. verify_number = psn_info.VerifyNumber
  24755. }
  24756. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24757. if id_card_type == 1 {
  24758. psn_info, _ := service.GetPsnByPatientId(id)
  24759. PsnNo = psn_info.PsnNo
  24760. PsnCertType = psn_info.PsnCertType
  24761. Certno = psn_info.Certno
  24762. PsnName = psn_info.PsnName
  24763. Gend = psn_info.Gend
  24764. Naty = psn_info.Naty
  24765. Brdy = psn_info.Brdy
  24766. Age = psn_info.Age
  24767. infoStr = psn_info.Insuinfo
  24768. idetinfoStr = psn_info.Idetinfo
  24769. infocode = 0
  24770. verify_number = psn_info.VerifyNumber
  24771. } else if id_card_type == 2 {
  24772. 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)
  24773. fmt.Println(errMsgLog)
  24774. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24775. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24776. utils.ErrorLog("解析失败:%v", err)
  24777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24778. return
  24779. }
  24780. PsnNo = res.Output.Baseinfo.PsnNo
  24781. PsnCertType = res.Output.Baseinfo.PsnCertType
  24782. Certno = res.Output.Baseinfo.Certno
  24783. PsnName = res.Output.Baseinfo.PsnName
  24784. Gend = res.Output.Baseinfo.Gend
  24785. Naty = res.Output.Baseinfo.Naty
  24786. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24787. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24788. infoStr = string(Iinfos)
  24789. idetinfoStr = string(Idetinfos)
  24790. infocode = res.Infcode
  24791. }
  24792. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24793. if id_card_type == 1 {
  24794. psn_info, _ := service.GetPsnByPatientId(id)
  24795. PsnNo = psn_info.PsnNo
  24796. PsnCertType = psn_info.PsnCertType
  24797. Certno = psn_info.Certno
  24798. PsnName = psn_info.PsnName
  24799. Gend = psn_info.Gend
  24800. Naty = psn_info.Naty
  24801. Brdy = psn_info.Brdy
  24802. Age = psn_info.Age
  24803. infoStr = psn_info.Insuinfo
  24804. idetinfoStr = psn_info.Idetinfo
  24805. infocode = 0
  24806. verify_number = psn_info.VerifyNumber
  24807. } else if id_card_type == 2 {
  24808. 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, "")
  24809. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24810. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24811. utils.ErrorLog("解析失败:%v", err)
  24812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24813. return
  24814. }
  24815. PsnNo = res.Output.Baseinfo.PsnNo
  24816. PsnCertType = res.Output.Baseinfo.PsnCertType
  24817. Certno = res.Output.Baseinfo.Certno
  24818. PsnName = res.Output.Baseinfo.PsnName
  24819. Gend = res.Output.Baseinfo.Gend
  24820. Naty = res.Output.Baseinfo.Naty
  24821. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24822. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24823. infoStr = string(Iinfos)
  24824. idetinfoStr = string(Idetinfos)
  24825. infocode = res.Infcode
  24826. } else {
  24827. psn_info, _ := service.GetPsnByPatientId(id)
  24828. PsnNo = psn_info.PsnNo
  24829. PsnCertType = psn_info.PsnCertType
  24830. Certno = psn_info.Certno
  24831. PsnName = psn_info.PsnName
  24832. Gend = psn_info.Gend
  24833. Naty = psn_info.Naty
  24834. Brdy = psn_info.Brdy
  24835. Age = psn_info.Age
  24836. infoStr = psn_info.Insuinfo
  24837. idetinfoStr = psn_info.Idetinfo
  24838. infocode = 0
  24839. verify_number = psn_info.VerifyNumber
  24840. }
  24841. } else if miConfig.MdtrtareaAdmvs == "361025" {
  24842. if id_card_type == 1 {
  24843. psn_info, _ := service.GetPsnByPatientId(id)
  24844. PsnNo = psn_info.PsnNo
  24845. PsnCertType = psn_info.PsnCertType
  24846. Certno = psn_info.Certno
  24847. PsnName = psn_info.PsnName
  24848. Gend = psn_info.Gend
  24849. Naty = psn_info.Naty
  24850. Brdy = psn_info.Brdy
  24851. Age = psn_info.Age
  24852. infoStr = psn_info.Insuinfo
  24853. idetinfoStr = psn_info.Idetinfo
  24854. infocode = 0
  24855. verify_number = psn_info.VerifyNumber
  24856. } else if id_card_type == 2 {
  24857. psn_info, _ := service.GetPsnByPatientId(id)
  24858. PsnNo = psn_info.PsnNo
  24859. PsnCertType = psn_info.PsnCertType
  24860. Certno = psn_info.Certno
  24861. PsnName = psn_info.PsnName
  24862. Gend = psn_info.Gend
  24863. Naty = psn_info.Naty
  24864. Brdy = psn_info.Brdy
  24865. Age = psn_info.Age
  24866. infoStr = psn_info.Insuinfo
  24867. idetinfoStr = psn_info.Idetinfo
  24868. infocode = 0
  24869. verify_number = psn_info.VerifyNumber
  24870. } else {
  24871. psn_info, _ := service.GetPsnByPatientId(id)
  24872. PsnNo = psn_info.PsnNo
  24873. PsnCertType = psn_info.PsnCertType
  24874. Certno = psn_info.Certno
  24875. PsnName = psn_info.PsnName
  24876. Gend = psn_info.Gend
  24877. Naty = psn_info.Naty
  24878. Brdy = psn_info.Brdy
  24879. Age = psn_info.Age
  24880. infoStr = psn_info.Insuinfo
  24881. idetinfoStr = psn_info.Idetinfo
  24882. infocode = 0
  24883. verify_number = psn_info.VerifyNumber
  24884. }
  24885. } else if miConfig.MdtrtareaAdmvs == "360100" {
  24886. if id_card_type == 1 {
  24887. psn_info, _ := service.GetPsnByPatientId(id)
  24888. PsnNo = psn_info.PsnNo
  24889. PsnCertType = psn_info.PsnCertType
  24890. Certno = psn_info.Certno
  24891. PsnName = psn_info.PsnName
  24892. Gend = psn_info.Gend
  24893. Naty = psn_info.Naty
  24894. Brdy = psn_info.Brdy
  24895. Age = psn_info.Age
  24896. infoStr = psn_info.Insuinfo
  24897. idetinfoStr = psn_info.Idetinfo
  24898. infocode = 0
  24899. verify_number = psn_info.VerifyNumber
  24900. } else if id_card_type == 2 {
  24901. psn_info, _ := service.GetPsnByPatientId(id)
  24902. PsnNo = psn_info.PsnNo
  24903. PsnCertType = psn_info.PsnCertType
  24904. Certno = psn_info.Certno
  24905. PsnName = psn_info.PsnName
  24906. Gend = psn_info.Gend
  24907. Naty = psn_info.Naty
  24908. Brdy = psn_info.Brdy
  24909. Age = psn_info.Age
  24910. infoStr = psn_info.Insuinfo
  24911. idetinfoStr = psn_info.Idetinfo
  24912. infocode = 0
  24913. verify_number = psn_info.VerifyNumber
  24914. } else {
  24915. psn_info, _ := service.GetPsnByPatientId(id)
  24916. PsnNo = psn_info.PsnNo
  24917. PsnCertType = psn_info.PsnCertType
  24918. Certno = psn_info.Certno
  24919. PsnName = psn_info.PsnName
  24920. Gend = psn_info.Gend
  24921. Naty = psn_info.Naty
  24922. Brdy = psn_info.Brdy
  24923. Age = psn_info.Age
  24924. infoStr = psn_info.Insuinfo
  24925. idetinfoStr = psn_info.Idetinfo
  24926. infocode = 0
  24927. verify_number = psn_info.VerifyNumber
  24928. }
  24929. } else if miConfig.MdtrtareaAdmvs == "341203" || miConfig.MdtrtareaAdmvs == "340699" {
  24930. psn_info, _ := service.GetPsnByPatientId(id)
  24931. PsnNo = psn_info.PsnNo
  24932. PsnCertType = psn_info.PsnCertType
  24933. Certno = psn_info.Certno
  24934. PsnName = psn_info.PsnName
  24935. Gend = psn_info.Gend
  24936. Naty = psn_info.Naty
  24937. Brdy = psn_info.Brdy
  24938. Age = psn_info.Age
  24939. infoStr = psn_info.Insuinfo
  24940. idetinfoStr = psn_info.Idetinfo
  24941. infocode = 0
  24942. verify_number = psn_info.VerifyNumber
  24943. idetinfoStr = psn_info.Idetinfo
  24944. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24945. if id_card_type == 1 {
  24946. psn_info, _ := service.GetPsnByPatientId(id)
  24947. PsnNo = psn_info.PsnNo
  24948. PsnCertType = psn_info.PsnCertType
  24949. Certno = psn_info.Certno
  24950. PsnName = psn_info.PsnName
  24951. Gend = psn_info.Gend
  24952. Naty = psn_info.Naty
  24953. Brdy = psn_info.Brdy
  24954. Age = psn_info.Age
  24955. infoStr = psn_info.Insuinfo
  24956. idetinfoStr = psn_info.Idetinfo
  24957. infocode = 0
  24958. verify_number = psn_info.VerifyNumber
  24959. } else if id_card_type == 2 {
  24960. 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)
  24961. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24962. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24963. utils.ErrorLog("解析失败:%v", err)
  24964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24965. return
  24966. }
  24967. PsnNo = res.Output.Baseinfo.PsnNo
  24968. PsnCertType = res.Output.Baseinfo.PsnCertType
  24969. Certno = res.Output.Baseinfo.Certno
  24970. PsnName = res.Output.Baseinfo.PsnName
  24971. Gend = res.Output.Baseinfo.Gend
  24972. Naty = res.Output.Baseinfo.Naty
  24973. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24974. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24975. infoStr = string(Iinfos)
  24976. idetinfoStr = string(Idetinfos)
  24977. infocode = res.Infcode
  24978. } else if id_card_type == 4 {
  24979. psn_info, _ := service.GetPsnByPatientId(id)
  24980. PsnNo = psn_info.PsnNo
  24981. PsnCertType = psn_info.PsnCertType
  24982. Certno = psn_info.Certno
  24983. PsnName = psn_info.PsnName
  24984. Gend = psn_info.Gend
  24985. Naty = psn_info.Naty
  24986. Brdy = psn_info.Brdy
  24987. Age = psn_info.Age
  24988. infoStr = psn_info.Insuinfo
  24989. idetinfoStr = psn_info.Idetinfo
  24990. infocode = 0
  24991. verify_number = psn_info.VerifyNumber
  24992. }
  24993. } else if miConfig.MdtrtareaAdmvs == "131023" {
  24994. var result string
  24995. var requestLog string
  24996. 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), "")
  24997. if id_card_type == 4 {
  24998. psn_info, _ := service.GetPsnByPatientId(id)
  24999. PsnNo = psn_info.PsnNo
  25000. PsnCertType = psn_info.PsnCertType
  25001. Certno = psn_info.Certno
  25002. PsnName = psn_info.PsnName
  25003. Gend = psn_info.Gend
  25004. Naty = psn_info.Naty
  25005. Brdy = psn_info.Brdy
  25006. Age = psn_info.Age
  25007. infoStr = psn_info.Insuinfo
  25008. idetinfoStr = psn_info.Idetinfo
  25009. infocode = 0
  25010. verify_number = psn_info.VerifyNumber
  25011. } else {
  25012. saveLog(result, requestLog, "1101", "人员基本信息获取")
  25013. if miConfig.Code == "H15049901371" {
  25014. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  25015. utils.ErrorLog("解析失败:%v", err)
  25016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25017. return
  25018. }
  25019. res.ErrMsg = res10265.ErrMsg
  25020. res.Output = res10265.Output
  25021. res.InfRefmsgid = res10265.InfRefmsgid
  25022. } else {
  25023. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25024. utils.ErrorLog("解析失败:%v", err)
  25025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25026. return
  25027. }
  25028. }
  25029. PsnNo = res.Output.Baseinfo.PsnNo
  25030. PsnCertType = res.Output.Baseinfo.PsnCertType
  25031. Certno = res.Output.Baseinfo.Certno
  25032. PsnName = res.Output.Baseinfo.PsnName
  25033. Gend = res.Output.Baseinfo.Gend
  25034. Naty = res.Output.Baseinfo.Naty
  25035. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  25036. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  25037. infoStr = string(Iinfos)
  25038. idetinfoStr = string(Idetinfos)
  25039. if miConfig.Code == "H15049901371" {
  25040. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  25041. } else {
  25042. infocode = res.Infcode
  25043. }
  25044. }
  25045. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25046. psn_info, _ := service.GetPsnByPatientId(id)
  25047. PsnNo = psn_info.PsnNo
  25048. PsnCertType = psn_info.PsnCertType
  25049. Certno = psn_info.Certno
  25050. PsnName = psn_info.PsnName
  25051. Gend = psn_info.Gend
  25052. Naty = psn_info.Naty
  25053. Brdy = psn_info.Brdy
  25054. Age = psn_info.Age
  25055. infoStr = psn_info.Insuinfo
  25056. idetinfoStr = psn_info.Idetinfo
  25057. infocode = 0
  25058. verify_number = psn_info.VerifyNumber
  25059. } else if miConfig.MdtrtareaAdmvs == "450721" {
  25060. psn_info, _ := service.GetPsnByPatientId(id)
  25061. PsnNo = psn_info.PsnNo
  25062. PsnCertType = psn_info.PsnCertType
  25063. Certno = psn_info.Certno
  25064. PsnName = psn_info.PsnName
  25065. Gend = psn_info.Gend
  25066. Naty = psn_info.Naty
  25067. Brdy = psn_info.Brdy
  25068. Age = psn_info.Age
  25069. infoStr = psn_info.Insuinfo
  25070. idetinfoStr = psn_info.Idetinfo
  25071. infocode = 0
  25072. verify_number = psn_info.VerifyNumber
  25073. } else {
  25074. var result string
  25075. var requestLog string
  25076. //if miConfig.UserOrgId == 10138 {
  25077. if id_card_type != 4 || id_card_type != 1 {
  25078. var insa string
  25079. if len(patient.InsuplcAdmdvs) > 0 {
  25080. insa = patient.InsuplcAdmdvs
  25081. } else {
  25082. insa = miConfig.InsuplcAdmdvs
  25083. }
  25084. //psn_info, _ := service.GetPsnByPatientId(id)
  25085. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  25086. 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)
  25087. }
  25088. //}
  25089. //else {
  25090. // var insa string
  25091. // if len(patient.InsuplcAdmdvs) > 0 {
  25092. // insa = patient.InsuplcAdmdvs
  25093. // } else {
  25094. // insa = miConfig.InsuplcAdmdvs
  25095. // }
  25096. // 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)
  25097. //}
  25098. if id_card_type == 4 || id_card_type == 1 {
  25099. psn_info, _ := service.GetPsnByPatientId(id)
  25100. PsnNo = psn_info.PsnNo
  25101. PsnCertType = psn_info.PsnCertType
  25102. Certno = psn_info.Certno
  25103. PsnName = psn_info.PsnName
  25104. Gend = psn_info.Gend
  25105. Naty = psn_info.Naty
  25106. Brdy = psn_info.Brdy
  25107. Age = psn_info.Age
  25108. infoStr = psn_info.Insuinfo
  25109. idetinfoStr = psn_info.Idetinfo
  25110. infocode = 0
  25111. verify_number = psn_info.VerifyNumber
  25112. } else {
  25113. saveLog(result, requestLog, "1101", "人员基本信息获取")
  25114. if miConfig.Code == "H15049901371" {
  25115. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  25116. utils.ErrorLog("解析失败:%v", err)
  25117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25118. return
  25119. }
  25120. res.ErrMsg = res10265.ErrMsg
  25121. res.Output = res10265.Output
  25122. res.InfRefmsgid = res10265.InfRefmsgid
  25123. } else {
  25124. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25125. utils.ErrorLog("解析失败:%v", err)
  25126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25127. return
  25128. }
  25129. }
  25130. PsnNo = res.Output.Baseinfo.PsnNo
  25131. PsnCertType = res.Output.Baseinfo.PsnCertType
  25132. Certno = res.Output.Baseinfo.Certno
  25133. PsnName = res.Output.Baseinfo.PsnName
  25134. Gend = res.Output.Baseinfo.Gend
  25135. Naty = res.Output.Baseinfo.Naty
  25136. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  25137. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  25138. infoStr = string(Iinfos)
  25139. idetinfoStr = string(Idetinfos)
  25140. if miConfig.Code == "H15049901371" {
  25141. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  25142. } else {
  25143. infocode = res.Infcode
  25144. }
  25145. }
  25146. }
  25147. if infocode == 0 {
  25148. his := models.VMHisPatient{
  25149. Name: name,
  25150. Gender: gender,
  25151. Birthday: birthUnix,
  25152. MedicalTreatmentType: medical_care,
  25153. IdType: certificates,
  25154. IdCardNo: id_card,
  25155. BalanceAccountsType: settlementValue,
  25156. SocialType: social_type,
  25157. MedicalInsuranceNumber: medical_insurance_card,
  25158. RegisterType: register_type,
  25159. RegisterCost: registration_fee,
  25160. TreatmentCost: medical_expenses,
  25161. Status: 1,
  25162. Ctime: time.Now().Unix(),
  25163. Mtime: time.Now().Unix(),
  25164. PsnNo: PsnNo,
  25165. PsnCertType: PsnCertType,
  25166. Certno: Certno,
  25167. PsnName: PsnName,
  25168. Gend: Gend,
  25169. Naty: Naty,
  25170. Brdy: Brdy,
  25171. Age: Age,
  25172. Iinfo: infoStr,
  25173. Idetinfo: idetinfoStr,
  25174. PatientId: patient.ID,
  25175. RecordDate: theTime.Unix(),
  25176. UserOrgId: adminInfo.CurrentOrgId,
  25177. AdminUserId: admin_user_id,
  25178. IsReturn: 1,
  25179. IdCardType: id_card_type,
  25180. Doctor: doctor,
  25181. Departments: department,
  25182. MdtrtGrpType: mdtrt_type,
  25183. }
  25184. timestamp := time.Now().Unix()
  25185. tempTime := time.Unix(timestamp, 0)
  25186. timeFormat := tempTime.Format("20060102150405")
  25187. chrgBchno := rand.Intn(100000) + 10000
  25188. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  25189. his.Number = ipt_otp_no
  25190. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  25191. department, _ := service.GetDepartMentDetail(department)
  25192. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  25193. IdCardNo := ""
  25194. if id_card_type == 1 {
  25195. // IdCardNo = medical_insurance_card
  25196. IdCardNo = patient.IdCardNo
  25197. } else {
  25198. IdCardNo = patient.IdCardNo
  25199. }
  25200. var rf []*ResultFive
  25201. json.Unmarshal([]byte(his.Iinfo), &rf)
  25202. var insutypes []*ResultFive
  25203. var insutype string
  25204. var insuplc_admdvs_temp string
  25205. var is390 int = 0
  25206. var is310 int = 0
  25207. for _, item := range rf {
  25208. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25209. insutypes = append(insutypes, item)
  25210. }
  25211. }
  25212. if len(insutypes) == 1 {
  25213. insutype = insutypes[0].Insutype
  25214. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  25215. if insutype == "390" {
  25216. is390 = 1
  25217. }
  25218. if insutype == "310" {
  25219. is310 = 1
  25220. }
  25221. } else {
  25222. for _, i := range insutypes {
  25223. if i.Insutype == "390" {
  25224. is390 = 1
  25225. }
  25226. if i.Insutype == "310" {
  25227. is310 = 1
  25228. }
  25229. }
  25230. }
  25231. if is390 == 1 {
  25232. insutype = "390"
  25233. }
  25234. if is310 == 1 {
  25235. insutype = "310"
  25236. }
  25237. fmt.Println(social_type)
  25238. if social_type > 0 {
  25239. insutype = strconv.FormatInt(social_type, 10)
  25240. }
  25241. var infocode int64
  25242. var resThree ResultThree
  25243. var resThree10265 ResultThree10265
  25244. if len(insuplc_admdvs) == 0 {
  25245. psn_info, _ := service.GetPsnByPatientId(id)
  25246. //if len(psn_info.InsuplcAdmdvs) > 0 {
  25247. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25248. //}
  25249. } else {
  25250. insuplc_admdvs_temp = insuplc_admdvs
  25251. }
  25252. if miConfig.MdtrtareaAdmvs == "421300" {
  25253. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25254. psn_info, _ := service.GetPsnByPatientId(id)
  25255. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25256. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25257. "&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
  25258. resp, requestErr := http.Get(api)
  25259. if requestErr != nil {
  25260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25261. return
  25262. }
  25263. body, ioErr := ioutil.ReadAll(resp.Body)
  25264. if ioErr != nil {
  25265. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25267. return
  25268. }
  25269. var respJSON map[string]interface{}
  25270. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25271. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25273. return
  25274. }
  25275. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25276. result, _ := json.Marshal(respJSON)
  25277. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25278. utils.ErrorLog("解析失败:%v", err)
  25279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25280. return
  25281. }
  25282. infocode = resThree.Infcode
  25283. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25284. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25285. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  25286. // insuplc_admdvs_temp =
  25287. //}
  25288. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  25289. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25290. //}
  25291. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25292. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25293. "&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
  25294. resp, requestErr := http.Get(api)
  25295. if requestErr != nil {
  25296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25297. return
  25298. }
  25299. body, ioErr := ioutil.ReadAll(resp.Body)
  25300. if ioErr != nil {
  25301. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25303. return
  25304. }
  25305. var respJSON map[string]interface{}
  25306. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25307. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25309. return
  25310. }
  25311. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25312. result, _ := json.Marshal(respJSON)
  25313. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25314. utils.ErrorLog("解析失败:%v", err)
  25315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25316. return
  25317. }
  25318. infocode = resThree.Infcode
  25319. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25320. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25321. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  25322. // insuplc_admdvs_temp =
  25323. //}
  25324. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  25325. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25326. //}
  25327. utils.ErrorLog("解析失败:%v", insutype)
  25328. utils.ErrorLog("解析失败:%v", PsnNo)
  25329. utils.ErrorLog("解析失败:%v", Certno)
  25330. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  25331. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  25332. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  25333. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  25334. utils.ErrorLog("解析失败:%v", PsnNo)
  25335. utils.ErrorLog("解析失败:%v", department.Number)
  25336. utils.ErrorLog("解析失败:%v", department.Name)
  25337. utils.ErrorLog("解析失败:%v", roles.UserName)
  25338. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25339. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25340. "&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
  25341. resp, requestErr := http.Get(api)
  25342. if requestErr != nil {
  25343. utils.ErrorLog("解析失败:%v", requestErr)
  25344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25345. return
  25346. }
  25347. body, ioErr := ioutil.ReadAll(resp.Body)
  25348. if ioErr != nil {
  25349. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25351. return
  25352. }
  25353. var respJSON map[string]interface{}
  25354. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25355. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25357. return
  25358. }
  25359. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25360. result, _ := json.Marshal(respJSON)
  25361. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25362. utils.ErrorLog("解析失败:%v", err)
  25363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25364. return
  25365. }
  25366. infocode = resThree.Infcode
  25367. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25368. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25369. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  25370. // insuplc_admdvs_temp =
  25371. //}
  25372. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  25373. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25374. //}
  25375. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25376. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25377. "&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
  25378. resp, requestErr := http.Get(api)
  25379. if requestErr != nil {
  25380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25381. return
  25382. }
  25383. body, ioErr := ioutil.ReadAll(resp.Body)
  25384. if ioErr != nil {
  25385. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25387. return
  25388. }
  25389. var respJSON map[string]interface{}
  25390. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25391. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25393. return
  25394. }
  25395. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25396. result, _ := json.Marshal(respJSON)
  25397. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25398. utils.ErrorLog("解析失败:%v", err)
  25399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25400. return
  25401. }
  25402. infocode = resThree.Infcode
  25403. } else if miConfig.MdtrtareaAdmvs == "150404" {
  25404. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25405. psn_info, _ := service.GetPsnByPatientId(id)
  25406. var verify_number string
  25407. if id_card_type == 4 {
  25408. verify_number = psn_info.VerifyNumber
  25409. } else if id_card_type == 1 {
  25410. bas := strings.Split(psn_info.CardInfo, "|")
  25411. cardNumber := bas[2]
  25412. verify_number = cardNumber
  25413. }
  25414. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25415. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25416. "&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
  25417. resp, requestErr := http.Get(api)
  25418. if requestErr != nil {
  25419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25420. return
  25421. }
  25422. body, ioErr := ioutil.ReadAll(resp.Body)
  25423. if ioErr != nil {
  25424. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25426. return
  25427. }
  25428. var respJSON map[string]interface{}
  25429. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25430. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25432. return
  25433. }
  25434. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25435. result, _ := json.Marshal(respJSON)
  25436. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25437. // utils.ErrorLog("解析失败:%v", err)
  25438. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25439. // return
  25440. //}
  25441. //infocode = resThree.Infcode
  25442. //result, _ := json.Marshal(respJSON)
  25443. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25444. utils.ErrorLog("解析失败:%v", err)
  25445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25446. return
  25447. }
  25448. resThree.ErrMsg = resThree10265.ErrMsg
  25449. resThree.Output = resThree10265.Output
  25450. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25451. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25452. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  25453. psn_info, _ := service.GetPsnByPatientId(id)
  25454. his.PsnNo = psn_info.PsnNo
  25455. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25456. var cert_no string
  25457. if id_card_type == 3 {
  25458. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  25459. cert_no = IdCardNo
  25460. } else if id_card_type == 4 {
  25461. cert_no = IdCardNo
  25462. psn_info.VerifyNumber = psn_info.VerifyNumber
  25463. } else {
  25464. bas := strings.Split(psn_info.CardInfo, "|")
  25465. cert_no = bas[2]
  25466. }
  25467. var hisPrescription []*models.HisPrescription
  25468. fmt.Println(hisPrescription)
  25469. for _, item := range rf {
  25470. if item.Insutype == insutype {
  25471. //insuplc_admdvs = item.InsuplcAdmdvs
  25472. his.InsuplcAdmdvs = insuplc_admdvs
  25473. }
  25474. }
  25475. his.Insutype = insutype
  25476. var res3101 Result3101
  25477. res3101.Infcode = "0"
  25478. //res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25479. if res3101.Infcode == "0" {
  25480. fmt.Println("33333333")
  25481. if len(res3101.Output.Result) > 0 {
  25482. fmt.Println("222222")
  25483. for _, item := range res3101.Output.Result {
  25484. if len(res3101.ErrMsg) == 0 {
  25485. res3101.ErrMsg = item.VolaCont
  25486. } else {
  25487. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  25488. }
  25489. }
  25490. c.ServeSuccessJSON(map[string]interface{}{
  25491. "failed_code": -10,
  25492. "msg": res3101.ErrMsg,
  25493. })
  25494. return
  25495. } else {
  25496. fmt.Println("11111")
  25497. var api string
  25498. if miConfig.MdtrtareaAdmvs == "320830" {
  25499. ipt_otp_no = timeFormat
  25500. api = miConfig.AppSecret + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25501. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25502. "&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
  25503. } else if miConfig.MdtrtareaAdmvs == "320921" {
  25504. ipt_otp_no = timeFormat
  25505. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25506. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25507. "&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
  25508. } else {
  25509. ipt_otp_no = timeFormat
  25510. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25511. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25512. "&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
  25513. }
  25514. resp, requestErr := http.Get(api)
  25515. if requestErr != nil {
  25516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25517. return
  25518. }
  25519. body, ioErr := ioutil.ReadAll(resp.Body)
  25520. if ioErr != nil {
  25521. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25523. return
  25524. }
  25525. var respJSON map[string]interface{}
  25526. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25527. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25529. return
  25530. }
  25531. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25532. result, _ := json.Marshal(respJSON)
  25533. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25534. utils.ErrorLog("解析失败:%v", err)
  25535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25536. return
  25537. }
  25538. resThree.ErrMsg = resThree10265.ErrMsg
  25539. resThree.Output = resThree10265.Output
  25540. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25541. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25542. }
  25543. } else if res3101.Infcode != "0" {
  25544. c.ServeSuccessJSON(map[string]interface{}{
  25545. "failed_code": -10,
  25546. "msg": res3101.ErrMsg,
  25547. })
  25548. return
  25549. }
  25550. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25551. psn_info, _ := service.GetPsnByPatientId(id)
  25552. var cert_no string
  25553. if id_card_type == 1 {
  25554. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  25555. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25556. } else if id_card_type == 4 {
  25557. cert_no = psn_info.VerifyNumber
  25558. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25559. } else {
  25560. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25561. cert_no = psn_info.VerifyNumber
  25562. }
  25563. 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)
  25564. saveLog(result, requestLog, "2201", "挂号")
  25565. if miConfig.Code == "H15049901371" {
  25566. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25567. utils.ErrorLog("解析失败:%v", err)
  25568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25569. return
  25570. }
  25571. resThree.ErrMsg = resThree10265.ErrMsg
  25572. resThree.Output = resThree10265.Output
  25573. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25574. } else {
  25575. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25576. utils.ErrorLog("解析失败:%v", err)
  25577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25578. return
  25579. }
  25580. }
  25581. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25582. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  25583. psn_info, _ := service.GetPsnByPatientId(id)
  25584. var result string
  25585. var requestLog string
  25586. if id_card_type == 1 {
  25587. bas := strings.Split(psn_info.CardInfo, "|")
  25588. basNumber := bas[2]
  25589. card_sn := bas[3]
  25590. 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)
  25591. saveLog(result, requestLog, "2201A", "挂号")
  25592. } else if id_card_type == 2 {
  25593. 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, "", "", "", "", "", "")
  25594. saveLog(result, requestLog, "2201A", "挂号")
  25595. } else {
  25596. 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)
  25597. saveLog(result, requestLog, "2201A", "挂号")
  25598. }
  25599. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25600. utils.ErrorLog("解析失败:%v", err)
  25601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25602. return
  25603. }
  25604. infocode = resThree.Infcode
  25605. } else if miConfig.MdtrtareaAdmvs == "361025" { //江西萍乡
  25606. psn_info, _ := service.GetPsnByPatientId(id)
  25607. var result string
  25608. var requestLog string
  25609. if id_card_type == 1 {
  25610. bas := strings.Split(psn_info.CardInfo, "|")
  25611. basNumber := bas[2]
  25612. card_sn := ""
  25613. 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)
  25614. saveLog(result, requestLog, "2201A", "挂号")
  25615. } else if id_card_type == 2 {
  25616. 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, "", "", "", "", "", "")
  25617. saveLog(result, requestLog, "2201A", "挂号")
  25618. } else {
  25619. 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)
  25620. saveLog(result, requestLog, "2201A", "挂号")
  25621. }
  25622. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25623. utils.ErrorLog("解析失败:%v", err)
  25624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25625. return
  25626. }
  25627. infocode = resThree.Infcode
  25628. } else if miConfig.MdtrtareaAdmvs == "360100" { //江西萍乡
  25629. psn_info, _ := service.GetPsnByPatientId(id)
  25630. var result string
  25631. var requestLog string
  25632. if id_card_type == 1 {
  25633. bas := strings.Split(psn_info.CardInfo, "|")
  25634. basNumber := bas[2]
  25635. card_sn := ""
  25636. 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)
  25637. saveLog(result, requestLog, "2201A", "挂号")
  25638. } else if id_card_type == 2 {
  25639. 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, "", "", "", "", "", "")
  25640. saveLog(result, requestLog, "2201A", "挂号")
  25641. } else {
  25642. 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)
  25643. saveLog(result, requestLog, "2201A", "挂号")
  25644. }
  25645. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25646. utils.ErrorLog("解析失败:%v", err)
  25647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25648. return
  25649. }
  25650. infocode = resThree.Infcode
  25651. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25652. psn_info, _ := service.GetPsnByPatientId(id)
  25653. his.PsnNo = psn_info.PsnNo
  25654. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25655. var cert_no string
  25656. if id_card_type == 1 {
  25657. bas := strings.Split(psn_info.CardInfo, "|")
  25658. cert_no = bas[2]
  25659. } else if id_card_type == 4 {
  25660. cert_no = psn_info.VerifyNumber
  25661. psn_info.VerifyNumber = psn_info.VerifyNumber
  25662. IdCardNo = psn_info.VerifyNumber
  25663. } else {
  25664. cert_no = IdCardNo
  25665. psn_info.VerifyNumber = cert_no
  25666. }
  25667. for _, item := range rf {
  25668. if item.Insutype == insutype {
  25669. his.InsuplcAdmdvs = insuplc_admdvs
  25670. }
  25671. }
  25672. his.Insutype = insutype
  25673. var api string
  25674. ipt_otp_no = timeFormat
  25675. 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 +
  25676. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25677. "&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
  25678. resp, requestErr := http.Get(api)
  25679. if requestErr != nil {
  25680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25681. return
  25682. }
  25683. body, ioErr := ioutil.ReadAll(resp.Body)
  25684. if ioErr != nil {
  25685. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25687. return
  25688. }
  25689. var respJSON map[string]interface{}
  25690. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25691. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25693. return
  25694. }
  25695. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25696. if status == "0" {
  25697. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25698. c.ServeSuccessJSON(map[string]interface{}{
  25699. "failed_code": -10,
  25700. "msg": err_msg,
  25701. })
  25702. return
  25703. }
  25704. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25705. result, _ := json.Marshal(respJSON)
  25706. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25707. utils.ErrorLog("解析失败:%v", err)
  25708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25709. return
  25710. }
  25711. infocode = resThree.Infcode
  25712. } else if miConfig.MdtrtareaAdmvs == "340699" {
  25713. psn_info, _ := service.GetPsnByPatientId(id)
  25714. his.PsnNo = psn_info.PsnNo
  25715. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25716. var cert_no string
  25717. if id_card_type == 1 {
  25718. bas := strings.Split(psn_info.CardInfo, "|")
  25719. cert_no = bas[2]
  25720. } else if id_card_type == 4 {
  25721. cert_no = psn_info.VerifyNumber
  25722. psn_info.VerifyNumber = psn_info.VerifyNumber
  25723. IdCardNo = psn_info.VerifyNumber
  25724. } else {
  25725. cert_no = IdCardNo
  25726. psn_info.VerifyNumber = cert_no
  25727. }
  25728. for _, item := range rf {
  25729. if item.Insutype == insutype {
  25730. his.InsuplcAdmdvs = insuplc_admdvs
  25731. patient.InsuplcAdmdvs = insuplc_admdvs
  25732. }
  25733. }
  25734. his.Insutype = insutype
  25735. var api string
  25736. ipt_otp_no = timeFormat
  25737. 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 +
  25738. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25739. "&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
  25740. resp, requestErr := http.Get(api)
  25741. if requestErr != nil {
  25742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25743. return
  25744. }
  25745. body, ioErr := ioutil.ReadAll(resp.Body)
  25746. if ioErr != nil {
  25747. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25749. return
  25750. }
  25751. var respJSON map[string]interface{}
  25752. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25753. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25755. return
  25756. }
  25757. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25758. if status == "0" {
  25759. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25760. c.ServeSuccessJSON(map[string]interface{}{
  25761. "failed_code": -10,
  25762. "msg": err_msg,
  25763. })
  25764. return
  25765. }
  25766. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25767. result, _ := json.Marshal(respJSON)
  25768. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25769. utils.ErrorLog("解析失败:%v", err)
  25770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25771. return
  25772. }
  25773. infocode = resThree.Infcode
  25774. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25775. hour := time.Now().Format("15")
  25776. min := time.Now().Format("04")
  25777. sec := time.Now().Format("05")
  25778. begin := record_time + " " + hour + ":" + min + ":" + sec
  25779. psn_info, _ := service.GetPsnByPatientId(id)
  25780. var result string
  25781. var requestLog string
  25782. if id_card_type == 1 {
  25783. bas := strings.Split(psn_info.CardInfo, "|")
  25784. basNumber := bas[2]
  25785. card_sn := bas[3]
  25786. 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)
  25787. saveLog(result, requestLog, "2201A", "挂号")
  25788. } else if id_card_type == 2 {
  25789. 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)
  25790. saveLog(result, requestLog, "2201A", "挂号")
  25791. } else {
  25792. 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)
  25793. saveLog(result, requestLog, "2201A", "挂号")
  25794. }
  25795. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25796. utils.ErrorLog("解析失败:%v", err)
  25797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25798. return
  25799. }
  25800. infocode = resThree.Infcode
  25801. } else if miConfig.MdtrtareaAdmvs == "131023" {
  25802. psn_info, _ := service.GetPsnByPatientId(id)
  25803. 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)
  25804. saveLog(result, requestLog, "2201A", "挂号")
  25805. if miConfig.Code == "H15049901371" {
  25806. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25807. utils.ErrorLog("解析失败:%v", err)
  25808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25809. return
  25810. }
  25811. resThree.ErrMsg = resThree10265.ErrMsg
  25812. resThree.Output = resThree10265.Output
  25813. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25814. } else {
  25815. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25816. utils.ErrorLog("解析失败:%v", err)
  25817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25818. return
  25819. }
  25820. }
  25821. if miConfig.Code == "H15049901371" {
  25822. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25823. } else {
  25824. infocode = resThree.Infcode
  25825. }
  25826. } else {
  25827. psn_info, _ := service.GetPsnByPatientId(id)
  25828. if id_card_type == 4 || id_card_type == 1 {
  25829. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25830. }
  25831. var rf []*ResultFive
  25832. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  25833. var insutypes []*ResultFive
  25834. var insutype string
  25835. var is390 int = 0
  25836. var is310 int = 0
  25837. for _, item := range rf {
  25838. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25839. insutypes = append(insutypes, item)
  25840. }
  25841. }
  25842. if len(insutypes) == 1 {
  25843. insutype = insutypes[0].Insutype
  25844. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  25845. } else {
  25846. for _, i := range insutypes {
  25847. if i.Insutype == "390" {
  25848. is390 = 1
  25849. }
  25850. if i.Insutype == "310" {
  25851. is310 = 1
  25852. }
  25853. }
  25854. }
  25855. if is390 == 1 {
  25856. insutype = "390"
  25857. }
  25858. if is310 == 1 {
  25859. insutype = "310"
  25860. }
  25861. fmt.Println(len(insutypes))
  25862. if len(insutypes) == 0 {
  25863. for index, item := range rf {
  25864. if index == 0 {
  25865. insutype = item.Insutype
  25866. insuplc_admdvs = item.InsuplcAdmdvs
  25867. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25868. }
  25869. }
  25870. fmt.Println(insutype)
  25871. fmt.Println(insuplc_admdvs)
  25872. }
  25873. if social_type > 0 {
  25874. insutype = strconv.FormatInt(social_type, 10)
  25875. }
  25876. fmt.Println("--------")
  25877. fmt.Println(psn_info)
  25878. fmt.Println(psn_info.PsnNo)
  25879. for _, item := range rf {
  25880. if item.Insutype == insutype {
  25881. insutype = item.Insutype
  25882. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25883. }
  25884. }
  25885. if miConfig.MdtrtareaAdmvs == "441202" {
  25886. var hisPrescription []*models.HisPrescription
  25887. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25888. if res3101.Infcode == 0 {
  25889. fmt.Println("33333333")
  25890. if len(res3101.Output.Result) > 0 {
  25891. fmt.Println("222222")
  25892. for _, item := range res3101.Output.Result {
  25893. if len(res3101.ErrMsg) == 0 {
  25894. res3101.ErrMsg = item.VolaCont
  25895. } else {
  25896. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  25897. }
  25898. }
  25899. c.ServeSuccessJSON(map[string]interface{}{
  25900. "failed_code": -10,
  25901. "msg": res3101.ErrMsg,
  25902. })
  25903. return
  25904. } else {
  25905. hour := time.Now().Format("15")
  25906. min := time.Now().Format("04")
  25907. sec := time.Now().Format("05")
  25908. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25909. fmt.Println(record_time_two)
  25910. 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)
  25911. saveLog(result, requestLog, "2201A", "挂号")
  25912. if miConfig.Code == "H15049901371" {
  25913. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25914. utils.ErrorLog("解析失败:%v", err)
  25915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25916. return
  25917. }
  25918. resThree.ErrMsg = resThree10265.ErrMsg
  25919. resThree.Output = resThree10265.Output
  25920. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25921. } else {
  25922. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25923. utils.ErrorLog("解析失败:%v", err)
  25924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25925. return
  25926. }
  25927. }
  25928. if miConfig.Code == "H15049901371" {
  25929. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25930. } else {
  25931. infocode = resThree.Infcode
  25932. }
  25933. }
  25934. } else if res3101.Infcode != 0 {
  25935. c.ServeSuccessJSON(map[string]interface{}{
  25936. "failed_code": -10,
  25937. "msg": res3101.ErrMsg,
  25938. })
  25939. return
  25940. }
  25941. } else if miConfig.MdtrtareaAdmvs == "440205" {
  25942. var hisPrescription []*models.HisPrescription
  25943. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25944. if res3101.Infcode == 0 {
  25945. fmt.Println("33333333")
  25946. if len(res3101.Output.Result) > 0 {
  25947. fmt.Println("222222")
  25948. for _, item := range res3101.Output.Result {
  25949. if len(res3101.ErrMsg) == 0 {
  25950. res3101.ErrMsg = item.VolaCont
  25951. } else {
  25952. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  25953. }
  25954. }
  25955. c.ServeSuccessJSON(map[string]interface{}{
  25956. "failed_code": -10,
  25957. "msg": res3101.ErrMsg,
  25958. })
  25959. return
  25960. } else {
  25961. hour := time.Now().Format("15")
  25962. min := time.Now().Format("04")
  25963. sec := time.Now().Format("05")
  25964. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25965. fmt.Println(record_time_two)
  25966. 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)
  25967. saveLog(result, requestLog, "2201A", "挂号")
  25968. if miConfig.Code == "H15049901371" {
  25969. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25970. utils.ErrorLog("解析失败:%v", err)
  25971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25972. return
  25973. }
  25974. resThree.ErrMsg = resThree10265.ErrMsg
  25975. resThree.Output = resThree10265.Output
  25976. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25977. } else {
  25978. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25979. utils.ErrorLog("解析失败:%v", err)
  25980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25981. return
  25982. }
  25983. }
  25984. if miConfig.Code == "H15049901371" {
  25985. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25986. } else {
  25987. infocode = resThree.Infcode
  25988. }
  25989. }
  25990. } else if res3101.Infcode != 0 {
  25991. c.ServeSuccessJSON(map[string]interface{}{
  25992. "failed_code": -10,
  25993. "msg": res3101.ErrMsg,
  25994. })
  25995. return
  25996. }
  25997. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25998. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25999. psn_info, _ := service.GetPsnByPatientId(id)
  26000. var verify_number string
  26001. if id_card_type == 4 {
  26002. verify_number = psn_info.VerifyNumber
  26003. } else if id_card_type == 1 {
  26004. bas := strings.Split(psn_info.CardInfo, "|")
  26005. cardNumber := bas[2]
  26006. verify_number = cardNumber
  26007. } else {
  26008. verify_number = psn_info.Certno
  26009. }
  26010. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  26011. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  26012. "&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
  26013. resp, requestErr := http.Get(api)
  26014. if requestErr != nil {
  26015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26016. return
  26017. }
  26018. body, ioErr := ioutil.ReadAll(resp.Body)
  26019. if ioErr != nil {
  26020. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26022. return
  26023. }
  26024. var respJSON map[string]interface{}
  26025. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26026. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26028. return
  26029. }
  26030. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26031. result, _ := json.Marshal(respJSON)
  26032. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  26033. utils.ErrorLog("解析失败:%v", err)
  26034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26035. return
  26036. }
  26037. infocode = resThree.Infcode
  26038. } else {
  26039. hour := time.Now().Format("15")
  26040. min := time.Now().Format("04")
  26041. sec := time.Now().Format("05")
  26042. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  26043. if id_card_type == 1 {
  26044. for _, item := range rf {
  26045. if item.Insutype == strconv.FormatInt(social_type, 10) {
  26046. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  26047. insuplc_admdvs_temp = item.InsuplcAdmdvs
  26048. } else if strconv.FormatInt(social_type, 10) == "390" {
  26049. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  26050. } else {
  26051. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  26052. }
  26053. }
  26054. }
  26055. }
  26056. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  26057. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  26058. }
  26059. if id_card_type == 1 {
  26060. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  26061. bas := strings.Split(psn_info.CardInfo, "|")
  26062. basNumber := bas[1]
  26063. IdCardNo = basNumber
  26064. }
  26065. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  26066. IdCardNo = psn_info.VerifyNumber
  26067. }
  26068. if len(insuplc_admdvs_temp) == 0 {
  26069. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  26070. }
  26071. var result string
  26072. var requestLog string
  26073. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" || miConfig.Code == "H44090200998"{
  26074. var hisPrescription []*models.HisPrescription
  26075. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  26076. if res3101.Infcode == 0 {
  26077. if len(res3101.Output.Result) > 0 {
  26078. if len(res3101.Output.Result) > 0 {
  26079. c.ServeSuccessJSON(map[string]interface{}{
  26080. "failed_code": -10,
  26081. "failed_type": 100,
  26082. "warm_type": 1,
  26083. "msg": res3101,
  26084. })
  26085. return
  26086. } else {
  26087. c.ServeSuccessJSON(map[string]interface{}{
  26088. "failed_code": -10,
  26089. "msg": res3101.ErrMsg,
  26090. })
  26091. return
  26092. }
  26093. } else {
  26094. hour := time.Now().Format("15")
  26095. min := time.Now().Format("04")
  26096. sec := time.Now().Format("05")
  26097. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  26098. fmt.Println(record_time_two)
  26099. if his.IdCardType == 2 {
  26100. IdCardNo = psn_info.Certno
  26101. psn_info.VerifyNumber = psn_info.Certno
  26102. } else if his.IdCardType == 4 {
  26103. IdCardNo = psn_info.Certno
  26104. } else {
  26105. bas := strings.Split(psn_info.CardInfo, "|")
  26106. IdCardNo = bas[2]
  26107. }
  26108. aaaa = insutype
  26109. 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)
  26110. saveLog(result, requestLog, "2201A", "挂号")
  26111. if miConfig.Code == "H15049901371" {
  26112. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  26113. utils.ErrorLog("解析失败:%v", err)
  26114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26115. return
  26116. }
  26117. resThree.ErrMsg = resThree10265.ErrMsg
  26118. resThree.Output = resThree10265.Output
  26119. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  26120. } else {
  26121. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  26122. utils.ErrorLog("解析失败:%v", err)
  26123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26124. return
  26125. }
  26126. }
  26127. if miConfig.Code == "H15049901371" {
  26128. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  26129. } else {
  26130. infocode = resThree.Infcode
  26131. }
  26132. }
  26133. } else if res3101.Infcode != 0 {
  26134. c.ServeSuccessJSON(map[string]interface{}{
  26135. "failed_code": -10,
  26136. "msg": res3101.ErrMsg,
  26137. })
  26138. return
  26139. }
  26140. } else {
  26141. psn_info, _ := service.GetPsnByPatientId(id)
  26142. var rf []*ResultFive
  26143. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  26144. //var insutypes []*ResultFive
  26145. var insutype string
  26146. var insutypes []*ResultFive
  26147. var is390 int = 0
  26148. var is310 int = 0
  26149. for _, item := range rf {
  26150. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26151. insutypes = append(insutypes, item)
  26152. }
  26153. }
  26154. if len(insutypes) == 1 {
  26155. insutype = insutypes[0].Insutype
  26156. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  26157. } else {
  26158. for _, i := range insutypes {
  26159. if i.Insutype == "390" {
  26160. is390 = 1
  26161. }
  26162. if i.Insutype == "310" {
  26163. is310 = 1
  26164. }
  26165. }
  26166. }
  26167. if is390 == 1 {
  26168. insutype = "390"
  26169. }
  26170. if is310 == 1 {
  26171. insutype = "310"
  26172. }
  26173. if len(insutypes) == 0 {
  26174. insutype = "310"
  26175. }
  26176. if social_type > 0 {
  26177. insutype = strconv.FormatInt(social_type, 10)
  26178. }
  26179. for _, item := range rf {
  26180. if item.Insutype == insutype {
  26181. insuplc_admdvs_temp = item.InsuplcAdmdvs
  26182. }
  26183. }
  26184. if len(insuplc_admdvs_tt) > 0 {
  26185. insuplc_admdvs_temp = insuplc_admdvs_tt
  26186. }
  26187. 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)
  26188. saveLog(result, requestLog, "2201A", "挂号")
  26189. }
  26190. if miConfig.Code == "H15049901371" {
  26191. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  26192. utils.ErrorLog("解析失败:%v", err)
  26193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26194. return
  26195. }
  26196. resThree.ErrMsg = resThree10265.ErrMsg
  26197. resThree.Output = resThree10265.Output
  26198. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  26199. } else {
  26200. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  26201. utils.ErrorLog("解析失败:%v", err)
  26202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26203. return
  26204. }
  26205. }
  26206. if miConfig.Code == "H15049901371" {
  26207. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  26208. } else {
  26209. infocode = resThree.Infcode
  26210. }
  26211. }
  26212. }
  26213. if infocode == -1 {
  26214. adminUser := c.GetAdminUserInfo()
  26215. errlog := &models.HisOrderError{
  26216. UserOrgId: adminUser.CurrentOrgId,
  26217. Ctime: time.Now().Unix(),
  26218. Mtime: time.Now().Unix(),
  26219. ErrMsg: resThree.ErrMsg,
  26220. Status: 1,
  26221. PatientId: id,
  26222. RecordTime: recordDateTime,
  26223. Stage: 2,
  26224. }
  26225. service.CreateErrMsgLog(errlog)
  26226. c.ServeSuccessJSON(map[string]interface{}{
  26227. "failed_code": -10,
  26228. "msg": resThree.ErrMsg,
  26229. })
  26230. return
  26231. }
  26232. utils.ErrorLog("解析失败:%v", insutype)
  26233. his.Number = resThree.Output.Data.MdtrtID
  26234. his.PsnNo = resThree.Output.Data.PsnNo
  26235. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  26236. his.IdCardNo = patient.IdCardNo
  26237. his.PhoneNumber = patient.Phone
  26238. his.UserOrgId = adminInfo.CurrentOrgId
  26239. his.Insutype = insutype
  26240. if miConfig.Code == "H44030500255" {
  26241. his.Insutype = aaaa
  26242. }
  26243. his.Ctime = time.Now().Unix()
  26244. his.Mtime = time.Now().Unix()
  26245. his.InsuplcAdmdvs = insuplc_admdvs_temp
  26246. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  26247. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  26248. }
  26249. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  26250. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  26251. }
  26252. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  26253. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  26254. }
  26255. his.Status = 1
  26256. his.MdtrtGrpType = mdtrt_type
  26257. service.UpdateHisPatientStatus(&his)
  26258. service.UpdateHisPatient123(&patient)
  26259. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  26260. c.ServeSuccessJSON(map[string]interface{}{
  26261. "his_info": his,
  26262. })
  26263. } else {
  26264. adminUser := c.GetAdminUserInfo()
  26265. errlog := &models.HisOrderError{
  26266. UserOrgId: adminUser.CurrentOrgId,
  26267. Ctime: time.Now().Unix(),
  26268. Mtime: time.Now().Unix(),
  26269. ErrMsg: res.ErrMsg,
  26270. Status: 1,
  26271. PatientId: id,
  26272. RecordTime: recordDateTime,
  26273. Stage: 1,
  26274. }
  26275. service.CreateErrMsgLog(errlog)
  26276. c.ServeSuccessJSON(map[string]interface{}{
  26277. "failed_code": -10,
  26278. "msg": res.ErrMsg,
  26279. })
  26280. return
  26281. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  26282. }
  26283. }
  26284. }
  26285. func (c *HisApiController) GetUploadInfo() {
  26286. id, _ := c.GetInt64("id")
  26287. record_time := c.GetString("record_time")
  26288. his_patient_id, _ := c.GetInt64("his_patient_id")
  26289. order_id, _ := c.GetInt64("order_id")
  26290. pay_way, _ := c.GetInt64("pay_way")
  26291. pay_ways := c.GetString("pay_ways")
  26292. oth_desc := c.GetString("oth_desc")
  26293. pay_price, _ := c.GetFloat("pay_price")
  26294. pay_card_no := c.GetString("pay_card_no")
  26295. discount_price, _ := c.GetFloat("discount_price")
  26296. preferential_price, _ := c.GetFloat("preferential_price")
  26297. reality_price, _ := c.GetFloat("reality_price")
  26298. found_price, _ := c.GetFloat("found_price")
  26299. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  26300. private_price, _ := c.GetFloat("private_price")
  26301. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  26302. admin_user_id, _ := c.GetInt64("admin_user_id")
  26303. fapiao_code := c.GetString("fapiao_code")
  26304. fapiao_number := c.GetString("fapiao_number")
  26305. diagnosis_id := c.GetString("diagnosis")
  26306. sick_type, _ := c.GetInt64("sick_type")
  26307. reg_type, _ := c.GetInt64("p_type")
  26308. begin_time := c.GetString("begin_time")
  26309. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  26310. cash_pay := c.GetString("cash_pay")
  26311. band_card_pay := c.GetString("band_card_pay")
  26312. wechat_pay := c.GetString("wechat_pay")
  26313. ali_pay := c.GetString("ali_pay")
  26314. jifen_pay := c.GetString("jifen_pay")
  26315. //jifen_pay := c.GetString("jifen_pay")
  26316. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  26317. fmt.Println(acct_used_flag)
  26318. id_str := c.GetString("ids")
  26319. ids_arr := strings.Split(id_str, ",")
  26320. timeLayout := "2006-01-02"
  26321. loc, _ := time.LoadLocation("Local")
  26322. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  26323. if err != nil {
  26324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26325. return
  26326. }
  26327. recordDateTime := theTime.Unix()
  26328. adminUser := c.GetAdminUserInfo()
  26329. var tempOrder models.HisOrder
  26330. tempOrder, _ = service.GetHisOrderByID(order_id)
  26331. var prescriptions []*models.HisPrescription
  26332. var start_time int64
  26333. var end_time int64
  26334. //押金模块
  26335. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  26336. tmp_decimal := c.GetString("tmp_decimal")
  26337. var decimal float64 //本次使用的押金
  26338. var errmsg error
  26339. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  26340. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  26341. return
  26342. }
  26343. if len(tmp_decimal) > 0 {
  26344. if tmp_decimal[0] == 45 {
  26345. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  26346. return
  26347. }
  26348. }
  26349. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  26350. fmt.Println(errs)
  26351. decimal = tt
  26352. //if adminUser.CurrentOrgId == 10106{
  26353. // if len(fapiao_code) == 0{
  26354. // fapiao_code = "144072080589"
  26355. // }
  26356. // if len(fapiao_number) == 0{
  26357. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  26358. // if order.ID == 0{
  26359. // fapiao_number = "00001520"
  26360. // }else{
  26361. // //fapiao_code = "00001520"
  26362. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  26363. // var zero string
  26364. // if fpNumber >= 1000{
  26365. // zero = "0000" + strconv.Itoa(fpNumber)
  26366. // }else if fpNumber >= 10000{
  26367. // zero = "000" + strconv.Itoa(fpNumber)
  26368. // } else if fpNumber >= 100000{
  26369. // zero = "00" + strconv.Itoa(fpNumber)
  26370. // } else if fpNumber >= 1000000{
  26371. // zero = "0" + strconv.Itoa(fpNumber)
  26372. // }else {
  26373. // zero = strconv.Itoa(fpNumber)
  26374. // }
  26375. // fapiao_number = zero
  26376. // }
  26377. // }
  26378. //}
  26379. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26380. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  26381. var patientPrescription models.HisPrescriptionInfo
  26382. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  26383. if patientPrescription.ID == 0 {
  26384. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  26385. }
  26386. //if patientPrescription.Do
  26387. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26388. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  26389. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  26390. diagnosis_ids := strings.Split(diagnosis_id, ",")
  26391. var config []*models.HisXtDiagnoseConfig
  26392. for _, item := range diagnosis_ids {
  26393. id, _ := strconv.ParseInt(item, 10, 64)
  26394. diagnosisConfig, _ := service.FindDiagnoseById(id)
  26395. config = append(config, &diagnosisConfig)
  26396. }
  26397. sickConfig, _ := service.FindSickById(sick_type)
  26398. //if tempOrder.ID == 0 {
  26399. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  26400. //}
  26401. if tempOrder.ID == 0 {
  26402. var result string
  26403. var requestLog string
  26404. var res2 ResultSix
  26405. var res3 GZResultSix
  26406. var ressix10265 ResultSix10265
  26407. if miConfig.MdtrtareaAdmvs == "421300" {
  26408. data := make(map[string]interface{})
  26409. client := &http.Client{}
  26410. data["psn_no"] = his.PsnNo
  26411. data["mdtrt_id"] = his.Number
  26412. data["opter"] = roles.UserName
  26413. data["org_name"] = miConfig.OrgName
  26414. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26415. data["doctor_id"] = doctor_info.DoctorNumber
  26416. data["doctor_name"] = doctor_info.UserName
  26417. data["department"] = department.Name
  26418. data["fixmedins_code"] = miConfig.Code
  26419. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26420. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26421. data["secret_key"] = miConfig.SecretKey
  26422. data["sick_code"] = sickConfig.CountryCode
  26423. data["sick_name"] = sickConfig.ClassName
  26424. data["dept"] = strconv.FormatInt(department.ID, 10)
  26425. data["config"] = config
  26426. data["begin_time"] = begin_time
  26427. bytesData, _ := json.Marshal(data)
  26428. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  26429. resp, _ := client.Do(req)
  26430. defer resp.Body.Close()
  26431. body, ioErr := ioutil.ReadAll(resp.Body)
  26432. if ioErr != nil {
  26433. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26435. return
  26436. }
  26437. var respJSON map[string]interface{}
  26438. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26439. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26441. return
  26442. }
  26443. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26444. userJSONBytes, _ := json.Marshal(respJSON)
  26445. fmt.Println("log")
  26446. fmt.Println(string(userJSONBytes))
  26447. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26448. utils.ErrorLog("解析失败:%v", err)
  26449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26450. return
  26451. }
  26452. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26453. data := make(map[string]interface{})
  26454. client := &http.Client{}
  26455. data["psn_no"] = his.PsnNo
  26456. data["mdtrt_id"] = his.Number
  26457. data["opter"] = roles.UserName
  26458. data["org_name"] = miConfig.OrgName
  26459. if reg_type == 11 && his.Insutype == "390" {
  26460. data["med_type"] = "110104"
  26461. } else {
  26462. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26463. }
  26464. data["doctor_id"] = doctor_info.DoctorNumber
  26465. data["doctor_name"] = doctor_info.UserName
  26466. data["department"] = department.Name
  26467. data["fixmedins_code"] = miConfig.Code
  26468. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26469. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26470. data["secret_key"] = miConfig.SecretKey
  26471. data["sick_code"] = sickConfig.CountryCode
  26472. data["sick_name"] = sickConfig.ClassName
  26473. data["dept"] = strconv.FormatInt(department.ID, 10)
  26474. data["config"] = config
  26475. data["begin_time"] = begin_time
  26476. bytesData, _ := json.Marshal(data)
  26477. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  26478. resp, _ := client.Do(req)
  26479. defer resp.Body.Close()
  26480. body, ioErr := ioutil.ReadAll(resp.Body)
  26481. if ioErr != nil {
  26482. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26484. return
  26485. }
  26486. var respJSON map[string]interface{}
  26487. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26488. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26490. return
  26491. }
  26492. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26493. userJSONBytes, _ := json.Marshal(respJSON)
  26494. fmt.Println("log")
  26495. fmt.Println(string(userJSONBytes))
  26496. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26497. utils.ErrorLog("解析失败:%v", err)
  26498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26499. return
  26500. }
  26501. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26502. data := make(map[string]interface{})
  26503. client := &http.Client{}
  26504. data["psn_no"] = his.PsnNo
  26505. data["mdtrt_id"] = his.Number
  26506. data["opter"] = roles.UserName
  26507. data["org_name"] = miConfig.OrgName
  26508. if reg_type == 11 && his.Insutype == "390" {
  26509. data["med_type"] = "110104"
  26510. } else {
  26511. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26512. }
  26513. data["doctor_id"] = doctor_info.DoctorNumber
  26514. data["doctor_name"] = doctor_info.UserName
  26515. data["department"] = department.Name
  26516. data["fixmedins_code"] = miConfig.Code
  26517. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26518. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26519. data["secret_key"] = miConfig.SecretKey
  26520. data["sick_code"] = sickConfig.CountryCode
  26521. data["sick_name"] = sickConfig.ClassName
  26522. data["dept"] = strconv.FormatInt(department.ID, 10)
  26523. data["config"] = config
  26524. data["begin_time"] = begin_time
  26525. bytesData, _ := json.Marshal(data)
  26526. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  26527. resp, _ := client.Do(req)
  26528. defer resp.Body.Close()
  26529. body, ioErr := ioutil.ReadAll(resp.Body)
  26530. if ioErr != nil {
  26531. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26533. return
  26534. }
  26535. var respJSON map[string]interface{}
  26536. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26537. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26539. return
  26540. }
  26541. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26542. userJSONBytes, _ := json.Marshal(respJSON)
  26543. fmt.Println("log")
  26544. fmt.Println(string(userJSONBytes))
  26545. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26546. utils.ErrorLog("解析失败:%v", err)
  26547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26548. return
  26549. }
  26550. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26551. data := make(map[string]interface{})
  26552. client := &http.Client{}
  26553. data["psn_no"] = his.PsnNo
  26554. data["mdtrt_id"] = his.Number
  26555. data["opter"] = roles.UserName
  26556. data["org_name"] = miConfig.OrgName
  26557. if reg_type == 11 && his.Insutype == "390" {
  26558. data["med_type"] = "110104"
  26559. } else {
  26560. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26561. }
  26562. data["doctor_id"] = doctor_info.DoctorNumber
  26563. data["doctor_name"] = doctor_info.UserName
  26564. data["department"] = department.Name
  26565. data["fixmedins_code"] = miConfig.Code
  26566. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26567. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26568. data["secret_key"] = miConfig.SecretKey
  26569. data["sick_code"] = sickConfig.CountryCode
  26570. data["sick_name"] = sickConfig.ClassName
  26571. data["dept"] = strconv.FormatInt(department.ID, 10)
  26572. data["config"] = config
  26573. data["begin_time"] = begin_time
  26574. bytesData, _ := json.Marshal(data)
  26575. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  26576. resp, _ := client.Do(req)
  26577. defer resp.Body.Close()
  26578. body, ioErr := ioutil.ReadAll(resp.Body)
  26579. if ioErr != nil {
  26580. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26582. return
  26583. }
  26584. var respJSON map[string]interface{}
  26585. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26586. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26588. return
  26589. }
  26590. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26591. userJSONBytes, _ := json.Marshal(respJSON)
  26592. fmt.Println("log")
  26593. fmt.Println(string(userJSONBytes))
  26594. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26595. utils.ErrorLog("解析失败:%v", err)
  26596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26597. return
  26598. }
  26599. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  26600. utils.ErrorLog("解析失败:%v", doctor_info)
  26601. data := make(map[string]interface{})
  26602. client := &http.Client{}
  26603. data["psn_no"] = his.PsnNo
  26604. data["mdtrt_id"] = his.Number
  26605. data["doctor"] = roles.UserName
  26606. data["department"] = department.Name
  26607. data["org_name"] = miConfig.OrgName
  26608. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26609. data["doctor_id"] = doctor_info.DoctorNumber
  26610. data["new_doctor_name"] = doctor_info.UserName
  26611. data["fixmedins_code"] = miConfig.Code
  26612. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26613. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26614. data["secret_key"] = miConfig.SecretKey
  26615. data["sick_code"] = sickConfig.CountryCode
  26616. data["sick_name"] = sickConfig.ClassName
  26617. data["url"] = miConfig.Url
  26618. data["ak"] = miConfig.AccessKey
  26619. data["begin_time"] = begin_time
  26620. data["cainfo"] = miConfig.Cainfo
  26621. data["dept"] = strconv.FormatInt(department.ID, 10)
  26622. data["config"] = config
  26623. bytesData, _ := json.Marshal(data)
  26624. var req *http.Request
  26625. if miConfig.MdtrtareaAdmvs == "320830" {
  26626. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2203", bytes.NewReader(bytesData))
  26627. //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 +
  26628. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  26629. } else if miConfig.MdtrtareaAdmvs == "320921" {
  26630. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  26631. //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 +
  26632. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  26633. } else {
  26634. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  26635. }
  26636. resp, _ := client.Do(req)
  26637. defer resp.Body.Close()
  26638. body, ioErr := ioutil.ReadAll(resp.Body)
  26639. if ioErr != nil {
  26640. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26642. return
  26643. }
  26644. var respJSON map[string]interface{}
  26645. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26646. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26648. return
  26649. }
  26650. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26651. userJSONBytes, _ := json.Marshal(respJSON)
  26652. fmt.Println("log")
  26653. fmt.Println(string(userJSONBytes))
  26654. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  26655. utils.ErrorLog("解析失败:%v", err)
  26656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26657. return
  26658. }
  26659. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26660. res2.Output = ressix10265.Output
  26661. res2.ErrMsg = ressix10265.ErrMsg
  26662. res2.Cainfo = ressix10265.Cainfo
  26663. res2.WarnMsg = ressix10265.WarnMsg
  26664. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26665. res2.Infcode = infocode
  26666. } else if miConfig.MdtrtareaAdmvs == "150404" {
  26667. data := make(map[string]interface{})
  26668. client := &http.Client{}
  26669. data["psn_no"] = his.PsnNo
  26670. data["mdtrt_id"] = his.Number
  26671. data["doctor"] = roles.UserName
  26672. data["department"] = department.Name
  26673. data["org_name"] = miConfig.OrgName
  26674. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26675. data["doctor_id"] = doctor_info.DoctorNumber
  26676. data["new_doctor_name"] = doctor_info.UserName
  26677. data["fixmedins_code"] = miConfig.Code
  26678. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26679. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26680. data["secret_key"] = miConfig.SecretKey
  26681. data["sick_code"] = sickConfig.CountryCode
  26682. data["sick_name"] = sickConfig.ClassName
  26683. data["url"] = miConfig.Url
  26684. data["ak"] = miConfig.AccessKey
  26685. data["begin_time"] = begin_time
  26686. data["cainfo"] = miConfig.Cainfo
  26687. data["dept"] = strconv.FormatInt(department.ID, 10)
  26688. data["config"] = config
  26689. bytesData, _ := json.Marshal(data)
  26690. var req *http.Request
  26691. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  26692. resp, _ := client.Do(req)
  26693. defer resp.Body.Close()
  26694. body, ioErr := ioutil.ReadAll(resp.Body)
  26695. if ioErr != nil {
  26696. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26698. return
  26699. }
  26700. var respJSON map[string]interface{}
  26701. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26704. return
  26705. }
  26706. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26707. userJSONBytes, _ := json.Marshal(respJSON)
  26708. fmt.Println("log")
  26709. fmt.Println(string(userJSONBytes))
  26710. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  26711. utils.ErrorLog("解析失败:%v", err)
  26712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26713. return
  26714. }
  26715. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26716. res2.Output = ressix10265.Output
  26717. res2.ErrMsg = ressix10265.ErrMsg
  26718. res2.Cainfo = ressix10265.Cainfo
  26719. res2.WarnMsg = ressix10265.WarnMsg
  26720. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26721. res2.Infcode = infocode
  26722. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26723. 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)
  26724. saveLog(result, requestLog, "2203", "上传就诊信息")
  26725. var respJSON2 map[string]interface{}
  26726. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26727. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26729. return
  26730. }
  26731. userJSONBytes2, _ := json.Marshal(respJSON2)
  26732. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26733. utils.ErrorLog("解析失败:%v", err)
  26734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26735. return
  26736. }
  26737. 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)
  26738. fmt.Println(result2)
  26739. fmt.Println(src_request)
  26740. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26741. data := make(map[string]interface{})
  26742. client := &http.Client{}
  26743. data["psn_no"] = his.PsnNo
  26744. data["mdtrt_id"] = his.Number
  26745. data["doctor"] = roles.UserName
  26746. data["department"] = department.Name
  26747. data["org_name"] = miConfig.OrgName
  26748. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26749. data["doctor_id"] = doctor_info.DoctorNumber
  26750. data["new_doctor_name"] = doctor_info.UserName
  26751. data["fixmedins_code"] = miConfig.Code
  26752. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26753. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26754. data["secret_key"] = miConfig.SecretKey
  26755. data["sick_code"] = sickConfig.CountryCode
  26756. data["sick_name"] = sickConfig.ClassName
  26757. data["url"] = miConfig.Url
  26758. data["ak"] = miConfig.AccessKey
  26759. data["begin_time"] = begin_time
  26760. data["cainfo"] = miConfig.Cainfo
  26761. data["dept"] = strconv.FormatInt(department.ID, 10)
  26762. data["config"] = config
  26763. bytesData, _ := json.Marshal(data)
  26764. var req *http.Request
  26765. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  26766. resp, _ := client.Do(req)
  26767. defer resp.Body.Close()
  26768. body, ioErr := ioutil.ReadAll(resp.Body)
  26769. if ioErr != nil {
  26770. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26772. return
  26773. }
  26774. var respJSON map[string]interface{}
  26775. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26776. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26778. return
  26779. }
  26780. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26781. userJSONBytes, _ := json.Marshal(respJSON)
  26782. fmt.Println("log")
  26783. fmt.Println(string(userJSONBytes))
  26784. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26785. utils.ErrorLog("解析失败:%v", err)
  26786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26787. return
  26788. }
  26789. } else {
  26790. if miConfig.MdtrtareaAdmvs == "440781" { //
  26791. 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)
  26792. } else {
  26793. if miConfig.Code == "H15049901371" {
  26794. //赤峰地区国家医保医疗类别
  26795. //职工透析:医疗类别选特殊情况门诊990502
  26796. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26797. var med_type string
  26798. if his.Insutype == "390" {
  26799. if reg_type == 14 {
  26800. med_type = "9933"
  26801. } else if reg_type == 11 {
  26802. med_type = "11"
  26803. }
  26804. } else if his.Insutype == "310" {
  26805. if reg_type == 14 {
  26806. med_type = "990502"
  26807. } else if reg_type == 11 {
  26808. med_type = "11"
  26809. }
  26810. }
  26811. 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)
  26812. } else {
  26813. 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)
  26814. }
  26815. }
  26816. saveLog(result, requestLog, "2203", "上传就诊信息")
  26817. var respJSON2 map[string]interface{}
  26818. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26819. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26821. return
  26822. }
  26823. userJSONBytes2, _ := json.Marshal(respJSON2)
  26824. if miConfig.Code == "H15049901371" {
  26825. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  26826. utils.ErrorLog("解析失败:%v", err)
  26827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26828. return
  26829. }
  26830. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26831. res2.Output = ressix10265.Output
  26832. res2.ErrMsg = ressix10265.ErrMsg
  26833. res2.Cainfo = ressix10265.Cainfo
  26834. res2.WarnMsg = ressix10265.WarnMsg
  26835. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26836. res2.Infcode = infocode
  26837. } else {
  26838. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26839. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  26840. utils.ErrorLog("解析失败:%v", err)
  26841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26842. return
  26843. }
  26844. res2.Infcode = res3.Infcode
  26845. } else {
  26846. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26847. utils.ErrorLog("解析失败:%v", err)
  26848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26849. return
  26850. }
  26851. }
  26852. }
  26853. }
  26854. if res2.Infcode == -1 {
  26855. adminUser := c.GetAdminUserInfo()
  26856. errlog := &models.HisOrderError{
  26857. UserOrgId: adminUser.CurrentOrgId,
  26858. Ctime: time.Now().Unix(),
  26859. Mtime: time.Now().Unix(),
  26860. ErrMsg: res2.ErrMsg,
  26861. Status: 1,
  26862. PatientId: id,
  26863. RecordTime: recordDateTime,
  26864. Stage: 3,
  26865. }
  26866. service.CreateErrMsgLog(errlog)
  26867. c.ServeSuccessJSON(map[string]interface{}{
  26868. "failed_code": -10,
  26869. "msg": res2.ErrMsg,
  26870. })
  26871. return
  26872. } else {
  26873. his.Diagnosis = diagnosis_id
  26874. his.SickType = sickConfig.ID
  26875. //var p_type int64
  26876. //if reg_type == 1111 || reg_type == 1112 {
  26877. // p_type = 11
  26878. //
  26879. //}
  26880. his.PType = fmt.Sprintf("%d", reg_type)
  26881. service.UpdateHisPatientThree(&his)
  26882. data := make(map[string]interface{})
  26883. if settle_accounts_type == 1 { //日结
  26884. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  26885. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  26886. } else {
  26887. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  26888. }
  26889. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  26890. data["pre"] = prescriptions
  26891. } else { //月结
  26892. start_time_str := c.GetString("start_time")
  26893. end_time_str := c.GetString("end_time")
  26894. timeLayout := "2006-01-02"
  26895. loc, _ := time.LoadLocation("Local")
  26896. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  26897. if err != nil {
  26898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26899. return
  26900. }
  26901. recordStartTime := theStartTime.Unix()
  26902. start_time = recordStartTime
  26903. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  26904. if err != nil {
  26905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26906. return
  26907. }
  26908. recordEndTime := theEndTime.Unix()
  26909. end_time = recordEndTime
  26910. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  26911. data["pre"] = prescriptions
  26912. }
  26913. timestamp := time.Now().Unix()
  26914. tempTime := time.Unix(timestamp, 0)
  26915. timeFormat := tempTime.Format("20060102150405")
  26916. chrgBchno := rand.Intn(100000) + 10000
  26917. new_chrg_bchno := ""
  26918. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  26919. new_chrg_bchno = chrg_bchno
  26920. strconv.FormatInt(his.PatientId, 10)
  26921. client := &http.Client{}
  26922. if adminUser.CurrentOrgId == 10265 {
  26923. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  26924. new_chrg_bchno = "0000"
  26925. }
  26926. }
  26927. data["psn_no"] = his.PsnNo
  26928. data["mdtrt_id"] = his.Number
  26929. data["chrg_bchno"] = new_chrg_bchno
  26930. data["org_name"] = miConfig.OrgName
  26931. data["doctor"] = doctor_info.UserName
  26932. data["doctor_id"] = doctor_info.DoctorNumber
  26933. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  26934. data["fixmedins_code"] = miConfig.Code
  26935. data["dept_code"] = department.Number
  26936. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26937. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26938. data["secret_key"] = miConfig.SecretKey
  26939. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  26940. data["url"] = miConfig.Url
  26941. data["ak"] = miConfig.AccessKey
  26942. data["new_doctor_name"] = patientPrescription.Doctor
  26943. data["diag_code"] = sickConfig.CountryCode
  26944. data["cainfo"] = miConfig.Cainfo
  26945. data["opter"] = roles.UserName
  26946. var ids []int64
  26947. for _, item := range prescriptions {
  26948. ids = append(ids, item.ID)
  26949. }
  26950. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26951. if config.IsOpen == 1 { //对接了医保,走医保流程
  26952. var res ResultFour
  26953. var resFour10265 ResultFour10265
  26954. if miConfig.MdtrtareaAdmvs == "421300" {
  26955. bytesData, _ := json.Marshal(data)
  26956. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  26957. resp, _ := client.Do(req)
  26958. defer resp.Body.Close()
  26959. body, ioErr := ioutil.ReadAll(resp.Body)
  26960. if ioErr != nil {
  26961. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26963. return
  26964. }
  26965. var respJSON map[string]interface{}
  26966. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26967. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26969. return
  26970. }
  26971. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26972. userJSONBytes, _ := json.Marshal(respJSON)
  26973. fmt.Println("log")
  26974. fmt.Println(string(userJSONBytes))
  26975. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26976. utils.ErrorLog("解析失败:%v", err)
  26977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26978. return
  26979. }
  26980. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26981. bytesData, _ := json.Marshal(data)
  26982. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  26983. resp, _ := client.Do(req)
  26984. defer resp.Body.Close()
  26985. body, ioErr := ioutil.ReadAll(resp.Body)
  26986. if ioErr != nil {
  26987. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26989. return
  26990. }
  26991. var respJSON map[string]interface{}
  26992. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26993. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26995. return
  26996. }
  26997. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26998. userJSONBytes, _ := json.Marshal(respJSON)
  26999. fmt.Println("log")
  27000. fmt.Println(string(userJSONBytes))
  27001. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27002. utils.ErrorLog("解析失败:%v", err)
  27003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27004. return
  27005. }
  27006. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27007. bytesData, _ := json.Marshal(data)
  27008. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  27009. resp, _ := client.Do(req)
  27010. defer resp.Body.Close()
  27011. body, ioErr := ioutil.ReadAll(resp.Body)
  27012. if ioErr != nil {
  27013. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27015. return
  27016. }
  27017. var respJSON map[string]interface{}
  27018. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27019. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27021. return
  27022. }
  27023. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27024. userJSONBytes, _ := json.Marshal(respJSON)
  27025. fmt.Println("log")
  27026. fmt.Println(string(userJSONBytes))
  27027. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27028. utils.ErrorLog("解析失败:%v", err)
  27029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27030. return
  27031. }
  27032. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27033. bytesData, _ := json.Marshal(data)
  27034. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  27035. resp, _ := client.Do(req)
  27036. defer resp.Body.Close()
  27037. body, ioErr := ioutil.ReadAll(resp.Body)
  27038. if ioErr != nil {
  27039. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27041. return
  27042. }
  27043. var respJSON map[string]interface{}
  27044. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27045. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27047. return
  27048. }
  27049. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27050. userJSONBytes, _ := json.Marshal(respJSON)
  27051. fmt.Println("log")
  27052. fmt.Println(string(userJSONBytes))
  27053. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27054. utils.ErrorLog("解析失败:%v", err)
  27055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27056. return
  27057. }
  27058. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  27059. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  27060. var result3101 Result3101
  27061. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  27062. result3101.Infcode = "0"
  27063. if result3101.Infcode == "0" {
  27064. if len(result3101.Output.Result) > 0 {
  27065. var errMsgs []string
  27066. for _, item := range result3101.Output.Result {
  27067. errMsgs = append(errMsgs, item.VolaCont)
  27068. }
  27069. c.ServeSuccessJSON(map[string]interface{}{
  27070. "failed_code": -10,
  27071. "msg": errMsgs,
  27072. })
  27073. return
  27074. }
  27075. }
  27076. bytesData, _ := json.Marshal(data)
  27077. var req *http.Request
  27078. if miConfig.MdtrtareaAdmvs == "320830" {
  27079. data["diag_code"] = sickConfig.CountryCode
  27080. fmt.Println(data)
  27081. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2204", bytes.NewReader(bytesData))
  27082. } else if miConfig.MdtrtareaAdmvs == "320921" {
  27083. data["diag_code"] = sickConfig.CountryCode
  27084. fmt.Println(data)
  27085. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27086. } else {
  27087. data["diag_code"] = sickConfig.CountryCode
  27088. fmt.Println(data)
  27089. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27090. }
  27091. resp, _ := client.Do(req)
  27092. defer resp.Body.Close()
  27093. body, ioErr := ioutil.ReadAll(resp.Body)
  27094. if ioErr != nil {
  27095. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27097. return
  27098. }
  27099. var respJSON map[string]interface{}
  27100. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27101. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27103. return
  27104. }
  27105. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27106. userJSONBytes, _ := json.Marshal(respJSON)
  27107. fmt.Println("log")
  27108. fmt.Println(string(userJSONBytes))
  27109. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27110. utils.ErrorLog("解析失败:%v", err)
  27111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27112. return
  27113. }
  27114. res.InfRefmsgid = resFour10265.InfRefmsgid
  27115. res.Output = resFour10265.Output
  27116. res.ErrMsg = resFour10265.ErrMsg
  27117. res.Cainfo = resFour10265.Cainfo
  27118. res.WarnMsg = resFour10265.WarnMsg
  27119. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27120. res.Infcode = infocode
  27121. } else if miConfig.MdtrtareaAdmvs == "150404" {
  27122. var pagesize int = 2
  27123. var start int = 1
  27124. var stop int
  27125. var pagecount int
  27126. var curpage int
  27127. var isSuccess bool = true
  27128. data["doctor_id"] = doctor_info.DoctorNumber
  27129. //总页数,向上取整,注意除之前要先转换类型为float64
  27130. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  27131. for curpage = 1; curpage <= pagecount; curpage++ {
  27132. if curpage == 1 {
  27133. start = 1
  27134. } else {
  27135. start = (curpage-1)*pagesize + 1
  27136. }
  27137. stop = curpage * pagesize
  27138. if stop > len(prescriptions) {
  27139. stop = len(prescriptions)
  27140. }
  27141. //var requestLog string
  27142. data["pre"] = prescriptions[start-1 : stop]
  27143. fmt.Println(data["pre"])
  27144. bytesData, _ := json.Marshal(data)
  27145. var req *http.Request
  27146. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  27147. resp, _ := client.Do(req)
  27148. defer resp.Body.Close()
  27149. body, ioErr := ioutil.ReadAll(resp.Body)
  27150. if ioErr != nil {
  27151. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27153. return
  27154. }
  27155. var respJSON map[string]interface{}
  27156. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27157. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27159. return
  27160. }
  27161. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27162. userJSONBytes, _ := json.Marshal(respJSON)
  27163. fmt.Println("log")
  27164. fmt.Println(string(userJSONBytes))
  27165. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27166. utils.ErrorLog("解析失败:%v", err)
  27167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27168. return
  27169. }
  27170. res.InfRefmsgid = resFour10265.InfRefmsgid
  27171. res.Output = resFour10265.Output
  27172. res.ErrMsg = resFour10265.ErrMsg
  27173. res.Cainfo = resFour10265.Cainfo
  27174. res.WarnMsg = resFour10265.WarnMsg
  27175. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27176. res.Infcode = infocode
  27177. if infocode == 0 {
  27178. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  27179. } else {
  27180. isSuccess = false
  27181. errlog := &models.HisOrderError{
  27182. UserOrgId: adminUser.CurrentOrgId,
  27183. Ctime: time.Now().Unix(),
  27184. Mtime: time.Now().Unix(),
  27185. Number: chrg_bchno,
  27186. ErrMsg: "",
  27187. Status: 1,
  27188. PatientId: id,
  27189. RecordTime: recordDateTime,
  27190. Stage: 4,
  27191. }
  27192. service.CreateErrMsgLog(errlog)
  27193. c.ServeSuccessJSON(map[string]interface{}{
  27194. "failed_code": -10,
  27195. "msg": res.ErrMsg,
  27196. })
  27197. return
  27198. }
  27199. }
  27200. if isSuccess {
  27201. res.Infcode = 0
  27202. }
  27203. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27204. 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)
  27205. var dat map[string]interface{}
  27206. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27207. fmt.Println(dat)
  27208. } else {
  27209. fmt.Println(err)
  27210. }
  27211. saveLog(result, request_log, "2204", "上传费用明细")
  27212. userJSONBytes, _ := json.Marshal(dat)
  27213. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27214. utils.ErrorLog("解析失败:%v", err)
  27215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27216. return
  27217. }
  27218. res.InfRefmsgid = resFour10265.InfRefmsgid
  27219. res.Output = resFour10265.Output
  27220. res.ErrMsg = resFour10265.ErrMsg
  27221. res.Cainfo = resFour10265.Cainfo
  27222. res.WarnMsg = resFour10265.WarnMsg
  27223. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27224. res.Infcode = infocode
  27225. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27226. bytesData, _ := json.Marshal(data)
  27227. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  27228. resp, _ := client.Do(req)
  27229. defer resp.Body.Close()
  27230. body, ioErr := ioutil.ReadAll(resp.Body)
  27231. if ioErr != nil {
  27232. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27234. return
  27235. }
  27236. var respJSON map[string]interface{}
  27237. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27238. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27240. return
  27241. }
  27242. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27243. userJSONBytes, _ := json.Marshal(respJSON)
  27244. fmt.Println("log")
  27245. fmt.Println(string(userJSONBytes))
  27246. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27247. utils.ErrorLog("解析失败:%v", err)
  27248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27249. return
  27250. }
  27251. } else {
  27252. if miConfig.Code == "H15049901371" {
  27253. 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)
  27254. var dat map[string]interface{}
  27255. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27256. fmt.Println(dat)
  27257. } else {
  27258. fmt.Println(err)
  27259. }
  27260. saveLog(result, request_log, "2204", "上传费用明细")
  27261. userJSONBytes, _ := json.Marshal(dat)
  27262. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27263. utils.ErrorLog("解析失败:%v", err)
  27264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27265. return
  27266. }
  27267. res.InfRefmsgid = resFour10265.InfRefmsgid
  27268. res.Output = resFour10265.Output
  27269. res.ErrMsg = resFour10265.ErrMsg
  27270. res.Cainfo = resFour10265.Cainfo
  27271. res.WarnMsg = resFour10265.WarnMsg
  27272. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27273. res.Infcode = infocode
  27274. } else {
  27275. 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)
  27276. var dat map[string]interface{}
  27277. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27278. fmt.Println(dat)
  27279. } else {
  27280. fmt.Println(err)
  27281. }
  27282. saveLog(result, request_log, "2204", "上传费用明细")
  27283. userJSONBytes, _ := json.Marshal(dat)
  27284. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27285. utils.ErrorLog("解析失败:%v", err)
  27286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27287. return
  27288. }
  27289. }
  27290. }
  27291. if res.Infcode == 0 {
  27292. order := &models.HisOrder{
  27293. UserOrgId: adminUser.CurrentOrgId,
  27294. HisPatientId: his.ID,
  27295. PatientId: his.PatientId,
  27296. SettleAccountsDate: recordDateTime,
  27297. MdtrtId: his.Number,
  27298. PsnNo: his.PsnNo,
  27299. MedType: strconv.FormatInt(reg_type, 10),
  27300. Ctime: time.Now().Unix(),
  27301. Mtime: time.Now().Unix(),
  27302. Status: 1,
  27303. Number: chrg_bchno,
  27304. Infcode: res.Infcode,
  27305. WarnMsg: res.WarnMsg,
  27306. Cainfo: res.Cainfo,
  27307. ErrMsg: res.ErrMsg,
  27308. RespondTime: res.RefmsgTime,
  27309. InfRefmsgid: res.InfRefmsgid,
  27310. OrderStatus: 1,
  27311. PayWay: pay_way,
  27312. PayWays: pay_ways,
  27313. OthDesc: oth_desc,
  27314. PayPrice: pay_price,
  27315. PayCardNo: pay_card_no,
  27316. DiscountPrice: discount_price,
  27317. PreferentialPrice: preferential_price,
  27318. RealityPrice: reality_price,
  27319. FoundPrice: found_price,
  27320. MedicalInsurancePrice: medical_insurance_price,
  27321. PrivatePrice: private_price,
  27322. IsMedicineInsurance: 1,
  27323. SettleType: settle_accounts_type,
  27324. SettleStartTime: start_time,
  27325. SettleEndTime: end_time,
  27326. Creator: roles.AdminUserId,
  27327. Modify: roles.AdminUserId,
  27328. FaPiaoNumber: fapiao_number,
  27329. FaPiaoCode: fapiao_code,
  27330. PType: 2,
  27331. Diagnosis: diagnosis_id,
  27332. CashPay: cash_pay,
  27333. WechatPay: wechat_pay,
  27334. AliPay: ali_pay,
  27335. JifenPay: jifen_pay,
  27336. BandCardPay: band_card_pay,
  27337. }
  27338. err = service.CreateOrder(order)
  27339. if err != nil {
  27340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  27341. return
  27342. }
  27343. for _, item := range res.Output.Result {
  27344. temp := strings.Split(item.FeedetlSn, "-")
  27345. var advice_id int64 = 0
  27346. var project_id int64 = 0
  27347. var types int64 = 0
  27348. id, _ := strconv.ParseInt(temp[2], 10, 64)
  27349. types, _ = strconv.ParseInt(temp[1], 10, 64)
  27350. if temp[1] == "1" {
  27351. advice_id = id
  27352. project_id = 0
  27353. } else if temp[1] == "2" {
  27354. advice_id = 0
  27355. project_id = id
  27356. }
  27357. if item.MedChrgitmType == "9" {
  27358. item.MedChrgitmType = "09"
  27359. }
  27360. info := &models.HisOrderInfo{
  27361. OrderNumber: order.Number,
  27362. FeedetlSn: item.FeedetlSn,
  27363. UploadDate: time.Now().Unix(),
  27364. AdviceId: advice_id,
  27365. DetItemFeeSumamt: item.DetItemFeeSumamt,
  27366. Cnt: item.Cnt,
  27367. Pric: float64(item.Pric),
  27368. PatientId: his.PatientId,
  27369. PricUplmtAmt: item.PricUplmtAmt,
  27370. SelfpayProp: item.SelfpayProp,
  27371. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  27372. OverlmtAmt: item.OverlmtAmt,
  27373. PreselfpayAmt: item.PreselfpayAmt,
  27374. BasMednFlag: item.BasMednFlag,
  27375. MedChrgitmType: item.MedChrgitmType,
  27376. HiNegoDrugFlag: item.HiNegoDrugFlag,
  27377. Status: 1,
  27378. Memo: item.Memo,
  27379. Mtime: time.Now().Unix(),
  27380. InscpScpAmt: item.InscpScpAmt,
  27381. DrtReimFlag: item.DrtReimFlag,
  27382. Ctime: time.Now().Unix(),
  27383. ListSpItemFlag: item.ListSpItemFlag,
  27384. ChldMedcFlag: item.ChldMedcFlag,
  27385. LmtUsedFlag: item.LmtUsedFlag,
  27386. ChrgitmLv: item.ChrgitmLv,
  27387. UserOrgId: adminUser.CurrentOrgId,
  27388. HisPatientId: his.ID,
  27389. OrderId: order.ID,
  27390. ProjectId: project_id,
  27391. Type: types,
  27392. }
  27393. service.CreateOrderInfo(info)
  27394. }
  27395. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  27396. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  27397. var total float64
  27398. for _, item := range prescriptions {
  27399. if item.Type == 1 { //药品
  27400. for _, subItem := range item.HisDoctorAdviceInfo {
  27401. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  27402. total_one := price * subItem.PrescribingNumber
  27403. total = total + total_one
  27404. }
  27405. }
  27406. if item.Type == 2 { //项目
  27407. for _, subItem := range item.HisPrescriptionProject {
  27408. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  27409. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  27410. total_one := price * cnt
  27411. total = total + total_one
  27412. }
  27413. }
  27414. }
  27415. allTotal := fmt.Sprintf("%.2f", total)
  27416. //if adminUser.CurrentOrgId == 9919 {
  27417. //
  27418. // allTotal = fmt.Sprintf("%.2f", total)
  27419. //
  27420. //} else {
  27421. //
  27422. // allTotal = fmt.Sprintf("%.2f", total)
  27423. //
  27424. //}
  27425. if res.Infcode == 0 {
  27426. var rf []*ResultFive
  27427. json.Unmarshal([]byte(his.Iinfo), &rf)
  27428. chrg_bchno := chrg_bchno
  27429. cert_no := his.Certno
  27430. var insutypes []string
  27431. var insutype string
  27432. var is390 int = 0
  27433. var is310 int = 0
  27434. for _, item := range rf {
  27435. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27436. insutypes = append(insutypes, item.Insutype)
  27437. }
  27438. }
  27439. if len(insutypes) == 1 {
  27440. insutype = insutypes[0]
  27441. } else {
  27442. for _, i := range insutypes {
  27443. if i == "390" {
  27444. is390 = 1
  27445. }
  27446. if i == "310" {
  27447. is310 = 1
  27448. }
  27449. }
  27450. }
  27451. if is390 == 1 {
  27452. insutype = "390"
  27453. }
  27454. if is310 == 1 {
  27455. insutype = "310"
  27456. }
  27457. if len(insutypes) == 0 {
  27458. insutype = "310"
  27459. }
  27460. if len(insutypes) == 2 {
  27461. insutype = strconv.FormatInt(his.SocialType, 10)
  27462. }
  27463. insutype = strconv.FormatInt(his.SocialType, 10)
  27464. //insutype = "390"
  27465. if his.IdCardType == 1 {
  27466. // cert_no = his.MedicalInsuranceNumber
  27467. cert_no = his.Certno
  27468. } else {
  27469. cert_no = his.Certno
  27470. }
  27471. var res ResultSeven
  27472. var resSeven10265 ResultSeven10265
  27473. var gzresSeven10265Two GZResultSeven10265Two
  27474. var src_resquest string
  27475. var result2 string
  27476. if miConfig.MdtrtareaAdmvs == "421300" {
  27477. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27478. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27479. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27480. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27481. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27482. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27483. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27484. resp, requestErr := http.Get(api)
  27485. if requestErr != nil {
  27486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27487. return
  27488. }
  27489. body, ioErr := ioutil.ReadAll(resp.Body)
  27490. if ioErr != nil {
  27491. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27493. return
  27494. }
  27495. var respJSON map[string]interface{}
  27496. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27497. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27499. return
  27500. }
  27501. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27502. result, _ := json.Marshal(respJSON)
  27503. if miConfig.Code == "H15049901371" {
  27504. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27505. utils.ErrorLog("解析失败:%v", err)
  27506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27507. return
  27508. }
  27509. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27510. res.Output = resSeven10265.Output
  27511. res.ErrMsg = resSeven10265.ErrMsg
  27512. res.Cainfo = resSeven10265.Cainfo
  27513. res.WarnMsg = resSeven10265.WarnMsg
  27514. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27515. res.Infcode = infocode
  27516. } else {
  27517. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27518. utils.ErrorLog("解析失败:%v", err)
  27519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27520. return
  27521. }
  27522. }
  27523. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27524. if reg_type == 11 && his.Insutype == "390" {
  27525. reg_type = 110104
  27526. }
  27527. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27528. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27529. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27530. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27531. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27532. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27533. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27534. resp, requestErr := http.Get(api)
  27535. if requestErr != nil {
  27536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27537. return
  27538. }
  27539. body, ioErr := ioutil.ReadAll(resp.Body)
  27540. if ioErr != nil {
  27541. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27543. return
  27544. }
  27545. var respJSON map[string]interface{}
  27546. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27547. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27549. return
  27550. }
  27551. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27552. result, _ := json.Marshal(respJSON)
  27553. if miConfig.Code == "H15049901371" {
  27554. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27555. utils.ErrorLog("解析失败:%v", err)
  27556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27557. return
  27558. }
  27559. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27560. res.Output = resSeven10265.Output
  27561. res.ErrMsg = resSeven10265.ErrMsg
  27562. res.Cainfo = resSeven10265.Cainfo
  27563. res.WarnMsg = resSeven10265.WarnMsg
  27564. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27565. res.Infcode = infocode
  27566. } else {
  27567. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27568. utils.ErrorLog("解析失败:%v", err)
  27569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27570. return
  27571. }
  27572. }
  27573. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27574. if reg_type == 11 && his.Insutype == "390" {
  27575. reg_type = 110104
  27576. }
  27577. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27578. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27579. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27580. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27581. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27582. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27583. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27584. resp, requestErr := http.Get(api)
  27585. if requestErr != nil {
  27586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27587. return
  27588. }
  27589. body, ioErr := ioutil.ReadAll(resp.Body)
  27590. if ioErr != nil {
  27591. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27593. return
  27594. }
  27595. var respJSON map[string]interface{}
  27596. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27597. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27599. return
  27600. }
  27601. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27602. result, _ := json.Marshal(respJSON)
  27603. if miConfig.Code == "H15049901371" {
  27604. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27605. utils.ErrorLog("解析失败:%v", err)
  27606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27607. return
  27608. }
  27609. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27610. res.Output = resSeven10265.Output
  27611. res.ErrMsg = resSeven10265.ErrMsg
  27612. res.Cainfo = resSeven10265.Cainfo
  27613. res.WarnMsg = resSeven10265.WarnMsg
  27614. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27615. res.Infcode = infocode
  27616. } else {
  27617. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27618. utils.ErrorLog("解析失败:%v", err)
  27619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27620. return
  27621. }
  27622. }
  27623. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27624. if reg_type == 11 && his.Insutype == "390" {
  27625. reg_type = 110104
  27626. }
  27627. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27628. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27629. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27630. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27631. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27632. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27633. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27634. resp, requestErr := http.Get(api)
  27635. if requestErr != nil {
  27636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27637. return
  27638. }
  27639. body, ioErr := ioutil.ReadAll(resp.Body)
  27640. if ioErr != nil {
  27641. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27643. return
  27644. }
  27645. var respJSON map[string]interface{}
  27646. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27647. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27649. return
  27650. }
  27651. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27652. result, _ := json.Marshal(respJSON)
  27653. if miConfig.Code == "H15049901371" {
  27654. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27655. utils.ErrorLog("解析失败:%v", err)
  27656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27657. return
  27658. }
  27659. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27660. res.Output = resSeven10265.Output
  27661. res.ErrMsg = resSeven10265.ErrMsg
  27662. res.Cainfo = resSeven10265.Cainfo
  27663. res.WarnMsg = resSeven10265.WarnMsg
  27664. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27665. res.Infcode = infocode
  27666. } else {
  27667. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27668. utils.ErrorLog("解析失败:%v", err)
  27669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27670. return
  27671. }
  27672. }
  27673. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  27674. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  27675. var result3101 Result3101
  27676. //utils.ErrorLog("解析失败:%v", result3101)
  27677. result3101.Infcode = "0"
  27678. if result3101.Infcode == "0" {
  27679. if len(result3101.Output.Result) > 0 {
  27680. var errMsgs []string
  27681. for _, item := range result3101.Output.Result {
  27682. errMsgs = append(errMsgs, item.VolaCont)
  27683. }
  27684. c.ServeSuccessJSON(map[string]interface{}{
  27685. "failed_code": -10,
  27686. "msg": errMsgs,
  27687. })
  27688. return
  27689. } else {
  27690. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27691. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27692. bas := strings.Split(psn_info.CardInfo, "|")
  27693. if his.IdCardType == 1 {
  27694. cert_no = bas[2]
  27695. } else if his.IdCardType == 3 {
  27696. cert_no = his.Certno
  27697. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27698. } else if his.IdCardType == 4 {
  27699. cert_no = his.Certno
  27700. psn_info.VerifyNumber = psn_info.VerifyNumber
  27701. }
  27702. var api string
  27703. if miConfig.MdtrtareaAdmvs == "320830" {
  27704. api = miConfig.AppSecret + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27705. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27706. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27707. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27708. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27709. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27710. "&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
  27711. } else if miConfig.MdtrtareaAdmvs == "320921" {
  27712. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27713. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27714. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27715. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27716. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27717. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27718. "&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
  27719. } else {
  27720. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27721. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27722. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27723. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27724. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27725. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27726. "&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
  27727. }
  27728. resp, requestErr := http.Get(api)
  27729. if requestErr != nil {
  27730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27731. return
  27732. }
  27733. body, ioErr := ioutil.ReadAll(resp.Body)
  27734. if ioErr != nil {
  27735. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27737. return
  27738. }
  27739. var respJSON map[string]interface{}
  27740. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27741. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27743. return
  27744. }
  27745. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27746. result, _ := json.Marshal(respJSON)
  27747. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27748. utils.ErrorLog("解析失败:%v", err)
  27749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27750. return
  27751. }
  27752. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27753. res.Output = resSeven10265.Output
  27754. res.ErrMsg = resSeven10265.ErrMsg
  27755. res.Cainfo = resSeven10265.Cainfo
  27756. res.WarnMsg = resSeven10265.WarnMsg
  27757. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27758. res.Infcode = infocode
  27759. }
  27760. }
  27761. } else if miConfig.MdtrtareaAdmvs == "150404" {
  27762. psn_info, _ := service.GetPsnByPatientId(id)
  27763. var verify_number string
  27764. if psn_info.IdCardType == 4 {
  27765. verify_number = psn_info.VerifyNumber
  27766. } else if psn_info.IdCardType == 1 {
  27767. bas := strings.Split(psn_info.CardInfo, "|")
  27768. cardNumber := bas[2]
  27769. verify_number = cardNumber
  27770. } else {
  27771. psn_info.IdCardType = 2
  27772. verify_number = psn_info.Certno
  27773. }
  27774. var api string
  27775. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27776. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27777. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27778. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27779. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27780. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27781. "&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
  27782. resp, requestErr := http.Get(api)
  27783. if requestErr != nil {
  27784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27785. return
  27786. }
  27787. body, ioErr := ioutil.ReadAll(resp.Body)
  27788. if ioErr != nil {
  27789. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27791. return
  27792. }
  27793. var respJSON map[string]interface{}
  27794. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27795. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27797. return
  27798. }
  27799. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27800. result, _ := json.Marshal(respJSON)
  27801. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27802. utils.ErrorLog("解析失败:%v", err)
  27803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27804. return
  27805. }
  27806. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27807. res.Output = resSeven10265.Output
  27808. res.ErrMsg = resSeven10265.ErrMsg
  27809. res.Cainfo = resSeven10265.Cainfo
  27810. res.WarnMsg = resSeven10265.WarnMsg
  27811. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27812. res.Infcode = infocode
  27813. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27814. var cert_no string
  27815. if his.IdCardType == 4 {
  27816. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27817. cert_no = psn_info.VerifyNumber
  27818. 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)
  27819. } else if his.IdCardType == 1 {
  27820. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27821. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27822. 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)
  27823. }
  27824. //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)
  27825. var dat map[string]interface{}
  27826. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27827. fmt.Println(dat)
  27828. } else {
  27829. fmt.Println(err)
  27830. }
  27831. saveLog(result2, src_resquest, "2207", "结算")
  27832. userJSONBytes, _ := json.Marshal(dat)
  27833. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27834. utils.ErrorLog("解析失败:%v", err)
  27835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27836. return
  27837. }
  27838. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27839. res.Output = resSeven10265.Output
  27840. res.ErrMsg = resSeven10265.ErrMsg
  27841. res.Cainfo = resSeven10265.Cainfo
  27842. res.WarnMsg = resSeven10265.WarnMsg
  27843. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27844. res.Infcode = infocode
  27845. } else if miConfig.MdtrtareaAdmvs == "450721" {
  27846. res2 := c.GetoleInfo()
  27847. if res2.Infcode == 0 {
  27848. var result string
  27849. var request_log string
  27850. var result_log string
  27851. if res2.Output.MdtrtCertType == "02" {
  27852. 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)
  27853. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27854. } else if res2.Output.MdtrtCertType == "01" {
  27855. 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)
  27856. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27857. } else {
  27858. 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)
  27859. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27860. }
  27861. var dat map[string]interface{}
  27862. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27863. fmt.Println(dat)
  27864. } else {
  27865. fmt.Println(err)
  27866. }
  27867. userJSONBytes, _ := json.Marshal(dat)
  27868. var res5 ResultTwo
  27869. //var resTwo10265 ResultTwo10265
  27870. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  27871. utils.ErrorLog("解析失败:%v", err)
  27872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27873. return
  27874. }
  27875. if res5.Infcode == -1 {
  27876. c.ServeSuccessJSON(map[string]interface{}{
  27877. "failed_code": -10,
  27878. "msg": res5.ErrMsg,
  27879. })
  27880. return
  27881. }
  27882. var insutypes []string
  27883. var insutype string
  27884. var is390 int = 0
  27885. var is310 int = 0
  27886. for _, item := range res5.Output.Iinfo {
  27887. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27888. insutypes = append(insutypes, item.Insutype)
  27889. }
  27890. }
  27891. if len(insutypes) == 1 {
  27892. insutype = insutypes[0]
  27893. } else {
  27894. for _, i := range insutypes {
  27895. if i == "390" {
  27896. is390 = 1
  27897. }
  27898. if i == "310" {
  27899. is310 = 1
  27900. }
  27901. }
  27902. }
  27903. if is390 == 1 {
  27904. insutype = "390"
  27905. }
  27906. if is310 == 1 {
  27907. insutype = "310"
  27908. }
  27909. if len(insutypes) == 0 {
  27910. insutype = "310"
  27911. }
  27912. fmt.Println(insutype)
  27913. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  27914. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  27915. infoStr := string(Iinfos)
  27916. idetinfoStr := string(Idetinfos)
  27917. psn := &models.HisPsn{
  27918. PsnNo: res5.Output.Baseinfo.PsnNo,
  27919. PatientId: id,
  27920. Certno: res5.Output.Baseinfo.Certno,
  27921. Gend: res5.Output.Baseinfo.Gend,
  27922. Naty: res5.Output.Baseinfo.Naty,
  27923. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  27924. PsnName: res5.Output.Baseinfo.PsnName,
  27925. Idetinfo: idetinfoStr,
  27926. Insuinfo: infoStr,
  27927. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  27928. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  27929. VerifyNumber: res2.Output.EcToken,
  27930. }
  27931. if res2.Output.MdtrtCertType == "01" {
  27932. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27933. psn.VerifyNumber = res2.Output.EcToken
  27934. } else if res2.Output.MdtrtCertType == "02" {
  27935. psn.VerifyNumber = res2.Output.CardNo
  27936. } else {
  27937. psn.VerifyNumber = res2.Output.MdtrtCertNo
  27938. }
  27939. service.CreateHisPsn(psn)
  27940. if res2.Output.MdtrtCertType == "01" {
  27941. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27942. token := res2.Output.EcToken
  27943. 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)
  27944. } else if res2.Output.MdtrtCertType == "02" {
  27945. 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)
  27946. } else {
  27947. 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)
  27948. }
  27949. var dat2 map[string]interface{}
  27950. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  27951. fmt.Println(dat2)
  27952. } else {
  27953. fmt.Println(err)
  27954. }
  27955. userJSONBytes3, _ := json.Marshal(dat2)
  27956. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  27957. utils.ErrorLog("解析失败:%v", err)
  27958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27959. return
  27960. }
  27961. saveLog(result2, src_resquest, "2207", "结算")
  27962. } else {
  27963. c.ServeSuccessJSON(map[string]interface{}{
  27964. "failed_code": -10,
  27965. "msg": res2.ErrMsg,
  27966. })
  27967. return
  27968. }
  27969. } else {
  27970. if miConfig.Code == "H15049901371" {
  27971. //赤峰地区国家医保医疗类别
  27972. //职工透析:医疗类别选特殊情况门诊990502
  27973. //居民定额血透门慢: 医疗类别选门诊慢病140104
  27974. var med_type string
  27975. if his.Insutype == "390" {
  27976. if reg_type == 14 {
  27977. med_type = "9933"
  27978. } else if reg_type == 11 {
  27979. med_type = "11"
  27980. }
  27981. } else if his.Insutype == "310" {
  27982. if reg_type == 14 {
  27983. med_type = "990502"
  27984. } else if reg_type == 11 {
  27985. med_type = "11"
  27986. }
  27987. }
  27988. 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)
  27989. } else {
  27990. if his.IdCardType == 4 {
  27991. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27992. var token string
  27993. token = psn_info.VerifyNumber
  27994. 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)
  27995. } else {
  27996. if his.IdCardType == 1 {
  27997. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27998. bas := strings.Split(psn_info.CardInfo, "|")
  27999. basNumber := bas[2]
  28000. cert_no = basNumber
  28001. }
  28002. 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)
  28003. }
  28004. }
  28005. //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)
  28006. var dat map[string]interface{}
  28007. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28008. fmt.Println(dat)
  28009. } else {
  28010. fmt.Println(err)
  28011. }
  28012. saveLog(result2, src_resquest, "2207", "结算")
  28013. userJSONBytes, _ := json.Marshal(dat)
  28014. if miConfig.Code == "H15049901371" {
  28015. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  28016. utils.ErrorLog("解析失败:%v", err)
  28017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28018. return
  28019. }
  28020. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28021. res.Output = resSeven10265.Output
  28022. res.ErrMsg = resSeven10265.ErrMsg
  28023. res.Cainfo = resSeven10265.Cainfo
  28024. res.WarnMsg = resSeven10265.WarnMsg
  28025. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28026. res.Infcode = infocode
  28027. } else {
  28028. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  28029. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  28030. utils.ErrorLog("解析失败:%v", err)
  28031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28032. return
  28033. }
  28034. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  28035. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  28036. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  28037. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  28038. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  28039. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  28040. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  28041. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28042. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  28043. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28044. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28045. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28046. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28047. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  28048. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  28049. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  28050. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  28051. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  28052. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  28053. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  28054. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28055. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  28056. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  28057. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  28058. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  28059. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  28060. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  28061. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  28062. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  28063. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  28064. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  28065. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  28066. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  28067. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  28068. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  28069. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  28070. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  28071. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  28072. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  28073. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  28074. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  28075. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  28076. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  28077. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  28078. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  28079. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  28080. res.ErrMsg = gzresSeven10265Two.ErrMsg
  28081. res.Cainfo = gzresSeven10265Two.Cainfo
  28082. res.WarnMsg = gzresSeven10265Two.WarnMsg
  28083. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  28084. //res.Infcode = infocode
  28085. } else {
  28086. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28087. utils.ErrorLog("解析失败:%v", err)
  28088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28089. return
  28090. }
  28091. }
  28092. }
  28093. }
  28094. if res.Infcode == -1 {
  28095. errlog := &models.HisOrderError{
  28096. UserOrgId: adminUser.CurrentOrgId,
  28097. Ctime: time.Now().Unix(),
  28098. Mtime: time.Now().Unix(),
  28099. Number: chrg_bchno,
  28100. ErrMsg: res.ErrMsg,
  28101. Status: 1,
  28102. PatientId: id,
  28103. RecordTime: recordDateTime,
  28104. Stage: 6,
  28105. }
  28106. service.CreateErrMsgLog(errlog)
  28107. c.ServeSuccessJSON(map[string]interface{}{
  28108. "failed_code": -10,
  28109. "msg": res.ErrMsg,
  28110. })
  28111. return
  28112. } else {
  28113. sickConfig, _ := service.FindSickById(his.SickType)
  28114. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  28115. order.OrderStatus = 2
  28116. order.Status = 1
  28117. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  28118. order.SetlId = res.Output.Setlinfo.SetlID
  28119. order.PsnNo = res.Output.Setlinfo.PsnNo
  28120. order.PsnName = res.Output.Setlinfo.PsnName
  28121. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  28122. order.Certno = res.Output.Setlinfo.Certno
  28123. order.Gend = res.Output.Setlinfo.Gend
  28124. order.Naty = res.Output.Setlinfo.Naty
  28125. order.Age = res.Output.Setlinfo.Age
  28126. order.Insutype = res.Output.Setlinfo.Insutype
  28127. order.PsnType = res.Output.Setlinfo.PsnType
  28128. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  28129. order.SetlTime = res.Output.Setlinfo.SetlTime
  28130. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  28131. if res.Output.Setlinfo.MedType == "140101" {
  28132. order.MedType = "14"
  28133. } else {
  28134. if res.Output.Setlinfo.MedType == "110104" {
  28135. order.MedType = "11"
  28136. } else {
  28137. order.MedType = res.Output.Setlinfo.MedType
  28138. }
  28139. }
  28140. if reg_type == 1112 {
  28141. order.MedType = "1112"
  28142. }
  28143. if reg_type == 1111 {
  28144. order.MedType = "1111"
  28145. }
  28146. order.ClrType = res.Output.Setlinfo.ClrType
  28147. if adminUser.CurrentOrgId == 10480 {
  28148. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  28149. order.ClrType = "11"
  28150. } else {
  28151. order.ClrType = "9903"
  28152. }
  28153. }
  28154. if adminUser.CurrentOrgId == 10721 {
  28155. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  28156. order.ClrType = "11"
  28157. } else {
  28158. order.ClrType = "9903"
  28159. }
  28160. }
  28161. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  28162. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  28163. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  28164. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  28165. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  28166. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  28167. order.HifpPay = res.Output.Setlinfo.HifpPay
  28168. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  28169. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  28170. order.HifesPay = res.Output.Setlinfo.HifesPay
  28171. order.HifobPay = res.Output.Setlinfo.HifobPay
  28172. order.MafPay = res.Output.Setlinfo.MafPay
  28173. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  28174. order.OthPay = res.Output.Setlinfo.OthPay
  28175. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  28176. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  28177. order.AcctPay = res.Output.Setlinfo.AcctPay
  28178. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  28179. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  28180. order.Balc = res.Output.Setlinfo.Balc
  28181. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  28182. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  28183. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  28184. //order.ClrType = res.Output.Setlinfo.ClrType
  28185. order.ClrWay = res.Output.Setlinfo.ClrWay
  28186. order.Creator = order.Creator
  28187. order.Modify = roles.AdminUserId
  28188. order.RequestLog = src_resquest
  28189. order.FaPiaoNumber = fapiao_number
  28190. order.FaPiaoCode = fapiao_code
  28191. order.SickName = sickConfig.ClassName
  28192. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  28193. //detailStr := string(setlDetail)
  28194. //order.SetlDetail = detailStr
  28195. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  28196. err = service.UpDateOrder(order)
  28197. if err == nil {
  28198. //判断是否使用了押金
  28199. if dec_way == "true" {
  28200. tmpstring := strconv.FormatInt(order.ID, 10)
  28201. order.Decimal = decimal
  28202. service.UpDateOrder(order)
  28203. //扣押金
  28204. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  28205. if errmsg != nil {
  28206. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  28207. return
  28208. }
  28209. }
  28210. c.ServeSuccessJSON(map[string]interface{}{
  28211. "msg": "结算成功",
  28212. })
  28213. } else {
  28214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  28215. return
  28216. }
  28217. }
  28218. } else {
  28219. adminUser := c.GetAdminUserInfo()
  28220. errlog := &models.HisOrderError{
  28221. UserOrgId: adminUser.CurrentOrgId,
  28222. Ctime: time.Now().Unix(),
  28223. Mtime: time.Now().Unix(),
  28224. ErrMsg: res.ErrMsg,
  28225. Status: 1,
  28226. PatientId: id,
  28227. RecordTime: recordDateTime,
  28228. Stage: 4,
  28229. }
  28230. service.CreateErrMsgLog(errlog)
  28231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  28232. return
  28233. }
  28234. } else {
  28235. adminUser := c.GetAdminUserInfo()
  28236. errlog := &models.HisOrderError{
  28237. UserOrgId: adminUser.CurrentOrgId,
  28238. Ctime: time.Now().Unix(),
  28239. Mtime: time.Now().Unix(),
  28240. ErrMsg: res.ErrMsg,
  28241. Status: 1,
  28242. PatientId: id,
  28243. RecordTime: recordDateTime,
  28244. Stage: 4,
  28245. }
  28246. service.CreateErrMsgLog(errlog)
  28247. c.ServeSuccessJSON(map[string]interface{}{
  28248. "failed_code": -10,
  28249. "msg": res.ErrMsg,
  28250. })
  28251. return
  28252. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  28253. //return
  28254. }
  28255. }
  28256. }
  28257. } else if tempOrder.ID > 0 {
  28258. if tempOrder.IsPre == 1 {
  28259. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  28260. var rf []*ResultFive
  28261. json.Unmarshal([]byte(his.Iinfo), &rf)
  28262. chrg_bchno := tempOrder.Number
  28263. cert_no := his.Certno
  28264. var insutypes []string
  28265. var insutype string
  28266. var is390 int = 0
  28267. var is310 int = 0
  28268. for _, item := range rf {
  28269. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28270. insutypes = append(insutypes, item.Insutype)
  28271. }
  28272. }
  28273. if len(insutypes) == 1 {
  28274. insutype = insutypes[0]
  28275. } else {
  28276. for _, i := range insutypes {
  28277. if i == "390" {
  28278. is390 = 1
  28279. }
  28280. if i == "310" {
  28281. is310 = 1
  28282. }
  28283. }
  28284. }
  28285. if is390 == 1 {
  28286. insutype = "390"
  28287. }
  28288. if is310 == 1 {
  28289. insutype = "310"
  28290. }
  28291. if len(insutypes) == 0 {
  28292. insutype = "310"
  28293. }
  28294. if len(insutypes) == 2 {
  28295. insutype = strconv.FormatInt(his.SocialType, 10)
  28296. }
  28297. //insutype = "390"
  28298. if his.IdCardType == 1 {
  28299. // cert_no = his.MedicalInsuranceNumber
  28300. cert_no = his.Certno
  28301. } else {
  28302. cert_no = his.Certno
  28303. }
  28304. var res ResultSeven
  28305. var ahres ResultSevenAH
  28306. var resSeven10265 ResultSeven10265
  28307. var gzresSeven10265Two GZResultSeven10265Two
  28308. var src_resquest string
  28309. var result2 string
  28310. if miConfig.MdtrtareaAdmvs == "450721" {
  28311. res2 := c.GetoleInfo()
  28312. if res2.Infcode == 0 {
  28313. var result string
  28314. var request_log string
  28315. var result_log string
  28316. if res2.Output.MdtrtCertType == "02" {
  28317. 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)
  28318. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  28319. } else if res2.Output.MdtrtCertType == "01" {
  28320. 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)
  28321. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  28322. } else {
  28323. 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)
  28324. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  28325. }
  28326. var dat map[string]interface{}
  28327. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28328. fmt.Println(dat)
  28329. } else {
  28330. fmt.Println(err)
  28331. }
  28332. userJSONBytes, _ := json.Marshal(dat)
  28333. var res5 ResultTwo
  28334. //var resTwo10265 ResultTwo10265
  28335. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  28336. utils.ErrorLog("解析失败:%v", err)
  28337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28338. return
  28339. }
  28340. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  28341. if res5.Infcode == -1 {
  28342. c.ServeSuccessJSON(map[string]interface{}{
  28343. "failed_code": -10,
  28344. "msg": res5.ErrMsg,
  28345. })
  28346. return
  28347. }
  28348. var insutypes []string
  28349. var insutype string
  28350. var is390 int = 0
  28351. var is310 int = 0
  28352. for _, item := range res5.Output.Iinfo {
  28353. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28354. insutypes = append(insutypes, item.Insutype)
  28355. }
  28356. }
  28357. if len(insutypes) == 1 {
  28358. insutype = insutypes[0]
  28359. } else {
  28360. for _, i := range insutypes {
  28361. if i == "390" {
  28362. is390 = 1
  28363. }
  28364. if i == "310" {
  28365. is310 = 1
  28366. }
  28367. }
  28368. }
  28369. if is390 == 1 {
  28370. insutype = "390"
  28371. }
  28372. if is310 == 1 {
  28373. insutype = "310"
  28374. }
  28375. if len(insutypes) == 0 {
  28376. insutype = "310"
  28377. }
  28378. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  28379. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  28380. infoStr := string(Iinfos)
  28381. idetinfoStr := string(Idetinfos)
  28382. psn := &models.HisPsn{
  28383. PsnNo: res5.Output.Baseinfo.PsnNo,
  28384. PatientId: id,
  28385. Certno: res5.Output.Baseinfo.Certno,
  28386. Gend: res5.Output.Baseinfo.Gend,
  28387. Naty: res5.Output.Baseinfo.Naty,
  28388. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  28389. PsnName: res5.Output.Baseinfo.PsnName,
  28390. Idetinfo: idetinfoStr,
  28391. Insuinfo: infoStr,
  28392. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  28393. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  28394. VerifyNumber: res2.Output.EcToken,
  28395. }
  28396. service.CreateHisPsn(psn)
  28397. if res2.Output.MdtrtCertType == "01" {
  28398. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28399. token := res2.Output.EcToken
  28400. 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)
  28401. } else if res2.Output.MdtrtCertType == "02" {
  28402. 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)
  28403. } else {
  28404. 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)
  28405. }
  28406. var dat2 map[string]interface{}
  28407. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28408. fmt.Println(dat2)
  28409. } else {
  28410. fmt.Println(err)
  28411. }
  28412. userJSONBytes3, _ := json.Marshal(dat2)
  28413. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28414. utils.ErrorLog("解析失败:%v", err)
  28415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28416. return
  28417. }
  28418. saveLog(result2, src_resquest, "2207", "结算")
  28419. } else {
  28420. c.ServeSuccessJSON(map[string]interface{}{
  28421. "failed_code": -10,
  28422. "msg": res2.ErrMsg,
  28423. })
  28424. return
  28425. }
  28426. } else if miConfig.MdtrtareaAdmvs == "421300" {
  28427. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28428. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28429. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28430. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28431. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28432. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28433. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28434. resp, requestErr := http.Get(api)
  28435. if requestErr != nil {
  28436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28437. return
  28438. }
  28439. body, ioErr := ioutil.ReadAll(resp.Body)
  28440. if ioErr != nil {
  28441. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28443. return
  28444. }
  28445. var respJSON map[string]interface{}
  28446. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28447. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28449. return
  28450. }
  28451. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28452. result, _ := json.Marshal(respJSON)
  28453. fmt.Println("log")
  28454. fmt.Println(string(result))
  28455. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28456. utils.ErrorLog("解析失败:%v", err)
  28457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28458. return
  28459. }
  28460. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28461. if reg_type == 11 && his.Insutype == "390" {
  28462. reg_type = 110104
  28463. }
  28464. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28465. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28466. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28467. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28468. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28469. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28470. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28471. resp, requestErr := http.Get(api)
  28472. if requestErr != nil {
  28473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28474. return
  28475. }
  28476. body, ioErr := ioutil.ReadAll(resp.Body)
  28477. if ioErr != nil {
  28478. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28480. return
  28481. }
  28482. var respJSON map[string]interface{}
  28483. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28484. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28486. return
  28487. }
  28488. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28489. result, _ := json.Marshal(respJSON)
  28490. fmt.Println("log")
  28491. fmt.Println(string(result))
  28492. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28493. utils.ErrorLog("解析失败:%v", err)
  28494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28495. return
  28496. }
  28497. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28498. if reg_type == 11 && his.Insutype == "390" {
  28499. reg_type = 110104
  28500. }
  28501. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28502. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28503. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28504. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28505. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28506. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28507. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28508. resp, requestErr := http.Get(api)
  28509. if requestErr != nil {
  28510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28511. return
  28512. }
  28513. body, ioErr := ioutil.ReadAll(resp.Body)
  28514. if ioErr != nil {
  28515. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28517. return
  28518. }
  28519. var respJSON map[string]interface{}
  28520. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28521. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28523. return
  28524. }
  28525. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28526. result, _ := json.Marshal(respJSON)
  28527. fmt.Println("log")
  28528. fmt.Println(string(result))
  28529. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28530. utils.ErrorLog("解析失败:%v", err)
  28531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28532. return
  28533. }
  28534. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28535. if reg_type == 11 && his.Insutype == "390" {
  28536. reg_type = 110104
  28537. }
  28538. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28539. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28540. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28541. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28542. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28543. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28544. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28545. resp, requestErr := http.Get(api)
  28546. if requestErr != nil {
  28547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28548. return
  28549. }
  28550. body, ioErr := ioutil.ReadAll(resp.Body)
  28551. if ioErr != nil {
  28552. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28554. return
  28555. }
  28556. var respJSON map[string]interface{}
  28557. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28558. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28560. return
  28561. }
  28562. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28563. result, _ := json.Marshal(respJSON)
  28564. fmt.Println("log")
  28565. fmt.Println(string(result))
  28566. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28567. utils.ErrorLog("解析失败:%v", err)
  28568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28569. return
  28570. }
  28571. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  28572. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  28573. var result3101 Result3101
  28574. //utils.ErrorLog("解析失败:%v", result3101)
  28575. result3101.Infcode = "0"
  28576. if result3101.Infcode == "0" {
  28577. if len(result3101.Output.Result) > 0 {
  28578. var errMsgs []string
  28579. for _, item := range result3101.Output.Result {
  28580. errMsgs = append(errMsgs, item.VolaCont)
  28581. }
  28582. c.ServeSuccessJSON(map[string]interface{}{
  28583. "failed_code": -10,
  28584. "msg": errMsgs,
  28585. })
  28586. return
  28587. } else {
  28588. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28589. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28590. bas := strings.Split(psn_info.CardInfo, "|")
  28591. if his.IdCardType == 1 {
  28592. cert_no = bas[2]
  28593. } else if his.IdCardType == 3 {
  28594. cert_no = his.Certno
  28595. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  28596. } else if his.IdCardType == 4 {
  28597. cert_no = his.Certno
  28598. psn_info.VerifyNumber = psn_info.VerifyNumber
  28599. }
  28600. //江苏地区国家医保医疗类别
  28601. //职工透析:医疗类别选特殊情况门诊9933
  28602. //居民血透门慢: 医疗类别选门诊慢病1402
  28603. //var med_type string
  28604. //if his.Insutype == "310" {
  28605. // if reg_type == 14 {
  28606. // med_type = "9933"
  28607. // } else if reg_type == 11 {
  28608. // med_type = "11"
  28609. //
  28610. // }
  28611. //} else if his.Insutype == "390" {
  28612. // if reg_type == 14 {
  28613. // med_type = "1402"
  28614. // } else if reg_type == 11 {
  28615. // med_type = "11"
  28616. // }
  28617. //}
  28618. var api string
  28619. if miConfig.MdtrtareaAdmvs == "320830" {
  28620. api = miConfig.AppSecret + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28621. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28622. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28623. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28624. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28625. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28626. "&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
  28627. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28628. } else if miConfig.MdtrtareaAdmvs == "320921" {
  28629. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28630. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28631. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28632. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28633. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28634. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28635. "&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
  28636. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28637. } else {
  28638. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28639. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28640. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28641. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28642. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28643. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28644. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28645. "&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
  28646. }
  28647. resp, requestErr := http.Get(api)
  28648. if requestErr != nil {
  28649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28650. return
  28651. }
  28652. body, ioErr := ioutil.ReadAll(resp.Body)
  28653. if ioErr != nil {
  28654. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28656. return
  28657. }
  28658. var respJSON map[string]interface{}
  28659. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28660. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28662. return
  28663. }
  28664. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28665. result, _ := json.Marshal(respJSON)
  28666. fmt.Println("log")
  28667. fmt.Println(string(result))
  28668. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  28669. utils.ErrorLog("解析失败:%v", err)
  28670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28671. return
  28672. }
  28673. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28674. res.Output = resSeven10265.Output
  28675. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28676. res.ErrMsg = resSeven10265.ErrMsg
  28677. res.Cainfo = resSeven10265.Cainfo
  28678. res.WarnMsg = resSeven10265.WarnMsg
  28679. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28680. res.Infcode = infocode
  28681. }
  28682. }
  28683. } else if miConfig.MdtrtareaAdmvs == "150404" {
  28684. psn_info, _ := service.GetPsnByPatientId(id)
  28685. var verify_number string
  28686. if psn_info.IdCardType == 4 {
  28687. verify_number = psn_info.VerifyNumber
  28688. } else if psn_info.IdCardType == 1 {
  28689. bas := strings.Split(psn_info.CardInfo, "|")
  28690. cardNumber := bas[2]
  28691. verify_number = cardNumber
  28692. } else {
  28693. verify_number = psn_info.Certno
  28694. psn_info.IdCardType = 2
  28695. }
  28696. var api string
  28697. new_chrg_bchno := chrg_bchno
  28698. if adminUser.CurrentOrgId == 10265 {
  28699. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  28700. new_chrg_bchno = "0000"
  28701. }
  28702. }
  28703. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28704. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  28705. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28706. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28707. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  28708. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28709. "&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
  28710. resp, requestErr := http.Get(api)
  28711. if requestErr != nil {
  28712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28713. return
  28714. }
  28715. body, ioErr := ioutil.ReadAll(resp.Body)
  28716. if ioErr != nil {
  28717. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28719. return
  28720. }
  28721. var respJSON map[string]interface{}
  28722. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28723. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28725. return
  28726. }
  28727. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28728. result, _ := json.Marshal(respJSON)
  28729. fmt.Println("log")
  28730. fmt.Println(string(result))
  28731. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  28732. utils.ErrorLog("解析失败:%v", err)
  28733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28734. return
  28735. }
  28736. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28737. res.Output = resSeven10265.Output
  28738. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28739. res.ErrMsg = resSeven10265.ErrMsg
  28740. res.Cainfo = resSeven10265.Cainfo
  28741. res.WarnMsg = resSeven10265.WarnMsg
  28742. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28743. res.Infcode = infocode
  28744. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28745. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28746. var cert_no string
  28747. if his.IdCardType == 1 {
  28748. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28749. } else {
  28750. cert_no = psn_info.VerifyNumber
  28751. }
  28752. 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)
  28753. var dat map[string]interface{}
  28754. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28755. fmt.Println(dat)
  28756. } else {
  28757. fmt.Println(err)
  28758. }
  28759. saveLog(result2, src_resquest, "2207", "结算")
  28760. userJSONBytes, _ := json.Marshal(dat)
  28761. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28762. utils.ErrorLog("解析失败:%v", err)
  28763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28764. return
  28765. }
  28766. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28767. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28768. var cert_no string
  28769. var card_sn string
  28770. if his.IdCardType == 1 {
  28771. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28772. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28773. bas := strings.Split(psn_info.CardInfo, "|")
  28774. card_sn = bas[3]
  28775. } else if his.IdCardType == 2 {
  28776. cert_no = his.IdCardNo
  28777. } else {
  28778. cert_no = psn_info.VerifyNumber
  28779. }
  28780. var rf []*ResultFive
  28781. json.Unmarshal([]byte(his.Iinfo), &rf)
  28782. var psn_type string
  28783. for _, item := range rf {
  28784. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28785. psn_type = item.PsnType
  28786. }
  28787. }
  28788. 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)
  28789. var dat map[string]interface{}
  28790. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28791. fmt.Println(dat)
  28792. } else {
  28793. fmt.Println(err)
  28794. }
  28795. saveLog(result2, src_resquest, "2207", "结算")
  28796. userJSONBytes, _ := json.Marshal(dat)
  28797. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28798. utils.ErrorLog("解析失败:%v", err)
  28799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28800. return
  28801. }
  28802. } else if miConfig.MdtrtareaAdmvs == "361025" {
  28803. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28804. var cert_no string
  28805. var card_sn string
  28806. if his.IdCardType == 1 {
  28807. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28808. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28809. //bas := strings.Split(psn_info.CardInfo, "|")
  28810. card_sn = ""
  28811. } else if his.IdCardType == 2 {
  28812. cert_no = his.IdCardNo
  28813. } else {
  28814. cert_no = psn_info.VerifyNumber
  28815. }
  28816. var rf []*ResultFive
  28817. json.Unmarshal([]byte(his.Iinfo), &rf)
  28818. var psn_type string
  28819. for _, item := range rf {
  28820. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28821. psn_type = item.PsnType
  28822. }
  28823. }
  28824. 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)
  28825. var dat map[string]interface{}
  28826. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28827. fmt.Println(dat)
  28828. } else {
  28829. fmt.Println(err)
  28830. }
  28831. saveLog(result2, src_resquest, "2207", "结算")
  28832. userJSONBytes, _ := json.Marshal(dat)
  28833. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28834. utils.ErrorLog("解析失败:%v", err)
  28835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28836. return
  28837. }
  28838. } else if miConfig.MdtrtareaAdmvs == "360100" {
  28839. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28840. var cert_no string
  28841. var card_sn string
  28842. if his.IdCardType == 1 {
  28843. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28844. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28845. //bas := strings.Split(psn_info.CardInfo, "|")
  28846. card_sn = ""
  28847. } else if his.IdCardType == 2 {
  28848. cert_no = his.IdCardNo
  28849. } else {
  28850. cert_no = psn_info.VerifyNumber
  28851. }
  28852. var rf []*ResultFive
  28853. json.Unmarshal([]byte(his.Iinfo), &rf)
  28854. var psn_type string
  28855. for _, item := range rf {
  28856. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28857. psn_type = item.PsnType
  28858. }
  28859. }
  28860. 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)
  28861. var dat map[string]interface{}
  28862. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28863. fmt.Println(dat)
  28864. } else {
  28865. fmt.Println(err)
  28866. }
  28867. saveLog(result2, src_resquest, "2207", "结算")
  28868. userJSONBytes, _ := json.Marshal(dat)
  28869. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28870. utils.ErrorLog("解析失败:%v", err)
  28871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28872. return
  28873. }
  28874. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28875. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28876. if his.IdCardType == 1 {
  28877. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28878. bas := strings.Split(psn_info.CardInfo, "|")
  28879. cert_no = bas[2]
  28880. } else if his.IdCardType == 3 {
  28881. cert_no = his.Certno
  28882. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  28883. } else if his.IdCardType == 4 {
  28884. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28885. cert_no = psn_info.VerifyNumber
  28886. psn_info.VerifyNumber = psn_info.VerifyNumber
  28887. } else {
  28888. cert_no = his.Certno
  28889. psn_info.VerifyNumber = his.Certno
  28890. }
  28891. var api string
  28892. var med_type string
  28893. if his.Insutype == "390" {
  28894. if reg_type == 992102 {
  28895. med_type = "992102"
  28896. }
  28897. if reg_type == 1104 {
  28898. med_type = "1104"
  28899. }
  28900. if reg_type == 1104 {
  28901. med_type = "1104"
  28902. }
  28903. if reg_type == 140104 {
  28904. med_type = "140104"
  28905. }
  28906. if reg_type == 140201 {
  28907. med_type = "140201"
  28908. }
  28909. if reg_type == 14 {
  28910. med_type = "14"
  28911. }
  28912. } else if his.Insutype == "310" {
  28913. if reg_type == 1104 {
  28914. med_type = "1104"
  28915. }
  28916. if reg_type == 992102 {
  28917. med_type = "992102"
  28918. }
  28919. if reg_type == 140104 {
  28920. med_type = "140104"
  28921. }
  28922. if reg_type == 140201 {
  28923. med_type = "140201"
  28924. }
  28925. if reg_type == 14 {
  28926. med_type = "14"
  28927. }
  28928. }
  28929. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28930. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28931. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28932. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28933. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28934. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28935. "&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
  28936. resp, requestErr := http.Get(api)
  28937. if requestErr != nil {
  28938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28939. return
  28940. }
  28941. body, ioErr := ioutil.ReadAll(resp.Body)
  28942. if ioErr != nil {
  28943. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28945. return
  28946. }
  28947. var respJSON map[string]interface{}
  28948. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28949. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28951. return
  28952. }
  28953. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28954. if status == "0" {
  28955. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28956. c.ServeSuccessJSON(map[string]interface{}{
  28957. "failed_code": -10,
  28958. "msg": err_msg,
  28959. })
  28960. return
  28961. }
  28962. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28963. result, _ := json.Marshal(respJSON)
  28964. fmt.Println("log")
  28965. fmt.Println(string(result))
  28966. if err := json.Unmarshal(result, &ahres); err != nil {
  28967. utils.ErrorLog("解析失败:%v", err)
  28968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28969. return
  28970. }
  28971. res.InfRefmsgid = ahres.InfRefmsgid
  28972. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  28973. // 创建对应的Time类型
  28974. t := time.UnixMilli(timestamp)
  28975. // 格式化成指定的日期字符串
  28976. str := t.Format("2006-01-02 15:04:05")
  28977. res.Output.Setlinfo.SetlTime = str
  28978. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  28979. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  28980. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28981. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  28982. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  28983. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  28984. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28985. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  28986. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  28987. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  28988. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  28989. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28990. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  28991. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  28992. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  28993. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  28994. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  28995. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  28996. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28997. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  28998. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  28999. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  29000. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  29001. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  29002. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  29003. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  29004. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  29005. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  29006. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  29007. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  29008. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  29009. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  29010. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  29011. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  29012. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  29013. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  29014. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  29015. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  29016. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  29017. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  29018. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  29019. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  29020. res.Output.Setldetail = ahres.Output.Setldetail
  29021. res.ErrMsg = ahres.ErrMsg
  29022. res.Cainfo = ahres.Cainfo
  29023. res.WarnMsg = ahres.WarnMsg
  29024. res.Infcode = ahres.Infcode
  29025. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  29026. res.Output.Setlinfo.ClrType = "11"
  29027. } else {
  29028. res.Output.Setlinfo.ClrType = "9903"
  29029. }
  29030. } else if miConfig.MdtrtareaAdmvs == "340699" {
  29031. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29032. if his.IdCardType == 1 {
  29033. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  29034. bas := strings.Split(psn_info.CardInfo, "|")
  29035. cert_no = bas[2]
  29036. } else if his.IdCardType == 3 {
  29037. cert_no = his.Certno
  29038. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  29039. } else if his.IdCardType == 4 {
  29040. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  29041. cert_no = his.Certno
  29042. psn_info.VerifyNumber = psn_info.VerifyNumber
  29043. } else {
  29044. cert_no = his.Certno
  29045. psn_info.VerifyNumber = his.Certno
  29046. }
  29047. var api string
  29048. var med_type string
  29049. if his.Insutype == "390" {
  29050. if reg_type == 1104 {
  29051. med_type = "1104"
  29052. }
  29053. if reg_type == 992102 {
  29054. med_type = "992102"
  29055. }
  29056. if reg_type == 140104 {
  29057. med_type = "140104"
  29058. }
  29059. if reg_type == 14 {
  29060. med_type = "14"
  29061. }
  29062. if reg_type == 140201 {
  29063. med_type = "140201"
  29064. }
  29065. } else if his.Insutype == "310" {
  29066. if reg_type == 1104 {
  29067. med_type = "1104"
  29068. }
  29069. if reg_type == 992102 {
  29070. med_type = "992102"
  29071. }
  29072. if reg_type == 14 {
  29073. med_type = "14"
  29074. }
  29075. if reg_type == 140104 {
  29076. med_type = "140104"
  29077. }
  29078. if reg_type == 140201 {
  29079. med_type = "140201"
  29080. }
  29081. }
  29082. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29083. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29084. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29085. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29086. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  29087. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29088. "&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
  29089. resp, requestErr := http.Get(api)
  29090. if requestErr != nil {
  29091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29092. return
  29093. }
  29094. body, ioErr := ioutil.ReadAll(resp.Body)
  29095. if ioErr != nil {
  29096. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29098. return
  29099. }
  29100. var respJSON map[string]interface{}
  29101. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29102. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29104. return
  29105. }
  29106. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29107. if status == "0" {
  29108. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29109. c.ServeSuccessJSON(map[string]interface{}{
  29110. "failed_code": -10,
  29111. "msg": err_msg,
  29112. })
  29113. return
  29114. }
  29115. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29116. result, _ := json.Marshal(respJSON)
  29117. fmt.Println("log")
  29118. fmt.Println(string(result))
  29119. if err := json.Unmarshal(result, &ahres); err != nil {
  29120. utils.ErrorLog("解析失败:%v", err)
  29121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29122. return
  29123. }
  29124. res.InfRefmsgid = ahres.InfRefmsgid
  29125. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  29126. // 创建对应的Time类型
  29127. t := time.UnixMilli(timestamp)
  29128. // 格式化成指定的日期字符串
  29129. str := t.Format("2006-01-02 15:04:05")
  29130. res.Output.Setlinfo.SetlTime = str
  29131. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  29132. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  29133. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29134. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  29135. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  29136. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  29137. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  29138. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  29139. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  29140. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  29141. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  29142. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29143. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  29144. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  29145. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  29146. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  29147. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  29148. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  29149. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29150. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  29151. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  29152. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  29153. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  29154. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  29155. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  29156. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  29157. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  29158. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  29159. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  29160. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  29161. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  29162. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  29163. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  29164. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  29165. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  29166. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  29167. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  29168. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  29169. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  29170. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  29171. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  29172. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  29173. res.Output.Setldetail = ahres.Output.Setldetail
  29174. res.ErrMsg = ahres.ErrMsg
  29175. res.Cainfo = ahres.Cainfo
  29176. res.WarnMsg = ahres.WarnMsg
  29177. res.Infcode = ahres.Infcode
  29178. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  29179. res.Output.Setlinfo.ClrType = "11"
  29180. } else {
  29181. res.Output.Setlinfo.ClrType = "9903"
  29182. }
  29183. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29184. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29185. var cert_no string
  29186. if his.IdCardType == 1 {
  29187. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  29188. } else if his.IdCardType == 2 {
  29189. cert_no = his.IdCardNo
  29190. } else {
  29191. cert_no = psn_info.VerifyNumber
  29192. }
  29193. 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, "")
  29194. var dat map[string]interface{}
  29195. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29196. fmt.Println(dat)
  29197. } else {
  29198. fmt.Println(err)
  29199. }
  29200. saveLog(result2, src_resquest, "2207", "结算")
  29201. userJSONBytes, _ := json.Marshal(dat)
  29202. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29203. utils.ErrorLog("解析失败:%v", err)
  29204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29205. return
  29206. }
  29207. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29208. psn_info, _ := service.GetPsnByPatientId(id)
  29209. var verify_number string
  29210. if psn_info.IdCardType == 4 {
  29211. verify_number = psn_info.VerifyNumber
  29212. } else if psn_info.IdCardType == 1 {
  29213. bas := strings.Split(psn_info.CardInfo, "|")
  29214. cardNumber := bas[2]
  29215. verify_number = cardNumber
  29216. } else {
  29217. verify_number = psn_info.Certno
  29218. psn_info.IdCardType = 2
  29219. }
  29220. var api string
  29221. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29222. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29223. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29224. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29225. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  29226. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29227. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  29228. resp, requestErr := http.Get(api)
  29229. if requestErr != nil {
  29230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29231. return
  29232. }
  29233. body, ioErr := ioutil.ReadAll(resp.Body)
  29234. if ioErr != nil {
  29235. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29237. return
  29238. }
  29239. var respJSON map[string]interface{}
  29240. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29241. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29243. return
  29244. }
  29245. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29246. result, _ := json.Marshal(respJSON)
  29247. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29248. utils.ErrorLog("解析失败:%v", err)
  29249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29250. return
  29251. }
  29252. } else {
  29253. var src_resquest string
  29254. if miConfig.Code == "H15049901371" {
  29255. //赤峰地区国家医保医疗类别
  29256. //职工透析:医疗类别选特殊情况门诊990502
  29257. //居民定额血透门慢: 医疗类别选门诊慢病140104
  29258. var med_type string
  29259. if his.Insutype == "390" {
  29260. if reg_type == 14 {
  29261. med_type = "9933"
  29262. } else if reg_type == 11 {
  29263. med_type = "11"
  29264. }
  29265. } else if his.Insutype == "310" {
  29266. if reg_type == 14 {
  29267. med_type = "990502"
  29268. } else if reg_type == 11 {
  29269. med_type = "11"
  29270. }
  29271. }
  29272. 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)
  29273. } else {
  29274. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" || miConfig.Code == "H44090200998"{
  29275. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  29276. if result3101.Infcode == 0 {
  29277. if len(result3101.Output.Result) > 0 {
  29278. c.ServeSuccessJSON(map[string]interface{}{
  29279. "failed_code": -10,
  29280. "failed_type": 100,
  29281. "warm_type": 2,
  29282. "msg": result3101,
  29283. })
  29284. return
  29285. }
  29286. } else {
  29287. c.ServeSuccessJSON(map[string]interface{}{
  29288. "failed_code": -10,
  29289. "msg": result3101.ErrMsg,
  29290. })
  29291. return
  29292. }
  29293. }
  29294. if his.IdCardType == 4 {
  29295. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29296. token := psn_info.VerifyNumber
  29297. 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)
  29298. } else {
  29299. 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)
  29300. }
  29301. }
  29302. var dat map[string]interface{}
  29303. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29304. fmt.Println(dat)
  29305. } else {
  29306. fmt.Println(err)
  29307. }
  29308. saveLog(result2, src_resquest, "2207", "结算")
  29309. userJSONBytes, _ := json.Marshal(dat)
  29310. if miConfig.Code == "H15049901371" {
  29311. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  29312. utils.ErrorLog("解析失败:%v", err)
  29313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29314. return
  29315. }
  29316. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29317. res.Output = resSeven10265.Output
  29318. res.ErrMsg = resSeven10265.ErrMsg
  29319. res.Cainfo = resSeven10265.Cainfo
  29320. res.WarnMsg = resSeven10265.WarnMsg
  29321. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29322. res.Infcode = infocode
  29323. } else {
  29324. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  29325. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  29326. utils.ErrorLog("解析失败:%v", err)
  29327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29328. return
  29329. }
  29330. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  29331. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  29332. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  29333. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  29334. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  29335. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  29336. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  29337. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  29338. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  29339. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29340. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29341. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29342. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29343. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  29344. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  29345. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  29346. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  29347. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  29348. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  29349. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  29350. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29351. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  29352. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  29353. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  29354. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  29355. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  29356. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  29357. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  29358. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  29359. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  29360. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  29361. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  29362. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  29363. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  29364. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  29365. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  29366. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  29367. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  29368. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29369. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  29370. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  29371. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  29372. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  29373. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  29374. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  29375. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  29376. res.ErrMsg = gzresSeven10265Two.ErrMsg
  29377. res.Cainfo = gzresSeven10265Two.Cainfo
  29378. res.WarnMsg = gzresSeven10265Two.WarnMsg
  29379. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  29380. //res.Infcode = infocode
  29381. } else {
  29382. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29383. utils.ErrorLog("解析失败:%v", err)
  29384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29385. return
  29386. }
  29387. }
  29388. }
  29389. }
  29390. if res.Infcode != 0 {
  29391. errlog := &models.HisOrderError{
  29392. UserOrgId: adminUser.CurrentOrgId,
  29393. Ctime: time.Now().Unix(),
  29394. Mtime: time.Now().Unix(),
  29395. Number: chrg_bchno,
  29396. ErrMsg: res.ErrMsg,
  29397. Status: 1,
  29398. PatientId: id,
  29399. RecordTime: recordDateTime,
  29400. Stage: 6,
  29401. }
  29402. service.CreateErrMsgLog(errlog)
  29403. c.ServeSuccessJSON(map[string]interface{}{
  29404. "failed_code": -10,
  29405. "msg": res.ErrMsg,
  29406. })
  29407. return
  29408. } else {
  29409. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  29410. order.OrderStatus = 2
  29411. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  29412. order.SetlId = res.Output.Setlinfo.SetlID
  29413. order.PsnNo = res.Output.Setlinfo.PsnNo
  29414. order.PsnName = res.Output.Setlinfo.PsnName
  29415. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  29416. order.Certno = res.Output.Setlinfo.Certno
  29417. order.Gend = res.Output.Setlinfo.Gend
  29418. order.Naty = res.Output.Setlinfo.Naty
  29419. order.Age = res.Output.Setlinfo.Age
  29420. order.Insutype = res.Output.Setlinfo.Insutype
  29421. order.PsnType = res.Output.Setlinfo.PsnType
  29422. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  29423. order.SetlTime = res.Output.Setlinfo.SetlTime
  29424. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  29425. order.PayWays = pay_ways
  29426. order.AcctUsedFlag = acct_used_flag
  29427. order.WechatPay = wechat_pay
  29428. order.AliPay = ali_pay
  29429. order.JifenPay = jifen_pay
  29430. order.BandCardPay = band_card_pay
  29431. order.CashPay = cash_pay
  29432. order.OthDesc = oth_desc
  29433. //order.MedType = res.Output.Setlinfo.MedType
  29434. if reg_type == 1112 {
  29435. order.MedType = "1112"
  29436. }
  29437. if reg_type == 1111 {
  29438. order.MedType = "1111"
  29439. }
  29440. order.ClrType = res.Output.Setlinfo.ClrType
  29441. if adminUser.CurrentOrgId == 10480 {
  29442. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  29443. order.ClrType = "11"
  29444. } else {
  29445. order.ClrType = "9903"
  29446. }
  29447. }
  29448. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  29449. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  29450. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  29451. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  29452. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  29453. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  29454. order.HifpPay = res.Output.Setlinfo.HifpPay
  29455. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  29456. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  29457. order.HifesPay = res.Output.Setlinfo.HifesPay
  29458. order.HifobPay = res.Output.Setlinfo.HifobPay
  29459. order.MafPay = res.Output.Setlinfo.MafPay
  29460. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  29461. order.OthPay = res.Output.Setlinfo.OthPay
  29462. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  29463. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  29464. order.AcctPay = res.Output.Setlinfo.AcctPay
  29465. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  29466. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  29467. order.Balc = res.Output.Setlinfo.Balc
  29468. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  29469. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  29470. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  29471. order.ClrWay = res.Output.Setlinfo.ClrWay
  29472. order.Creator = order.Creator
  29473. order.Modify = roles.AdminUserId
  29474. order.RequestLog = src_resquest
  29475. order.Diagnosis = diagnosis_id
  29476. order.FaPiaoNumber = fapiao_number
  29477. order.FaPiaoCode = fapiao_code
  29478. order.PayCardNo = pay_card_no
  29479. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  29480. detailStr := string(setlDetail)
  29481. order.SetlDetail = detailStr
  29482. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  29483. err = service.UpDateOrder(order)
  29484. if err == nil {
  29485. //判断是否使用了押金
  29486. if dec_way == "true" {
  29487. tmpstring := strconv.FormatInt(order.ID, 10)
  29488. //扣押金
  29489. order.Decimal = decimal
  29490. service.UpDateOrder(order)
  29491. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  29492. if errmsg != nil {
  29493. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  29494. return
  29495. }
  29496. }
  29497. c.ServeSuccessJSON(map[string]interface{}{
  29498. "msg": "结算成功",
  29499. })
  29500. } else {
  29501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  29502. return
  29503. }
  29504. }
  29505. }
  29506. }
  29507. }
  29508. // 上传明细-预结算-
  29509. func (c *HisApiController) GetPreUploadInfo() {
  29510. id, _ := c.GetInt64("id")
  29511. record_time := c.GetString("record_time")
  29512. his_patient_id, _ := c.GetInt64("his_patient_id")
  29513. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  29514. admin_user_id, _ := c.GetInt64("admin_user_id")
  29515. diagnosis_id := c.GetString("diagnosis")
  29516. sick_type, _ := c.GetInt64("sick_type")
  29517. reg_type, _ := c.GetInt64("p_type")
  29518. begin_time := c.GetString("begin_time")
  29519. acct_used_flag := c.GetString("acct_used_flag")
  29520. id_str := c.GetString("ids")
  29521. ids_arr := strings.Split(id_str, ",")
  29522. timeLayout := "2006-01-02"
  29523. loc, _ := time.LoadLocation("Local")
  29524. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  29525. if err != nil {
  29526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  29527. return
  29528. }
  29529. recordDateTime := theTime.Unix()
  29530. adminUser := c.GetAdminUserInfo()
  29531. diagnosis_ids := strings.Split(diagnosis_id, ",")
  29532. var config []*models.HisXtDiagnoseConfig
  29533. for _, item := range diagnosis_ids {
  29534. id, _ := strconv.ParseInt(item, 10, 64)
  29535. if id > 0 {
  29536. diagnosisConfig, _ := service.FindDiagnoseById(id)
  29537. config = append(config, &diagnosisConfig)
  29538. }
  29539. }
  29540. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  29541. sickConfig, _ := service.FindSickById(sick_type)
  29542. var prescriptions []*models.HisPrescription
  29543. var start_time int64
  29544. var end_time int64
  29545. var isSuccess bool = true
  29546. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29547. fmt.Println(his_patient_id)
  29548. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  29549. timestamp := time.Now().Unix()
  29550. tempTime := time.Unix(timestamp, 0)
  29551. timeFormat := tempTime.Format("20060102150405")
  29552. chrgBchno := rand.Intn(100000) + 10000
  29553. new_chrg_bchno := ""
  29554. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  29555. new_chrg_bchno = chrg_bchno
  29556. if adminUser.CurrentOrgId == 10265 {
  29557. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  29558. new_chrg_bchno = "0000"
  29559. }
  29560. }
  29561. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29562. var patientPrescription models.HisPrescriptionInfo
  29563. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  29564. if patientPrescription.ID == 0 {
  29565. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  29566. }
  29567. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29568. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  29569. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  29570. strconv.FormatInt(his.PatientId, 10)
  29571. var res2406 Result2406
  29572. //安徽单病种处理
  29573. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  29574. data := make(map[string]interface{})
  29575. client := &http.Client{}
  29576. data["psn_no"] = his.PsnNo
  29577. data["mdtrt_id"] = his.Number
  29578. data["operator"] = roles.UserName
  29579. data["cert_no"] = his.IdCardNo
  29580. data["org_name"] = miConfig.OrgName
  29581. data["psn_name"] = his.Name
  29582. data["ipt_otp_no"] = his.IptOtpNo
  29583. data["ipt_psn_sp_flag_type"] = "0901"
  29584. data["ipt_psn_sp_flag"] = "1"
  29585. data["fixmedins_code"] = miConfig.Code
  29586. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29587. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29588. data["url"] = miConfig.Url
  29589. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  29590. bytesData, _ := json.Marshal(data)
  29591. var req *http.Request
  29592. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  29593. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  29594. resp, _ := client.Do(req)
  29595. defer resp.Body.Close()
  29596. body, ioErr := ioutil.ReadAll(resp.Body)
  29597. if ioErr != nil {
  29598. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29600. return
  29601. }
  29602. var respJSON map[string]interface{}
  29603. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29604. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29606. return
  29607. }
  29608. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29609. if status == "0" {
  29610. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29611. c.ServeSuccessJSON(map[string]interface{}{
  29612. "failed_code": -10,
  29613. "msg": err_msg,
  29614. })
  29615. return
  29616. }
  29617. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29618. userJSONBytes, _ := json.Marshal(respJSON)
  29619. fmt.Println("log")
  29620. fmt.Println(string(userJSONBytes))
  29621. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  29622. utils.ErrorLog("解析失败:%v", err)
  29623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29624. return
  29625. }
  29626. } else if miConfig.MdtrtareaAdmvs == "340699" && reg_type == 992102 {
  29627. data := make(map[string]interface{})
  29628. client := &http.Client{}
  29629. data["psn_no"] = his.PsnNo
  29630. data["mdtrt_id"] = his.Number
  29631. data["operator"] = roles.UserName
  29632. data["cert_no"] = his.IdCardNo
  29633. data["org_name"] = miConfig.OrgName
  29634. data["psn_name"] = his.Name
  29635. data["ipt_otp_no"] = his.IptOtpNo
  29636. data["ipt_psn_sp_flag_type"] = "0901"
  29637. data["ipt_psn_sp_flag"] = "1"
  29638. data["fixmedins_code"] = miConfig.Code
  29639. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29640. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29641. data["url"] = miConfig.Url
  29642. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  29643. bytesData, _ := json.Marshal(data)
  29644. var req *http.Request
  29645. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  29646. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  29647. resp, _ := client.Do(req)
  29648. defer resp.Body.Close()
  29649. body, ioErr := ioutil.ReadAll(resp.Body)
  29650. if ioErr != nil {
  29651. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29653. return
  29654. }
  29655. var respJSON map[string]interface{}
  29656. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29659. return
  29660. }
  29661. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29662. if status == "0" {
  29663. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29664. c.ServeSuccessJSON(map[string]interface{}{
  29665. "failed_code": -10,
  29666. "msg": err_msg,
  29667. })
  29668. return
  29669. }
  29670. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29671. userJSONBytes, _ := json.Marshal(respJSON)
  29672. fmt.Println("log")
  29673. fmt.Println(string(userJSONBytes))
  29674. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  29675. utils.ErrorLog("解析失败:%v", err)
  29676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29677. return
  29678. }
  29679. }
  29680. if res2406.Infcode != 0 {
  29681. adminUser := c.GetAdminUserInfo()
  29682. errlog := &models.HisOrderError{
  29683. UserOrgId: adminUser.CurrentOrgId,
  29684. Ctime: time.Now().Unix(),
  29685. Mtime: time.Now().Unix(),
  29686. ErrMsg: res2406.ErrMsg,
  29687. Status: 1,
  29688. PatientId: id,
  29689. RecordTime: recordDateTime,
  29690. Stage: 3,
  29691. }
  29692. service.CreateErrMsgLog(errlog)
  29693. c.ServeSuccessJSON(map[string]interface{}{
  29694. "failed_code": -10,
  29695. "msg": res2406.ErrMsg,
  29696. })
  29697. return
  29698. }
  29699. var res2 ResultSix
  29700. var res3 GZResultSix
  29701. var resSix10265 ResultSix10265
  29702. //var time_stamp string
  29703. if miConfig.MdtrtareaAdmvs == "421300" {
  29704. data := make(map[string]interface{})
  29705. client := &http.Client{}
  29706. data["psn_no"] = his.PsnNo
  29707. data["mdtrt_id"] = his.Number
  29708. data["department"] = department.Name
  29709. data["org_name"] = miConfig.OrgName
  29710. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29711. data["doctor_id"] = doctor_info.DoctorNumber
  29712. data["doctor_name"] = roles.UserName
  29713. data["fixmedins_code"] = miConfig.Code
  29714. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29715. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29716. data["secret_key"] = miConfig.SecretKey
  29717. data["sick_code"] = sickConfig.CountryCode
  29718. data["sick_name"] = sickConfig.ClassName
  29719. data["begin_time"] = begin_time
  29720. data["dept"] = strconv.FormatInt(department.ID, 10)
  29721. data["config"] = config
  29722. data["opter"] = roles.UserName
  29723. fmt.Println(data)
  29724. bytesData, _ := json.Marshal(data)
  29725. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  29726. resp, _ := client.Do(req)
  29727. defer resp.Body.Close()
  29728. body, ioErr := ioutil.ReadAll(resp.Body)
  29729. if ioErr != nil {
  29730. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29732. return
  29733. }
  29734. var respJSON map[string]interface{}
  29735. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29736. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29738. return
  29739. }
  29740. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29741. userJSONBytes, _ := json.Marshal(respJSON)
  29742. fmt.Println("log")
  29743. fmt.Println(string(userJSONBytes))
  29744. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29745. utils.ErrorLog("解析失败:%v", err)
  29746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29747. return
  29748. }
  29749. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29750. data := make(map[string]interface{})
  29751. client := &http.Client{}
  29752. data["psn_no"] = his.PsnNo
  29753. data["mdtrt_id"] = his.Number
  29754. data["department"] = department.Name
  29755. data["org_name"] = miConfig.OrgName
  29756. if reg_type == 11 && his.Insutype == "390" {
  29757. data["med_type"] = "110104"
  29758. } else {
  29759. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29760. }
  29761. data["doctor_id"] = doctor_info.DoctorNumber
  29762. data["doctor_name"] = roles.UserName
  29763. data["fixmedins_code"] = miConfig.Code
  29764. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29765. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29766. data["secret_key"] = miConfig.SecretKey
  29767. data["sick_code"] = sickConfig.CountryCode
  29768. data["sick_name"] = sickConfig.ClassName
  29769. data["begin_time"] = begin_time
  29770. data["dept"] = strconv.FormatInt(department.ID, 10)
  29771. data["config"] = config
  29772. data["opter"] = roles.UserName
  29773. fmt.Println(data)
  29774. bytesData, _ := json.Marshal(data)
  29775. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  29776. resp, _ := client.Do(req)
  29777. defer resp.Body.Close()
  29778. body, ioErr := ioutil.ReadAll(resp.Body)
  29779. if ioErr != nil {
  29780. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29782. return
  29783. }
  29784. var respJSON map[string]interface{}
  29785. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29786. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29788. return
  29789. }
  29790. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29791. userJSONBytes, _ := json.Marshal(respJSON)
  29792. fmt.Println("log")
  29793. fmt.Println(string(userJSONBytes))
  29794. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29795. utils.ErrorLog("解析失败:%v", err)
  29796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29797. return
  29798. }
  29799. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29800. data := make(map[string]interface{})
  29801. client := &http.Client{}
  29802. data["psn_no"] = his.PsnNo
  29803. data["mdtrt_id"] = his.Number
  29804. data["department"] = department.Name
  29805. data["org_name"] = miConfig.OrgName
  29806. if reg_type == 11 && his.Insutype == "390" {
  29807. data["med_type"] = "110104"
  29808. } else {
  29809. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29810. }
  29811. data["doctor_id"] = doctor_info.DoctorNumber
  29812. data["doctor_name"] = roles.UserName
  29813. data["fixmedins_code"] = miConfig.Code
  29814. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29815. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29816. data["secret_key"] = miConfig.SecretKey
  29817. data["sick_code"] = sickConfig.CountryCode
  29818. data["sick_name"] = sickConfig.ClassName
  29819. data["begin_time"] = begin_time
  29820. data["dept"] = strconv.FormatInt(department.ID, 10)
  29821. data["config"] = config
  29822. data["opter"] = roles.UserName
  29823. fmt.Println(data)
  29824. bytesData, _ := json.Marshal(data)
  29825. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  29826. resp, _ := client.Do(req)
  29827. defer resp.Body.Close()
  29828. body, ioErr := ioutil.ReadAll(resp.Body)
  29829. if ioErr != nil {
  29830. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29832. return
  29833. }
  29834. var respJSON map[string]interface{}
  29835. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29836. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29838. return
  29839. }
  29840. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29841. userJSONBytes, _ := json.Marshal(respJSON)
  29842. fmt.Println("log")
  29843. fmt.Println(string(userJSONBytes))
  29844. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29845. utils.ErrorLog("解析失败:%v", err)
  29846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29847. return
  29848. }
  29849. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29850. data := make(map[string]interface{})
  29851. client := &http.Client{}
  29852. data["psn_no"] = his.PsnNo
  29853. data["mdtrt_id"] = his.Number
  29854. data["department"] = department.Name
  29855. data["org_name"] = miConfig.OrgName
  29856. if reg_type == 11 && his.Insutype == "390" {
  29857. data["med_type"] = "110104"
  29858. } else {
  29859. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29860. }
  29861. data["doctor_id"] = doctor_info.DoctorNumber
  29862. data["doctor_name"] = roles.UserName
  29863. data["fixmedins_code"] = miConfig.Code
  29864. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29865. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29866. data["secret_key"] = miConfig.SecretKey
  29867. data["sick_code"] = sickConfig.CountryCode
  29868. data["sick_name"] = sickConfig.ClassName
  29869. data["begin_time"] = begin_time
  29870. data["dept"] = strconv.FormatInt(department.ID, 10)
  29871. data["config"] = config
  29872. data["opter"] = roles.UserName
  29873. fmt.Println(data)
  29874. bytesData, _ := json.Marshal(data)
  29875. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  29876. resp, _ := client.Do(req)
  29877. defer resp.Body.Close()
  29878. body, ioErr := ioutil.ReadAll(resp.Body)
  29879. if ioErr != nil {
  29880. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29882. return
  29883. }
  29884. var respJSON map[string]interface{}
  29885. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29886. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29888. return
  29889. }
  29890. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29891. userJSONBytes, _ := json.Marshal(respJSON)
  29892. fmt.Println("log")
  29893. fmt.Println(string(userJSONBytes))
  29894. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29895. utils.ErrorLog("解析失败:%v", err)
  29896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29897. return
  29898. }
  29899. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  29900. utils.ErrorLog("解析失败:%v", doctor_info)
  29901. data := make(map[string]interface{})
  29902. client := &http.Client{}
  29903. data["psn_no"] = his.PsnNo
  29904. data["mdtrt_id"] = his.Number
  29905. data["doctor"] = roles.UserName
  29906. data["department"] = department.Name
  29907. data["org_name"] = miConfig.OrgName
  29908. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29909. data["doctor_id"] = doctor_info.DoctorNumber
  29910. data["new_doctor_name"] = doctor_info.UserName
  29911. data["fixmedins_code"] = miConfig.Code
  29912. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29913. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29914. data["secret_key"] = miConfig.SecretKey
  29915. data["sick_code"] = sickConfig.CountryCode
  29916. data["sick_name"] = sickConfig.ClassName
  29917. data["url"] = miConfig.Url
  29918. data["ak"] = miConfig.AccessKey
  29919. data["begin_time"] = begin_time
  29920. data["cainfo"] = miConfig.Cainfo
  29921. data["dept"] = strconv.FormatInt(department.ID, 10)
  29922. data["config"] = config
  29923. bytesData, _ := json.Marshal(data)
  29924. var req *http.Request
  29925. if miConfig.MdtrtareaAdmvs == "320830" {
  29926. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2203", bytes.NewReader(bytesData))
  29927. } else if miConfig.MdtrtareaAdmvs == "320921" {
  29928. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  29929. } else {
  29930. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  29931. }
  29932. resp, _ := client.Do(req)
  29933. defer resp.Body.Close()
  29934. body, ioErr := ioutil.ReadAll(resp.Body)
  29935. if ioErr != nil {
  29936. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29938. return
  29939. }
  29940. var respJSON map[string]interface{}
  29941. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29942. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29944. return
  29945. }
  29946. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  29947. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  29948. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  29949. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29950. userJSONBytes, _ := json.Marshal(respJSON)
  29951. fmt.Println("log")
  29952. fmt.Println(string(userJSONBytes))
  29953. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  29954. utils.ErrorLog("解析失败:%v", err)
  29955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29956. return
  29957. }
  29958. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29959. res2.Output = resSix10265.Output
  29960. res2.ErrMsg = resSix10265.ErrMsg
  29961. res2.Cainfo = resSix10265.Cainfo
  29962. res2.WarnMsg = resSix10265.WarnMsg
  29963. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29964. res2.Infcode = infocode
  29965. } else if miConfig.MdtrtareaAdmvs == "150404" {
  29966. data := make(map[string]interface{})
  29967. client := &http.Client{}
  29968. data["psn_no"] = his.PsnNo
  29969. data["mdtrt_id"] = his.Number
  29970. data["doctor"] = roles.UserName
  29971. data["department"] = department.Name
  29972. data["org_name"] = miConfig.OrgName
  29973. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29974. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  29975. data["fixmedins_code"] = miConfig.Code
  29976. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29977. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29978. data["secret_key"] = miConfig.SecretKey
  29979. data["sick_code"] = sickConfig.CountryCode
  29980. data["sick_name"] = sickConfig.ClassName
  29981. data["begin_time"] = begin_time
  29982. data["dept"] = strconv.FormatInt(department.ID, 10)
  29983. data["config"] = config
  29984. //data["url"] = miConfig.Url
  29985. //data["ak"] = miConfig.AccessKey
  29986. data["cainfo"] = miConfig.Cainfo
  29987. fmt.Println(data)
  29988. bytesData, _ := json.Marshal(data)
  29989. var req *http.Request
  29990. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  29991. resp, _ := client.Do(req)
  29992. defer resp.Body.Close()
  29993. body, ioErr := ioutil.ReadAll(resp.Body)
  29994. if ioErr != nil {
  29995. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29997. return
  29998. }
  29999. var respJSON map[string]interface{}
  30000. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30001. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30003. return
  30004. }
  30005. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  30006. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  30007. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  30008. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30009. userJSONBytes, _ := json.Marshal(respJSON)
  30010. fmt.Println("log")
  30011. fmt.Println(string(userJSONBytes))
  30012. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  30013. utils.ErrorLog("解析失败:%v", err)
  30014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30015. return
  30016. }
  30017. res2.InfRefmsgid = resSix10265.InfRefmsgid
  30018. res2.Output = resSix10265.Output
  30019. res2.ErrMsg = resSix10265.ErrMsg
  30020. res2.Cainfo = resSix10265.Cainfo
  30021. res2.WarnMsg = resSix10265.WarnMsg
  30022. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30023. res2.Infcode = infocode
  30024. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30025. 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)
  30026. saveLog(result, requestLog, "2203", "上传就诊信息")
  30027. var respJSON2 map[string]interface{}
  30028. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30029. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30031. return
  30032. }
  30033. userJSONBytes2, _ := json.Marshal(respJSON2)
  30034. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30035. utils.ErrorLog("解析失败:%v", err)
  30036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30037. return
  30038. }
  30039. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30040. var result string
  30041. var requestLog string
  30042. 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, "")
  30043. saveLog(result, requestLog, "2203", "上传就诊信息")
  30044. var respJSON2 map[string]interface{}
  30045. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30046. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30048. return
  30049. }
  30050. userJSONBytes2, _ := json.Marshal(respJSON2)
  30051. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30052. utils.ErrorLog("解析失败:%v", err)
  30053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30054. return
  30055. }
  30056. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30057. var result string
  30058. var requestLog string
  30059. 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, "")
  30060. saveLog(result, requestLog, "2203", "上传就诊信息")
  30061. var respJSON2 map[string]interface{}
  30062. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30063. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30065. return
  30066. }
  30067. userJSONBytes2, _ := json.Marshal(respJSON2)
  30068. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30069. utils.ErrorLog("解析失败:%v", err)
  30070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30071. return
  30072. }
  30073. } else if miConfig.MdtrtareaAdmvs == "360100" {
  30074. var result string
  30075. var requestLog string
  30076. 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, "")
  30077. saveLog(result, requestLog, "2203", "上传就诊信息")
  30078. var respJSON2 map[string]interface{}
  30079. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30080. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30082. return
  30083. }
  30084. userJSONBytes2, _ := json.Marshal(respJSON2)
  30085. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30086. utils.ErrorLog("解析失败:%v", err)
  30087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30088. return
  30089. }
  30090. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30091. data := make(map[string]interface{})
  30092. client := &http.Client{}
  30093. data["psn_no"] = his.PsnNo
  30094. data["mdtrt_id"] = his.Number
  30095. data["operator"] = roles.UserName
  30096. data["department"] = department.Name
  30097. data["org_name"] = miConfig.OrgName
  30098. var med_type string
  30099. if his.Insutype == "390" {
  30100. if reg_type == 992102 {
  30101. med_type = "992102"
  30102. data["sick_code"] = "ZDZ940"
  30103. data["sick_name"] = "慢性肾衰竭"
  30104. }
  30105. if reg_type == 140104 {
  30106. med_type = "140104"
  30107. data["sick_code"] = sickConfig.CountryCode
  30108. data["sick_name"] = sickConfig.ClassName
  30109. }
  30110. if reg_type == 14 {
  30111. med_type = "140104"
  30112. data["sick_code"] = sickConfig.CountryCode
  30113. data["sick_name"] = sickConfig.ClassName
  30114. }
  30115. if reg_type == 1104 {
  30116. med_type = "1104"
  30117. data["sick_code"] = sickConfig.CountryCode
  30118. data["sick_name"] = sickConfig.ClassName
  30119. }
  30120. } else if his.Insutype == "310" {
  30121. if reg_type == 992102 {
  30122. med_type = "992102"
  30123. data["sick_code"] = "ZDZ940"
  30124. data["sick_name"] = "慢性肾衰竭"
  30125. }
  30126. if reg_type == 140104 {
  30127. med_type = "140104"
  30128. data["sick_code"] = sickConfig.CountryCode
  30129. data["sick_name"] = sickConfig.ClassName
  30130. }
  30131. if reg_type == 14 {
  30132. med_type = "14"
  30133. data["sick_code"] = sickConfig.CountryCode
  30134. data["sick_name"] = sickConfig.ClassName
  30135. }
  30136. if reg_type == 1104 {
  30137. med_type = "1104"
  30138. data["sick_code"] = sickConfig.CountryCode
  30139. data["sick_name"] = sickConfig.ClassName
  30140. }
  30141. }
  30142. data["med_type"] = med_type
  30143. data["doctor_number"] = doctor_info.DoctorNumber
  30144. data["doctor_name"] = doctor_info.UserName
  30145. data["fixmedins_code"] = miConfig.Code
  30146. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30147. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30148. data["secret_key"] = miConfig.SecretKey
  30149. data["begin_time"] = begin_time
  30150. data["dept"] = strconv.FormatInt(department.ID, 10)
  30151. data["config"] = config
  30152. data["url"] = miConfig.Url
  30153. data["ak"] = miConfig.AccessKey
  30154. data["cainfo"] = miConfig.Cainfo
  30155. bytesData, _ := json.Marshal(data)
  30156. var req *http.Request
  30157. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  30158. resp, _ := client.Do(req)
  30159. defer resp.Body.Close()
  30160. body, ioErr := ioutil.ReadAll(resp.Body)
  30161. if ioErr != nil {
  30162. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30164. return
  30165. }
  30166. var respJSON map[string]interface{}
  30167. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30168. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30170. return
  30171. }
  30172. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30173. if status == "0" {
  30174. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30175. c.ServeSuccessJSON(map[string]interface{}{
  30176. "failed_code": -10,
  30177. "msg": err_msg,
  30178. })
  30179. return
  30180. }
  30181. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30182. userJSONBytes, _ := json.Marshal(respJSON)
  30183. fmt.Println("log")
  30184. fmt.Println(string(userJSONBytes))
  30185. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30186. utils.ErrorLog("解析失败:%v", err)
  30187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30188. return
  30189. }
  30190. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30191. data := make(map[string]interface{})
  30192. client := &http.Client{}
  30193. data["psn_no"] = his.PsnNo
  30194. data["mdtrt_id"] = his.Number
  30195. data["operator"] = roles.UserName
  30196. data["department"] = department.Name
  30197. data["org_name"] = miConfig.OrgName
  30198. var med_type string
  30199. if his.Insutype == "390" {
  30200. if reg_type == 992102 {
  30201. med_type = "992102"
  30202. data["sick_code"] = sickConfig.CountryCode
  30203. data["sick_name"] = sickConfig.ClassName
  30204. }
  30205. if reg_type == 140104 {
  30206. med_type = "140104"
  30207. data["sick_code"] = sickConfig.CountryCode
  30208. data["sick_name"] = sickConfig.ClassName
  30209. }
  30210. if reg_type == 140201 {
  30211. med_type = "140201"
  30212. data["sick_code"] = sickConfig.CountryCode
  30213. data["sick_name"] = sickConfig.ClassName
  30214. }
  30215. if reg_type == 14 {
  30216. med_type = "14"
  30217. data["sick_code"] = sickConfig.CountryCode
  30218. data["sick_name"] = sickConfig.ClassName
  30219. }
  30220. if reg_type == 11 {
  30221. med_type = "11"
  30222. data["sick_code"] = sickConfig.CountryCode
  30223. data["sick_name"] = sickConfig.ClassName
  30224. }
  30225. } else if his.Insutype == "310" {
  30226. if reg_type == 992102 {
  30227. med_type = "992102"
  30228. data["sick_code"] = sickConfig.CountryCode
  30229. data["sick_name"] = sickConfig.ClassName
  30230. }
  30231. if reg_type == 140104 {
  30232. med_type = "140104"
  30233. data["sick_code"] = sickConfig.CountryCode
  30234. data["sick_name"] = sickConfig.ClassName
  30235. }
  30236. if reg_type == 140201 {
  30237. med_type = "140201"
  30238. data["sick_code"] = sickConfig.CountryCode
  30239. data["sick_name"] = sickConfig.ClassName
  30240. }
  30241. if reg_type == 14 {
  30242. med_type = "14"
  30243. data["sick_code"] = sickConfig.CountryCode
  30244. data["sick_name"] = sickConfig.ClassName
  30245. }
  30246. if reg_type == 11 {
  30247. med_type = "11"
  30248. data["sick_code"] = sickConfig.CountryCode
  30249. data["sick_name"] = sickConfig.ClassName
  30250. }
  30251. }
  30252. data["med_type"] = med_type
  30253. data["doctor_number"] = doctor_info.DoctorNumber
  30254. data["doctor_name"] = doctor_info.UserName
  30255. data["fixmedins_code"] = miConfig.Code
  30256. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30257. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30258. data["secret_key"] = miConfig.SecretKey
  30259. data["begin_time"] = begin_time
  30260. data["dept"] = strconv.FormatInt(department.ID, 10)
  30261. data["config"] = config
  30262. data["url"] = miConfig.Url
  30263. data["ak"] = miConfig.AccessKey
  30264. data["cainfo"] = miConfig.Cainfo
  30265. bytesData, _ := json.Marshal(data)
  30266. var req *http.Request
  30267. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  30268. resp, _ := client.Do(req)
  30269. defer resp.Body.Close()
  30270. body, ioErr := ioutil.ReadAll(resp.Body)
  30271. if ioErr != nil {
  30272. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30274. return
  30275. }
  30276. var respJSON map[string]interface{}
  30277. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30278. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30280. return
  30281. }
  30282. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30283. if status == "0" {
  30284. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30285. c.ServeSuccessJSON(map[string]interface{}{
  30286. "failed_code": -10,
  30287. "msg": err_msg,
  30288. })
  30289. return
  30290. }
  30291. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30292. userJSONBytes, _ := json.Marshal(respJSON)
  30293. fmt.Println("log")
  30294. fmt.Println(string(userJSONBytes))
  30295. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30296. utils.ErrorLog("解析失败:%v", err)
  30297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30298. return
  30299. }
  30300. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30301. var result string
  30302. var requestLog string
  30303. 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)
  30304. saveLog(result, requestLog, "2203", "上传就诊信息")
  30305. var respJSON2 map[string]interface{}
  30306. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30307. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30309. return
  30310. }
  30311. userJSONBytes2, _ := json.Marshal(respJSON2)
  30312. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30313. utils.ErrorLog("解析失败:%v", err)
  30314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30315. return
  30316. }
  30317. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30318. data := make(map[string]interface{})
  30319. client := &http.Client{}
  30320. data["psn_no"] = his.PsnNo
  30321. data["mdtrt_id"] = his.Number
  30322. data["doctor"] = roles.UserName
  30323. data["department"] = department.Name
  30324. data["org_name"] = miConfig.OrgName
  30325. data["med_type"] = strconv.FormatInt(reg_type, 10)
  30326. data["doctor_id"] = doctor_info.DoctorNumber
  30327. data["fixmedins_code"] = miConfig.Code
  30328. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30329. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30330. data["secret_key"] = miConfig.SecretKey
  30331. data["sick_code"] = sickConfig.CountryCode
  30332. data["sick_name"] = sickConfig.ClassName
  30333. data["begin_time"] = begin_time
  30334. data["new_doctor_name"] = doctor_info.UserName
  30335. data["dept"] = strconv.FormatInt(department.ID, 10)
  30336. data["config"] = config
  30337. bytesData, _ := json.Marshal(data)
  30338. var req *http.Request
  30339. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  30340. resp, _ := client.Do(req)
  30341. defer resp.Body.Close()
  30342. body, ioErr := ioutil.ReadAll(resp.Body)
  30343. if ioErr != nil {
  30344. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30346. return
  30347. }
  30348. var respJSON map[string]interface{}
  30349. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30350. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30352. return
  30353. }
  30354. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30355. userJSONBytes, _ := json.Marshal(respJSON)
  30356. fmt.Println("log")
  30357. fmt.Println(string(userJSONBytes))
  30358. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30359. utils.ErrorLog("解析失败:%v", err)
  30360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30361. return
  30362. }
  30363. } else {
  30364. var result string
  30365. var requestLog string
  30366. if miConfig.MdtrtareaAdmvs == "440781" { //
  30367. 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)
  30368. } else {
  30369. if miConfig.Code == "H15049901371" {
  30370. //赤峰地区国家医保医疗类别
  30371. //职工透析:医疗类别选特殊情况门诊990502
  30372. //居民定额血透门慢: 医疗类别选门诊慢病140104
  30373. var med_type string
  30374. if his.Insutype == "390" {
  30375. if reg_type == 14 {
  30376. med_type = "9933"
  30377. } else if reg_type == 11 {
  30378. med_type = "11"
  30379. }
  30380. } else if his.Insutype == "310" {
  30381. if reg_type == 14 {
  30382. med_type = "990502"
  30383. } else if reg_type == 11 {
  30384. med_type = "11"
  30385. }
  30386. }
  30387. 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)
  30388. } else {
  30389. 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)
  30390. }
  30391. saveLog(result, requestLog, "2203", "上传就诊信息")
  30392. var respJSON2 map[string]interface{}
  30393. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30394. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30396. return
  30397. }
  30398. userJSONBytes2, _ := json.Marshal(respJSON2)
  30399. if miConfig.Code == "H15049901371" {
  30400. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  30401. utils.ErrorLog("解析失败:%v", err)
  30402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30403. return
  30404. }
  30405. res2.InfRefmsgid = resSix10265.InfRefmsgid
  30406. res2.Output = resSix10265.Output
  30407. res2.ErrMsg = resSix10265.ErrMsg
  30408. res2.Cainfo = resSix10265.Cainfo
  30409. res2.WarnMsg = resSix10265.WarnMsg
  30410. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30411. res2.Infcode = infocode
  30412. } else {
  30413. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  30414. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  30415. utils.ErrorLog("解析失败:%v", err)
  30416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30417. return
  30418. }
  30419. res2.Infcode = res3.Infcode
  30420. } else {
  30421. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30422. utils.ErrorLog("解析失败:%v", err)
  30423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30424. return
  30425. }
  30426. }
  30427. }
  30428. }
  30429. }
  30430. if res2.Infcode == -1 {
  30431. adminUser := c.GetAdminUserInfo()
  30432. errlog := &models.HisOrderError{
  30433. UserOrgId: adminUser.CurrentOrgId,
  30434. Ctime: time.Now().Unix(),
  30435. Mtime: time.Now().Unix(),
  30436. ErrMsg: res2.ErrMsg,
  30437. Status: 1,
  30438. PatientId: id,
  30439. RecordTime: recordDateTime,
  30440. Stage: 3,
  30441. }
  30442. service.CreateErrMsgLog(errlog)
  30443. c.ServeSuccessJSON(map[string]interface{}{
  30444. "failed_code": -10,
  30445. "msg": res2.ErrMsg,
  30446. })
  30447. return
  30448. }
  30449. if res2.Infcode != 0 {
  30450. adminUser := c.GetAdminUserInfo()
  30451. errlog := &models.HisOrderError{
  30452. UserOrgId: adminUser.CurrentOrgId,
  30453. Ctime: time.Now().Unix(),
  30454. Mtime: time.Now().Unix(),
  30455. ErrMsg: res2.ErrMsg,
  30456. Status: 1,
  30457. PatientId: id,
  30458. RecordTime: recordDateTime,
  30459. Stage: 3,
  30460. }
  30461. service.CreateErrMsgLog(errlog)
  30462. c.ServeSuccessJSON(map[string]interface{}{
  30463. "failed_code": -10,
  30464. "msg": res2.ErrMsg,
  30465. })
  30466. return
  30467. } else {
  30468. his.Diagnosis = diagnosis_id
  30469. his.SickType = sickConfig.ID
  30470. his.PType = fmt.Sprintf("%d", reg_type)
  30471. service.UpdateHisPatientThree(&his)
  30472. data := make(map[string]interface{})
  30473. if settle_accounts_type == 1 { //日结
  30474. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  30475. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  30476. } else {
  30477. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  30478. }
  30479. data["pre"] = prescriptions
  30480. } else { //月结
  30481. start_time_str := c.GetString("start_time")
  30482. end_time_str := c.GetString("end_time")
  30483. timeLayout := "2006-01-02"
  30484. loc, _ := time.LoadLocation("Local")
  30485. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  30486. if err != nil {
  30487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30488. return
  30489. }
  30490. recordStartTime := theStartTime.Unix()
  30491. start_time = recordStartTime
  30492. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  30493. if err != nil {
  30494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30495. return
  30496. }
  30497. recordEndTime := theEndTime.Unix()
  30498. end_time = recordEndTime
  30499. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  30500. data["pre"] = prescriptions
  30501. }
  30502. client := &http.Client{}
  30503. data["psn_no"] = his.PsnNo
  30504. data["mdtrt_id"] = his.Number
  30505. data["chrg_bchno"] = new_chrg_bchno
  30506. data["org_name"] = miConfig.OrgName
  30507. data["doctor"] = doctor_info.UserName
  30508. data["doctor_id"] = doctor_info.DoctorNumber
  30509. data["dept"] = department.Name
  30510. data["fixmedins_code"] = miConfig.Code
  30511. data["opter"] = roles.UserName
  30512. data["dept_code"] = department.Number
  30513. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30514. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30515. data["secret_key"] = miConfig.SecretKey
  30516. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  30517. data["url"] = miConfig.Url
  30518. data["ak"] = miConfig.AccessKey
  30519. data["new_doctor_name"] = patientPrescription.Doctor
  30520. if his.Insutype == "390" {
  30521. if reg_type == 992102 {
  30522. data["diag_code"] = "ZDZ940"
  30523. }
  30524. if reg_type == 140104 {
  30525. data["diag_code"] = sickConfig.CountryCode
  30526. }
  30527. if reg_type == 140201 {
  30528. data["diag_code"] = sickConfig.CountryCode
  30529. }
  30530. if reg_type == 14 {
  30531. data["diag_code"] = sickConfig.CountryCode
  30532. }
  30533. if reg_type == 1104 {
  30534. data["diag_code"] = sickConfig.CountryCode
  30535. }
  30536. } else if his.Insutype == "310" {
  30537. if miConfig.MdtrtareaAdmvs == "341203" {
  30538. if reg_type == 992102 {
  30539. data["diag_code"] = "ZDZ940"
  30540. }
  30541. if reg_type != 992102 {
  30542. data["diag_code"] = sickConfig.CountryCode
  30543. }
  30544. } else {
  30545. data["diag_code"] = sickConfig.CountryCode
  30546. }
  30547. }
  30548. data["cainfo"] = miConfig.Cainfo
  30549. data["opter"] = roles.UserName
  30550. var ids []int64
  30551. for _, item := range prescriptions {
  30552. ids = append(ids, item.ID)
  30553. }
  30554. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30555. if config.IsOpen == 1 { //对接了医保,走医保流程
  30556. var res ResultFour
  30557. var resFour10265 ResultFour10265
  30558. if miConfig.MdtrtareaAdmvs == "421300" {
  30559. bytesData, _ := json.Marshal(data)
  30560. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  30561. resp, _ := client.Do(req)
  30562. defer resp.Body.Close()
  30563. body, ioErr := ioutil.ReadAll(resp.Body)
  30564. if ioErr != nil {
  30565. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30567. return
  30568. }
  30569. var respJSON map[string]interface{}
  30570. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30571. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30573. return
  30574. }
  30575. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30576. userJSONBytes, _ := json.Marshal(respJSON)
  30577. fmt.Println("log")
  30578. fmt.Println(string(userJSONBytes))
  30579. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30580. utils.ErrorLog("解析失败:%v", err)
  30581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30582. return
  30583. }
  30584. } else if miConfig.MdtrtareaAdmvs == "420200" {
  30585. bytesData, _ := json.Marshal(data)
  30586. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  30587. resp, _ := client.Do(req)
  30588. defer resp.Body.Close()
  30589. body, ioErr := ioutil.ReadAll(resp.Body)
  30590. if ioErr != nil {
  30591. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30593. return
  30594. }
  30595. var respJSON map[string]interface{}
  30596. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30597. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30599. return
  30600. }
  30601. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30602. userJSONBytes, _ := json.Marshal(respJSON)
  30603. fmt.Println("log")
  30604. fmt.Println(string(userJSONBytes))
  30605. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30606. utils.ErrorLog("解析失败:%v", err)
  30607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30608. return
  30609. }
  30610. } else if miConfig.MdtrtareaAdmvs == "420902" {
  30611. bytesData, _ := json.Marshal(data)
  30612. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  30613. resp, _ := client.Do(req)
  30614. defer resp.Body.Close()
  30615. body, ioErr := ioutil.ReadAll(resp.Body)
  30616. if ioErr != nil {
  30617. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30619. return
  30620. }
  30621. var respJSON map[string]interface{}
  30622. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30623. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30625. return
  30626. }
  30627. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30628. userJSONBytes, _ := json.Marshal(respJSON)
  30629. fmt.Println("log")
  30630. fmt.Println(string(userJSONBytes))
  30631. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30632. utils.ErrorLog("解析失败:%v", err)
  30633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30634. return
  30635. }
  30636. } else if miConfig.MdtrtareaAdmvs == "421182" {
  30637. bytesData, _ := json.Marshal(data)
  30638. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  30639. resp, _ := client.Do(req)
  30640. defer resp.Body.Close()
  30641. body, ioErr := ioutil.ReadAll(resp.Body)
  30642. if ioErr != nil {
  30643. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30645. return
  30646. }
  30647. var respJSON map[string]interface{}
  30648. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30649. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30651. return
  30652. }
  30653. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30654. userJSONBytes, _ := json.Marshal(respJSON)
  30655. fmt.Println("log")
  30656. fmt.Println(string(userJSONBytes))
  30657. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30658. utils.ErrorLog("解析失败:%v", err)
  30659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30660. return
  30661. }
  30662. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  30663. var result3101 Result3101
  30664. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30665. result3101.Infcode = "0"
  30666. if result3101.Infcode == "0" {
  30667. if len(result3101.Output.Result) > 0 {
  30668. var errMsgs []string
  30669. for _, item := range result3101.Output.Result {
  30670. errMsgs = append(errMsgs, item.VolaCont)
  30671. }
  30672. c.ServeSuccessJSON(map[string]interface{}{
  30673. "failed_code": -10,
  30674. "msg": errMsgs,
  30675. })
  30676. return
  30677. } else {
  30678. if miConfig.MdtrtareaAdmvs == "320921" {
  30679. data["doctor_id"] = doctor_info.DoctorNumber
  30680. } else {
  30681. data["doctor_id"] = doctor_info.DoctorNumber
  30682. }
  30683. bytesData, _ := json.Marshal(data)
  30684. var req *http.Request
  30685. if miConfig.MdtrtareaAdmvs == "320830" {
  30686. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2204", bytes.NewReader(bytesData))
  30687. } else if miConfig.MdtrtareaAdmvs == "320921" {
  30688. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30689. } else {
  30690. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30691. }
  30692. resp, _ := client.Do(req)
  30693. defer resp.Body.Close()
  30694. body, ioErr := ioutil.ReadAll(resp.Body)
  30695. if ioErr != nil {
  30696. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30698. return
  30699. }
  30700. var respJSON map[string]interface{}
  30701. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30704. return
  30705. }
  30706. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30707. userJSONBytes, _ := json.Marshal(respJSON)
  30708. fmt.Println("log")
  30709. fmt.Println(string(userJSONBytes))
  30710. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  30711. utils.ErrorLog("解析失败:%v", err)
  30712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30713. return
  30714. }
  30715. res.InfRefmsgid = resFour10265.InfRefmsgid
  30716. res.Output = resFour10265.Output
  30717. res.ErrMsg = resFour10265.ErrMsg
  30718. res.Cainfo = resFour10265.Cainfo
  30719. res.WarnMsg = resFour10265.WarnMsg
  30720. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  30721. res.Infcode = infocode
  30722. }
  30723. }
  30724. } else if miConfig.MdtrtareaAdmvs == "150404" {
  30725. var pagesize int = 5
  30726. var start int = 1
  30727. var stop int
  30728. var pagecount int
  30729. var curpage int
  30730. data["doctor_id"] = doctor_info.DoctorNumber
  30731. var res2 ResultFour
  30732. //var result res.
  30733. //总页数,向上取整,注意除之前要先转换类型为float64
  30734. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  30735. for curpage = 1; curpage <= pagecount; curpage++ {
  30736. if curpage == 1 {
  30737. start = 1
  30738. } else {
  30739. start = (curpage-1)*pagesize + 1
  30740. }
  30741. stop = curpage * pagesize
  30742. if stop > len(prescriptions) {
  30743. stop = len(prescriptions)
  30744. }
  30745. //var requestLog string
  30746. data["pre"] = prescriptions[start-1 : stop]
  30747. fmt.Println(data["pre"])
  30748. bytesData, _ := json.Marshal(data)
  30749. var req *http.Request
  30750. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  30751. resp, _ := client.Do(req)
  30752. defer resp.Body.Close()
  30753. body, ioErr := ioutil.ReadAll(resp.Body)
  30754. if ioErr != nil {
  30755. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30757. return
  30758. }
  30759. var respJSON map[string]interface{}
  30760. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30761. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30763. return
  30764. }
  30765. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30766. userJSONBytes, _ := json.Marshal(respJSON)
  30767. fmt.Println("log")
  30768. fmt.Println(string(userJSONBytes))
  30769. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  30770. utils.ErrorLog("解析失败:%v", err)
  30771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30772. return
  30773. }
  30774. res.InfRefmsgid = resFour10265.InfRefmsgid
  30775. res.Output = resFour10265.Output
  30776. res.ErrMsg = resFour10265.ErrMsg
  30777. res.Cainfo = resFour10265.Cainfo
  30778. res.WarnMsg = resFour10265.WarnMsg
  30779. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  30780. res.Infcode = infocode
  30781. if infocode == 0 {
  30782. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  30783. } else {
  30784. isSuccess = false
  30785. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  30786. res.Infcode = -1
  30787. res.ErrMsg = resFour10265.ErrMsg
  30788. errlog := &models.HisOrderError{
  30789. UserOrgId: adminUser.CurrentOrgId,
  30790. Ctime: time.Now().Unix(),
  30791. Mtime: time.Now().Unix(),
  30792. Number: chrg_bchno,
  30793. ErrMsg: "",
  30794. Status: 1,
  30795. PatientId: id,
  30796. RecordTime: recordDateTime,
  30797. Stage: 4,
  30798. }
  30799. service.CreateErrMsgLog(errlog)
  30800. }
  30801. }
  30802. if isSuccess {
  30803. res.Infcode = 0
  30804. res.Output.Result = res2.Output.Result
  30805. } else {
  30806. order := &models.HisOrder{
  30807. UserOrgId: adminUser.CurrentOrgId,
  30808. HisPatientId: his.ID,
  30809. PatientId: his.PatientId,
  30810. SettleAccountsDate: recordDateTime,
  30811. Ctime: time.Now().Unix(),
  30812. Mtime: time.Now().Unix(),
  30813. MdtrtId: his.Number,
  30814. PsnNo: his.PsnNo,
  30815. MedType: strconv.FormatInt(reg_type, 10),
  30816. Status: 1,
  30817. Number: chrg_bchno,
  30818. Infcode: res.Infcode,
  30819. WarnMsg: res.WarnMsg,
  30820. Cainfo: res.Cainfo,
  30821. ErrMsg: res.ErrMsg,
  30822. RespondTime: res.RefmsgTime,
  30823. InfRefmsgid: res.InfRefmsgid,
  30824. OrderStatus: 1,
  30825. IsMedicineInsurance: 1,
  30826. SettleType: settle_accounts_type,
  30827. SettleStartTime: start_time,
  30828. SettleEndTime: end_time,
  30829. Creator: roles.AdminUserId,
  30830. Modify: roles.AdminUserId,
  30831. PType: 2,
  30832. Diagnosis: diagnosis_id,
  30833. }
  30834. err = service.CreateOrder(order)
  30835. if err != nil {
  30836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  30837. return
  30838. }
  30839. c.ServeSuccessJSON(map[string]interface{}{
  30840. "failed_code": -10,
  30841. "msg": res2.ErrMsg,
  30842. })
  30843. return
  30844. }
  30845. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30846. 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)
  30847. var dat map[string]interface{}
  30848. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30849. fmt.Println(dat)
  30850. } else {
  30851. fmt.Println(err)
  30852. }
  30853. saveLog(result, request_log, "2204", "上传费用明细")
  30854. userJSONBytes, _ := json.Marshal(dat)
  30855. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30856. utils.ErrorLog("解析失败:%v", err)
  30857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30858. return
  30859. }
  30860. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30861. 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, "", "")
  30862. var dat map[string]interface{}
  30863. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30864. fmt.Println(dat)
  30865. } else {
  30866. fmt.Println(err)
  30867. }
  30868. saveLog(result, request_log, "2204", "上传费用明细")
  30869. userJSONBytes, _ := json.Marshal(dat)
  30870. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30871. utils.ErrorLog("解析失败:%v", err)
  30872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30873. return
  30874. }
  30875. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30876. 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, "", "")
  30877. var dat map[string]interface{}
  30878. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30879. fmt.Println(dat)
  30880. } else {
  30881. fmt.Println(err)
  30882. }
  30883. saveLog(result, request_log, "2204", "上传费用明细")
  30884. userJSONBytes, _ := json.Marshal(dat)
  30885. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30886. utils.ErrorLog("解析失败:%v", err)
  30887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30888. return
  30889. }
  30890. } else if miConfig.MdtrtareaAdmvs == "360100" {
  30891. 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, "", "")
  30892. var dat map[string]interface{}
  30893. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30894. fmt.Println(dat)
  30895. } else {
  30896. fmt.Println(err)
  30897. }
  30898. saveLog(result, request_log, "2204", "上传费用明细")
  30899. userJSONBytes, _ := json.Marshal(dat)
  30900. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30901. utils.ErrorLog("解析失败:%v", err)
  30902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30903. return
  30904. }
  30905. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30906. bytesData, _ := json.Marshal(data)
  30907. var req *http.Request
  30908. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  30909. resp, _ := client.Do(req)
  30910. defer resp.Body.Close()
  30911. body, ioErr := ioutil.ReadAll(resp.Body)
  30912. if ioErr != nil {
  30913. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30915. return
  30916. }
  30917. var respJSON map[string]interface{}
  30918. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30919. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30921. return
  30922. }
  30923. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30924. if status == "0" {
  30925. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30926. c.ServeSuccessJSON(map[string]interface{}{
  30927. "failed_code": -10,
  30928. "msg": err_msg,
  30929. })
  30930. return
  30931. }
  30932. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30933. userJSONBytes, _ := json.Marshal(respJSON)
  30934. fmt.Println("log")
  30935. fmt.Println(string(userJSONBytes))
  30936. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30937. utils.ErrorLog("解析失败:%v", err)
  30938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30939. return
  30940. }
  30941. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30942. bytesData, _ := json.Marshal(data)
  30943. var req *http.Request
  30944. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  30945. resp, _ := client.Do(req)
  30946. defer resp.Body.Close()
  30947. body, ioErr := ioutil.ReadAll(resp.Body)
  30948. if ioErr != nil {
  30949. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30951. return
  30952. }
  30953. var respJSON map[string]interface{}
  30954. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30955. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30957. return
  30958. }
  30959. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30960. if status == "0" {
  30961. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30962. c.ServeSuccessJSON(map[string]interface{}{
  30963. "failed_code": -10,
  30964. "msg": err_msg,
  30965. })
  30966. return
  30967. }
  30968. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30969. userJSONBytes, _ := json.Marshal(respJSON)
  30970. fmt.Println("log")
  30971. fmt.Println(string(userJSONBytes))
  30972. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30973. utils.ErrorLog("解析失败:%v", err)
  30974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30975. return
  30976. }
  30977. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30978. 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, "", "")
  30979. var dat map[string]interface{}
  30980. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30981. fmt.Println(dat)
  30982. } else {
  30983. fmt.Println(err)
  30984. }
  30985. saveLog(result, request_log, "2204", "上传费用明细")
  30986. userJSONBytes, _ := json.Marshal(dat)
  30987. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30988. utils.ErrorLog("解析失败:%v", err)
  30989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30990. return
  30991. }
  30992. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30993. bytesData, _ := json.Marshal(data)
  30994. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  30995. resp, _ := client.Do(req)
  30996. defer resp.Body.Close()
  30997. body, ioErr := ioutil.ReadAll(resp.Body)
  30998. if ioErr != nil {
  30999. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31001. return
  31002. }
  31003. var respJSON map[string]interface{}
  31004. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31005. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31007. return
  31008. }
  31009. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31010. userJSONBytes, _ := json.Marshal(respJSON)
  31011. fmt.Println("log")
  31012. fmt.Println(string(userJSONBytes))
  31013. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31014. utils.ErrorLog("解析失败:%v", err)
  31015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31016. return
  31017. }
  31018. } else {
  31019. if miConfig.MdtrtareaAdmvs == "441202" {
  31020. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  31021. if result3101.Infcode == 0 {
  31022. if len(result3101.Output.Result) > 0 {
  31023. var errMsgs []string
  31024. for _, item := range result3101.Output.Result {
  31025. errMsgs = append(errMsgs, item.VolaCont)
  31026. }
  31027. c.ServeSuccessJSON(map[string]interface{}{
  31028. "failed_code": -10,
  31029. "msg": errMsgs,
  31030. })
  31031. return
  31032. } else {
  31033. 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)
  31034. var dat map[string]interface{}
  31035. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31036. fmt.Println(dat)
  31037. } else {
  31038. fmt.Println(err)
  31039. }
  31040. saveLog(result, request_log, "2204", "上传费用明细")
  31041. userJSONBytes, _ := json.Marshal(dat)
  31042. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31043. utils.ErrorLog("解析失败:%v", err)
  31044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31045. return
  31046. }
  31047. }
  31048. } else {
  31049. c.ServeSuccessJSON(map[string]interface{}{
  31050. "failed_code": -10,
  31051. "msg": result3101.ErrMsg,
  31052. })
  31053. return
  31054. }
  31055. } else if miConfig.MdtrtareaAdmvs == "440205" {
  31056. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  31057. if result3101.Infcode == 0 {
  31058. if len(result3101.Output.Result) > 0 {
  31059. var errMsgs []string
  31060. for _, item := range result3101.Output.Result {
  31061. errMsgs = append(errMsgs, item.VolaCont)
  31062. }
  31063. c.ServeSuccessJSON(map[string]interface{}{
  31064. "failed_code": -10,
  31065. "msg": errMsgs,
  31066. })
  31067. return
  31068. } else {
  31069. 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)
  31070. var dat map[string]interface{}
  31071. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31072. fmt.Println(dat)
  31073. } else {
  31074. fmt.Println(err)
  31075. }
  31076. saveLog(result, request_log, "2204", "上传费用明细")
  31077. userJSONBytes, _ := json.Marshal(dat)
  31078. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31079. utils.ErrorLog("解析失败:%v", err)
  31080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31081. return
  31082. }
  31083. }
  31084. } else {
  31085. c.ServeSuccessJSON(map[string]interface{}{
  31086. "failed_code": -10,
  31087. "msg": result3101.ErrMsg,
  31088. })
  31089. return
  31090. }
  31091. } else {
  31092. if miConfig.Code == "H15049901371" {
  31093. 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)
  31094. var dat map[string]interface{}
  31095. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31096. fmt.Println(dat)
  31097. } else {
  31098. fmt.Println(err)
  31099. }
  31100. saveLog(result, request_log, "2204", "上传费用明细")
  31101. userJSONBytes, _ := json.Marshal(dat)
  31102. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  31103. utils.ErrorLog("解析失败:%v", err)
  31104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31105. return
  31106. }
  31107. res.InfRefmsgid = resFour10265.InfRefmsgid
  31108. res.Output = resFour10265.Output
  31109. res.ErrMsg = resFour10265.ErrMsg
  31110. res.Cainfo = resFour10265.Cainfo
  31111. res.WarnMsg = resFour10265.WarnMsg
  31112. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  31113. res.Infcode = infocode
  31114. } else {
  31115. if miConfig.Code == "H44030903432" || miConfig.Code == "H44030501364" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" || miConfig.Code == "H44090200998" {
  31116. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  31117. if result3101.Infcode == 0 {
  31118. if len(result3101.Output.Result) > 0 {
  31119. c.ServeSuccessJSON(map[string]interface{}{
  31120. "failed_code": -10,
  31121. "failed_type": 100,
  31122. "warm_type": 1,
  31123. "msg": result3101,
  31124. })
  31125. return
  31126. } else {
  31127. 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)
  31128. var dat map[string]interface{}
  31129. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31130. fmt.Println(dat)
  31131. } else {
  31132. fmt.Println(err)
  31133. }
  31134. saveLog(result, request_log, "2204", "上传费用明细")
  31135. userJSONBytes, _ := json.Marshal(dat)
  31136. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31137. utils.ErrorLog("解析失败:%v", err)
  31138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31139. return
  31140. }
  31141. }
  31142. } else {
  31143. c.ServeSuccessJSON(map[string]interface{}{
  31144. "failed_code": -10,
  31145. "msg": result3101.ErrMsg,
  31146. })
  31147. return
  31148. }
  31149. } else {
  31150. 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)
  31151. var dat map[string]interface{}
  31152. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31153. fmt.Println(dat)
  31154. } else {
  31155. fmt.Println(err)
  31156. }
  31157. saveLog(result, request_log, "2204", "上传费用明细")
  31158. userJSONBytes, _ := json.Marshal(dat)
  31159. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31160. utils.ErrorLog("解析失败:%v", err)
  31161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31162. return
  31163. }
  31164. }
  31165. }
  31166. }
  31167. }
  31168. var total_two float64
  31169. if res.Infcode == -1 {
  31170. errlog := &models.HisOrderError{
  31171. UserOrgId: adminUser.CurrentOrgId,
  31172. Ctime: time.Now().Unix(),
  31173. Mtime: time.Now().Unix(),
  31174. Number: chrg_bchno,
  31175. ErrMsg: res.ErrMsg,
  31176. Status: 1,
  31177. PatientId: id,
  31178. RecordTime: recordDateTime,
  31179. Stage: 4,
  31180. }
  31181. service.CreateErrMsgLog(errlog)
  31182. c.ServeSuccessJSON(map[string]interface{}{
  31183. "failed_code": -10,
  31184. "msg": res.ErrMsg,
  31185. })
  31186. return
  31187. }
  31188. if res.Infcode == 0 {
  31189. order := &models.HisOrder{
  31190. UserOrgId: adminUser.CurrentOrgId,
  31191. HisPatientId: his.ID,
  31192. PatientId: his.PatientId,
  31193. SettleAccountsDate: recordDateTime,
  31194. Ctime: time.Now().Unix(),
  31195. Mtime: time.Now().Unix(),
  31196. MdtrtId: his.Number,
  31197. PsnNo: his.PsnNo,
  31198. MedType: strconv.FormatInt(reg_type, 10),
  31199. Status: 1,
  31200. Number: chrg_bchno,
  31201. Infcode: res.Infcode,
  31202. WarnMsg: res.WarnMsg,
  31203. Cainfo: res.Cainfo,
  31204. ErrMsg: res.ErrMsg,
  31205. RespondTime: res.RefmsgTime,
  31206. InfRefmsgid: res.InfRefmsgid,
  31207. OrderStatus: 1,
  31208. IsMedicineInsurance: 1,
  31209. SettleType: settle_accounts_type,
  31210. SettleStartTime: start_time,
  31211. SettleEndTime: end_time,
  31212. Creator: roles.AdminUserId,
  31213. Modify: roles.AdminUserId,
  31214. PType: 2,
  31215. Diagnosis: diagnosis_id,
  31216. }
  31217. err = service.CreateOrder(order)
  31218. if err != nil {
  31219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  31220. return
  31221. }
  31222. for _, item := range res.Output.Result {
  31223. temp := strings.Split(item.FeedetlSn, "-")
  31224. var advice_id int64 = 0
  31225. var project_id int64 = 0
  31226. var types int64 = 0
  31227. id, _ := strconv.ParseInt(temp[2], 10, 64)
  31228. types, _ = strconv.ParseInt(temp[1], 10, 64)
  31229. if temp[1] == "1" {
  31230. advice_id = id
  31231. project_id = 0
  31232. } else if temp[1] == "2" {
  31233. advice_id = 0
  31234. project_id = id
  31235. }
  31236. total_two = total_two + item.DetItemFeeSumamt
  31237. info := &models.HisOrderInfo{
  31238. OrderNumber: order.Number,
  31239. FeedetlSn: item.FeedetlSn,
  31240. UploadDate: time.Now().Unix(),
  31241. AdviceId: advice_id,
  31242. DetItemFeeSumamt: item.DetItemFeeSumamt,
  31243. Cnt: item.Cnt,
  31244. Pric: float64(item.Pric),
  31245. PatientId: his.PatientId,
  31246. PricUplmtAmt: item.PricUplmtAmt,
  31247. SelfpayProp: item.SelfpayProp,
  31248. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  31249. OverlmtAmt: item.OverlmtAmt,
  31250. PreselfpayAmt: item.PreselfpayAmt,
  31251. BasMednFlag: item.BasMednFlag,
  31252. MedChrgitmType: item.MedChrgitmType,
  31253. HiNegoDrugFlag: item.HiNegoDrugFlag,
  31254. Status: 1,
  31255. Memo: item.Memo,
  31256. Mtime: time.Now().Unix(),
  31257. InscpScpAmt: item.InscpScpAmt,
  31258. DrtReimFlag: item.DrtReimFlag,
  31259. Ctime: time.Now().Unix(),
  31260. ListSpItemFlag: item.ListSpItemFlag,
  31261. ChldMedcFlag: item.ChldMedcFlag,
  31262. LmtUsedFlag: item.LmtUsedFlag,
  31263. ChrgitmLv: item.ChrgitmLv,
  31264. UserOrgId: adminUser.CurrentOrgId,
  31265. HisPatientId: his.ID,
  31266. OrderId: order.ID,
  31267. ProjectId: project_id,
  31268. Type: types,
  31269. }
  31270. service.CreateOrderInfo(info)
  31271. }
  31272. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  31273. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  31274. var total float64
  31275. for _, item := range prescriptions {
  31276. if item.Type == 1 { //药品
  31277. for _, subItem := range item.HisDoctorAdviceInfo {
  31278. price, _ := strconv.ParseFloat(fmt.Sprintf("%.4f", subItem.Price), 64)
  31279. total_one := price * subItem.PrescribingNumber
  31280. fmt.Println("subItem")
  31281. fmt.Println(subItem.Price)
  31282. fmt.Println("price")
  31283. fmt.Println(price)
  31284. fmt.Println("total_one")
  31285. fmt.Println(total_one)
  31286. total = total + total_one
  31287. fmt.Println(total)
  31288. }
  31289. }
  31290. if item.Type == 2 { //项目
  31291. for _, subItem := range item.HisPrescriptionProject {
  31292. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  31293. price, _ := strconv.ParseFloat(fmt.Sprintf("%.4f", subItem.Price), 64)
  31294. total_one := price * cnt
  31295. total = total + total_one
  31296. }
  31297. }
  31298. }
  31299. allTotal := fmt.Sprintf("%.2f", total)
  31300. if res.Infcode == 0 {
  31301. var rf []*ResultFive
  31302. json.Unmarshal([]byte(his.Iinfo), &rf)
  31303. chrg_bchno := chrg_bchno
  31304. cert_no := his.Certno
  31305. var insutypes []string
  31306. var insutype string
  31307. var is390 int = 0
  31308. var is310 int = 0
  31309. for _, item := range rf {
  31310. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  31311. insutypes = append(insutypes, item.Insutype)
  31312. }
  31313. }
  31314. if len(insutypes) == 1 {
  31315. insutype = insutypes[0]
  31316. } else {
  31317. for _, i := range insutypes {
  31318. if i == "390" {
  31319. is390 = 1
  31320. }
  31321. if i == "310" {
  31322. is310 = 1
  31323. }
  31324. }
  31325. }
  31326. if is390 == 1 {
  31327. insutype = "390"
  31328. }
  31329. if is310 == 1 {
  31330. insutype = "310"
  31331. }
  31332. if len(insutypes) == 0 {
  31333. insutype = "390"
  31334. }
  31335. if len(insutypes) == 2 {
  31336. insutype = strconv.FormatInt(his.SocialType, 10)
  31337. }
  31338. //insutype = "390"
  31339. if his.IdCardType == 1 {
  31340. cert_no = his.MedicalInsuranceNumber
  31341. } else {
  31342. cert_no = his.Certno
  31343. }
  31344. var res ResultSeven
  31345. var res10633 ResultSeven10633
  31346. var ahres ResultSevenAH
  31347. var resSeven10265 ResultSeven10265
  31348. var resSeven10265Two ResultSeven10265Two
  31349. var resSeven10633Three ResultSeven10633Three
  31350. var gzresSeven10265Two GZResultSeven10265Two
  31351. if miConfig.MdtrtareaAdmvs == "421300" {
  31352. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  31353. api := "http://192.168.124.4:9532/" + "hbyb/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=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31360. resp, requestErr := http.Get(api)
  31361. if requestErr != nil {
  31362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31363. return
  31364. }
  31365. body, ioErr := ioutil.ReadAll(resp.Body)
  31366. if ioErr != nil {
  31367. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31369. return
  31370. }
  31371. var respJSON map[string]interface{}
  31372. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31373. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31375. return
  31376. }
  31377. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31378. result, _ := json.Marshal(respJSON)
  31379. fmt.Println("log")
  31380. fmt.Println(string(result))
  31381. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31382. utils.ErrorLog("解析失败:%v", err)
  31383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31384. return
  31385. }
  31386. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31387. if reg_type == 11 && his.Insutype == "390" {
  31388. reg_type = 110104
  31389. }
  31390. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31391. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31392. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31393. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31394. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31395. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31396. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31397. resp, requestErr := http.Get(api)
  31398. if requestErr != nil {
  31399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31400. return
  31401. }
  31402. body, ioErr := ioutil.ReadAll(resp.Body)
  31403. if ioErr != nil {
  31404. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31406. return
  31407. }
  31408. var respJSON map[string]interface{}
  31409. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31410. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31412. return
  31413. }
  31414. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31415. result, _ := json.Marshal(respJSON)
  31416. fmt.Println("log")
  31417. fmt.Println(string(result))
  31418. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31419. utils.ErrorLog("解析失败:%v", err)
  31420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31421. return
  31422. }
  31423. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31424. if reg_type == 11 && his.Insutype == "390" {
  31425. reg_type = 110104
  31426. }
  31427. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31428. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31429. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31430. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31431. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31432. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31433. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31434. resp, requestErr := http.Get(api)
  31435. if requestErr != nil {
  31436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31437. return
  31438. }
  31439. body, ioErr := ioutil.ReadAll(resp.Body)
  31440. if ioErr != nil {
  31441. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31443. return
  31444. }
  31445. var respJSON map[string]interface{}
  31446. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31447. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31449. return
  31450. }
  31451. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31452. result, _ := json.Marshal(respJSON)
  31453. fmt.Println("log")
  31454. fmt.Println(string(result))
  31455. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31456. utils.ErrorLog("解析失败:%v", err)
  31457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31458. return
  31459. }
  31460. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31461. if reg_type == 11 && his.Insutype == "390" {
  31462. reg_type = 110104
  31463. }
  31464. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31465. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31466. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31467. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31468. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31469. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31470. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31471. resp, requestErr := http.Get(api)
  31472. if requestErr != nil {
  31473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31474. return
  31475. }
  31476. body, ioErr := ioutil.ReadAll(resp.Body)
  31477. if ioErr != nil {
  31478. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31480. return
  31481. }
  31482. var respJSON map[string]interface{}
  31483. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31484. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31486. return
  31487. }
  31488. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31489. result, _ := json.Marshal(respJSON)
  31490. fmt.Println("log")
  31491. fmt.Println(string(result))
  31492. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31493. utils.ErrorLog("解析失败:%v", err)
  31494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31495. return
  31496. }
  31497. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  31498. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  31499. var result3101 Result3101
  31500. //utils.ErrorLog("解析失败:%v", result3101)
  31501. result3101.Infcode = "0"
  31502. if result3101.Infcode == "0" {
  31503. if len(result3101.Output.Result) > 0 {
  31504. var errMsgs []string
  31505. for _, item := range result3101.Output.Result {
  31506. errMsgs = append(errMsgs, item.VolaCont)
  31507. }
  31508. c.ServeSuccessJSON(map[string]interface{}{
  31509. "failed_code": -10,
  31510. "msg": errMsgs,
  31511. })
  31512. return
  31513. } else {
  31514. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31515. if his.IdCardType != 4 {
  31516. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  31517. bas := strings.Split(psn_info.CardInfo, "|")
  31518. if his.IdCardType == 1 {
  31519. cert_no = bas[2]
  31520. } else {
  31521. cert_no = bas[1]
  31522. }
  31523. } else {
  31524. cert_no = his.Certno
  31525. }
  31526. //江苏地区国家医保医疗类别
  31527. //职工透析:医疗类别选特殊情况门诊9933
  31528. //居民血透门慢: 医疗类别选门诊慢病1402
  31529. //var med_type string
  31530. //if his.Insutype == "310" {
  31531. // if reg_type == 14 {
  31532. // med_type = "9933"
  31533. // } else if reg_type == 11 {
  31534. // med_type = "11"
  31535. //
  31536. // }
  31537. //} else if his.Insutype == "390" {
  31538. // if reg_type == 14 {
  31539. // med_type = "1402"
  31540. // } else if reg_type == 11 {
  31541. // med_type = "11"
  31542. // }
  31543. //}
  31544. var api string
  31545. if miConfig.MdtrtareaAdmvs == "320830" {
  31546. api = miConfig.AppSecret + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31547. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31548. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31549. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31550. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31551. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31552. "&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
  31553. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31554. } else if miConfig.MdtrtareaAdmvs == "320921" {
  31555. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31556. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31557. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31558. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31559. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31560. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31561. "&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
  31562. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31563. } else {
  31564. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31565. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31566. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31567. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31568. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31569. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31570. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31571. "&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
  31572. }
  31573. resp, requestErr := http.Get(api)
  31574. if requestErr != nil {
  31575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31576. return
  31577. }
  31578. body, ioErr := ioutil.ReadAll(resp.Body)
  31579. if ioErr != nil {
  31580. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31582. return
  31583. }
  31584. var respJSON map[string]interface{}
  31585. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31586. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31588. return
  31589. }
  31590. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31591. result, _ := json.Marshal(respJSON)
  31592. fmt.Println("log")
  31593. fmt.Println(string(result))
  31594. {
  31595. if miConfig.MdtrtareaAdmvs == "320830" {
  31596. if strings.HasPrefix(his.InsuplcAdmdvs[0:3], "320") && !strings.HasPrefix(his.InsuplcAdmdvs[0:4], "3208") {
  31597. fmt.Println("log")
  31598. fmt.Println(string(result))
  31599. if err := json.Unmarshal([]byte(result), &resSeven10633Three); err != nil {
  31600. utils.ErrorLog("解析失败:%v", err)
  31601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31602. return
  31603. }
  31604. res10633.InfRefmsgid = resSeven10633Three.InfRefmsgid
  31605. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.AcctMulaidPay, 64)
  31606. res10633.Output.Setlinfo.AcctPay = resSeven10633Three.Output.Setlinfo.AcctPay
  31607. res10633.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31608. res10633.Output.Setlinfo.ActPayDedc = resSeven10633Three.Output.Setlinfo.ActPayDedc
  31609. res10633.Output.Setlinfo.Age = resSeven10633Three.Output.Setlinfo.Age
  31610. res10633.Output.Setlinfo.Balc = resSeven10633Three.Output.Setlinfo.Balc
  31611. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31612. res10633.Output.Setlinfo.Certno = resSeven10633Three.Output.Setlinfo.Certno
  31613. res10633.Output.Setlinfo.ClrOptins = resSeven10633Three.Output.Setlinfo.ClrOptins
  31614. res10633.Output.Setlinfo.ClrType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31615. res10633.Output.Setlinfo.ClrWay = resSeven10633Three.Output.Setlinfo.ClrOptins
  31616. res10633.Output.Setlinfo.CvlservFlag = resSeven10633Three.Output.Setlinfo.ClrOptins
  31617. res10633.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31618. res10633.Output.Setlinfo.FulamtOwnpayAmt = resSeven10633Three.Output.Setlinfo.FulamtOwnpayAmt
  31619. res10633.Output.Setlinfo.FundPaySumamt = resSeven10633Three.Output.Setlinfo.FundPaySumamt
  31620. res10633.Output.Setlinfo.Gend = resSeven10633Three.Output.Setlinfo.Gend
  31621. res10633.Output.Setlinfo.HifesPay = resSeven10633Three.Output.Setlinfo.HifesPay
  31622. res10633.Output.Setlinfo.HifmiPay = resSeven10633Three.Output.Setlinfo.HifmiPay
  31623. res10633.Output.Setlinfo.HifpPay = resSeven10633Three.Output.Setlinfo.HifpPay
  31624. //HospPartAmt, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.HospPartAmt, 64)
  31625. res10633.Output.Setlinfo.InscpScpAmt = resSeven10633Three.Output.Setlinfo.InscpScpAmt
  31626. res10633.Output.Setlinfo.Insutype = resSeven10633Three.Output.Setlinfo.Insutype
  31627. res10633.Output.Setlinfo.MafPay = resSeven10633Three.Output.Setlinfo.MafPay
  31628. res10633.Output.Setlinfo.MdtrtCertType = resSeven10633Three.Output.Setlinfo.MdtrtCertType
  31629. res10633.Output.Setlinfo.HifobPay = resSeven10633Three.Output.Setlinfo.HifobPay
  31630. res10633.Output.Setlinfo.MdtrtID = resSeven10633Three.Output.Setlinfo.MdtrtID
  31631. res10633.Output.Setlinfo.MedType = resSeven10633Three.Output.Setlinfo.MedType
  31632. res10633.Output.Setlinfo.MedfeeSumamt = resSeven10633Three.Output.Setlinfo.MedfeeSumamt
  31633. res10633.Output.Setlinfo.MedinsSetlID = resSeven10633Three.Output.Setlinfo.MedinsSetlID
  31634. res10633.Output.Setlinfo.Naty = resSeven10633Three.Output.Setlinfo.Naty
  31635. res10633.Output.Setlinfo.OthPay = resSeven10633Three.Output.Setlinfo.OthPay
  31636. res10633.Output.Setlinfo.OverlmtSelfpay = resSeven10633Three.Output.Setlinfo.OverlmtSelfpay
  31637. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.PoolPropSelfpay, 64)
  31638. res10633.Output.Setlinfo.PreselfpayAmt = resSeven10633Three.Output.Setlinfo.PreselfpayAmt
  31639. res10633.Output.Setlinfo.PsnCashPay = resSeven10633Three.Output.Setlinfo.PsnCashPay
  31640. res10633.Output.Setlinfo.PsnCertType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31641. res10633.Output.Setlinfo.PsnName = resSeven10633Three.Output.Setlinfo.PsnName
  31642. res10633.Output.Setlinfo.PsnNo = resSeven10633Three.Output.Setlinfo.PsnNo
  31643. res10633.Output.Setlinfo.PsnPartAmt = resSeven10633Three.Output.Setlinfo.PsnPartAmt
  31644. res10633.Output.Setlinfo.PsnType = resSeven10633Three.Output.Setlinfo.PsnType
  31645. res10633.Output.Setlinfo.SetlID = resSeven10633Three.Output.Setlinfo.SetlID
  31646. res10633.Output.Setlinfo.SetlTime = resSeven10633Three.Output.Setlinfo.SetlTime
  31647. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31648. res10633.ErrMsg = resSeven10633Three.ErrMsg
  31649. res10633.Cainfo = resSeven10633Three.Cainfo
  31650. res10633.WarnMsg = resSeven10633Three.WarnMsg
  31651. infocode, _ := strconv.ParseInt(resSeven10633Three.Infcode, 10, 64)
  31652. res10633.Infcode =infocode
  31653. } else {
  31654. if err := json.Unmarshal([]byte(result), &resSeven10633Three); err != nil {
  31655. utils.ErrorLog("解析失败:%v", err)
  31656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31657. return
  31658. }
  31659. res10633.InfRefmsgid = resSeven10633Three.InfRefmsgid
  31660. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  31661. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  31662. res10633.Output.Setlinfo.AcctPay = resSeven10633Three.Output.Setlinfo.AcctPay
  31663. res10633.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31664. res10633.Output.Setlinfo.ActPayDedc = resSeven10633Three.Output.Setlinfo.ActPayDedc
  31665. res10633.Output.Setlinfo.Age = resSeven10633Three.Output.Setlinfo.Age
  31666. res10633.Output.Setlinfo.Balc = resSeven10633Three.Output.Setlinfo.Balc
  31667. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31668. res10633.Output.Setlinfo.Certno = resSeven10633Three.Output.Setlinfo.Certno
  31669. res10633.Output.Setlinfo.ClrOptins = resSeven10633Three.Output.Setlinfo.ClrOptins
  31670. res10633.Output.Setlinfo.ClrType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31671. res10633.Output.Setlinfo.ClrWay = resSeven10633Three.Output.Setlinfo.ClrOptins
  31672. res10633.Output.Setlinfo.CvlservFlag = resSeven10633Three.Output.Setlinfo.ClrOptins
  31673. res10633.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31674. res10633.Output.Setlinfo.FulamtOwnpayAmt = resSeven10633Three.Output.Setlinfo.FulamtOwnpayAmt
  31675. res10633.Output.Setlinfo.FundPaySumamt = resSeven10633Three.Output.Setlinfo.FundPaySumamt
  31676. res10633.Output.Setlinfo.Gend = resSeven10633Three.Output.Setlinfo.Gend
  31677. res10633.Output.Setlinfo.HifesPay = resSeven10633Three.Output.Setlinfo.HifesPay
  31678. res10633.Output.Setlinfo.HifmiPay = resSeven10633Three.Output.Setlinfo.HifmiPay
  31679. res10633.Output.Setlinfo.HifpPay = resSeven10633Three.Output.Setlinfo.HifpPay
  31680. res10633.Output.Setlinfo.InscpScpAmt = resSeven10633Three.Output.Setlinfo.InscpScpAmt
  31681. res10633.Output.Setlinfo.Insutype = resSeven10633Three.Output.Setlinfo.Insutype
  31682. res10633.Output.Setlinfo.MafPay = resSeven10633Three.Output.Setlinfo.MafPay
  31683. res10633.Output.Setlinfo.MdtrtCertType = resSeven10633Three.Output.Setlinfo.MdtrtCertType
  31684. res10633.Output.Setlinfo.HifobPay = resSeven10633Three.Output.Setlinfo.HifobPay
  31685. res10633.Output.Setlinfo.MdtrtID = resSeven10633Three.Output.Setlinfo.MdtrtID
  31686. res10633.Output.Setlinfo.MedType = resSeven10633Three.Output.Setlinfo.MedType
  31687. res10633.Output.Setlinfo.MedfeeSumamt = resSeven10633Three.Output.Setlinfo.MedfeeSumamt
  31688. res10633.Output.Setlinfo.MedinsSetlID = resSeven10633Three.Output.Setlinfo.MedinsSetlID
  31689. res10633.Output.Setlinfo.Naty = resSeven10633Three.Output.Setlinfo.Naty
  31690. res10633.Output.Setlinfo.OthPay = resSeven10633Three.Output.Setlinfo.OthPay
  31691. res10633.Output.Setlinfo.OverlmtSelfpay = resSeven10633Three.Output.Setlinfo.OverlmtSelfpay
  31692. res10633.Output.Setlinfo.PreselfpayAmt = resSeven10633Three.Output.Setlinfo.PreselfpayAmt
  31693. res10633.Output.Setlinfo.PsnCashPay = resSeven10633Three.Output.Setlinfo.PsnCashPay
  31694. res10633.Output.Setlinfo.PsnCertType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31695. res10633.Output.Setlinfo.PsnName = resSeven10633Three.Output.Setlinfo.PsnName
  31696. res10633.Output.Setlinfo.PsnNo = resSeven10633Three.Output.Setlinfo.PsnNo
  31697. res10633.Output.Setlinfo.PsnPartAmt = resSeven10633Three.Output.Setlinfo.PsnPartAmt
  31698. res10633.Output.Setlinfo.PsnType = resSeven10633Three.Output.Setlinfo.PsnType
  31699. res10633.Output.Setlinfo.SetlID = resSeven10633Three.Output.Setlinfo.SetlID
  31700. res10633.Output.Setlinfo.SetlTime = resSeven10633Three.Output.Setlinfo.SetlTime
  31701. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31702. res10633.ErrMsg = resSeven10633Three.ErrMsg
  31703. res10633.Cainfo = resSeven10633Three.Cainfo
  31704. res10633.WarnMsg = resSeven10633Three.WarnMsg
  31705. infocode, _ := strconv.ParseInt(resSeven10633Three.Infcode, 10, 64)
  31706. res10633.Infcode =infocode
  31707. }
  31708. } else {
  31709. fmt.Println("log")
  31710. //fmt.Println(string(result))
  31711. if strings.HasPrefix(his.InsuplcAdmdvs[0:3], "320") && !strings.HasPrefix(his.InsuplcAdmdvs[0:4], "3209") {
  31712. if err := json.Unmarshal([]byte(result), &resSeven10633Three); err != nil {
  31713. utils.ErrorLog("解析失败:%v", err)
  31714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31715. return
  31716. }
  31717. res.InfRefmsgid = resSeven10633Three.InfRefmsgid
  31718. res10633.Output.Setlinfo.AcctPay = resSeven10633Three.Output.Setlinfo.AcctPay
  31719. res10633.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31720. res10633.Output.Setlinfo.ActPayDedc = resSeven10633Three.Output.Setlinfo.ActPayDedc
  31721. res10633.Output.Setlinfo.Age = resSeven10633Three.Output.Setlinfo.Age
  31722. res10633.Output.Setlinfo.Balc = resSeven10633Three.Output.Setlinfo.Balc
  31723. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31724. res10633.Output.Setlinfo.Certno = resSeven10633Three.Output.Setlinfo.Certno
  31725. res10633.Output.Setlinfo.ClrOptins = resSeven10633Three.Output.Setlinfo.ClrOptins
  31726. res10633.Output.Setlinfo.ClrType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31727. res10633.Output.Setlinfo.ClrWay = resSeven10633Three.Output.Setlinfo.ClrOptins
  31728. res10633.Output.Setlinfo.CvlservFlag = resSeven10633Three.Output.Setlinfo.ClrOptins
  31729. res10633.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31730. res10633.Output.Setlinfo.FulamtOwnpayAmt = resSeven10633Three.Output.Setlinfo.FulamtOwnpayAmt
  31731. res10633.Output.Setlinfo.FundPaySumamt = resSeven10633Three.Output.Setlinfo.FundPaySumamt
  31732. res10633.Output.Setlinfo.Gend = resSeven10633Three.Output.Setlinfo.Gend
  31733. res10633.Output.Setlinfo.HifesPay = resSeven10633Three.Output.Setlinfo.HifesPay
  31734. res10633.Output.Setlinfo.HifmiPay = resSeven10633Three.Output.Setlinfo.HifmiPay
  31735. res10633.Output.Setlinfo.HifpPay = resSeven10633Three.Output.Setlinfo.HifpPay
  31736. res10633.Output.Setlinfo.InscpScpAmt = resSeven10633Three.Output.Setlinfo.InscpScpAmt
  31737. res10633.Output.Setlinfo.Insutype = resSeven10633Three.Output.Setlinfo.Insutype
  31738. res10633.Output.Setlinfo.MafPay = resSeven10633Three.Output.Setlinfo.MafPay
  31739. res10633.Output.Setlinfo.MdtrtCertType = resSeven10633Three.Output.Setlinfo.MdtrtCertType
  31740. res10633.Output.Setlinfo.HifobPay = resSeven10633Three.Output.Setlinfo.HifobPay
  31741. res10633.Output.Setlinfo.MdtrtID = resSeven10633Three.Output.Setlinfo.MdtrtID
  31742. res10633.Output.Setlinfo.MedType = resSeven10633Three.Output.Setlinfo.MedType
  31743. res10633.Output.Setlinfo.MedfeeSumamt = resSeven10633Three.Output.Setlinfo.MedfeeSumamt
  31744. res10633.Output.Setlinfo.MedinsSetlID = resSeven10633Three.Output.Setlinfo.MedinsSetlID
  31745. res10633.Output.Setlinfo.Naty = resSeven10633Three.Output.Setlinfo.Naty
  31746. res10633.Output.Setlinfo.OthPay = resSeven10633Three.Output.Setlinfo.OthPay
  31747. res10633.Output.Setlinfo.OverlmtSelfpay = resSeven10633Three.Output.Setlinfo.OverlmtSelfpay
  31748. res10633.Output.Setlinfo.PreselfpayAmt = resSeven10633Three.Output.Setlinfo.PreselfpayAmt
  31749. res10633.Output.Setlinfo.PsnCashPay = resSeven10633Three.Output.Setlinfo.PsnCashPay
  31750. res10633.Output.Setlinfo.PsnCertType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31751. res10633.Output.Setlinfo.PsnName = resSeven10633Three.Output.Setlinfo.PsnName
  31752. res10633.Output.Setlinfo.PsnNo = resSeven10633Three.Output.Setlinfo.PsnNo
  31753. res10633.Output.Setlinfo.PsnPartAmt = resSeven10633Three.Output.Setlinfo.PsnPartAmt
  31754. res10633.Output.Setlinfo.PsnType = resSeven10633Three.Output.Setlinfo.PsnType
  31755. res10633.Output.Setlinfo.SetlID = resSeven10633Three.Output.Setlinfo.SetlID
  31756. res10633.Output.Setlinfo.SetlTime = resSeven10633Three.Output.Setlinfo.SetlTime
  31757. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31758. res10633.ErrMsg = resSeven10633Three.ErrMsg
  31759. res10633.Cainfo = resSeven10633Three.Cainfo
  31760. res10633.WarnMsg = resSeven10633Three.WarnMsg
  31761. infocode, _ := strconv.ParseInt(resSeven10633Three.Infcode, 10, 64)
  31762. res10633.Infcode =infocode
  31763. } else {
  31764. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  31765. utils.ErrorLog("解析失败:%v", err)
  31766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31767. return
  31768. }
  31769. res10633.InfRefmsgid = resSeven10633Three.InfRefmsgid
  31770. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  31771. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPayv
  31772. res10633.Output.Setlinfo.AcctPay = resSeven10633Three.Output.Setlinfo.AcctPay
  31773. res10633.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31774. res10633.Output.Setlinfo.ActPayDedc = resSeven10633Three.Output.Setlinfo.ActPayDedc
  31775. res10633.Output.Setlinfo.Age = resSeven10633Three.Output.Setlinfo.Age
  31776. res10633.Output.Setlinfo.Balc = resSeven10633Three.Output.Setlinfo.Balc
  31777. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31778. res10633.Output.Setlinfo.Certno = resSeven10633Three.Output.Setlinfo.Certno
  31779. res10633.Output.Setlinfo.ClrOptins = resSeven10633Three.Output.Setlinfo.ClrOptins
  31780. res10633.Output.Setlinfo.ClrType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31781. res10633.Output.Setlinfo.ClrWay = resSeven10633Three.Output.Setlinfo.ClrOptins
  31782. res10633.Output.Setlinfo.CvlservFlag = resSeven10633Three.Output.Setlinfo.ClrOptins
  31783. res10633.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31784. res10633.Output.Setlinfo.FulamtOwnpayAmt = resSeven10633Three.Output.Setlinfo.FulamtOwnpayAmt
  31785. res10633.Output.Setlinfo.FundPaySumamt = resSeven10633Three.Output.Setlinfo.FundPaySumamt
  31786. res10633.Output.Setlinfo.Gend = resSeven10633Three.Output.Setlinfo.Gend
  31787. res10633.Output.Setlinfo.HifesPay = resSeven10633Three.Output.Setlinfo.HifesPay
  31788. res10633.Output.Setlinfo.HifmiPay = resSeven10633Three.Output.Setlinfo.HifmiPay
  31789. res10633.Output.Setlinfo.HifpPay = resSeven10633Three.Output.Setlinfo.HifpPay
  31790. res10633.Output.Setlinfo.InscpScpAmt = resSeven10633Three.Output.Setlinfo.InscpScpAmt
  31791. res10633.Output.Setlinfo.Insutype = resSeven10633Three.Output.Setlinfo.Insutype
  31792. res10633.Output.Setlinfo.MafPay = resSeven10633Three.Output.Setlinfo.MafPay
  31793. res10633.Output.Setlinfo.MdtrtCertType = resSeven10633Three.Output.Setlinfo.MdtrtCertType
  31794. res10633.Output.Setlinfo.HifobPay = resSeven10633Three.Output.Setlinfo.HifobPay
  31795. res10633.Output.Setlinfo.MdtrtID = resSeven10633Three.Output.Setlinfo.MdtrtID
  31796. res10633.Output.Setlinfo.MedType = resSeven10633Three.Output.Setlinfo.MedType
  31797. res10633.Output.Setlinfo.MedfeeSumamt = resSeven10633Three.Output.Setlinfo.MedfeeSumamt
  31798. res10633.Output.Setlinfo.MedinsSetlID = resSeven10633Three.Output.Setlinfo.MedinsSetlID
  31799. res10633.Output.Setlinfo.Naty = resSeven10633Three.Output.Setlinfo.Naty
  31800. res10633.Output.Setlinfo.OthPay = resSeven10633Three.Output.Setlinfo.OthPay
  31801. res10633.Output.Setlinfo.OverlmtSelfpay = resSeven10633Three.Output.Setlinfo.OverlmtSelfpay
  31802. res10633.Output.Setlinfo.PreselfpayAmt = resSeven10633Three.Output.Setlinfo.PreselfpayAmt
  31803. res10633.Output.Setlinfo.PsnCashPay = resSeven10633Three.Output.Setlinfo.PsnCashPay
  31804. res10633.Output.Setlinfo.PsnCertType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31805. res10633.Output.Setlinfo.PsnName = resSeven10633Three.Output.Setlinfo.PsnName
  31806. res10633.Output.Setlinfo.PsnNo = resSeven10633Three.Output.Setlinfo.PsnNo
  31807. res10633.Output.Setlinfo.PsnPartAmt = resSeven10633Three.Output.Setlinfo.PsnPartAmt
  31808. res10633.Output.Setlinfo.PsnType = resSeven10633Three.Output.Setlinfo.PsnType
  31809. res10633.Output.Setlinfo.SetlID = resSeven10633Three.Output.Setlinfo.SetlID
  31810. res10633.Output.Setlinfo.SetlTime = resSeven10633Three.Output.Setlinfo.SetlTime
  31811. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31812. res10633.ErrMsg = resSeven10633Three.ErrMsg
  31813. res10633.Cainfo = resSeven10633Three.Cainfo
  31814. res10633.WarnMsg = resSeven10633Three.WarnMsg
  31815. infocode, _ := strconv.ParseInt(resSeven10633Three.Infcode, 10, 64)
  31816. res10633.Infcode =infocode
  31817. }
  31818. }
  31819. }
  31820. }
  31821. }
  31822. } else if miConfig.MdtrtareaAdmvs == "150404" {
  31823. psn_info, _ := service.GetPsnByPatientId(id)
  31824. var verify_number string
  31825. if psn_info.IdCardType == 4 {
  31826. verify_number = psn_info.VerifyNumber
  31827. } else if psn_info.IdCardType == 1 {
  31828. bas := strings.Split(psn_info.CardInfo, "|")
  31829. cardNumber := bas[2]
  31830. verify_number = cardNumber
  31831. } else {
  31832. psn_info.IdCardType = 2
  31833. verify_number = psn_info.Certno
  31834. }
  31835. var api string
  31836. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31837. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  31838. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31839. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31840. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  31841. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31842. "&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
  31843. resp, requestErr := http.Get(api)
  31844. if requestErr != nil {
  31845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31846. return
  31847. }
  31848. body, ioErr := ioutil.ReadAll(resp.Body)
  31849. if ioErr != nil {
  31850. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31852. return
  31853. }
  31854. var respJSON map[string]interface{}
  31855. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31856. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31858. return
  31859. }
  31860. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31861. result, _ := json.Marshal(respJSON)
  31862. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  31863. utils.ErrorLog("解析失败:%v", err)
  31864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31865. return
  31866. }
  31867. res.InfRefmsgid = resSeven10265.InfRefmsgid
  31868. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  31869. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  31870. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  31871. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  31872. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  31873. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  31874. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  31875. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  31876. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  31877. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  31878. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  31879. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  31880. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  31881. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  31882. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  31883. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  31884. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  31885. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  31886. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  31887. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31888. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  31889. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  31890. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  31891. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  31892. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  31893. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  31894. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  31895. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  31896. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  31897. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  31898. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  31899. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  31900. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  31901. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  31902. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  31903. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  31904. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  31905. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  31906. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  31907. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  31908. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  31909. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  31910. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  31911. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  31912. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  31913. res.ErrMsg = resSeven10265.ErrMsg
  31914. res.Cainfo = resSeven10265.Cainfo
  31915. res.WarnMsg = resSeven10265.WarnMsg
  31916. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  31917. res.Infcode = infocode
  31918. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31919. acct_used_flag := "1"
  31920. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  31921. var result string
  31922. var request_log string
  31923. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  31924. 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)
  31925. } else {
  31926. 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)
  31927. }
  31928. var dat map[string]interface{}
  31929. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31930. fmt.Println(dat)
  31931. } else {
  31932. fmt.Println(err)
  31933. }
  31934. saveLog(result, request_log, "2206", "预结算")
  31935. userJSONBytes, _ := json.Marshal(dat)
  31936. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31937. utils.ErrorLog("解析失败:%v", err)
  31938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31939. return
  31940. }
  31941. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31942. var result string
  31943. var request_log string
  31944. if his.IdCardType == 2 {
  31945. insutype = strconv.FormatInt(his.SocialType, 10)
  31946. 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, "")
  31947. } else if his.IdCardType == 1 {
  31948. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31949. bas := strings.Split(psn_info.CardInfo, "|")
  31950. basNumber := bas[2]
  31951. card_sn := bas[3]
  31952. var rf []*ResultFive
  31953. json.Unmarshal([]byte(his.Iinfo), &rf)
  31954. var psn_type string
  31955. for _, item := range rf {
  31956. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31957. psn_type = item.PsnType
  31958. }
  31959. }
  31960. insutype = strconv.FormatInt(his.SocialType, 10)
  31961. 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)
  31962. } else {
  31963. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31964. //bas := strings.Split(psn_info.CardInfo, "|")
  31965. //basNumber := bas[2]
  31966. //card_sn := bas[3]
  31967. var rf []*ResultFive
  31968. json.Unmarshal([]byte(his.Iinfo), &rf)
  31969. var psn_type string
  31970. for _, item := range rf {
  31971. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31972. psn_type = item.PsnType
  31973. }
  31974. }
  31975. insutype = strconv.FormatInt(his.SocialType, 10)
  31976. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31977. 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)
  31978. }
  31979. var dat map[string]interface{}
  31980. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31981. fmt.Println(dat)
  31982. } else {
  31983. fmt.Println(err)
  31984. }
  31985. saveLog(result, request_log, "2206", "预结算")
  31986. userJSONBytes, _ := json.Marshal(dat)
  31987. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31988. utils.ErrorLog("解析失败:%v", err)
  31989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31990. return
  31991. }
  31992. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31993. var result string
  31994. var request_log string
  31995. if his.IdCardType == 2 {
  31996. insutype = strconv.FormatInt(his.SocialType, 10)
  31997. 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, "")
  31998. } else if his.IdCardType == 1 {
  31999. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32000. bas := strings.Split(psn_info.CardInfo, "|")
  32001. basNumber := bas[0]
  32002. card_sn := ""
  32003. var rf []*ResultFive
  32004. json.Unmarshal([]byte(his.Iinfo), &rf)
  32005. var psn_type string
  32006. for _, item := range rf {
  32007. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  32008. psn_type = item.PsnType
  32009. }
  32010. }
  32011. insutype = strconv.FormatInt(his.SocialType, 10)
  32012. 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)
  32013. } else {
  32014. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32015. //bas := strings.Split(psn_info.CardInfo, "|")
  32016. //basNumber := bas[2]
  32017. //card_sn := bas[3]
  32018. var rf []*ResultFive
  32019. json.Unmarshal([]byte(his.Iinfo), &rf)
  32020. var psn_type string
  32021. for _, item := range rf {
  32022. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  32023. psn_type = item.PsnType
  32024. }
  32025. }
  32026. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32027. 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)
  32028. }
  32029. var dat map[string]interface{}
  32030. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32031. fmt.Println(dat)
  32032. } else {
  32033. fmt.Println(err)
  32034. }
  32035. saveLog(result, request_log, "2206", "预结算")
  32036. userJSONBytes, _ := json.Marshal(dat)
  32037. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32038. utils.ErrorLog("解析失败:%v", err)
  32039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32040. return
  32041. }
  32042. } else if miConfig.MdtrtareaAdmvs == "360100" {
  32043. var result string
  32044. var request_log string
  32045. if his.IdCardType == 2 {
  32046. insutype = strconv.FormatInt(his.SocialType, 10)
  32047. 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, "")
  32048. } else if his.IdCardType == 1 {
  32049. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32050. bas := strings.Split(psn_info.CardInfo, "|")
  32051. basNumber := bas[0]
  32052. card_sn := ""
  32053. var rf []*ResultFive
  32054. json.Unmarshal([]byte(his.Iinfo), &rf)
  32055. var psn_type string
  32056. for _, item := range rf {
  32057. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  32058. psn_type = item.PsnType
  32059. }
  32060. }
  32061. insutype = strconv.FormatInt(his.SocialType, 10)
  32062. 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)
  32063. } else {
  32064. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32065. //bas := strings.Split(psn_info.CardInfo, "|")
  32066. //basNumber := bas[2]
  32067. //card_sn := bas[3]
  32068. var rf []*ResultFive
  32069. json.Unmarshal([]byte(his.Iinfo), &rf)
  32070. var psn_type string
  32071. for _, item := range rf {
  32072. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  32073. psn_type = item.PsnType
  32074. }
  32075. }
  32076. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32077. 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)
  32078. }
  32079. var dat map[string]interface{}
  32080. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32081. fmt.Println(dat)
  32082. } else {
  32083. fmt.Println(err)
  32084. }
  32085. saveLog(result, request_log, "2206", "预结算")
  32086. userJSONBytes, _ := json.Marshal(dat)
  32087. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32088. utils.ErrorLog("解析失败:%v", err)
  32089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32090. return
  32091. }
  32092. } else if miConfig.MdtrtareaAdmvs == "341203" {
  32093. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32094. if his.IdCardType == 4 {
  32095. psn_info.VerifyNumber = psn_info.VerifyNumber
  32096. cert_no = psn_info.VerifyNumber
  32097. } else if his.IdCardType == 2 {
  32098. cert_no = psn_info.Certno
  32099. psn_info.VerifyNumber = psn_info.Certno
  32100. } else {
  32101. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  32102. bas := strings.Split(psn_info.CardInfo, "|")
  32103. if his.IdCardType == 1 {
  32104. cert_no = bas[2]
  32105. } else {
  32106. cert_no = bas[1]
  32107. }
  32108. }
  32109. var api string
  32110. var med_type string
  32111. if his.Insutype == "390" {
  32112. if reg_type == 992102 {
  32113. med_type = "992102"
  32114. }
  32115. if reg_type == 140104 {
  32116. med_type = "140104"
  32117. }
  32118. if reg_type == 140201 {
  32119. med_type = "140201"
  32120. }
  32121. if reg_type == 14 {
  32122. med_type = "140104"
  32123. }
  32124. if reg_type == 1104 {
  32125. med_type = "1104"
  32126. }
  32127. } else if his.Insutype == "310" {
  32128. if reg_type == 1104 {
  32129. med_type = "1104"
  32130. }
  32131. if reg_type == 992102 {
  32132. med_type = "992102"
  32133. }
  32134. if reg_type == 140104 {
  32135. med_type = "140104"
  32136. }
  32137. if reg_type == 140201 {
  32138. med_type = "140201"
  32139. }
  32140. if reg_type == 14 {
  32141. med_type = "140104"
  32142. }
  32143. }
  32144. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  32145. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  32146. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32147. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32148. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  32149. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  32150. "&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
  32151. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32152. resp, requestErr := http.Get(api)
  32153. if requestErr != nil {
  32154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32155. return
  32156. }
  32157. body, ioErr := ioutil.ReadAll(resp.Body)
  32158. if ioErr != nil {
  32159. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32161. return
  32162. }
  32163. var respJSON map[string]interface{}
  32164. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32165. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32167. return
  32168. }
  32169. status := respJSON["data"].(map[string]interface{})["status"].(string)
  32170. if status == "0" {
  32171. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  32172. c.ServeSuccessJSON(map[string]interface{}{
  32173. "failed_code": -10,
  32174. "msg": err_msg,
  32175. })
  32176. return
  32177. }
  32178. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32179. result, _ := json.Marshal(respJSON)
  32180. fmt.Println("log")
  32181. fmt.Println(string(result))
  32182. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  32183. utils.ErrorLog("解析失败:%v", err)
  32184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32185. return
  32186. }
  32187. res.InfRefmsgid = ahres.InfRefmsgid
  32188. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  32189. // 创建对应的Time类型
  32190. t := time.UnixMilli(timestamp)
  32191. // 格式化成指定的日期字符串
  32192. str := t.Format("2006-01-02 15:04:05")
  32193. res.Output.Setlinfo.SetlTime = str
  32194. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  32195. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  32196. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32197. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  32198. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  32199. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  32200. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32201. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  32202. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  32203. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  32204. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  32205. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  32206. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32207. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  32208. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  32209. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  32210. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  32211. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  32212. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  32213. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32214. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  32215. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  32216. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  32217. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  32218. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  32219. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  32220. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  32221. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  32222. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  32223. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  32224. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  32225. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  32226. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  32227. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  32228. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  32229. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  32230. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  32231. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  32232. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  32233. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  32234. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  32235. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  32236. //res.Output.Setldetail = ahres.Output.Setldetail
  32237. res.ErrMsg = ahres.ErrMsg
  32238. res.Cainfo = ahres.Cainfo
  32239. res.WarnMsg = ahres.WarnMsg
  32240. res.Infcode = ahres.Infcode
  32241. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32242. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32243. if his.IdCardType == 4 {
  32244. psn_info.VerifyNumber = psn_info.VerifyNumber
  32245. cert_no = psn_info.Certno
  32246. } else if his.IdCardType == 2 {
  32247. cert_no = psn_info.Certno
  32248. psn_info.VerifyNumber = psn_info.Certno
  32249. } else {
  32250. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  32251. bas := strings.Split(psn_info.CardInfo, "|")
  32252. if his.IdCardType == 1 {
  32253. cert_no = bas[2]
  32254. } else {
  32255. cert_no = bas[1]
  32256. }
  32257. }
  32258. var api string
  32259. var med_type string
  32260. if his.Insutype == "390" {
  32261. if reg_type == 992102 {
  32262. med_type = "992102"
  32263. }
  32264. if reg_type == 140104 {
  32265. med_type = "140104"
  32266. }
  32267. if reg_type == 140201 {
  32268. med_type = "140201"
  32269. }
  32270. if reg_type == 14 {
  32271. med_type = "14"
  32272. }
  32273. } else if his.Insutype == "310" {
  32274. if reg_type == 992102 {
  32275. med_type = "992102"
  32276. }
  32277. if reg_type == 140104 {
  32278. med_type = "140104"
  32279. }
  32280. if reg_type == 140201 {
  32281. med_type = "140201"
  32282. }
  32283. if reg_type == 14 {
  32284. med_type = "14"
  32285. }
  32286. }
  32287. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  32288. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  32289. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32290. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32291. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  32292. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  32293. "&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
  32294. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32295. resp, requestErr := http.Get(api)
  32296. if requestErr != nil {
  32297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32298. return
  32299. }
  32300. body, ioErr := ioutil.ReadAll(resp.Body)
  32301. if ioErr != nil {
  32302. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32304. return
  32305. }
  32306. var respJSON map[string]interface{}
  32307. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32308. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32310. return
  32311. }
  32312. status := respJSON["data"].(map[string]interface{})["status"].(string)
  32313. if status == "0" {
  32314. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  32315. c.ServeSuccessJSON(map[string]interface{}{
  32316. "failed_code": -10,
  32317. "msg": err_msg,
  32318. })
  32319. return
  32320. }
  32321. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32322. result, _ := json.Marshal(respJSON)
  32323. fmt.Println("log")
  32324. fmt.Println(string(result))
  32325. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  32326. utils.ErrorLog("解析失败:%v", err)
  32327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32328. return
  32329. }
  32330. res.InfRefmsgid = ahres.InfRefmsgid
  32331. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  32332. // 创建对应的Time类型
  32333. t := time.UnixMilli(timestamp)
  32334. // 格式化成指定的日期字符串
  32335. str := t.Format("2006-01-02 15:04:05")
  32336. res.Output.Setlinfo.SetlTime = str
  32337. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  32338. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  32339. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32340. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  32341. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  32342. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  32343. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32344. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  32345. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  32346. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  32347. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  32348. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  32349. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32350. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  32351. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  32352. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  32353. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  32354. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  32355. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  32356. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32357. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  32358. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  32359. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  32360. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  32361. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  32362. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  32363. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  32364. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  32365. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  32366. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  32367. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  32368. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  32369. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  32370. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  32371. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  32372. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  32373. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  32374. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  32375. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  32376. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  32377. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  32378. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  32379. //res.Output.Setldetail = ahres.Output.Setldetail
  32380. res.ErrMsg = ahres.ErrMsg
  32381. res.Cainfo = ahres.Cainfo
  32382. res.WarnMsg = ahres.WarnMsg
  32383. res.Infcode = ahres.Infcode
  32384. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32385. var result string
  32386. var request_log string
  32387. if his.IdCardType == 2 {
  32388. 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")
  32389. } else if his.IdCardType == 1 {
  32390. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32391. bas := strings.Split(psn_info.CardInfo, "|")
  32392. basNumber := bas[2]
  32393. card_sn := bas[3]
  32394. 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")
  32395. } else {
  32396. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32397. 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")
  32398. }
  32399. var dat map[string]interface{}
  32400. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32401. fmt.Println(dat)
  32402. } else {
  32403. fmt.Println(err)
  32404. }
  32405. saveLog(result, request_log, "2206", "预结算")
  32406. userJSONBytes, _ := json.Marshal(dat)
  32407. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32408. utils.ErrorLog("解析失败:%v", err)
  32409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32410. return
  32411. }
  32412. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32413. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  32414. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  32415. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32416. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32417. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  32418. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  32419. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  32420. resp, requestErr := http.Get(api)
  32421. if requestErr != nil {
  32422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32423. return
  32424. }
  32425. body, ioErr := ioutil.ReadAll(resp.Body)
  32426. if ioErr != nil {
  32427. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32429. return
  32430. }
  32431. var respJSON map[string]interface{}
  32432. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32433. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32435. return
  32436. }
  32437. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32438. result, _ := json.Marshal(respJSON)
  32439. fmt.Println("log")
  32440. fmt.Println(string(result))
  32441. if err := json.Unmarshal([]byte(result), &res); err != nil {
  32442. utils.ErrorLog("解析失败:%v", err)
  32443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32444. return
  32445. }
  32446. } else {
  32447. if miConfig.MdtrtareaAdmvs == "441202" {
  32448. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  32449. if result3101.Infcode == 0 {
  32450. if len(result3101.Output.Result) > 0 {
  32451. c.ServeSuccessJSON(map[string]interface{}{
  32452. "failed_code": -10,
  32453. "failed_type": 100,
  32454. "msg": result3101.Output.Result,
  32455. })
  32456. return
  32457. } else {
  32458. var result string
  32459. var request_log string
  32460. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32461. allTotal = fmt.Sprintf("%.2f", total_two)
  32462. if his.IdCardType == 4 {
  32463. 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,acct_used_flag)
  32464. } else {
  32465. 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,acct_used_flag)
  32466. }
  32467. var dat map[string]interface{}
  32468. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32469. fmt.Println(dat)
  32470. } else {
  32471. fmt.Println(err)
  32472. }
  32473. saveLog(result, request_log, "2206", "预结算")
  32474. //userJSONBytes, _ := json.Marshal(dat)
  32475. //
  32476. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32477. // utils.ErrorLog("解析失败:%v", err)
  32478. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32479. // return
  32480. //}
  32481. userJSONBytes, _ := json.Marshal(dat)
  32482. if miConfig.Code == "H15049901371" {
  32483. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  32484. utils.ErrorLog("解析失败:%v", err)
  32485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32486. return
  32487. }
  32488. res.InfRefmsgid = resSeven10265.InfRefmsgid
  32489. res.Output = resSeven10265.Output
  32490. res.ErrMsg = resSeven10265.ErrMsg
  32491. res.Cainfo = resSeven10265.Cainfo
  32492. res.WarnMsg = resSeven10265.WarnMsg
  32493. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32494. res.Infcode = infocode
  32495. } else {
  32496. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32497. utils.ErrorLog("解析失败:%v", err)
  32498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32499. return
  32500. }
  32501. }
  32502. }
  32503. } else {
  32504. c.ServeSuccessJSON(map[string]interface{}{
  32505. "failed_code": -10,
  32506. "msg": result3101.ErrMsg,
  32507. })
  32508. return
  32509. }
  32510. } else if miConfig.MdtrtareaAdmvs == "440205" {
  32511. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  32512. if result3101.Infcode == 0 {
  32513. if len(result3101.Output.Result) > 0 {
  32514. var errMsgs []string
  32515. for _, item := range result3101.Output.Result {
  32516. errMsgs = append(errMsgs, item.VolaCont)
  32517. }
  32518. c.ServeSuccessJSON(map[string]interface{}{
  32519. "failed_code": -10,
  32520. "msg": errMsgs,
  32521. })
  32522. return
  32523. } else {
  32524. var result string
  32525. var request_log string
  32526. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32527. allTotal = fmt.Sprintf("%.2f", total_two)
  32528. if his.IdCardType == 4 {
  32529. 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,acct_used_flag)
  32530. } else {
  32531. 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,acct_used_flag)
  32532. }
  32533. var dat map[string]interface{}
  32534. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32535. fmt.Println(dat)
  32536. } else {
  32537. fmt.Println(err)
  32538. }
  32539. saveLog(result, request_log, "2206", "预结算")
  32540. //userJSONBytes, _ := json.Marshal(dat)
  32541. //
  32542. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32543. // utils.ErrorLog("解析失败:%v", err)
  32544. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32545. // return
  32546. //}
  32547. userJSONBytes, _ := json.Marshal(dat)
  32548. if miConfig.Code == "H15049901371" {
  32549. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  32550. utils.ErrorLog("解析失败:%v", err)
  32551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32552. return
  32553. }
  32554. res.InfRefmsgid = resSeven10265.InfRefmsgid
  32555. res.Output = resSeven10265.Output
  32556. res.ErrMsg = resSeven10265.ErrMsg
  32557. res.Cainfo = resSeven10265.Cainfo
  32558. res.WarnMsg = resSeven10265.WarnMsg
  32559. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32560. res.Infcode = infocode
  32561. } else {
  32562. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32563. utils.ErrorLog("解析失败:%v", err)
  32564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32565. return
  32566. }
  32567. }
  32568. }
  32569. } else {
  32570. c.ServeSuccessJSON(map[string]interface{}{
  32571. "failed_code": -10,
  32572. "msg": result3101.ErrMsg,
  32573. })
  32574. return
  32575. }
  32576. } else {
  32577. var result string
  32578. var request_log string
  32579. var dat map[string]interface{}
  32580. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32581. allTotal = fmt.Sprintf("%.2f", total_two)
  32582. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" || miConfig.Code == "H44090200998" {
  32583. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  32584. if result3101.Infcode == 0 {
  32585. if len(result3101.Output.Result) > 0 {
  32586. c.ServeSuccessJSON(map[string]interface{}{
  32587. "failed_code": -10,
  32588. "failed_type": 100,
  32589. "warm_type": 2,
  32590. "msg": result3101,
  32591. })
  32592. return
  32593. } else {
  32594. var result string
  32595. var request_log string
  32596. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32597. allTotal = fmt.Sprintf("%.2f", total_two)
  32598. if his.IdCardType == 4 {
  32599. 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,acct_used_flag)
  32600. } else {
  32601. if his.IdCardType == 2 {
  32602. cert_no = psn_info.Certno
  32603. psn_info.VerifyNumber = psn_info.Certno
  32604. } else {
  32605. bas := strings.Split(psn_info.CardInfo, "|")
  32606. cert_no = bas[2]
  32607. }
  32608. 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,acct_used_flag)
  32609. }
  32610. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32611. fmt.Println(dat)
  32612. } else {
  32613. fmt.Println(err)
  32614. }
  32615. saveLog(result, request_log, "2206", "预结算")
  32616. }
  32617. } else {
  32618. c.ServeSuccessJSON(map[string]interface{}{
  32619. "failed_code": -10,
  32620. "msg": result3101.ErrMsg,
  32621. })
  32622. return
  32623. }
  32624. } else {
  32625. if his.IdCardType == 4 {
  32626. 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,acct_used_flag)
  32627. } else {
  32628. if his.IdCardType == 2 {
  32629. cert_no = psn_info.Certno
  32630. psn_info.VerifyNumber = psn_info.Certno
  32631. } else {
  32632. bas := strings.Split(psn_info.CardInfo, "|")
  32633. cert_no = bas[2]
  32634. }
  32635. 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,acct_used_flag)
  32636. }
  32637. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32638. fmt.Println(dat)
  32639. } else {
  32640. fmt.Println(err)
  32641. }
  32642. saveLog(result, request_log, "2206", "预结算")
  32643. }
  32644. //userJSONBytes, _ := json.Marshal(dat)
  32645. //
  32646. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32647. // utils.ErrorLog("解析失败:%v", err)
  32648. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32649. // return
  32650. //}
  32651. userJSONBytes, _ := json.Marshal(dat)
  32652. if miConfig.Code == "H15049901371" {
  32653. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  32654. utils.ErrorLog("解析失败:%v", err)
  32655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32656. return
  32657. }
  32658. res.InfRefmsgid = resSeven10265.InfRefmsgid
  32659. res.Output = resSeven10265.Output
  32660. res.ErrMsg = resSeven10265.ErrMsg
  32661. res.Cainfo = resSeven10265.Cainfo
  32662. res.WarnMsg = resSeven10265.WarnMsg
  32663. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32664. res.Infcode = infocode
  32665. } else {
  32666. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32667. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  32668. utils.ErrorLog("解析失败:%v", err)
  32669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32670. return
  32671. }
  32672. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  32673. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  32674. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  32675. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  32676. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  32677. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  32678. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  32679. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32680. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  32681. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32682. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32683. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32684. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32685. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  32686. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  32687. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  32688. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  32689. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  32690. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  32691. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  32692. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32693. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  32694. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  32695. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  32696. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  32697. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  32698. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  32699. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  32700. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  32701. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  32702. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  32703. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  32704. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  32705. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  32706. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  32707. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  32708. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  32709. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  32710. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32711. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  32712. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  32713. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  32714. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  32715. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  32716. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  32717. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  32718. res.ErrMsg = gzresSeven10265Two.ErrMsg
  32719. res.Cainfo = gzresSeven10265Two.Cainfo
  32720. res.WarnMsg = gzresSeven10265Two.WarnMsg
  32721. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  32722. //res.Infcode = infocode
  32723. } else {
  32724. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32725. utils.ErrorLog("解析失败:%v", err)
  32726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32727. return
  32728. }
  32729. }
  32730. }
  32731. }
  32732. }
  32733. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  32734. if res10633.Infcode == -1 {
  32735. errlog := &models.HisOrderError{
  32736. UserOrgId: adminUser.CurrentOrgId,
  32737. Ctime: time.Now().Unix(),
  32738. Mtime: time.Now().Unix(),
  32739. Number: chrg_bchno,
  32740. ErrMsg: res10633.ErrMsg,
  32741. Status: 1,
  32742. PatientId: id,
  32743. RecordTime: recordDateTime,
  32744. Stage: 20,
  32745. }
  32746. service.CreateErrMsgLog(errlog)
  32747. c.ServeSuccessJSON(map[string]interface{}{
  32748. "failed_code": -10,
  32749. "msg": res10633.ErrMsg,
  32750. })
  32751. return
  32752. }
  32753. if res10633.Infcode != 0 {
  32754. errlog := &models.HisOrderError{
  32755. UserOrgId: adminUser.CurrentOrgId,
  32756. Ctime: time.Now().Unix(),
  32757. Mtime: time.Now().Unix(),
  32758. Number: chrg_bchno,
  32759. ErrMsg: res10633.ErrMsg,
  32760. Status: 1,
  32761. PatientId: id,
  32762. RecordTime: recordDateTime,
  32763. Stage: 20,
  32764. }
  32765. service.CreateErrMsgLog(errlog)
  32766. c.ServeSuccessJSON(map[string]interface{}{
  32767. "failed_code": -10,
  32768. "msg": res10633.ErrMsg,
  32769. })
  32770. return
  32771. } else {
  32772. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  32773. order.OrderStatus = 1
  32774. order.IsPre = 1
  32775. order.Status = 1
  32776. order.MdtrtId = res10633.Output.Setlinfo.MdtrtID
  32777. order.SetlId = res10633.Output.Setlinfo.SetlID
  32778. order.PsnNo = res10633.Output.Setlinfo.PsnNo
  32779. order.PsnName = res10633.Output.Setlinfo.PsnName
  32780. order.PsnCertType = res10633.Output.Setlinfo.PsnCertType
  32781. order.Certno = res10633.Output.Setlinfo.Certno
  32782. order.Gend = res10633.Output.Setlinfo.Gend
  32783. order.Naty = res10633.Output.Setlinfo.Naty
  32784. order.Age = res10633.Output.Setlinfo.Age
  32785. order.Insutype = res10633.Output.Setlinfo.Insutype
  32786. order.PsnType = res10633.Output.Setlinfo.PsnType
  32787. order.CvlservFlag = res10633.Output.Setlinfo.CvlservFlag
  32788. order.SetlTime = res10633.Output.Setlinfo.SetlTime
  32789. order.AcctUsedFlag = acct_used_flag
  32790. order.MdtrtCertType = res10633.Output.Setlinfo.MdtrtCertType
  32791. if res10633.Output.Setlinfo.MedType == "140101" {
  32792. order.MedType = "14"
  32793. } else {
  32794. if res10633.Output.Setlinfo.MedType == "110104" {
  32795. order.MedType = "11"
  32796. } else {
  32797. order.MedType = res10633.Output.Setlinfo.MedType
  32798. }
  32799. }
  32800. if res10633.Output.Setlinfo.MedType == "992102" {
  32801. order.MedType = "992102"
  32802. }
  32803. if res10633.Output.Setlinfo.MedType == "140104" {
  32804. order.MedType = "140104"
  32805. }
  32806. if res10633.Output.Setlinfo.MedType == "1104" {
  32807. order.MedType = "1104"
  32808. }
  32809. if res10633.Output.Setlinfo.MedType == "140201" {
  32810. order.MedType = "140201"
  32811. }
  32812. if res10633.Output.Setlinfo.MedType == "14" {
  32813. order.MedType = "14"
  32814. }
  32815. if reg_type == 1112 {
  32816. order.MedType = "1112"
  32817. }
  32818. if reg_type == 1111 {
  32819. order.MedType = "1111"
  32820. }
  32821. order.ClrType = res10633.Output.Setlinfo.ClrType
  32822. if adminUser.CurrentOrgId == 10480 {
  32823. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  32824. order.ClrType = "11"
  32825. } else {
  32826. order.ClrType = "9903"
  32827. }
  32828. }
  32829. order.MedfeeSumamt = res10633.Output.Setlinfo.MedfeeSumamt
  32830. order.FulamtOwnpayAmt = res10633.Output.Setlinfo.FulamtOwnpayAmt
  32831. order.OverlmtSelfPay = res10633.Output.Setlinfo.OverlmtSelfpay
  32832. order.PreselfpayAmt = res10633.Output.Setlinfo.PreselfpayAmt
  32833. order.InscpScpAmt = res10633.Output.Setlinfo.InscpScpAmt
  32834. order.ActPayDedc = res10633.Output.Setlinfo.ActPayDedc
  32835. order.HifpPay = res10633.Output.Setlinfo.HifpPay
  32836. order.CvlservPay = res10633.Output.Setlinfo.CvlservPay
  32837. order.HifesPay = res10633.Output.Setlinfo.HifesPay
  32838. order.HifobPay = res10633.Output.Setlinfo.HifobPay
  32839. order.MafPay = res10633.Output.Setlinfo.MafPay
  32840. order.HifmiPay = res10633.Output.Setlinfo.HifmiPay
  32841. order.OthPay = res10633.Output.Setlinfo.OthPay
  32842. order.FundPaySumamt = res10633.Output.Setlinfo.FundPaySumamt
  32843. order.PsnPartAmt = res10633.Output.Setlinfo.PsnPartAmt
  32844. order.AcctPay = res10633.Output.Setlinfo.AcctPay
  32845. order.PsnCashPay = res10633.Output.Setlinfo.PsnCashPay
  32846. order.Balc = res10633.Output.Setlinfo.Balc
  32847. order.MedinsSetlId = res10633.Output.Setlinfo.MedinsSetlID
  32848. order.ClrOptins = res10633.Output.Setlinfo.ClrOptins
  32849. order.ClrWay = res10633.Output.Setlinfo.ClrWay
  32850. order.Creator = order.Creator
  32851. order.Modify = roles.AdminUserId
  32852. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  32853. //detailStr := string(setlDetail)
  32854. //order.SetlDetail = detailStr
  32855. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  32856. err = service.UpDateOrder(order)
  32857. if err == nil {
  32858. c.ServeSuccessJSON(map[string]interface{}{
  32859. "msg": "预结算成功",
  32860. })
  32861. } else {
  32862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  32863. return
  32864. }
  32865. }
  32866. }else{
  32867. if res.Infcode == -1 {
  32868. errlog := &models.HisOrderError{
  32869. UserOrgId: adminUser.CurrentOrgId,
  32870. Ctime: time.Now().Unix(),
  32871. Mtime: time.Now().Unix(),
  32872. Number: chrg_bchno,
  32873. ErrMsg: res.ErrMsg,
  32874. Status: 1,
  32875. PatientId: id,
  32876. RecordTime: recordDateTime,
  32877. Stage: 20,
  32878. }
  32879. service.CreateErrMsgLog(errlog)
  32880. c.ServeSuccessJSON(map[string]interface{}{
  32881. "failed_code": -10,
  32882. "msg": res.ErrMsg,
  32883. })
  32884. return
  32885. }
  32886. if res.Infcode != 0 {
  32887. errlog := &models.HisOrderError{
  32888. UserOrgId: adminUser.CurrentOrgId,
  32889. Ctime: time.Now().Unix(),
  32890. Mtime: time.Now().Unix(),
  32891. Number: chrg_bchno,
  32892. ErrMsg: res.ErrMsg,
  32893. Status: 1,
  32894. PatientId: id,
  32895. RecordTime: recordDateTime,
  32896. Stage: 20,
  32897. }
  32898. service.CreateErrMsgLog(errlog)
  32899. c.ServeSuccessJSON(map[string]interface{}{
  32900. "failed_code": -10,
  32901. "msg": res.ErrMsg,
  32902. })
  32903. return
  32904. } else {
  32905. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  32906. order.OrderStatus = 1
  32907. order.IsPre = 1
  32908. order.Status = 1
  32909. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  32910. order.SetlId = res.Output.Setlinfo.SetlID
  32911. order.PsnNo = res.Output.Setlinfo.PsnNo
  32912. order.PsnName = res.Output.Setlinfo.PsnName
  32913. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  32914. order.Certno = res.Output.Setlinfo.Certno
  32915. order.Gend = res.Output.Setlinfo.Gend
  32916. order.Naty = res.Output.Setlinfo.Naty
  32917. order.Age = res.Output.Setlinfo.Age
  32918. order.Insutype = res.Output.Setlinfo.Insutype
  32919. order.PsnType = res.Output.Setlinfo.PsnType
  32920. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  32921. order.SetlTime = res.Output.Setlinfo.SetlTime
  32922. order.AcctUsedFlag = acct_used_flag
  32923. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  32924. if res.Output.Setlinfo.MedType == "140101" {
  32925. order.MedType = "14"
  32926. } else {
  32927. if res.Output.Setlinfo.MedType == "110104" {
  32928. order.MedType = "11"
  32929. } else {
  32930. order.MedType = res.Output.Setlinfo.MedType
  32931. }
  32932. }
  32933. if res.Output.Setlinfo.MedType == "992102" {
  32934. order.MedType = "992102"
  32935. }
  32936. if res.Output.Setlinfo.MedType == "140104" {
  32937. order.MedType = "140104"
  32938. }
  32939. if res.Output.Setlinfo.MedType == "1104" {
  32940. order.MedType = "1104"
  32941. }
  32942. if res.Output.Setlinfo.MedType == "140201" {
  32943. order.MedType = "140201"
  32944. }
  32945. if res.Output.Setlinfo.MedType == "14" {
  32946. order.MedType = "14"
  32947. }
  32948. if reg_type == 1112 {
  32949. order.MedType = "1112"
  32950. }
  32951. if reg_type == 1111 {
  32952. order.MedType = "1111"
  32953. }
  32954. order.ClrType = res.Output.Setlinfo.ClrType
  32955. if adminUser.CurrentOrgId == 10480 {
  32956. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  32957. order.ClrType = "11"
  32958. } else {
  32959. order.ClrType = "9903"
  32960. }
  32961. }
  32962. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  32963. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  32964. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  32965. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  32966. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  32967. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  32968. order.HifpPay = res.Output.Setlinfo.HifpPay
  32969. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  32970. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  32971. order.HifesPay = res.Output.Setlinfo.HifesPay
  32972. order.HifobPay = res.Output.Setlinfo.HifobPay
  32973. order.MafPay = res.Output.Setlinfo.MafPay
  32974. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  32975. order.OthPay = res.Output.Setlinfo.OthPay
  32976. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  32977. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  32978. order.AcctPay = res.Output.Setlinfo.AcctPay
  32979. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  32980. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  32981. order.Balc = res.Output.Setlinfo.Balc
  32982. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  32983. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  32984. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  32985. order.ClrWay = res.Output.Setlinfo.ClrWay
  32986. order.Creator = order.Creator
  32987. order.Modify = roles.AdminUserId
  32988. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  32989. //detailStr := string(setlDetail)
  32990. //order.SetlDetail = detailStr
  32991. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  32992. err = service.UpDateOrder(order)
  32993. if err == nil {
  32994. c.ServeSuccessJSON(map[string]interface{}{
  32995. "msg": "预结算成功",
  32996. })
  32997. } else {
  32998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  32999. return
  33000. }
  33001. }
  33002. }
  33003. } else {
  33004. adminUser := c.GetAdminUserInfo()
  33005. errlog := &models.HisOrderError{
  33006. UserOrgId: adminUser.CurrentOrgId,
  33007. Ctime: time.Now().Unix(),
  33008. Mtime: time.Now().Unix(),
  33009. ErrMsg: res.ErrMsg,
  33010. Status: 1,
  33011. PatientId: id,
  33012. RecordTime: recordDateTime,
  33013. Stage: 4,
  33014. }
  33015. service.CreateErrMsgLog(errlog)
  33016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  33017. return
  33018. }
  33019. } else {
  33020. if miConfig.MdtrtareaAdmvs == "150404" {
  33021. order := &models.HisOrder{
  33022. UserOrgId: adminUser.CurrentOrgId,
  33023. HisPatientId: his.ID,
  33024. PatientId: his.PatientId,
  33025. SettleAccountsDate: recordDateTime,
  33026. Ctime: time.Now().Unix(),
  33027. Mtime: time.Now().Unix(),
  33028. MdtrtId: his.Number,
  33029. PsnNo: his.PsnNo,
  33030. MedType: strconv.FormatInt(reg_type, 10),
  33031. Status: 1,
  33032. Number: chrg_bchno,
  33033. Infcode: res.Infcode,
  33034. WarnMsg: res.WarnMsg,
  33035. Cainfo: res.Cainfo,
  33036. ErrMsg: res.ErrMsg,
  33037. RespondTime: res.RefmsgTime,
  33038. InfRefmsgid: res.InfRefmsgid,
  33039. OrderStatus: 1,
  33040. IsMedicineInsurance: 1,
  33041. SettleType: settle_accounts_type,
  33042. SettleStartTime: start_time,
  33043. SettleEndTime: end_time,
  33044. Creator: roles.AdminUserId,
  33045. Modify: roles.AdminUserId,
  33046. PType: 2,
  33047. Diagnosis: diagnosis_id,
  33048. }
  33049. err = service.CreateOrder(order)
  33050. if err != nil {
  33051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  33052. return
  33053. }
  33054. }
  33055. adminUser := c.GetAdminUserInfo()
  33056. errlog := &models.HisOrderError{
  33057. UserOrgId: adminUser.CurrentOrgId,
  33058. Ctime: time.Now().Unix(),
  33059. Mtime: time.Now().Unix(),
  33060. ErrMsg: res.ErrMsg,
  33061. Status: 1,
  33062. PatientId: id,
  33063. RecordTime: recordDateTime,
  33064. Stage: 4,
  33065. }
  33066. service.CreateErrMsgLog(errlog)
  33067. c.ServeSuccessJSON(map[string]interface{}{
  33068. "failed_code": -10,
  33069. "msg": res.ErrMsg,
  33070. })
  33071. return
  33072. }
  33073. }
  33074. }
  33075. }
  33076. // 退款
  33077. func (c *HisApiController) Refund() {
  33078. order_id, _ := c.GetInt64("order_id")
  33079. admin_user_id, _ := c.GetInt64("admin_user_id")
  33080. adminUser := c.GetAdminUserInfo()
  33081. var order models.HisOrder
  33082. order, _ = service.GetHisOrderByID(order_id)
  33083. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  33084. if fapiao.ID > 0 {
  33085. c.ServeSuccessJSON(map[string]interface{}{
  33086. "failed_code": -10,
  33087. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  33088. })
  33089. return
  33090. }
  33091. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33092. if order.ID == 0 {
  33093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  33094. return
  33095. }
  33096. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  33097. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33098. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33099. if config.IsOpen == 1 { //对接了医保,走医保流程
  33100. var res ResultSixteen
  33101. var ahres ResultSevenAH
  33102. var resSixteen10265 ResultSixteen10265
  33103. var resSixteen10265Two ResultSixteen10265Two
  33104. var gz ResultgzSixteen10265Two
  33105. var src_resquest string
  33106. var result string
  33107. if miConfig.MdtrtareaAdmvs == "421300" {
  33108. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  33109. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33110. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33111. resp3, requestErr3 := http.Get(api3)
  33112. if requestErr3 != nil {
  33113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33114. return
  33115. }
  33116. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33117. if ioErr3 != nil {
  33118. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33120. return
  33121. }
  33122. var respJSON3 map[string]interface{}
  33123. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33124. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33126. return
  33127. }
  33128. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33129. userJSONBytes3, _ := json.Marshal(respJSON3)
  33130. fmt.Println("log")
  33131. fmt.Println(string(userJSONBytes3))
  33132. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33133. utils.ErrorLog("解析失败:%v", err)
  33134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33135. return
  33136. }
  33137. } else if miConfig.MdtrtareaAdmvs == "420200" {
  33138. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  33139. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33140. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33141. resp3, requestErr3 := http.Get(api3)
  33142. if requestErr3 != nil {
  33143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33144. return
  33145. }
  33146. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33147. if ioErr3 != nil {
  33148. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33150. return
  33151. }
  33152. var respJSON3 map[string]interface{}
  33153. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33154. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33156. return
  33157. }
  33158. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33159. userJSONBytes3, _ := json.Marshal(respJSON3)
  33160. fmt.Println("log")
  33161. fmt.Println(string(userJSONBytes3))
  33162. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33163. utils.ErrorLog("解析失败:%v", err)
  33164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33165. return
  33166. }
  33167. } else if miConfig.MdtrtareaAdmvs == "420902" {
  33168. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  33169. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33170. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33171. resp3, requestErr3 := http.Get(api3)
  33172. if requestErr3 != nil {
  33173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33174. return
  33175. }
  33176. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33177. if ioErr3 != nil {
  33178. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33180. return
  33181. }
  33182. var respJSON3 map[string]interface{}
  33183. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33184. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33186. return
  33187. }
  33188. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33189. userJSONBytes3, _ := json.Marshal(respJSON3)
  33190. fmt.Println("log")
  33191. fmt.Println(string(userJSONBytes3))
  33192. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33193. utils.ErrorLog("解析失败:%v", err)
  33194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33195. return
  33196. }
  33197. } else if miConfig.MdtrtareaAdmvs == "421182" {
  33198. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  33199. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33200. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33201. resp3, requestErr3 := http.Get(api3)
  33202. if requestErr3 != nil {
  33203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33204. return
  33205. }
  33206. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33207. if ioErr3 != nil {
  33208. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33210. return
  33211. }
  33212. var respJSON3 map[string]interface{}
  33213. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33214. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33216. return
  33217. }
  33218. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33219. userJSONBytes3, _ := json.Marshal(respJSON3)
  33220. fmt.Println("log")
  33221. fmt.Println(string(userJSONBytes3))
  33222. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33223. utils.ErrorLog("解析失败:%v", err)
  33224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33225. return
  33226. }
  33227. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  33228. var api3 string
  33229. if miConfig.MdtrtareaAdmvs == "320830" {
  33230. api3 = miConfig.AppSecret + "jsyb/2208?psn_no=" + order.PsnNo +
  33231. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33232. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33233. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33234. } else if miConfig.MdtrtareaAdmvs == "320921" {
  33235. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  33236. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33237. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33238. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33239. } else {
  33240. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33241. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  33242. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33243. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33244. }
  33245. resp3, requestErr3 := http.Get(api3)
  33246. if requestErr3 != nil {
  33247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33248. return
  33249. }
  33250. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33251. if ioErr3 != nil {
  33252. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33254. return
  33255. }
  33256. var respJSON3 map[string]interface{}
  33257. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33258. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33260. return
  33261. }
  33262. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33263. userJSONBytes3, _ := json.Marshal(respJSON3)
  33264. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  33265. utils.ErrorLog("解析失败:%v", err)
  33266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33267. return
  33268. }
  33269. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  33270. res.Output = resSixteen10265.Output
  33271. res.ErrMsg = resSixteen10265.ErrMsg
  33272. res.Cainfo = resSixteen10265.Cainfo
  33273. res.WarnMsg = resSixteen10265.WarnMsg
  33274. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  33275. res.Infcode = infocode
  33276. } else if miConfig.MdtrtareaAdmvs == "150404" {
  33277. var api3 string
  33278. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  33279. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33280. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33281. resp3, requestErr3 := http.Get(api3)
  33282. if requestErr3 != nil {
  33283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33284. return
  33285. }
  33286. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33287. if ioErr3 != nil {
  33288. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33290. return
  33291. }
  33292. var respJSON3 map[string]interface{}
  33293. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33294. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33296. return
  33297. }
  33298. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33299. userJSONBytes3, _ := json.Marshal(respJSON3)
  33300. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  33301. utils.ErrorLog("解析失败:%v", err)
  33302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33303. return
  33304. }
  33305. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  33306. res.Output = resSixteen10265.Output
  33307. res.ErrMsg = resSixteen10265.ErrMsg
  33308. res.Cainfo = resSixteen10265.Cainfo
  33309. res.WarnMsg = resSixteen10265.WarnMsg
  33310. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  33311. res.Infcode = infocode
  33312. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33313. 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)
  33314. var dat map[string]interface{}
  33315. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33316. fmt.Println(dat)
  33317. } else {
  33318. fmt.Println(err)
  33319. }
  33320. saveLog(result, src_resquest, "2208", "退费")
  33321. userJSONBytes, _ := json.Marshal(dat)
  33322. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33323. utils.ErrorLog("解析失败:%v", err)
  33324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33325. return
  33326. }
  33327. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33328. 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, "")
  33329. var dat map[string]interface{}
  33330. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33331. fmt.Println(dat)
  33332. } else {
  33333. fmt.Println(err)
  33334. }
  33335. saveLog(result, src_resquest, "2208", "退费")
  33336. userJSONBytes, _ := json.Marshal(dat)
  33337. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33338. utils.ErrorLog("解析失败:%v", err)
  33339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33340. return
  33341. }
  33342. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33343. 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, "")
  33344. var dat map[string]interface{}
  33345. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33346. fmt.Println(dat)
  33347. } else {
  33348. fmt.Println(err)
  33349. }
  33350. saveLog(result, src_resquest, "2208", "退费")
  33351. userJSONBytes, _ := json.Marshal(dat)
  33352. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33353. utils.ErrorLog("解析失败:%v", err)
  33354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33355. return
  33356. }
  33357. } else if miConfig.MdtrtareaAdmvs == "360100" {
  33358. 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, "")
  33359. var dat map[string]interface{}
  33360. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33361. fmt.Println(dat)
  33362. } else {
  33363. fmt.Println(err)
  33364. }
  33365. saveLog(result, src_resquest, "2208", "退费")
  33366. userJSONBytes, _ := json.Marshal(dat)
  33367. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33368. utils.ErrorLog("解析失败:%v", err)
  33369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33370. return
  33371. }
  33372. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33373. var api3 string
  33374. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  33375. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33376. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33377. resp3, requestErr3 := http.Get(api3)
  33378. if requestErr3 != nil {
  33379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33380. return
  33381. }
  33382. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33383. if ioErr3 != nil {
  33384. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33386. return
  33387. }
  33388. var respJSON3 map[string]interface{}
  33389. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33390. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33392. return
  33393. }
  33394. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33395. if status == "0" {
  33396. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33397. c.ServeSuccessJSON(map[string]interface{}{
  33398. "failed_code": -10,
  33399. "msg": err_msg,
  33400. })
  33401. return
  33402. }
  33403. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33404. userJSONBytes3, _ := json.Marshal(respJSON3)
  33405. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33406. // utils.ErrorLog("解析失败:%v", err)
  33407. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33408. // return
  33409. //}
  33410. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  33411. utils.ErrorLog("解析失败:%v", err)
  33412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33413. return
  33414. }
  33415. res.InfRefmsgid = ahres.InfRefmsgid
  33416. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  33417. // 创建对应的Time类型
  33418. t := time.UnixMilli(timestamp)
  33419. // 格式化成指定的日期字符串
  33420. str := t.Format("2006-01-02 15:04:05")
  33421. res.Output.Setlinfo.SetlTime = str
  33422. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  33423. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  33424. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33425. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  33426. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  33427. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  33428. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  33429. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  33430. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  33431. //
  33432. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  33433. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  33434. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  33435. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33436. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  33437. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  33438. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  33439. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  33440. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  33441. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  33442. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  33443. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  33444. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  33445. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  33446. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  33447. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  33448. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  33449. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  33450. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  33451. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  33452. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  33453. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  33454. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  33455. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  33456. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  33457. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  33458. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  33459. //res.Output.Setldetail = ahres.Output.Setldetail
  33460. res.ErrMsg = ahres.ErrMsg
  33461. res.Cainfo = ahres.Cainfo
  33462. res.WarnMsg = ahres.WarnMsg
  33463. res.Infcode = ahres.Infcode
  33464. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33465. var api3 string
  33466. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  33467. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33468. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33469. resp3, requestErr3 := http.Get(api3)
  33470. if requestErr3 != nil {
  33471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33472. return
  33473. }
  33474. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33475. if ioErr3 != nil {
  33476. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33478. return
  33479. }
  33480. var respJSON3 map[string]interface{}
  33481. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33482. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33484. return
  33485. }
  33486. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33487. if status == "0" {
  33488. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33489. c.ServeSuccessJSON(map[string]interface{}{
  33490. "failed_code": -10,
  33491. "msg": err_msg,
  33492. })
  33493. return
  33494. }
  33495. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33496. userJSONBytes3, _ := json.Marshal(respJSON3)
  33497. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33498. // utils.ErrorLog("解析失败:%v", err)
  33499. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33500. // return
  33501. //}
  33502. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  33503. utils.ErrorLog("解析失败:%v", err)
  33504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33505. return
  33506. }
  33507. res.InfRefmsgid = ahres.InfRefmsgid
  33508. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  33509. // 创建对应的Time类型
  33510. t := time.UnixMilli(timestamp)
  33511. // 格式化成指定的日期字符串
  33512. str := t.Format("2006-01-02 15:04:05")
  33513. res.Output.Setlinfo.SetlTime = str
  33514. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  33515. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  33516. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33517. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  33518. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  33519. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  33520. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  33521. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  33522. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  33523. //
  33524. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  33525. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  33526. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  33527. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33528. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  33529. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  33530. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  33531. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  33532. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  33533. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  33534. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  33535. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  33536. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  33537. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  33538. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  33539. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  33540. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  33541. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  33542. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  33543. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  33544. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  33545. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  33546. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  33547. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  33548. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  33549. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  33550. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  33551. //res.Output.Setldetail = ahres.Output.Setldetail
  33552. res.ErrMsg = ahres.ErrMsg
  33553. res.Cainfo = ahres.Cainfo
  33554. res.WarnMsg = ahres.WarnMsg
  33555. res.Infcode = ahres.Infcode
  33556. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33557. 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, "")
  33558. var dat map[string]interface{}
  33559. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33560. fmt.Println(dat)
  33561. } else {
  33562. fmt.Println(err)
  33563. }
  33564. saveLog(result, src_resquest, "2208", "退费")
  33565. userJSONBytes, _ := json.Marshal(dat)
  33566. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33567. utils.ErrorLog("解析失败:%v", err)
  33568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33569. return
  33570. }
  33571. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33572. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  33573. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33574. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33575. resp3, requestErr3 := http.Get(api3)
  33576. if requestErr3 != nil {
  33577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33578. return
  33579. }
  33580. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33581. if ioErr3 != nil {
  33582. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33584. return
  33585. }
  33586. var respJSON3 map[string]interface{}
  33587. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33588. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33590. return
  33591. }
  33592. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33593. userJSONBytes3, _ := json.Marshal(respJSON3)
  33594. fmt.Println("log")
  33595. fmt.Println(string(userJSONBytes3))
  33596. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33597. utils.ErrorLog("解析失败:%v", err)
  33598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33599. return
  33600. }
  33601. } else {
  33602. if miConfig.Code == "H15049901371" {
  33603. 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)
  33604. var dat map[string]interface{}
  33605. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33606. fmt.Println(dat)
  33607. } else {
  33608. fmt.Println(err)
  33609. }
  33610. saveLog(result, src_resquest, "2208", "退费")
  33611. if strings.Contains(result, "Post") {
  33612. res.Infcode = -1
  33613. res.ErrMsg = result
  33614. }
  33615. userJSONBytes, _ := json.Marshal(dat)
  33616. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  33617. utils.ErrorLog("解析失败:%v", err)
  33618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33619. return
  33620. }
  33621. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  33622. res.Output = resSixteen10265.Output
  33623. res.ErrMsg = resSixteen10265.ErrMsg
  33624. res.Cainfo = resSixteen10265.Cainfo
  33625. res.WarnMsg = resSixteen10265.WarnMsg
  33626. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  33627. res.Infcode = infocode
  33628. } else {
  33629. 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)
  33630. var dat map[string]interface{}
  33631. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33632. fmt.Println(dat)
  33633. } else {
  33634. fmt.Println(err)
  33635. }
  33636. saveLog(result, src_resquest, "2208", "退费")
  33637. userJSONBytes, _ := json.Marshal(dat)
  33638. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  33639. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  33640. utils.ErrorLog("解析失败:%v", err)
  33641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33642. return
  33643. }
  33644. res.Infcode = gz.Infcode
  33645. } else {
  33646. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33647. utils.ErrorLog("解析失败:%v", err)
  33648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33649. return
  33650. }
  33651. }
  33652. if strings.Contains(result, "Post") {
  33653. res.Infcode = -1
  33654. res.ErrMsg = result
  33655. }
  33656. }
  33657. }
  33658. if res.Infcode == -1 {
  33659. c.ServeSuccessJSON(map[string]interface{}{
  33660. "failed_code": -10,
  33661. "msg": res.ErrMsg,
  33662. })
  33663. return
  33664. }
  33665. if res.Infcode != -1 {
  33666. var res2 ResultSix
  33667. var resSix10265 ResultSix10265
  33668. if miConfig.MdtrtareaAdmvs == "421300" {
  33669. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  33670. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33671. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33672. resp3, requestErr3 := http.Get(api3)
  33673. if requestErr3 != nil {
  33674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33675. return
  33676. }
  33677. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33678. if ioErr3 != nil {
  33679. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33681. return
  33682. }
  33683. var respJSON3 map[string]interface{}
  33684. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33685. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33687. return
  33688. }
  33689. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33690. userJSONBytes3, _ := json.Marshal(respJSON3)
  33691. fmt.Println("log")
  33692. fmt.Println(string(userJSONBytes3))
  33693. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33694. utils.ErrorLog("解析失败:%v", err)
  33695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33696. return
  33697. }
  33698. } else if miConfig.MdtrtareaAdmvs == "420200" {
  33699. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  33700. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33701. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33702. resp3, requestErr3 := http.Get(api3)
  33703. if requestErr3 != nil {
  33704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33705. return
  33706. }
  33707. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33708. if ioErr3 != nil {
  33709. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33711. return
  33712. }
  33713. var respJSON3 map[string]interface{}
  33714. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33715. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33717. return
  33718. }
  33719. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33720. userJSONBytes3, _ := json.Marshal(respJSON3)
  33721. fmt.Println("log")
  33722. fmt.Println(string(userJSONBytes3))
  33723. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33724. utils.ErrorLog("解析失败:%v", err)
  33725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33726. return
  33727. }
  33728. } else if miConfig.MdtrtareaAdmvs == "420902" {
  33729. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  33730. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33731. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33732. resp3, requestErr3 := http.Get(api3)
  33733. if requestErr3 != nil {
  33734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33735. return
  33736. }
  33737. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33738. if ioErr3 != nil {
  33739. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33741. return
  33742. }
  33743. var respJSON3 map[string]interface{}
  33744. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33745. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33747. return
  33748. }
  33749. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33750. userJSONBytes3, _ := json.Marshal(respJSON3)
  33751. fmt.Println("log")
  33752. fmt.Println(string(userJSONBytes3))
  33753. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33754. utils.ErrorLog("解析失败:%v", err)
  33755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33756. return
  33757. }
  33758. } else if miConfig.MdtrtareaAdmvs == "421182" {
  33759. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  33760. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33761. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33762. resp3, requestErr3 := http.Get(api3)
  33763. if requestErr3 != nil {
  33764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33765. return
  33766. }
  33767. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33768. if ioErr3 != nil {
  33769. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33771. return
  33772. }
  33773. var respJSON3 map[string]interface{}
  33774. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33775. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33777. return
  33778. }
  33779. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33780. userJSONBytes3, _ := json.Marshal(respJSON3)
  33781. fmt.Println("log")
  33782. fmt.Println(string(userJSONBytes3))
  33783. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33784. utils.ErrorLog("解析失败:%v", err)
  33785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33786. return
  33787. }
  33788. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  33789. var api3 string
  33790. if miConfig.MdtrtareaAdmvs == "320830" {
  33791. api3 = miConfig.AppSecret + "jsyb/2205?psn_no=" + order.PsnNo +
  33792. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + "0000" + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33793. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33794. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33795. } else if miConfig.MdtrtareaAdmvs == "320921" {
  33796. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  33797. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33798. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33799. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33800. } else {
  33801. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33802. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  33803. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33804. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33805. }
  33806. resp3, requestErr3 := http.Get(api3)
  33807. if requestErr3 != nil {
  33808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33809. return
  33810. }
  33811. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33812. if ioErr3 != nil {
  33813. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33815. return
  33816. }
  33817. var respJSON3 map[string]interface{}
  33818. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33819. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33821. return
  33822. }
  33823. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33824. userJSONBytes3, _ := json.Marshal(respJSON3)
  33825. fmt.Println("log")
  33826. fmt.Println(string(userJSONBytes3))
  33827. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33828. utils.ErrorLog("解析失败:%v", err)
  33829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33830. return
  33831. }
  33832. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33833. res2.Output = resSix10265.Output
  33834. res2.ErrMsg = resSix10265.ErrMsg
  33835. res2.Cainfo = resSix10265.Cainfo
  33836. res2.WarnMsg = resSix10265.WarnMsg
  33837. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33838. res2.Infcode = infocode
  33839. } else if miConfig.MdtrtareaAdmvs == "150404" {
  33840. var api3 string
  33841. new_chrg_bchno := order.Number
  33842. if adminUser.CurrentOrgId == 10265 {
  33843. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  33844. new_chrg_bchno = "0000"
  33845. }
  33846. }
  33847. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  33848. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33849. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33850. resp3, requestErr3 := http.Get(api3)
  33851. if requestErr3 != nil {
  33852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33853. return
  33854. }
  33855. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33856. if ioErr3 != nil {
  33857. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33859. return
  33860. }
  33861. var respJSON3 map[string]interface{}
  33862. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33863. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33865. return
  33866. }
  33867. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33868. userJSONBytes3, _ := json.Marshal(respJSON3)
  33869. fmt.Println("log")
  33870. fmt.Println(string(userJSONBytes3))
  33871. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33872. utils.ErrorLog("解析失败:%v", err)
  33873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33874. return
  33875. }
  33876. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33877. res2.Output = resSix10265.Output
  33878. res2.ErrMsg = resSix10265.ErrMsg
  33879. res2.Cainfo = resSix10265.Cainfo
  33880. res2.WarnMsg = resSix10265.WarnMsg
  33881. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33882. res2.Infcode = infocode
  33883. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33884. 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)
  33885. var dat map[string]interface{}
  33886. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33887. fmt.Println(dat)
  33888. } else {
  33889. fmt.Println(err)
  33890. }
  33891. saveLog(result2, src_request, "2205", "撤销明细")
  33892. userJSONBytes, _ := json.Marshal(dat)
  33893. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33894. utils.ErrorLog("解析失败:%v", err)
  33895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33896. return
  33897. }
  33898. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33899. 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, "")
  33900. var dat map[string]interface{}
  33901. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33902. fmt.Println(dat)
  33903. } else {
  33904. fmt.Println(err)
  33905. }
  33906. saveLog(result2, src_request, "2205", "撤销明细")
  33907. userJSONBytes, _ := json.Marshal(dat)
  33908. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33909. utils.ErrorLog("解析失败:%v", err)
  33910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33911. return
  33912. }
  33913. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33914. 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, "")
  33915. var dat map[string]interface{}
  33916. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33917. fmt.Println(dat)
  33918. } else {
  33919. fmt.Println(err)
  33920. }
  33921. saveLog(result2, src_request, "2205", "撤销明细")
  33922. userJSONBytes, _ := json.Marshal(dat)
  33923. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33924. utils.ErrorLog("解析失败:%v", err)
  33925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33926. return
  33927. }
  33928. } else if miConfig.MdtrtareaAdmvs == "360100" {
  33929. 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, "")
  33930. var dat map[string]interface{}
  33931. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33932. fmt.Println(dat)
  33933. } else {
  33934. fmt.Println(err)
  33935. }
  33936. saveLog(result2, src_request, "2205", "撤销明细")
  33937. userJSONBytes, _ := json.Marshal(dat)
  33938. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33939. utils.ErrorLog("解析失败:%v", err)
  33940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33941. return
  33942. }
  33943. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33944. var api3 string
  33945. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  33946. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33947. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33948. resp3, requestErr3 := http.Get(api3)
  33949. if requestErr3 != nil {
  33950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33951. return
  33952. }
  33953. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33954. if ioErr3 != nil {
  33955. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33957. return
  33958. }
  33959. var respJSON3 map[string]interface{}
  33960. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33961. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33963. return
  33964. }
  33965. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33966. if status == "0" {
  33967. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33968. c.ServeSuccessJSON(map[string]interface{}{
  33969. "failed_code": -10,
  33970. "msg": err_msg,
  33971. })
  33972. return
  33973. }
  33974. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33975. userJSONBytes3, _ := json.Marshal(respJSON3)
  33976. fmt.Println("log")
  33977. fmt.Println(string(userJSONBytes3))
  33978. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33979. utils.ErrorLog("解析失败:%v", err)
  33980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33981. return
  33982. }
  33983. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33984. 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, "")
  33985. var dat map[string]interface{}
  33986. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33987. fmt.Println(dat)
  33988. } else {
  33989. fmt.Println(err)
  33990. }
  33991. saveLog(result2, src_request, "2205", "撤销明细")
  33992. userJSONBytes, _ := json.Marshal(dat)
  33993. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33994. utils.ErrorLog("解析失败:%v", err)
  33995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33996. return
  33997. }
  33998. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33999. 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, "")
  34000. var dat map[string]interface{}
  34001. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34002. fmt.Println(dat)
  34003. } else {
  34004. fmt.Println(err)
  34005. }
  34006. saveLog(result2, src_request, "2205", "撤销明细")
  34007. userJSONBytes, _ := json.Marshal(dat)
  34008. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34009. utils.ErrorLog("解析失败:%v", err)
  34010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34011. return
  34012. }
  34013. } else if miConfig.MdtrtareaAdmvs == "360100" {
  34014. 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, "")
  34015. var dat map[string]interface{}
  34016. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34017. fmt.Println(dat)
  34018. } else {
  34019. fmt.Println(err)
  34020. }
  34021. saveLog(result2, src_request, "2205", "撤销明细")
  34022. userJSONBytes, _ := json.Marshal(dat)
  34023. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34024. utils.ErrorLog("解析失败:%v", err)
  34025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34026. return
  34027. }
  34028. } else if miConfig.MdtrtareaAdmvs == "340699" {
  34029. var api3 string
  34030. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  34031. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34032. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34033. resp3, requestErr3 := http.Get(api3)
  34034. if requestErr3 != nil {
  34035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34036. return
  34037. }
  34038. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34039. if ioErr3 != nil {
  34040. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34042. return
  34043. }
  34044. var respJSON3 map[string]interface{}
  34045. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34046. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34048. return
  34049. }
  34050. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34051. if status == "0" {
  34052. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34053. c.ServeSuccessJSON(map[string]interface{}{
  34054. "failed_code": -10,
  34055. "msg": err_msg,
  34056. })
  34057. return
  34058. }
  34059. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34060. userJSONBytes3, _ := json.Marshal(respJSON3)
  34061. fmt.Println("log")
  34062. fmt.Println(string(userJSONBytes3))
  34063. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34064. utils.ErrorLog("解析失败:%v", err)
  34065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34066. return
  34067. }
  34068. } else if miConfig.MdtrtareaAdmvs == "430800" {
  34069. 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, "")
  34070. var dat map[string]interface{}
  34071. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34072. fmt.Println(dat)
  34073. } else {
  34074. fmt.Println(err)
  34075. }
  34076. saveLog(result2, src_request, "2205", "撤销明细")
  34077. userJSONBytes, _ := json.Marshal(dat)
  34078. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34079. utils.ErrorLog("解析失败:%v", err)
  34080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34081. return
  34082. }
  34083. } else if miConfig.MdtrtareaAdmvs == "441799" {
  34084. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  34085. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34086. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34087. resp3, requestErr3 := http.Get(api3)
  34088. if requestErr3 != nil {
  34089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34090. return
  34091. }
  34092. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34093. if ioErr3 != nil {
  34094. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34096. return
  34097. }
  34098. var respJSON3 map[string]interface{}
  34099. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34100. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34102. return
  34103. }
  34104. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34105. userJSONBytes3, _ := json.Marshal(respJSON3)
  34106. fmt.Println("log")
  34107. fmt.Println(string(userJSONBytes3))
  34108. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34109. utils.ErrorLog("解析失败:%v", err)
  34110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34111. return
  34112. }
  34113. } else {
  34114. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  34115. res2.Infcode = 0
  34116. } else {
  34117. 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)
  34118. var dat map[string]interface{}
  34119. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34120. fmt.Println(dat)
  34121. } else {
  34122. fmt.Println(err)
  34123. }
  34124. saveLog(result2, src_request, "2205", "撤销明细")
  34125. userJSONBytes, _ := json.Marshal(dat)
  34126. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34127. utils.ErrorLog("解析失败:%v", err)
  34128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34129. return
  34130. }
  34131. }
  34132. }
  34133. if res2.Infcode == -1 {
  34134. c.ServeSuccessJSON(map[string]interface{}{
  34135. "failed_code": -10,
  34136. "msg": res2.ErrMsg,
  34137. })
  34138. return
  34139. }
  34140. if res2.Infcode == 0 {
  34141. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  34142. if err == nil {
  34143. //当押金不为零时产生退费记录
  34144. if order.Decimal != 0 {
  34145. tmp := strconv.FormatInt(order.ID, 10)
  34146. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  34147. if err != nil {
  34148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34149. return
  34150. }
  34151. }
  34152. c.ServeSuccessJSON(map[string]interface{}{
  34153. "msg": "退费成功",
  34154. })
  34155. } else {
  34156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34157. return
  34158. }
  34159. } else {
  34160. c.ServeSuccessJSON(map[string]interface{}{
  34161. "failed_code": -10,
  34162. "msg": res2.ErrMsg,
  34163. })
  34164. }
  34165. } else {
  34166. c.ServeSuccessJSON(map[string]interface{}{
  34167. "failed_code": -10,
  34168. "msg": res.ErrMsg,
  34169. })
  34170. }
  34171. }
  34172. }
  34173. func (c *HisApiController) RefundNumber() {
  34174. record_time := c.GetString("record_time")
  34175. //patient_id, _ := c.GetInt64("patient_id")
  34176. admin_user_id, _ := c.GetInt64("admin_user_id")
  34177. his_patient_id, _ := c.GetInt64("id")
  34178. timeLayout := "2006-01-02"
  34179. loc, _ := time.LoadLocation("Local")
  34180. adminUser := c.GetAdminUserInfo()
  34181. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  34182. fmt.Println(err)
  34183. if err != nil {
  34184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  34185. return
  34186. }
  34187. recordDateTime := theTime.Unix()
  34188. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  34189. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  34190. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  34191. //order, _ := service.GetHisOrderByID(order_id)
  34192. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34193. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34194. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34195. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  34196. if count > 0 {
  34197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  34198. return
  34199. }
  34200. if config.IsOpen == 1 { //对接了医保,走医保流程
  34201. var res2 ResultSix
  34202. var res3 GZResultSix
  34203. var resSix10265 ResultSix10265
  34204. if miConfig.MdtrtareaAdmvs == "421300" {
  34205. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  34206. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34207. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34208. resp3, requestErr3 := http.Get(api3)
  34209. if requestErr3 != nil {
  34210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34211. return
  34212. }
  34213. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34214. if ioErr3 != nil {
  34215. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34217. return
  34218. }
  34219. var respJSON3 map[string]interface{}
  34220. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34221. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34223. return
  34224. }
  34225. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34226. userJSONBytes3, _ := json.Marshal(respJSON3)
  34227. fmt.Println("log")
  34228. fmt.Println(string(userJSONBytes3))
  34229. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34230. utils.ErrorLog("解析失败:%v", err)
  34231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34232. return
  34233. }
  34234. } else if miConfig.MdtrtareaAdmvs == "420200" {
  34235. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  34236. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34237. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34238. resp3, requestErr3 := http.Get(api3)
  34239. if requestErr3 != nil {
  34240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34241. return
  34242. }
  34243. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34244. if ioErr3 != nil {
  34245. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34247. return
  34248. }
  34249. var respJSON3 map[string]interface{}
  34250. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34251. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34253. return
  34254. }
  34255. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34256. userJSONBytes3, _ := json.Marshal(respJSON3)
  34257. fmt.Println("log")
  34258. fmt.Println(string(userJSONBytes3))
  34259. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34260. utils.ErrorLog("解析失败:%v", err)
  34261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34262. return
  34263. }
  34264. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34265. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  34266. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34267. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34268. resp3, requestErr3 := http.Get(api3)
  34269. if requestErr3 != nil {
  34270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34271. return
  34272. }
  34273. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34274. if ioErr3 != nil {
  34275. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34277. return
  34278. }
  34279. var respJSON3 map[string]interface{}
  34280. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34281. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34283. return
  34284. }
  34285. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34286. userJSONBytes3, _ := json.Marshal(respJSON3)
  34287. fmt.Println("log")
  34288. fmt.Println(string(userJSONBytes3))
  34289. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34290. utils.ErrorLog("解析失败:%v", err)
  34291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34292. return
  34293. }
  34294. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34295. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  34296. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34297. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34298. resp3, requestErr3 := http.Get(api3)
  34299. if requestErr3 != nil {
  34300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34301. return
  34302. }
  34303. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34304. if ioErr3 != nil {
  34305. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34307. return
  34308. }
  34309. var respJSON3 map[string]interface{}
  34310. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34311. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34313. return
  34314. }
  34315. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34316. userJSONBytes3, _ := json.Marshal(respJSON3)
  34317. fmt.Println("log")
  34318. fmt.Println(string(userJSONBytes3))
  34319. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34320. utils.ErrorLog("解析失败:%v", err)
  34321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34322. return
  34323. }
  34324. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  34325. var api3 string
  34326. if miConfig.MdtrtareaAdmvs == "320830" {
  34327. api3 = miConfig.AppSecret + "jsyb/2202?psn_no=" + his.PsnNo +
  34328. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34329. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34330. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34331. } else if miConfig.MdtrtareaAdmvs == "320921" {
  34332. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  34333. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34334. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34335. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34336. } else {
  34337. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34338. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  34339. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34340. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34341. }
  34342. resp3, requestErr3 := http.Get(api3)
  34343. if requestErr3 != nil {
  34344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34345. return
  34346. }
  34347. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34348. if ioErr3 != nil {
  34349. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34351. return
  34352. }
  34353. var respJSON3 map[string]interface{}
  34354. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34355. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34357. return
  34358. }
  34359. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34360. userJSONBytes3, _ := json.Marshal(respJSON3)
  34361. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34362. utils.ErrorLog("解析失败:%v", err)
  34363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34364. return
  34365. }
  34366. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34367. res2.Output = resSix10265.Output
  34368. res2.ErrMsg = resSix10265.ErrMsg
  34369. res2.Cainfo = resSix10265.Cainfo
  34370. res2.WarnMsg = resSix10265.WarnMsg
  34371. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34372. res2.Infcode = infocode
  34373. } else if miConfig.MdtrtareaAdmvs == "150404" {
  34374. var api3 string
  34375. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  34376. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34377. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34378. resp3, requestErr3 := http.Get(api3)
  34379. if requestErr3 != nil {
  34380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34381. return
  34382. }
  34383. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34384. if ioErr3 != nil {
  34385. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34387. return
  34388. }
  34389. var respJSON3 map[string]interface{}
  34390. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34391. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34393. return
  34394. }
  34395. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34396. userJSONBytes3, _ := json.Marshal(respJSON3)
  34397. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34398. utils.ErrorLog("解析失败:%v", err)
  34399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34400. return
  34401. }
  34402. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34403. res2.Output = resSix10265.Output
  34404. res2.ErrMsg = resSix10265.ErrMsg
  34405. res2.Cainfo = resSix10265.Cainfo
  34406. res2.WarnMsg = resSix10265.WarnMsg
  34407. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34408. res2.Infcode = infocode
  34409. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34410. 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)
  34411. var dat map[string]interface{}
  34412. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34413. fmt.Println(dat)
  34414. } else {
  34415. fmt.Println(err)
  34416. }
  34417. saveLog(result, request, "2202", "退号")
  34418. userJSONBytes, _ := json.Marshal(dat)
  34419. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34420. utils.ErrorLog("解析失败:%v", err)
  34421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34422. return
  34423. }
  34424. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34425. 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, "")
  34426. var dat map[string]interface{}
  34427. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34428. fmt.Println(dat)
  34429. } else {
  34430. fmt.Println(err)
  34431. }
  34432. saveLog(result, request, "2202", "退号")
  34433. userJSONBytes, _ := json.Marshal(dat)
  34434. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34435. utils.ErrorLog("解析失败:%v", err)
  34436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34437. return
  34438. }
  34439. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34440. 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, "")
  34441. var dat map[string]interface{}
  34442. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34443. fmt.Println(dat)
  34444. } else {
  34445. fmt.Println(err)
  34446. }
  34447. saveLog(result, request, "2202", "退号")
  34448. userJSONBytes, _ := json.Marshal(dat)
  34449. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34450. utils.ErrorLog("解析失败:%v", err)
  34451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34452. return
  34453. }
  34454. } else if miConfig.MdtrtareaAdmvs == "360100" {
  34455. 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, "")
  34456. var dat map[string]interface{}
  34457. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34458. fmt.Println(dat)
  34459. } else {
  34460. fmt.Println(err)
  34461. }
  34462. saveLog(result, request, "2202", "退号")
  34463. userJSONBytes, _ := json.Marshal(dat)
  34464. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34465. utils.ErrorLog("解析失败:%v", err)
  34466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34467. return
  34468. }
  34469. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34470. var api3 string
  34471. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  34472. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34473. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34474. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34475. resp3, requestErr3 := http.Get(api3)
  34476. if requestErr3 != nil {
  34477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34478. return
  34479. }
  34480. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34481. if ioErr3 != nil {
  34482. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34484. return
  34485. }
  34486. var respJSON3 map[string]interface{}
  34487. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34488. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34490. return
  34491. }
  34492. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34493. if status == "0" {
  34494. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34495. c.ServeSuccessJSON(map[string]interface{}{
  34496. "failed_code": -10,
  34497. "msg": err_msg,
  34498. })
  34499. return
  34500. }
  34501. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34502. userJSONBytes3, _ := json.Marshal(respJSON3)
  34503. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34504. utils.ErrorLog("解析失败:%v", err)
  34505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34506. return
  34507. }
  34508. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  34509. } else if miConfig.MdtrtareaAdmvs == "340699" {
  34510. var api3 string
  34511. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  34512. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34513. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34514. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34515. resp3, requestErr3 := http.Get(api3)
  34516. if requestErr3 != nil {
  34517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34518. return
  34519. }
  34520. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34521. if ioErr3 != nil {
  34522. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34524. return
  34525. }
  34526. var respJSON3 map[string]interface{}
  34527. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34528. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34530. return
  34531. }
  34532. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34533. if status == "0" {
  34534. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34535. c.ServeSuccessJSON(map[string]interface{}{
  34536. "failed_code": -10,
  34537. "msg": err_msg,
  34538. })
  34539. return
  34540. }
  34541. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34542. userJSONBytes3, _ := json.Marshal(respJSON3)
  34543. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34544. utils.ErrorLog("解析失败:%v", err)
  34545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34546. return
  34547. }
  34548. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  34549. } else if miConfig.MdtrtareaAdmvs == "430800" {
  34550. 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, "")
  34551. var dat map[string]interface{}
  34552. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34553. fmt.Println(dat)
  34554. } else {
  34555. fmt.Println(err)
  34556. }
  34557. saveLog(result, request, "2202", "退号")
  34558. userJSONBytes, _ := json.Marshal(dat)
  34559. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34560. utils.ErrorLog("解析失败:%v", err)
  34561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34562. return
  34563. }
  34564. } else if miConfig.MdtrtareaAdmvs == "441799" {
  34565. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  34566. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34567. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  34568. resp3, requestErr3 := http.Get(api3)
  34569. if requestErr3 != nil {
  34570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34571. return
  34572. }
  34573. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34574. if ioErr3 != nil {
  34575. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34577. return
  34578. }
  34579. var respJSON3 map[string]interface{}
  34580. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34581. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34583. return
  34584. }
  34585. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34586. userJSONBytes3, _ := json.Marshal(respJSON3)
  34587. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34588. utils.ErrorLog("解析失败:%v", err)
  34589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34590. return
  34591. }
  34592. } else {
  34593. var api3 string
  34594. if miConfig.Code == "H15049901371" {
  34595. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  34596. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34597. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34598. } else {
  34599. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  34600. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34601. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  34602. }
  34603. resp3, requestErr3 := http.Get(api3)
  34604. if requestErr3 != nil {
  34605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34606. return
  34607. }
  34608. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34609. if ioErr3 != nil {
  34610. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34612. return
  34613. }
  34614. var respJSON3 map[string]interface{}
  34615. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34616. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34618. return
  34619. }
  34620. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34621. userJSONBytes3, _ := json.Marshal(respJSON3)
  34622. if miConfig.Code == "H15049901371" {
  34623. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34624. utils.ErrorLog("解析失败:%v", err)
  34625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34626. return
  34627. }
  34628. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34629. res2.Output = resSix10265.Output
  34630. res2.ErrMsg = resSix10265.ErrMsg
  34631. res2.Cainfo = resSix10265.Cainfo
  34632. res2.WarnMsg = resSix10265.WarnMsg
  34633. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34634. res2.Infcode = infocode
  34635. } else {
  34636. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  34637. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  34638. utils.ErrorLog("解析失败:%v", err)
  34639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34640. return
  34641. }
  34642. res2.Infcode = res3.Infcode
  34643. } else {
  34644. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34645. utils.ErrorLog("解析失败:%v", err)
  34646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34647. return
  34648. }
  34649. }
  34650. }
  34651. }
  34652. if res2.Infcode == -1 {
  34653. c.ServeSuccessJSON(map[string]interface{}{
  34654. "failed_code": -10,
  34655. "msg": res2.ErrMsg,
  34656. })
  34657. return
  34658. }
  34659. if res2.Infcode == 0 {
  34660. if err == nil {
  34661. c.ServeSuccessJSON(map[string]interface{}{
  34662. "msg": "退号成功",
  34663. })
  34664. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  34665. //service.UpdataOrderStatusTen(his., recordDateTime, adminUser.CurrentOrgId)
  34666. } else {
  34667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34668. return
  34669. }
  34670. }
  34671. } else {
  34672. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  34673. //if err == nil {
  34674. // c.ServeSuccessJSON(map[string]interface{}{
  34675. // "msg": "退费成功",
  34676. // })
  34677. //} else {
  34678. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34679. // return
  34680. //}
  34681. }
  34682. }
  34683. func (c *HisApiController) RefundDetail() {
  34684. order_id, _ := c.GetInt64("order_id")
  34685. admin_user_id, _ := c.GetInt64("admin_user_id")
  34686. //his_patient_id, _ := c.GetInt64("his_patient_id")
  34687. number := c.GetString("number")
  34688. record_time := c.GetString("record_time")
  34689. patient_id, _ := c.GetInt64("patient_id")
  34690. //med_type, _ := c.GetInt64("med_type")
  34691. timeLayout := "2006-01-02"
  34692. loc, _ := time.LoadLocation("Local")
  34693. adminUser := c.GetAdminUserInfo()
  34694. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34695. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  34696. fmt.Println(err)
  34697. if err != nil {
  34698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  34699. return
  34700. }
  34701. recordDateTime := theTime.Unix()
  34702. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  34703. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  34704. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34705. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34706. var order models.HisOrder
  34707. order, _ = service.GetHisOrderByID(order_id)
  34708. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34709. if config.IsOpen == 1 { //对接了医保,走医保流程
  34710. var res2 ResultSix
  34711. if miConfig.MdtrtareaAdmvs == "421300" {
  34712. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  34713. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34714. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34715. resp3, requestErr3 := http.Get(api3)
  34716. if requestErr3 != nil {
  34717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34718. return
  34719. }
  34720. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34721. if ioErr3 != nil {
  34722. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34724. return
  34725. }
  34726. var respJSON3 map[string]interface{}
  34727. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34728. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34730. return
  34731. }
  34732. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34733. userJSONBytes3, _ := json.Marshal(respJSON3)
  34734. fmt.Println("log")
  34735. fmt.Println(string(userJSONBytes3))
  34736. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34737. utils.ErrorLog("解析失败:%v", err)
  34738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34739. return
  34740. }
  34741. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34742. if err == nil {
  34743. c.ServeSuccessJSON(map[string]interface{}{
  34744. "msg": "撤销明细成功",
  34745. })
  34746. return
  34747. } else {
  34748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34749. return
  34750. }
  34751. } else if miConfig.MdtrtareaAdmvs == "420200" {
  34752. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  34753. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34754. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34755. resp3, requestErr3 := http.Get(api3)
  34756. if requestErr3 != nil {
  34757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34758. return
  34759. }
  34760. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34761. if ioErr3 != nil {
  34762. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34764. return
  34765. }
  34766. var respJSON3 map[string]interface{}
  34767. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34768. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34770. return
  34771. }
  34772. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34773. userJSONBytes3, _ := json.Marshal(respJSON3)
  34774. fmt.Println("log")
  34775. fmt.Println(string(userJSONBytes3))
  34776. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34777. utils.ErrorLog("解析失败:%v", err)
  34778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34779. return
  34780. }
  34781. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34782. if err == nil {
  34783. c.ServeSuccessJSON(map[string]interface{}{
  34784. "msg": "撤销明细成功",
  34785. })
  34786. return
  34787. } else {
  34788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34789. return
  34790. }
  34791. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34792. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  34793. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34794. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34795. resp3, requestErr3 := http.Get(api3)
  34796. if requestErr3 != nil {
  34797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34798. return
  34799. }
  34800. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34801. if ioErr3 != nil {
  34802. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34804. return
  34805. }
  34806. var respJSON3 map[string]interface{}
  34807. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34808. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34810. return
  34811. }
  34812. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34813. userJSONBytes3, _ := json.Marshal(respJSON3)
  34814. fmt.Println("log")
  34815. fmt.Println(string(userJSONBytes3))
  34816. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34817. utils.ErrorLog("解析失败:%v", err)
  34818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34819. return
  34820. }
  34821. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34822. if err == nil {
  34823. c.ServeSuccessJSON(map[string]interface{}{
  34824. "msg": "撤销明细成功",
  34825. })
  34826. return
  34827. } else {
  34828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34829. return
  34830. }
  34831. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34832. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  34833. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34834. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34835. resp3, requestErr3 := http.Get(api3)
  34836. if requestErr3 != nil {
  34837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34838. return
  34839. }
  34840. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34841. if ioErr3 != nil {
  34842. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34844. return
  34845. }
  34846. var respJSON3 map[string]interface{}
  34847. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34848. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34850. return
  34851. }
  34852. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34853. userJSONBytes3, _ := json.Marshal(respJSON3)
  34854. fmt.Println("log")
  34855. fmt.Println(string(userJSONBytes3))
  34856. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34857. utils.ErrorLog("解析失败:%v", err)
  34858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34859. return
  34860. }
  34861. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34862. if err == nil {
  34863. c.ServeSuccessJSON(map[string]interface{}{
  34864. "msg": "撤销明细成功",
  34865. })
  34866. return
  34867. } else {
  34868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34869. return
  34870. }
  34871. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  34872. var resSix10265 ResultSix10265
  34873. var api3 string
  34874. if miConfig.MdtrtareaAdmvs == "320830" {
  34875. api3 = miConfig.AppSecret + "jsyb/2205?psn_no=" + order.PsnNo +
  34876. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + "0000" + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34877. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34878. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34879. } else if miConfig.MdtrtareaAdmvs == "320921" {
  34880. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  34881. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34882. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34883. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34884. } else {
  34885. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34886. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  34887. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34888. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34889. }
  34890. resp3, requestErr3 := http.Get(api3)
  34891. utils.ErrorLog("接口: %v", requestErr3)
  34892. if requestErr3 != nil {
  34893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34894. return
  34895. }
  34896. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34897. if ioErr3 != nil {
  34898. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34900. return
  34901. }
  34902. var respJSON3 map[string]interface{}
  34903. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34904. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34906. return
  34907. }
  34908. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34909. userJSONBytes3, _ := json.Marshal(respJSON3)
  34910. fmt.Println("log")
  34911. fmt.Println(string(userJSONBytes3))
  34912. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34913. utils.ErrorLog("解析失败:%v", err)
  34914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34915. return
  34916. }
  34917. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34918. res2.Output = resSix10265.Output
  34919. res2.ErrMsg = resSix10265.ErrMsg
  34920. res2.Cainfo = resSix10265.Cainfo
  34921. res2.WarnMsg = resSix10265.WarnMsg
  34922. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34923. res2.Infcode = infocode
  34924. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34925. if err == nil {
  34926. c.ServeSuccessJSON(map[string]interface{}{
  34927. "msg": "撤销明细成功",
  34928. })
  34929. return
  34930. } else {
  34931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34932. return
  34933. }
  34934. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34935. var api3 string
  34936. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  34937. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34938. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34939. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34940. resp3, requestErr3 := http.Get(api3)
  34941. utils.ErrorLog("接口: %v", requestErr3)
  34942. if requestErr3 != nil {
  34943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34944. return
  34945. }
  34946. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34947. if ioErr3 != nil {
  34948. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34950. return
  34951. }
  34952. var respJSON3 map[string]interface{}
  34953. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34954. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34956. return
  34957. }
  34958. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34959. if status == "0" {
  34960. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34961. c.ServeSuccessJSON(map[string]interface{}{
  34962. "failed_code": -10,
  34963. "msg": err_msg,
  34964. })
  34965. return
  34966. }
  34967. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34968. userJSONBytes3, _ := json.Marshal(respJSON3)
  34969. fmt.Println("log")
  34970. fmt.Println(string(userJSONBytes3))
  34971. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34972. utils.ErrorLog("解析失败:%v", err)
  34973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34974. return
  34975. }
  34976. fmt.Println(res2.Infcode)
  34977. if res2.Infcode == -1 {
  34978. c.ServeSuccessJSON(map[string]interface{}{
  34979. "failed_code": -10,
  34980. "msg": res2.ErrMsg,
  34981. })
  34982. return
  34983. }
  34984. if res2.Infcode == 0 {
  34985. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34986. if err == nil {
  34987. c.ServeSuccessJSON(map[string]interface{}{
  34988. "msg": "撤销明细成功",
  34989. })
  34990. return
  34991. } else {
  34992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34993. return
  34994. }
  34995. } else {
  34996. c.ServeSuccessJSON(map[string]interface{}{
  34997. "failed_code": -10,
  34998. "msg": res2.ErrMsg,
  34999. })
  35000. }
  35001. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35002. if err == nil {
  35003. c.ServeSuccessJSON(map[string]interface{}{
  35004. "msg": "撤销明细成功",
  35005. })
  35006. return
  35007. } else {
  35008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35009. return
  35010. }
  35011. } else if miConfig.MdtrtareaAdmvs == "340699" {
  35012. var api3 string
  35013. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  35014. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  35015. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35016. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35017. resp3, requestErr3 := http.Get(api3)
  35018. utils.ErrorLog("接口: %v", requestErr3)
  35019. if requestErr3 != nil {
  35020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35021. return
  35022. }
  35023. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  35024. if ioErr3 != nil {
  35025. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  35026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35027. return
  35028. }
  35029. var respJSON3 map[string]interface{}
  35030. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  35031. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35033. return
  35034. }
  35035. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  35036. if status == "0" {
  35037. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  35038. c.ServeSuccessJSON(map[string]interface{}{
  35039. "failed_code": -10,
  35040. "msg": err_msg,
  35041. })
  35042. return
  35043. }
  35044. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35045. userJSONBytes3, _ := json.Marshal(respJSON3)
  35046. fmt.Println("log")
  35047. fmt.Println(string(userJSONBytes3))
  35048. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  35049. utils.ErrorLog("解析失败:%v", err)
  35050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35051. return
  35052. }
  35053. fmt.Println(res2.Infcode)
  35054. if res2.Infcode == -1 {
  35055. c.ServeSuccessJSON(map[string]interface{}{
  35056. "failed_code": -10,
  35057. "msg": res2.ErrMsg,
  35058. })
  35059. return
  35060. }
  35061. if res2.Infcode == 0 {
  35062. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35063. if err == nil {
  35064. c.ServeSuccessJSON(map[string]interface{}{
  35065. "msg": "撤销明细成功",
  35066. })
  35067. return
  35068. } else {
  35069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35070. return
  35071. }
  35072. } else {
  35073. c.ServeSuccessJSON(map[string]interface{}{
  35074. "failed_code": -10,
  35075. "msg": res2.ErrMsg,
  35076. })
  35077. }
  35078. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35079. if err == nil {
  35080. c.ServeSuccessJSON(map[string]interface{}{
  35081. "msg": "撤销明细成功",
  35082. })
  35083. return
  35084. } else {
  35085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35086. return
  35087. }
  35088. } else if miConfig.MdtrtareaAdmvs == "150404" {
  35089. var resSix10265 ResultSix10265
  35090. new_chrg_bchno := order.Number
  35091. if adminUser.CurrentOrgId == 10265 {
  35092. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  35093. new_chrg_bchno = "0000"
  35094. }
  35095. }
  35096. var api3 string
  35097. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  35098. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  35099. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35100. resp3, requestErr3 := http.Get(api3)
  35101. if requestErr3 != nil {
  35102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35103. return
  35104. }
  35105. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  35106. if ioErr3 != nil {
  35107. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  35108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35109. return
  35110. }
  35111. var respJSON3 map[string]interface{}
  35112. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  35113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35115. return
  35116. }
  35117. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35118. userJSONBytes3, _ := json.Marshal(respJSON3)
  35119. fmt.Println("log")
  35120. fmt.Println(string(userJSONBytes3))
  35121. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  35122. utils.ErrorLog("解析失败:%v", err)
  35123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35124. return
  35125. }
  35126. res2.InfRefmsgid = resSix10265.InfRefmsgid
  35127. res2.Output = resSix10265.Output
  35128. res2.ErrMsg = resSix10265.ErrMsg
  35129. res2.Cainfo = resSix10265.Cainfo
  35130. res2.WarnMsg = resSix10265.WarnMsg
  35131. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  35132. res2.Infcode = infocode
  35133. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35134. if err == nil {
  35135. c.ServeSuccessJSON(map[string]interface{}{
  35136. "msg": "撤销明细成功",
  35137. })
  35138. return
  35139. } else {
  35140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35141. return
  35142. }
  35143. } else if miConfig.MdtrtareaAdmvs == "350500" {
  35144. 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)
  35145. var dat map[string]interface{}
  35146. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  35147. fmt.Println(dat)
  35148. } else {
  35149. fmt.Println(err)
  35150. }
  35151. saveLog(result2, src_request, "2205", "撤销明细")
  35152. userJSONBytes, _ := json.Marshal(dat)
  35153. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35154. utils.ErrorLog("解析失败:%v", err)
  35155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35156. return
  35157. }
  35158. if res2.Infcode == 0 {
  35159. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35160. if err == nil {
  35161. c.ServeSuccessJSON(map[string]interface{}{
  35162. "msg": "撤销明细成功",
  35163. })
  35164. return
  35165. } else {
  35166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35167. return
  35168. }
  35169. } else {
  35170. c.ServeSuccessJSON(map[string]interface{}{
  35171. "failed_code": -10,
  35172. "msg": res2.ErrMsg,
  35173. })
  35174. }
  35175. } else if miConfig.MdtrtareaAdmvs == "360302" {
  35176. 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, "")
  35177. var dat map[string]interface{}
  35178. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  35179. fmt.Println(dat)
  35180. } else {
  35181. fmt.Println(err)
  35182. }
  35183. saveLog(result2, src_request, "2205", "撤销明细")
  35184. userJSONBytes, _ := json.Marshal(dat)
  35185. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35186. utils.ErrorLog("解析失败:%v", err)
  35187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35188. return
  35189. }
  35190. if res2.Infcode == 0 {
  35191. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35192. if err == nil {
  35193. c.ServeSuccessJSON(map[string]interface{}{
  35194. "msg": "撤销明细成功",
  35195. })
  35196. return
  35197. } else {
  35198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35199. return
  35200. }
  35201. } else {
  35202. c.ServeSuccessJSON(map[string]interface{}{
  35203. "failed_code": -10,
  35204. "msg": res2.ErrMsg,
  35205. })
  35206. }
  35207. } else if miConfig.MdtrtareaAdmvs == "361025" {
  35208. 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, "")
  35209. var dat map[string]interface{}
  35210. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  35211. fmt.Println(dat)
  35212. } else {
  35213. fmt.Println(err)
  35214. }
  35215. saveLog(result2, src_request, "2205", "撤销明细")
  35216. userJSONBytes, _ := json.Marshal(dat)
  35217. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35218. utils.ErrorLog("解析失败:%v", err)
  35219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35220. return
  35221. }
  35222. if res2.Infcode == 0 {
  35223. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35224. if err == nil {
  35225. c.ServeSuccessJSON(map[string]interface{}{
  35226. "msg": "撤销明细成功",
  35227. })
  35228. return
  35229. } else {
  35230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35231. return
  35232. }
  35233. } else {
  35234. c.ServeSuccessJSON(map[string]interface{}{
  35235. "failed_code": -10,
  35236. "msg": res2.ErrMsg,
  35237. })
  35238. }
  35239. } else if miConfig.MdtrtareaAdmvs == "360100" {
  35240. 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, "")
  35241. var dat map[string]interface{}
  35242. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  35243. fmt.Println(dat)
  35244. } else {
  35245. fmt.Println(err)
  35246. }
  35247. saveLog(result2, src_request, "2205", "撤销明细")
  35248. userJSONBytes, _ := json.Marshal(dat)
  35249. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35250. utils.ErrorLog("解析失败:%v", err)
  35251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35252. return
  35253. }
  35254. if res2.Infcode == 0 {
  35255. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35256. if err == nil {
  35257. c.ServeSuccessJSON(map[string]interface{}{
  35258. "msg": "撤销明细成功",
  35259. })
  35260. return
  35261. } else {
  35262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35263. return
  35264. }
  35265. } else {
  35266. c.ServeSuccessJSON(map[string]interface{}{
  35267. "failed_code": -10,
  35268. "msg": res2.ErrMsg,
  35269. })
  35270. }
  35271. } else if miConfig.MdtrtareaAdmvs == "430800" {
  35272. 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, "")
  35273. var dat map[string]interface{}
  35274. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  35275. fmt.Println(dat)
  35276. } else {
  35277. fmt.Println(err)
  35278. }
  35279. saveLog(result2, src_request, "2205", "撤销明细")
  35280. userJSONBytes, _ := json.Marshal(dat)
  35281. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35282. utils.ErrorLog("解析失败:%v", err)
  35283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35284. return
  35285. }
  35286. if res2.Infcode == 0 {
  35287. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35288. if err == nil {
  35289. c.ServeSuccessJSON(map[string]interface{}{
  35290. "msg": "撤销明细成功",
  35291. })
  35292. return
  35293. } else {
  35294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35295. return
  35296. }
  35297. } else {
  35298. c.ServeSuccessJSON(map[string]interface{}{
  35299. "failed_code": -10,
  35300. "msg": res2.ErrMsg,
  35301. })
  35302. }
  35303. } else if miConfig.MdtrtareaAdmvs == "441799" {
  35304. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  35305. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  35306. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35307. resp2, requestErr2 := http.Get(api2)
  35308. if requestErr2 != nil {
  35309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35310. return
  35311. }
  35312. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  35313. if ioErr2 != nil {
  35314. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  35315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35316. return
  35317. }
  35318. var respJSON2 map[string]interface{}
  35319. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  35320. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35322. return
  35323. }
  35324. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35325. userJSONBytes3, _ := json.Marshal(respJSON2)
  35326. fmt.Println("log")
  35327. fmt.Println(string(userJSONBytes3))
  35328. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  35329. utils.ErrorLog("解析失败:%v", err)
  35330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35331. return
  35332. }
  35333. if res2.Infcode == 0 {
  35334. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35335. if err == nil {
  35336. c.ServeSuccessJSON(map[string]interface{}{
  35337. "msg": "撤销明细成功",
  35338. })
  35339. return
  35340. } else {
  35341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35342. return
  35343. }
  35344. } else {
  35345. c.ServeSuccessJSON(map[string]interface{}{
  35346. "failed_code": -10,
  35347. "msg": res2.ErrMsg,
  35348. })
  35349. }
  35350. } else {
  35351. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  35352. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  35353. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  35354. resp2, requestErr2 := http.Get(api2)
  35355. if requestErr2 != nil {
  35356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35357. return
  35358. }
  35359. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  35360. if ioErr2 != nil {
  35361. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  35362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35363. return
  35364. }
  35365. var respJSON2 map[string]interface{}
  35366. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  35367. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35369. return
  35370. }
  35371. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35372. userJSONBytes3, _ := json.Marshal(respJSON2)
  35373. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  35374. utils.ErrorLog("解析失败:%v", err)
  35375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35376. return
  35377. }
  35378. if res2.Infcode == -1 {
  35379. c.ServeSuccessJSON(map[string]interface{}{
  35380. "failed_code": -10,
  35381. "msg": res2.ErrMsg,
  35382. })
  35383. return
  35384. } else {
  35385. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35386. if err == nil {
  35387. c.ServeSuccessJSON(map[string]interface{}{
  35388. "msg": "撤销明细成功",
  35389. })
  35390. return
  35391. } else {
  35392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35393. return
  35394. }
  35395. }
  35396. }
  35397. } else {
  35398. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35399. if err == nil {
  35400. c.ServeSuccessJSON(map[string]interface{}{
  35401. "msg": "退费成功",
  35402. })
  35403. } else {
  35404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35405. return
  35406. }
  35407. }
  35408. }
  35409. // 对账
  35410. func (c *HisApiController) GetCheckAccount() {
  35411. start_time := c.GetString("start_time")
  35412. end_time := c.GetString("end_time")
  35413. insutype := c.GetString("insutype")
  35414. clr_type := c.GetString("clr_type")
  35415. clr_org := c.GetString("clr_optins")
  35416. admin_user_id, _ := c.GetInt64("admin_user_id")
  35417. adminUser := c.GetAdminUserInfo()
  35418. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35419. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35420. if len(clr_org) == 0 {
  35421. clr_org = miConfig.InsuplcAdmdvs
  35422. }
  35423. timeLayout := "2006-01-02"
  35424. loc, _ := time.LoadLocation("Local")
  35425. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  35426. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  35427. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35428. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35429. fixmedins_setl_cnt := int64(len(orders))
  35430. var medfee_sumamt float64
  35431. var acct_pay float64
  35432. var fund_pay_sumamt float64
  35433. for _, item := range orders {
  35434. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35435. acct_pay = acct_pay + item.AcctPay
  35436. if miConfig.MdtrtareaAdmvs == "361025" || miConfig.MdtrtareaAdmvs == "360100" {
  35437. fund_pay_sumamt = fund_pay_sumamt + item.HifpPay + item.HifmiPay + item.MafPay + item.HifobPay + item.HifesPay
  35438. } else {
  35439. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35440. }
  35441. }
  35442. var user_name string
  35443. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35444. if role.ID == 0 {
  35445. user_name = "xxx"
  35446. } else {
  35447. user_name = role.UserName
  35448. }
  35449. var res ResultEight
  35450. var res10188 ResultEightFor10188
  35451. if config.IsOpen == 1 {
  35452. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  35453. api := miConfig.AppSecret + "jsyb/3201?" +
  35454. "insutype=" + insutype +
  35455. "&clr_type=" + clr_type +
  35456. "&setl_optins=" + clr_org +
  35457. "&stmt_begndate=" + start_time +
  35458. "&stm_enddate=" + end_time +
  35459. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35460. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35461. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35462. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35463. "&fixmedins_code=" + miConfig.Code +
  35464. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35465. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35466. "&secret_key=" + miConfig.SecretKey +
  35467. "&org_name=" + miConfig.OrgName +
  35468. "&doctor=" + user_name +
  35469. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35470. fmt.Println(api)
  35471. resp, requestErr := http.Get(api)
  35472. if requestErr != nil {
  35473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35474. return
  35475. }
  35476. body, ioErr := ioutil.ReadAll(resp.Body)
  35477. fmt.Println(body)
  35478. if ioErr != nil {
  35479. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35481. return
  35482. }
  35483. var respJSON map[string]interface{}
  35484. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35485. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35487. return
  35488. }
  35489. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35490. userJSONBytes, _ := json.Marshal(respJSON)
  35491. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35492. utils.ErrorLog("解析失败:%v", err)
  35493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35494. return
  35495. }
  35496. res.InfRefmsgid = res10188.InfRefmsgid
  35497. res.Output = res10188.Output
  35498. res.ErrMsg = res10188.ErrMsg
  35499. res.Cainfo = res10188.Cainfo
  35500. res.WarnMsg = res10188.WarnMsg
  35501. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  35502. res.Infcode = infocode
  35503. } else if miConfig.MdtrtareaAdmvs == "150404" {
  35504. if clr_type != "9903" {
  35505. clr_type = "99" // 就诊 ID(来自2201接口返回)
  35506. }
  35507. if clr_type == "9903" {
  35508. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  35509. }
  35510. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  35511. "insutype=" + insutype +
  35512. "&clr_type=" + clr_type +
  35513. "&setl_optins=" + clr_org +
  35514. "&stmt_begndate=" + start_time +
  35515. "&stm_enddate=" + end_time +
  35516. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35517. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35518. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35519. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35520. "&fixmedins_code=" + miConfig.Code +
  35521. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35522. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35523. "&secret_key=" + miConfig.SecretKey +
  35524. "&org_name=" + miConfig.OrgName +
  35525. "&doctor=" + user_name
  35526. resp, requestErr := http.Get(api)
  35527. if requestErr != nil {
  35528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35529. return
  35530. }
  35531. body, ioErr := ioutil.ReadAll(resp.Body)
  35532. if ioErr != nil {
  35533. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35535. return
  35536. }
  35537. var respJSON map[string]interface{}
  35538. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35539. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35541. return
  35542. }
  35543. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35544. result, _ := json.Marshal(respJSON)
  35545. fmt.Println("log")
  35546. fmt.Println(string(result))
  35547. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  35548. utils.ErrorLog("解析失败:%v", err)
  35549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35550. return
  35551. }
  35552. res.InfRefmsgid = res10188.InfRefmsgid
  35553. res.Output = res10188.Output
  35554. res.ErrMsg = res10188.ErrMsg
  35555. res.Cainfo = res10188.Cainfo
  35556. res.WarnMsg = res10188.WarnMsg
  35557. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  35558. res.Infcode = infocode
  35559. } else if miConfig.MdtrtareaAdmvs == "350500" {
  35560. var baseParams models.BaseParams
  35561. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35562. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35563. baseParams.SecretKey = miConfig.SecretKey
  35564. baseParams.OrgName = miConfig.OrgName
  35565. baseParams.FixmedinsCode = miConfig.Code
  35566. baseParams.EncKey = miConfig.EncKey
  35567. baseParams.AppSecret = miConfig.AppSecret
  35568. baseParams.SignKey = miConfig.SignKey
  35569. baseParams.AppID = miConfig.Code
  35570. baseParams.Doctor = role.UserName
  35571. baseParams.RequestUrl = miConfig.Url
  35572. businessParams := models.BusinessParams{
  35573. Insutype: insutype,
  35574. ClrType: clr_type,
  35575. SetlOptins: clr_org,
  35576. StmtBegndate: start_time,
  35577. StmtEnddate: end_time,
  35578. MedfeeSumamt: medfee_sumamt,
  35579. FundPaySumamt: fund_pay_sumamt,
  35580. AcctPay: acct_pay,
  35581. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35582. }
  35583. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  35584. fmt.Println(requestLog)
  35585. fmt.Println(result)
  35586. fmt.Println(err_msg)
  35587. var dat map[string]interface{}
  35588. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35589. fmt.Println(dat)
  35590. } else {
  35591. fmt.Println(err)
  35592. }
  35593. userJSONBytes, _ := json.Marshal(dat)
  35594. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35595. utils.ErrorLog("解析失败:%v", err)
  35596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35597. return
  35598. }
  35599. } else if miConfig.MdtrtareaAdmvs == "430800" {
  35600. var baseParams models.BaseParams
  35601. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35602. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35603. baseParams.SecretKey = miConfig.SecretKey
  35604. baseParams.OrgName = miConfig.OrgName
  35605. baseParams.FixmedinsCode = miConfig.Code
  35606. baseParams.EncKey = miConfig.EncKey
  35607. baseParams.AppSecret = miConfig.AppSecret
  35608. baseParams.SignKey = miConfig.SignKey
  35609. baseParams.AppID = miConfig.Code
  35610. baseParams.Doctor = role.UserName
  35611. baseParams.RequestUrl = miConfig.Url
  35612. baseParams.AccessKey = miConfig.AccessKey
  35613. businessParams := models.BusinessParams{
  35614. Insutype: insutype,
  35615. ClrType: clr_type,
  35616. SetlOptins: "430822",
  35617. StmtBegndate: start_time,
  35618. StmtEnddate: end_time,
  35619. MedfeeSumamt: medfee_sumamt,
  35620. FundPaySumamt: fund_pay_sumamt,
  35621. AcctPay: acct_pay,
  35622. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35623. }
  35624. 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)
  35625. fmt.Println(requestLog)
  35626. fmt.Println(result)
  35627. var dat map[string]interface{}
  35628. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35629. fmt.Println(dat)
  35630. } else {
  35631. fmt.Println(err)
  35632. }
  35633. userJSONBytes, _ := json.Marshal(dat)
  35634. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35635. utils.ErrorLog("解析失败:%v", err)
  35636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35637. return
  35638. }
  35639. } else if miConfig.MdtrtareaAdmvs == "350500" {
  35640. var baseParams models.BaseParams
  35641. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35642. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35643. baseParams.SecretKey = miConfig.SecretKey
  35644. baseParams.OrgName = miConfig.OrgName
  35645. baseParams.FixmedinsCode = miConfig.Code
  35646. baseParams.EncKey = miConfig.EncKey
  35647. baseParams.AppSecret = miConfig.AppSecret
  35648. baseParams.SignKey = miConfig.SignKey
  35649. baseParams.AppID = miConfig.Code
  35650. baseParams.Doctor = role.UserName
  35651. baseParams.RequestUrl = miConfig.Url
  35652. businessParams := models.BusinessParams{
  35653. Insutype: insutype,
  35654. ClrType: clr_type,
  35655. SetlOptins: clr_org,
  35656. StmtBegndate: start_time,
  35657. StmtEnddate: end_time,
  35658. MedfeeSumamt: medfee_sumamt,
  35659. FundPaySumamt: fund_pay_sumamt,
  35660. AcctPay: acct_pay,
  35661. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35662. }
  35663. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  35664. fmt.Println(requestLog)
  35665. fmt.Println(result)
  35666. fmt.Println(err_msg)
  35667. var dat map[string]interface{}
  35668. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35669. fmt.Println(dat)
  35670. } else {
  35671. fmt.Println(err)
  35672. }
  35673. userJSONBytes, _ := json.Marshal(dat)
  35674. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35675. utils.ErrorLog("解析失败:%v", err)
  35676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35677. return
  35678. }
  35679. } else if miConfig.MdtrtareaAdmvs == "441799" {
  35680. if len(clr_type) == 0 {
  35681. clr_type = "11"
  35682. }
  35683. api := miConfig.Url + "gdyb/ten?" +
  35684. "insutype=" + insutype +
  35685. "&clr_type=" + clr_type +
  35686. "&setl_optins=" + clr_org +
  35687. "&stmt_begndate=" + start_time +
  35688. "&stm_enddate=" + end_time +
  35689. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35690. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35691. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35692. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  35693. "&fixmedins_code=" + miConfig.Code +
  35694. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35695. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35696. "&secret_key=" + miConfig.SecretKey +
  35697. "&org_name=" + miConfig.OrgName +
  35698. "&doctor=" + user_name
  35699. fmt.Println(api)
  35700. resp, requestErr := http.Get(api)
  35701. if requestErr != nil {
  35702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35703. return
  35704. }
  35705. body, ioErr := ioutil.ReadAll(resp.Body)
  35706. fmt.Println(body)
  35707. if ioErr != nil {
  35708. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35710. return
  35711. }
  35712. var respJSON map[string]interface{}
  35713. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35714. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35716. return
  35717. }
  35718. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35719. userJSONBytes, _ := json.Marshal(respJSON)
  35720. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35721. utils.ErrorLog("解析失败:%v", err)
  35722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35723. return
  35724. }
  35725. } else if miConfig.MdtrtareaAdmvs == "360100" {
  35726. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35727. //fixmedins_setl_cnt := int64(len(orders_two))
  35728. //var medfee_sumamt float64
  35729. //var acct_pay float64
  35730. //var fund_pay_sumamt float64
  35731. //for _, item := range orders_two {
  35732. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35733. // acct_pay = acct_pay + item.AcctPay
  35734. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35735. //}
  35736. var baseParams models.BaseParams
  35737. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35738. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35739. baseParams.SecretKey = miConfig.SecretKey
  35740. baseParams.OrgName = miConfig.OrgName
  35741. baseParams.FixmedinsCode = miConfig.Code
  35742. baseParams.EncKey = miConfig.EncKey
  35743. baseParams.AppSecret = miConfig.AppSecret
  35744. baseParams.SignKey = miConfig.SignKey
  35745. baseParams.AppID = miConfig.Code
  35746. baseParams.Doctor = role.UserName
  35747. baseParams.RequestUrl = miConfig.Url
  35748. businessParams := models.BusinessParams{
  35749. Insutype: insutype,
  35750. ClrType: clr_type,
  35751. SetlOptins: "360102",
  35752. StmtBegndate: start_time,
  35753. StmtEnddate: end_time,
  35754. MedfeeSumamt: 0,
  35755. FundPaySumamt: 0,
  35756. AcctPay: 0,
  35757. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35758. }
  35759. 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))
  35760. fmt.Println(requestLog)
  35761. fmt.Println(result)
  35762. var dat map[string]interface{}
  35763. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35764. fmt.Println(dat)
  35765. } else {
  35766. fmt.Println(err)
  35767. }
  35768. userJSONBytes, _ := json.Marshal(dat)
  35769. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35770. utils.ErrorLog("解析失败:%v", err)
  35771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35772. return
  35773. }
  35774. } else if miConfig.MdtrtareaAdmvs == "361025" {
  35775. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35776. //fixmedins_setl_cnt := int64(len(orders_two))
  35777. //var medfee_sumamt float64
  35778. //var acct_pay float64
  35779. //var fund_pay_sumamt float64
  35780. //for _, item := range orders_two {
  35781. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35782. // acct_pay = acct_pay + item.AcctPay
  35783. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35784. //}
  35785. var baseParams models.BaseParams
  35786. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35787. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35788. baseParams.SecretKey = miConfig.SecretKey
  35789. baseParams.OrgName = miConfig.OrgName
  35790. baseParams.FixmedinsCode = miConfig.Code
  35791. baseParams.EncKey = miConfig.EncKey
  35792. baseParams.AppSecret = miConfig.AppSecret
  35793. baseParams.SignKey = miConfig.SignKey
  35794. baseParams.AppID = miConfig.Code
  35795. baseParams.Doctor = role.UserName
  35796. baseParams.RequestUrl = miConfig.Url
  35797. if clr_type == "9903" {
  35798. clr_type = "9994"
  35799. }
  35800. businessParams := models.BusinessParams{
  35801. Insutype: insutype,
  35802. ClrType: clr_type,
  35803. SetlOptins: "361025",
  35804. StmtBegndate: start_time,
  35805. StmtEnddate: end_time,
  35806. MedfeeSumamt: 0,
  35807. FundPaySumamt: 0,
  35808. AcctPay: 0,
  35809. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35810. }
  35811. 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))
  35812. fmt.Println(requestLog)
  35813. fmt.Println(result)
  35814. var dat map[string]interface{}
  35815. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35816. fmt.Println(dat)
  35817. } else {
  35818. fmt.Println(err)
  35819. }
  35820. userJSONBytes, _ := json.Marshal(dat)
  35821. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35822. utils.ErrorLog("解析失败:%v", err)
  35823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35824. return
  35825. }
  35826. } else if miConfig.MdtrtareaAdmvs == "360106" {
  35827. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35828. //fixmedins_setl_cnt := int64(len(orders_two))
  35829. //var medfee_sumamt float64
  35830. //var acct_pay float64
  35831. //var fund_pay_sumamt float64
  35832. //for _, item := range orders_two {
  35833. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35834. // acct_pay = acct_pay + item.AcctPay
  35835. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35836. //}
  35837. var baseParams models.BaseParams
  35838. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35839. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35840. baseParams.SecretKey = miConfig.SecretKey
  35841. baseParams.OrgName = miConfig.OrgName
  35842. baseParams.FixmedinsCode = miConfig.Code
  35843. baseParams.EncKey = miConfig.EncKey
  35844. baseParams.AppSecret = miConfig.AppSecret
  35845. baseParams.SignKey = miConfig.SignKey
  35846. baseParams.AppID = miConfig.Code
  35847. baseParams.Doctor = role.UserName
  35848. baseParams.RequestUrl = miConfig.Url
  35849. if clr_type == "9903" {
  35850. clr_type = "9994"
  35851. }
  35852. businessParams := models.BusinessParams{
  35853. Insutype: insutype,
  35854. ClrType: clr_type,
  35855. SetlOptins: "360102",
  35856. StmtBegndate: start_time,
  35857. StmtEnddate: end_time,
  35858. MedfeeSumamt: 0,
  35859. FundPaySumamt: 0,
  35860. AcctPay: 0,
  35861. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35862. }
  35863. 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))
  35864. fmt.Println(requestLog)
  35865. fmt.Println(result)
  35866. var dat map[string]interface{}
  35867. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35868. fmt.Println(dat)
  35869. } else {
  35870. fmt.Println(err)
  35871. }
  35872. userJSONBytes, _ := json.Marshal(dat)
  35873. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35874. utils.ErrorLog("解析失败:%v", err)
  35875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35876. return
  35877. }
  35878. } else if miConfig.MdtrtareaAdmvs == "341203" {
  35879. var api string
  35880. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  35881. "&clr_type=" + clr_type +
  35882. "&setl_optins=" + clr_org +
  35883. "&stmt_begndate=" + start_time +
  35884. "&stm_enddate=" + end_time +
  35885. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35886. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35887. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35888. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35889. "&fixmedins_code=" + miConfig.Code +
  35890. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35891. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35892. "&secret_key=" + miConfig.SecretKey +
  35893. "&org_name=" + miConfig.OrgName +
  35894. "&doctor=" + user_name + "&url=" + miConfig.Url
  35895. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35896. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35897. resp, requestErr := http.Get(api)
  35898. if requestErr != nil {
  35899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35900. return
  35901. }
  35902. body, ioErr := ioutil.ReadAll(resp.Body)
  35903. if ioErr != nil {
  35904. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35906. return
  35907. }
  35908. var respJSON map[string]interface{}
  35909. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35910. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35912. return
  35913. }
  35914. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35915. if status == "0" {
  35916. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35917. c.ServeSuccessJSON(map[string]interface{}{
  35918. "failed_code": -10,
  35919. "msg": err_msg,
  35920. })
  35921. return
  35922. }
  35923. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35924. userJSONBytes, _ := json.Marshal(respJSON)
  35925. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35926. utils.ErrorLog("解析失败:%v", err)
  35927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35928. return
  35929. }
  35930. } else if miConfig.MdtrtareaAdmvs == "340699" {
  35931. var api string
  35932. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  35933. "&clr_type=" + clr_type +
  35934. "&setl_optins=" + clr_org +
  35935. "&stmt_begndate=" + start_time +
  35936. "&stm_enddate=" + end_time +
  35937. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35938. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35939. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35940. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35941. "&fixmedins_code=" + miConfig.Code +
  35942. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35943. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35944. "&secret_key=" + miConfig.SecretKey +
  35945. "&org_name=" + miConfig.OrgName +
  35946. "&doctor=" + user_name + "&url=" + miConfig.Url
  35947. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35948. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35949. resp, requestErr := http.Get(api)
  35950. if requestErr != nil {
  35951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35952. return
  35953. }
  35954. body, ioErr := ioutil.ReadAll(resp.Body)
  35955. if ioErr != nil {
  35956. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35958. return
  35959. }
  35960. var respJSON map[string]interface{}
  35961. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35962. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35964. return
  35965. }
  35966. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35967. if status == "0" {
  35968. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35969. c.ServeSuccessJSON(map[string]interface{}{
  35970. "failed_code": -10,
  35971. "msg": err_msg,
  35972. })
  35973. return
  35974. }
  35975. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35976. userJSONBytes, _ := json.Marshal(respJSON)
  35977. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35978. utils.ErrorLog("解析失败:%v", err)
  35979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35980. return
  35981. }
  35982. } else {
  35983. if len(clr_type) == 0 {
  35984. clr_type = "11"
  35985. }
  35986. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  35987. "insutype=" + insutype +
  35988. "&clr_type=" + clr_type +
  35989. "&setl_optins=" + clr_org +
  35990. "&stmt_begndate=" + start_time +
  35991. "&stm_enddate=" + end_time +
  35992. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35993. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35994. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35995. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  35996. "&fixmedins_code=" + miConfig.Code +
  35997. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35998. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35999. "&secret_key=" + miConfig.SecretKey +
  36000. "&org_name=" + miConfig.OrgName +
  36001. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  36002. fmt.Println(api)
  36003. resp, requestErr := http.Get(api)
  36004. if requestErr != nil {
  36005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36006. return
  36007. }
  36008. body, ioErr := ioutil.ReadAll(resp.Body)
  36009. fmt.Println(body)
  36010. if ioErr != nil {
  36011. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36013. return
  36014. }
  36015. var respJSON map[string]interface{}
  36016. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36017. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36019. return
  36020. }
  36021. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36022. userJSONBytes, _ := json.Marshal(respJSON)
  36023. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36024. utils.ErrorLog("解析失败:%v", err)
  36025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36026. return
  36027. }
  36028. }
  36029. if res.Infcode == 0 {
  36030. if res.Output.Stmtinfo.StmtRslt == "0" {
  36031. micc := &models.MedicalInsuranceCostCompare{
  36032. StartTime: startime.Unix(),
  36033. EndTime: endtime.Unix(),
  36034. Insutype: insutype,
  36035. CheckType: 1,
  36036. Num: fixmedins_setl_cnt,
  36037. Mtime: time.Now().Unix(),
  36038. Status: 1,
  36039. UserOrgId: adminUser.CurrentOrgId,
  36040. CostTotal: medfee_sumamt,
  36041. FuncTotal: fund_pay_sumamt,
  36042. PsnPay: acct_pay,
  36043. Creator: admin_user_id,
  36044. Ctime: time.Now().Unix(),
  36045. ClrType: clr_type,
  36046. }
  36047. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  36048. if err == nil {
  36049. c.ServeSuccessJSON(map[string]interface{}{
  36050. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  36051. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  36052. })
  36053. } else {
  36054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36055. }
  36056. } else {
  36057. c.ServeSuccessJSON(map[string]interface{}{
  36058. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  36059. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  36060. })
  36061. }
  36062. } else {
  36063. c.ServeSuccessJSON(map[string]interface{}{
  36064. "failed_code": -10,
  36065. "msg": res.ErrMsg,
  36066. })
  36067. }
  36068. }
  36069. }
  36070. func (c *HisApiController) Check310() {
  36071. adminUser := c.GetAdminUserInfo()
  36072. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36073. var user_name string
  36074. user_name = "高慧裕"
  36075. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  36076. "insutype=" + "310" +
  36077. "&clr_type=" + "" +
  36078. "&setl_optins=" + "441202" +
  36079. "&stmt_begndate=" + "2022-03-01" +
  36080. "&stm_enddate=" + "2022-03-31" +
  36081. "&medfee_sumamt=" + "194930.12" +
  36082. "&fund_pay_sumamt=" + "188741.46" +
  36083. "&acct_pay=" + "0" +
  36084. "&fixmedins_setl_cnt=" + "452" +
  36085. "&fixmedins_code=" + miConfig.Code +
  36086. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  36087. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  36088. "&secret_key=" + miConfig.SecretKey +
  36089. "&org_name=" + miConfig.OrgName +
  36090. "&doctor=" + user_name
  36091. fmt.Println(api)
  36092. resp, requestErr := http.Get(api)
  36093. if requestErr != nil {
  36094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36095. return
  36096. }
  36097. body, ioErr := ioutil.ReadAll(resp.Body)
  36098. fmt.Println(body)
  36099. if ioErr != nil {
  36100. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36102. return
  36103. }
  36104. var respJSON map[string]interface{}
  36105. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36106. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36108. return
  36109. }
  36110. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36111. userJSONBytes, _ := json.Marshal(respJSON)
  36112. var res ResultEight
  36113. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36114. utils.ErrorLog("解析失败:%v", err)
  36115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36116. return
  36117. }
  36118. }
  36119. func (c *HisApiController) Check390() {
  36120. adminUser := c.GetAdminUserInfo()
  36121. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36122. var user_name string
  36123. user_name = "高慧裕"
  36124. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  36125. "insutype=" + "390" +
  36126. "&clr_type=" + "" +
  36127. "&setl_optins=" + "441202" +
  36128. "&stmt_begndate=" + "2022-03-01" +
  36129. "&stm_enddate=" + "2022-03-31" +
  36130. "&medfee_sumamt=" + "1068448.89" +
  36131. "&fund_pay_sumamt=" + "1014677.62" +
  36132. "&acct_pay=" + "0" +
  36133. "&fixmedins_setl_cnt=" + "1950" +
  36134. "&fixmedins_code=" + miConfig.Code +
  36135. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  36136. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  36137. "&secret_key=" + miConfig.SecretKey +
  36138. "&org_name=" + miConfig.OrgName +
  36139. "&doctor=" + user_name
  36140. fmt.Println(api)
  36141. resp, requestErr := http.Get(api)
  36142. if requestErr != nil {
  36143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36144. return
  36145. }
  36146. body, ioErr := ioutil.ReadAll(resp.Body)
  36147. fmt.Println(body)
  36148. if ioErr != nil {
  36149. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36151. return
  36152. }
  36153. var respJSON map[string]interface{}
  36154. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36155. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36157. return
  36158. }
  36159. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36160. userJSONBytes, _ := json.Marshal(respJSON)
  36161. var res ResultEight
  36162. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36163. utils.ErrorLog("解析失败:%v", err)
  36164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36165. return
  36166. }
  36167. }
  36168. // 对账明细
  36169. func (c *HisApiController) GetCheckDetailAccount() {
  36170. start_time := c.GetString("start_time")
  36171. end_time := c.GetString("end_time")
  36172. admin_user_id, _ := c.GetInt64("admin_user_id")
  36173. adminUser := c.GetAdminUserInfo()
  36174. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36175. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36176. timeLayout := "2006-01-02"
  36177. loc, _ := time.LoadLocation("Local")
  36178. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  36179. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  36180. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  36181. rand.Seed(time.Now().UnixNano())
  36182. num := rand.Intn(30000)
  36183. Mkdir(miConfig.OrgName)
  36184. file := strconv.FormatInt(int64(num), 10)
  36185. file_name := file + ".txt"
  36186. zip_name := file + ".zip"
  36187. zip_path := miConfig.OrgName + "/" + zip_name
  36188. file_path := miConfig.OrgName + "/" + file_name
  36189. decimal.DivisionPrecision = 2
  36190. var medfee_sumamt float64
  36191. var psn_cash_pay float64
  36192. var fund_pay_sumamt float64
  36193. fixmedins_setl_cnt := int64(len(orders))
  36194. for _, item := range orders {
  36195. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  36196. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  36197. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  36198. }
  36199. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  36200. defer f.Close()
  36201. if err != nil {
  36202. fmt.Println(err.Error())
  36203. } else {
  36204. for _, item := range orders {
  36205. var refd_setl_flag string
  36206. if item.OrderStatus == 2 {
  36207. refd_setl_flag = "0"
  36208. var str string
  36209. str = item.SetlId + " " +
  36210. item.MdtrtId + " " +
  36211. item.PsnNo + " " +
  36212. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  36213. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  36214. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  36215. _, err = f.Write([]byte(str))
  36216. }
  36217. if item.OrderStatus == 3 {
  36218. var str string
  36219. str = item.SetlId + " " +
  36220. item.MdtrtId + " " +
  36221. item.PsnNo + " " +
  36222. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  36223. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  36224. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  36225. _, err = f.Write([]byte(str))
  36226. var str2 string
  36227. str2 = item.SetlId + " " +
  36228. item.MdtrtId + " " +
  36229. item.PsnNo + " " +
  36230. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  36231. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  36232. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  36233. _, err = f.Write([]byte(str2))
  36234. }
  36235. }
  36236. }
  36237. Zip(file_path, zip_path)
  36238. fmt.Println(ReadFile(zip_path))
  36239. fmt.Println(string(ReadFile(zip_path)))
  36240. if config.IsOpen == 1 {
  36241. var user_name string
  36242. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36243. if role.ID == 0 {
  36244. user_name = "管理员"
  36245. } else {
  36246. user_name = role.UserName
  36247. }
  36248. baseParams := models.BaseParams{
  36249. SecretKey: miConfig.SecretKey,
  36250. FixmedinsCode: miConfig.Code,
  36251. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36252. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36253. OrgName: miConfig.OrgName,
  36254. Doctor: user_name,
  36255. }
  36256. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  36257. var dat map[string]interface{}
  36258. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36259. fmt.Println(dat)
  36260. } else {
  36261. fmt.Println(err)
  36262. }
  36263. userJSONBytes, _ := json.Marshal(dat)
  36264. var res ResultNine
  36265. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36266. utils.ErrorLog("解析失败:%v", err)
  36267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36268. return
  36269. }
  36270. if res.Infcode == 0 {
  36271. fileNo := res.Output.FileQuryNo
  36272. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  36273. "file_qury_no=" + fileNo +
  36274. "&setl_optins=" + "定点医保中心" +
  36275. "&stmt_begndate=" + start_time +
  36276. "&stm_enddate=" + end_time +
  36277. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  36278. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  36279. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  36280. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  36281. "&fixmedins_code=" + miConfig.Code +
  36282. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  36283. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  36284. "&secret_key=" + miConfig.SecretKey +
  36285. "&org_name=" + miConfig.OrgName +
  36286. "&doctor=" + user_name
  36287. resp, requestErr := http.Get(api)
  36288. if requestErr != nil {
  36289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36290. return
  36291. }
  36292. body, ioErr := ioutil.ReadAll(resp.Body)
  36293. if ioErr != nil {
  36294. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36296. return
  36297. }
  36298. var respJSON map[string]interface{}
  36299. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36300. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36302. return
  36303. }
  36304. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36305. userJSONBytes, _ := json.Marshal(respJSON)
  36306. var res ResultTen
  36307. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36308. utils.ErrorLog("解析失败:%v", err)
  36309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36310. return
  36311. }
  36312. if res.Infcode == 0 {
  36313. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  36314. micc := &models.MedicalInsuranceCostCompare{
  36315. StartTime: startime.Unix(),
  36316. EndTime: endtime.Unix(),
  36317. Insutype: "0",
  36318. CheckType: 2,
  36319. Num: fixmedins_setl_cnt,
  36320. Mtime: time.Now().Unix(),
  36321. Status: 1,
  36322. UserOrgId: adminUser.CurrentOrgId,
  36323. CostTotal: medfee_sumamt,
  36324. FuncTotal: fund_pay_sumamt,
  36325. PsnPay: psn_cash_pay,
  36326. Creator: admin_user_id,
  36327. Ctime: time.Now().Unix(),
  36328. }
  36329. service.CreateMedicalInsuranceCostCompareRecord(micc)
  36330. c.ServeSuccessJSON(map[string]interface{}{
  36331. "msg": "明细对账成功",
  36332. })
  36333. }
  36334. } else {
  36335. }
  36336. }
  36337. }
  36338. type CustomOrderInfo struct {
  36339. Name string
  36340. Spec string
  36341. Unit string
  36342. Count float64
  36343. Price float64
  36344. Total float64
  36345. }
  36346. func (c *HisApiController) GetBatchSettleAccounts() {
  36347. admin_user_id, _ := c.GetInt64("admin_user_id")
  36348. order_ids := c.GetString("order_ids")
  36349. order_ids_arr := strings.Split(order_ids, ",")
  36350. data3 := []map[string]interface{}{}
  36351. for _, item := range order_ids_arr {
  36352. id, _ := strconv.ParseInt(item, 10, 64)
  36353. order_id := id
  36354. adminUser := c.GetAdminUserInfo()
  36355. order, _ := service.GetHisOrderByID(order_id)
  36356. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  36357. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  36358. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  36359. orderInfos = append(orderInfos, orderInfos_two...)
  36360. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  36361. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  36362. var diagnosis_ids []string
  36363. if his.ID > 0 {
  36364. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  36365. } else {
  36366. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  36367. }
  36368. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  36369. var dia_config []*models.HisXtDiagnoseConfig
  36370. var name string
  36371. for _, item := range diagnosis_ids {
  36372. id, _ := strconv.ParseInt(item, 10, 64)
  36373. diagnosisConfig, _ := service.FindDiagnoseById(id)
  36374. dia_config = append(dia_config, &diagnosisConfig)
  36375. if len(name) == 0 {
  36376. name = diagnosisConfig.ClassName
  36377. }
  36378. //} else {
  36379. // name = name + "," + diagnosisConfig.ClassName
  36380. //}
  36381. }
  36382. var bedCostTotal float64 = 0 //床位总费
  36383. var bedCostSelfTotal float64 = 0 //床位自费
  36384. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  36385. var bedSelfTotal float64 = 0 //床位部分项目自费
  36386. var bedInscpTotal float64 = 0 //床位部分项目自费
  36387. var operationCostTotal float64 = 0 //手术费
  36388. var operationCostSelfTotal float64 = 0 //手术费
  36389. var operationCostPartSelfTotal float64 = 0 //手术费
  36390. var operationSelfTotal float64 = 0 //床位部分项目自费
  36391. var operationInscpTotal float64 = 0 //床位部分项目自费
  36392. var otherCostTotal float64 = 0 //其他费用
  36393. var otherCostSelfTotal float64 = 0 //其他费用
  36394. var otherCostPartSelfTotal float64 = 0 //其他费用
  36395. var otherSelfTotal float64 = 0 //床位部分项目自费
  36396. var otherInscpTotal float64 = 0 //床位部分项目自费
  36397. var materialCostTotal float64 = 0 //材料费
  36398. var materialCostSelfTotal float64 = 0 //材料费
  36399. var materialCostPartSelfTotal float64 = 0 //材料费
  36400. var materialSelfTotal float64 = 0 //床位部分项目自费
  36401. var materialInscpTotal float64 = 0 //床位部分项目自费
  36402. var westernMedicineCostTotal float64 = 0 //西药费
  36403. var westernMedicineCostSelfTotal float64 = 0 //西药费
  36404. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  36405. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  36406. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  36407. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  36408. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  36409. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  36410. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  36411. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  36412. var checkCostTotal float64 = 0 //检查费
  36413. var checkCostSelfTotal float64 = 0 //检查费
  36414. var checkCostPartSelfTotal float64 = 0 //检查费
  36415. var checkSelfTotal float64 = 0 //床位部分项目自费
  36416. var checkInscpTotal float64 = 0 //床位部分项目自费
  36417. var laboratoryCostTotal float64 = 0 //化验费
  36418. var laboratoryCostSelfTotal float64 = 0 //化验费
  36419. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  36420. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  36421. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  36422. var treatCostTotal float64 = 0 //治疗费用
  36423. var treatCostSelfTotal float64 = 0 //治疗费用
  36424. var treatCostPartSelfTotal float64 = 0 //治疗费用
  36425. var treatSelfTotal float64 = 0 //床位部分项目自费
  36426. var treatInscpTotal float64 = 0 //床位部分项目自费
  36427. decimal.DivisionPrecision = 2
  36428. for _, item := range orderInfos {
  36429. if item.MedChrgitmType == "01" { //床位费
  36430. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36431. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36432. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36433. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36434. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36435. }
  36436. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  36437. if item.MedChrgitmType == "03" { //检查费
  36438. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36439. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36440. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36441. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36442. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36443. }
  36444. } else {
  36445. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  36446. fmt.Println("------------")
  36447. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36448. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36449. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36450. }
  36451. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  36452. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36453. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36454. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36455. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36456. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36457. }
  36458. }
  36459. if item.MedChrgitmType == "04" { //化验费
  36460. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36461. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36462. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36463. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36464. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36465. }
  36466. if item.MedChrgitmType == "05" { //治疗费
  36467. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36468. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36469. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36470. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36471. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36472. }
  36473. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  36474. fmt.Println("------------")
  36475. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36476. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36477. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36478. }
  36479. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  36480. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36481. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36482. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36483. }
  36484. //if item.MedChrgitmType == "06" { //手术费
  36485. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36486. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36487. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36488. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36489. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36490. //
  36491. //}
  36492. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  36493. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36494. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36495. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36496. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36497. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36498. }
  36499. if item.MedChrgitmType == "09" { //西药费
  36500. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36501. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36502. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36503. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36504. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36505. }
  36506. if item.MedChrgitmType == "11" { //中成费
  36507. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36508. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36509. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36510. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36511. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36512. }
  36513. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  36514. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36515. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36516. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36517. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36518. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36519. }
  36520. }
  36521. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36522. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36523. var user_name string
  36524. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36525. if role.ID == 0 {
  36526. user_name = "管理员"
  36527. } else {
  36528. user_name = role.UserName
  36529. }
  36530. baseParams := models.BaseParams{
  36531. SecretKey: miConfig.SecretKey,
  36532. FixmedinsCode: miConfig.Code,
  36533. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36534. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36535. OrgName: miConfig.OrgName,
  36536. Doctor: user_name,
  36537. RequestUrl: miConfig.Url,
  36538. AccessKey: miConfig.AccessKey,
  36539. }
  36540. businessParams := models.BusinessParams{
  36541. PsnNo: order.PsnNo,
  36542. MdtrtId: order.MdtrtId,
  36543. SetlId: order.SetlId,
  36544. }
  36545. var res ResultEleven
  36546. var resEleven10265 ResultEleven10265
  36547. if config.IsOpen == 1 {
  36548. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36549. result := service.Gdyb5203(baseParams, businessParams)
  36550. service.Gdyb5204(baseParams, businessParams)
  36551. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  36552. var dat map[string]interface{}
  36553. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36554. fmt.Println(dat)
  36555. } else {
  36556. fmt.Println(err)
  36557. }
  36558. userJSONBytes, _ := json.Marshal(dat)
  36559. if miConfig.Code == "H15049901371" {
  36560. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  36561. utils.ErrorLog("解析失败:%v", err)
  36562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36563. return
  36564. }
  36565. res.InfRefmsgid = resEleven10265.InfRefmsgid
  36566. res.Output = resEleven10265.Output
  36567. res.ErrMsg = resEleven10265.ErrMsg
  36568. res.Cainfo = resEleven10265.Cainfo
  36569. res.WarnMsg = resEleven10265.WarnMsg
  36570. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  36571. res.Infcode = infocode
  36572. } else {
  36573. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36574. utils.ErrorLog("解析失败:%v", err)
  36575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36576. return
  36577. }
  36578. }
  36579. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36580. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  36581. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  36582. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  36583. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  36584. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36585. var doctor_name string
  36586. if roles.ID == 0 {
  36587. doctor_name = "管理员"
  36588. } else {
  36589. doctor_name = roles.UserName
  36590. }
  36591. yiliao_leibie := ""
  36592. switch order.MedType {
  36593. case "11":
  36594. yiliao_leibie = "普通门诊"
  36595. break
  36596. case "12":
  36597. yiliao_leibie = "门诊挂号"
  36598. break
  36599. case "13":
  36600. yiliao_leibie = "急诊"
  36601. break
  36602. case "14":
  36603. yiliao_leibie = "门诊特殊病"
  36604. break
  36605. case "15":
  36606. yiliao_leibie = "门诊统筹"
  36607. break
  36608. case "16":
  36609. yiliao_leibie = "门诊慢性病"
  36610. break
  36611. case "21":
  36612. yiliao_leibie = "普通住院"
  36613. break
  36614. }
  36615. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  36616. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  36617. if res.Infcode == 0 {
  36618. data2 := map[string]interface{}{
  36619. "diagnosis": name,
  36620. "order_infos": orderInfos,
  36621. "number": order.MdtrtId,
  36622. "date": order.SettleAccountsDate,
  36623. "charge_admin": charge_admin,
  36624. "printor_admin": printor_admin,
  36625. "info": res.Output.Setlinfo,
  36626. "order": order,
  36627. "bedCostTotal": bedCostTotal,
  36628. "bedCostSelfTotal": bedCostSelfTotal,
  36629. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  36630. "bedSelfTotal": bedSelfTotal,
  36631. "bedInscpTotal": bedInscpTotal,
  36632. "operationCostTotal": operationCostTotal,
  36633. "operationCostSelfTotal": operationCostSelfTotal,
  36634. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  36635. "operationSelfTotal": operationSelfTotal,
  36636. "operationInscpTotal": operationInscpTotal,
  36637. "otherCostTotal": otherCostTotal,
  36638. "otherCostSelfTotal": otherCostSelfTotal,
  36639. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  36640. "otherSelfTotal": otherSelfTotal,
  36641. "otherInscpTotal": otherInscpTotal,
  36642. "materialCostTotal": materialCostTotal,
  36643. "materialCostSelfTotal": materialCostSelfTotal,
  36644. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  36645. "materialSelfTotal": materialSelfTotal,
  36646. "materialInscpTotal": materialInscpTotal,
  36647. "westernMedicineCostTotal": westernMedicineCostTotal,
  36648. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  36649. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  36650. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  36651. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  36652. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  36653. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  36654. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  36655. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  36656. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  36657. "checkCostTotal": checkCostTotal,
  36658. "checkCostSelfTotal": checkCostSelfTotal,
  36659. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  36660. "checkSelfTotal": checkSelfTotal,
  36661. "checkInscpTotal": checkInscpTotal,
  36662. "laboratoryCostTotal": laboratoryCostTotal,
  36663. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  36664. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  36665. "laboratorySelfTotal": laboratorySelfTotal,
  36666. "laboratoryInscpTotal": laboratoryInscpTotal,
  36667. "treatCostTotal": treatCostTotal,
  36668. "treatCostSelfTotal": treatCostSelfTotal,
  36669. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  36670. "treatSelfTotal": treatSelfTotal,
  36671. "treatInscpTotal": treatInscpTotal,
  36672. "doctor_info": doctor_info,
  36673. "doctor_code": adminRole_two.DoctorCode,
  36674. "doctor_name": doctor_name,
  36675. "health_card_no": order.PsnNo,
  36676. "department": departments.Name,
  36677. "yiliao_leibie": yiliao_leibie,
  36678. "after_money": order.AccountPrice,
  36679. "patient": patient,
  36680. "org_name": miConfig.OrgName,
  36681. "org_code": miConfig.Code,
  36682. "order_number": order.Number,
  36683. "his_hospital": his_hospital,
  36684. "his": his,
  36685. "dia_config": dia_config,
  36686. "psn_cash_pay": order.PsnCashPay,
  36687. //"check_order_info": cus_slice,
  36688. }
  36689. data3 = append(data3, data2)
  36690. }
  36691. }
  36692. }
  36693. c.ServeSuccessJSON(map[string]interface{}{
  36694. "infos": data3,
  36695. })
  36696. }
  36697. func (c *HisApiController) GetSettleAccounts() {
  36698. //id, _ := c.GetInt64("id")
  36699. //record_time := c.GetString("record_time")
  36700. order_id, _ := c.GetInt64("order_id")
  36701. admin_user_id, _ := c.GetInt64("admin_user_id")
  36702. //timeLayout := "2006-01-02"
  36703. //loc, _ := time.LoadLocation("Local")
  36704. //
  36705. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  36706. //if err != nil {
  36707. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  36708. // return
  36709. //}Hbyb5203
  36710. //recordDateTime := theTime.Unix()
  36711. adminUser := c.GetAdminUserInfo()
  36712. order, _ := service.GetHisOrderByID(order_id)
  36713. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  36714. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  36715. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  36716. orderInfos = append(orderInfos, orderInfos_two...)
  36717. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  36718. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  36719. var diagnosis_ids []string
  36720. if his.ID > 0 {
  36721. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  36722. } else {
  36723. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  36724. }
  36725. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  36726. var dia_config []*models.HisXtDiagnoseConfig
  36727. var name string
  36728. for _, item := range diagnosis_ids {
  36729. id, _ := strconv.ParseInt(item, 10, 64)
  36730. diagnosisConfig, _ := service.FindDiagnoseById(id)
  36731. dia_config = append(dia_config, &diagnosisConfig)
  36732. if len(name) == 0 {
  36733. name = diagnosisConfig.ClassName
  36734. } else {
  36735. name = name + "," + diagnosisConfig.ClassName
  36736. }
  36737. }
  36738. if patient.UserOrgId == 10215 {
  36739. name = "慢性肾功能不全(血透治疗)"
  36740. }
  36741. var bedCostTotal float64 = 0 //床位总费
  36742. var bedCostSelfTotal float64 = 0 //床位自费
  36743. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  36744. var bedSelfTotal float64 = 0 //床位部分项目自费
  36745. var bedInscpTotal float64 = 0 //床位部分项目自费
  36746. var operationCostTotal float64 = 0 //手术费
  36747. var operationCostSelfTotal float64 = 0 //手术费
  36748. var operationCostPartSelfTotal float64 = 0 //手术费
  36749. var operationSelfTotal float64 = 0 //床位部分项目自费
  36750. var operationInscpTotal float64 = 0 //床位部分项目自费
  36751. var otherCostTotal float64 = 0 //其他费用
  36752. var otherCostSelfTotal float64 = 0 //其他费用
  36753. var otherCostPartSelfTotal float64 = 0 //其他费用
  36754. var otherSelfTotal float64 = 0 //床位部分项目自费
  36755. var otherInscpTotal float64 = 0 //床位部分项目自费
  36756. var materialCostTotal float64 = 0 //材料费
  36757. var materialCostSelfTotal float64 = 0 //材料费
  36758. var materialCostPartSelfTotal float64 = 0 //材料费
  36759. var materialSelfTotal float64 = 0 //床位部分项目自费
  36760. var materialInscpTotal float64 = 0 //床位部分项目自费
  36761. var westernMedicineCostTotal float64 = 0 //西药费
  36762. var westernMedicineCostSelfTotal float64 = 0 //西药费
  36763. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  36764. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  36765. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  36766. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  36767. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  36768. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  36769. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  36770. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  36771. var checkCostTotal float64 = 0 //检查费
  36772. var checkCostSelfTotal float64 = 0 //检查费
  36773. var checkCostPartSelfTotal float64 = 0 //检查费
  36774. var checkSelfTotal float64 = 0 //床位部分项目自费
  36775. var checkInscpTotal float64 = 0 //床位部分项目自费
  36776. var laboratoryCostTotal float64 = 0 //化验费
  36777. var laboratoryCostSelfTotal float64 = 0 //化验费
  36778. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  36779. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  36780. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  36781. var treatCostTotal float64 = 0 //治疗费用
  36782. var treatCostSelfTotal float64 = 0 //治疗费用
  36783. var treatCostPartSelfTotal float64 = 0 //治疗费用
  36784. var treatSelfTotal float64 = 0 //床位部分项目自费
  36785. var treatInscpTotal float64 = 0 //床位部分项目自费
  36786. var zcCostTotal float64 = 0 //治疗费用
  36787. var zcCostSelfTotal float64 = 0 //治疗费用
  36788. var zcCostPartSelfTotal float64 = 0 //治疗费用
  36789. var zcSelfTotal float64 = 0 //床位部分项目自费
  36790. var zcInscpTotal float64 = 0 //床位部分项目自费
  36791. var huliCostTotal float64 = 0 //治疗费用
  36792. var huliCostSelfTotal float64 = 0 //治疗费用
  36793. var huliCostPartSelfTotal float64 = 0 //治疗费用
  36794. var huliSelfTotal float64 = 0 //床位部分项目自费
  36795. var huliInscpTotal float64 = 0 //床位部分项目自费
  36796. decimal.DivisionPrecision = 2
  36797. for _, item := range orderInfos {
  36798. if item.MedChrgitmType == "01" { //床位费
  36799. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36800. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36801. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36802. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36803. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36804. }
  36805. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  36806. if item.MedChrgitmType == "03" { //检查费
  36807. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36808. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36809. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36810. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36811. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36812. }
  36813. } else {
  36814. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  36815. fmt.Println("------------")
  36816. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36817. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36818. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36819. }
  36820. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  36821. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36822. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36823. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36824. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36825. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36826. }
  36827. }
  36828. if item.MedChrgitmType == "04" { //化验费
  36829. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36830. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36831. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36832. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36833. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36834. }
  36835. if item.MedChrgitmType == "05" { //治疗费
  36836. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36837. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36838. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36839. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36840. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36841. }
  36842. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  36843. fmt.Println("------------")
  36844. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36845. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36846. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36847. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36848. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36849. }
  36850. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  36851. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36852. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36853. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36854. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36855. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36856. }
  36857. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  36858. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36859. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36860. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36861. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36862. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36863. }
  36864. if item.MedChrgitmType == "09" { //西药费
  36865. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36866. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36867. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36868. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36869. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36870. }
  36871. if item.MedChrgitmType == "11" { //中成费
  36872. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36873. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36874. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36875. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36876. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36877. }
  36878. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  36879. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36880. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36881. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36882. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36883. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36884. }
  36885. if item.MedChrgitmType == "02" { //其他费
  36886. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36887. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36888. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36889. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36890. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36891. }
  36892. if item.MedChrgitmType == "07" { //其他费
  36893. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36894. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36895. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36896. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36897. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36898. }
  36899. }
  36900. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36901. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36902. var user_name string
  36903. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36904. if role.ID == 0 {
  36905. user_name = "管理员"
  36906. } else {
  36907. user_name = role.UserName
  36908. }
  36909. baseParams := models.BaseParams{
  36910. SecretKey: miConfig.SecretKey,
  36911. FixmedinsCode: miConfig.Code,
  36912. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36913. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36914. OrgName: miConfig.OrgName,
  36915. Doctor: user_name,
  36916. RequestUrl: miConfig.Url,
  36917. AccessKey: miConfig.AccessKey,
  36918. }
  36919. businessParams := models.BusinessParams{
  36920. PsnNo: order.PsnNo,
  36921. MdtrtId: order.MdtrtId,
  36922. SetlId: order.SetlId,
  36923. }
  36924. var res ResultEleven
  36925. var resah ResultElevenah
  36926. var resEleven10265 ResultEleven10265
  36927. if config.IsOpen == 1 {
  36928. if miConfig.MdtrtareaAdmvs == "421300" {
  36929. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36930. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36931. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36932. resp, requestErr := http.Get(api)
  36933. if requestErr != nil {
  36934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36935. return
  36936. }
  36937. body, ioErr := ioutil.ReadAll(resp.Body)
  36938. if ioErr != nil {
  36939. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36941. return
  36942. }
  36943. var respJSON map[string]interface{}
  36944. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36945. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36947. return
  36948. }
  36949. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36950. result, _ := json.Marshal(respJSON)
  36951. fmt.Println("log")
  36952. fmt.Println(string(result))
  36953. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36954. utils.ErrorLog("解析失败:%v", err)
  36955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36956. return
  36957. }
  36958. } else if miConfig.MdtrtareaAdmvs == "420200" {
  36959. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36960. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36961. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36962. resp, requestErr := http.Get(api)
  36963. if requestErr != nil {
  36964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36965. return
  36966. }
  36967. body, ioErr := ioutil.ReadAll(resp.Body)
  36968. if ioErr != nil {
  36969. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36971. return
  36972. }
  36973. var respJSON map[string]interface{}
  36974. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36975. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36977. return
  36978. }
  36979. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36980. result, _ := json.Marshal(respJSON)
  36981. fmt.Println("log")
  36982. fmt.Println(string(result))
  36983. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36984. utils.ErrorLog("解析失败:%v", err)
  36985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36986. return
  36987. }
  36988. } else if miConfig.MdtrtareaAdmvs == "420902" {
  36989. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36990. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36991. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36992. resp, requestErr := http.Get(api)
  36993. if requestErr != nil {
  36994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36995. return
  36996. }
  36997. body, ioErr := ioutil.ReadAll(resp.Body)
  36998. if ioErr != nil {
  36999. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37001. return
  37002. }
  37003. var respJSON map[string]interface{}
  37004. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37005. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37007. return
  37008. }
  37009. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37010. result, _ := json.Marshal(respJSON)
  37011. fmt.Println("log")
  37012. fmt.Println(string(result))
  37013. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37014. utils.ErrorLog("解析失败:%v", err)
  37015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37016. return
  37017. }
  37018. } else if miConfig.MdtrtareaAdmvs == "421182" {
  37019. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37020. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37021. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  37022. resp, requestErr := http.Get(api)
  37023. if requestErr != nil {
  37024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37025. return
  37026. }
  37027. body, ioErr := ioutil.ReadAll(resp.Body)
  37028. if ioErr != nil {
  37029. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37031. return
  37032. }
  37033. var respJSON map[string]interface{}
  37034. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37035. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37037. return
  37038. }
  37039. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37040. result, _ := json.Marshal(respJSON)
  37041. fmt.Println("log")
  37042. fmt.Println(string(result))
  37043. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37044. utils.ErrorLog("解析失败:%v", err)
  37045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37046. return
  37047. }
  37048. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  37049. var api string
  37050. if miConfig.MdtrtareaAdmvs == "320830" {
  37051. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37052. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37053. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  37054. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37055. } else if miConfig.MdtrtareaAdmvs == "320921" {
  37056. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37057. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37058. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  37059. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37060. } else {
  37061. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37062. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37063. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37064. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  37065. }
  37066. resp, requestErr := http.Get(api)
  37067. if requestErr != nil {
  37068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37069. return
  37070. }
  37071. body, ioErr := ioutil.ReadAll(resp.Body)
  37072. if ioErr != nil {
  37073. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37075. return
  37076. }
  37077. var respJSON map[string]interface{}
  37078. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37079. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37081. return
  37082. }
  37083. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37084. result, _ := json.Marshal(respJSON)
  37085. fmt.Println("log")
  37086. fmt.Println(string(result))
  37087. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  37088. utils.ErrorLog("解析失败:%v", err)
  37089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37090. return
  37091. }
  37092. res.InfRefmsgid = resEleven10265.InfRefmsgid
  37093. res.Output = resEleven10265.Output
  37094. res.ErrMsg = resEleven10265.ErrMsg
  37095. res.Cainfo = resEleven10265.Cainfo
  37096. res.WarnMsg = resEleven10265.WarnMsg
  37097. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  37098. res.Infcode = infocode
  37099. } else if miConfig.MdtrtareaAdmvs == "350500" {
  37100. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  37101. saveLog(result, requestLog, "5203", "结算单")
  37102. var dat map[string]interface{}
  37103. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37104. fmt.Println(dat)
  37105. } else {
  37106. fmt.Println(err)
  37107. }
  37108. userJSONBytes, _ := json.Marshal(dat)
  37109. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37110. utils.ErrorLog("解析失败:%v", err)
  37111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37112. return
  37113. }
  37114. } else if miConfig.MdtrtareaAdmvs == "360302" {
  37115. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  37116. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  37117. saveLog(result, requestLog, "5203", "结算单")
  37118. var dat map[string]interface{}
  37119. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37120. fmt.Println(dat)
  37121. } else {
  37122. fmt.Println(err)
  37123. }
  37124. userJSONBytes, _ := json.Marshal(dat)
  37125. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37126. utils.ErrorLog("解析失败:%v", err)
  37127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37128. return
  37129. }
  37130. } else if miConfig.MdtrtareaAdmvs == "361025" {
  37131. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  37132. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  37133. saveLog(result, requestLog, "5203", "结算单")
  37134. var dat map[string]interface{}
  37135. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37136. fmt.Println(dat)
  37137. } else {
  37138. fmt.Println(err)
  37139. }
  37140. userJSONBytes, _ := json.Marshal(dat)
  37141. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37142. utils.ErrorLog("解析失败:%v", err)
  37143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37144. return
  37145. }
  37146. } else if miConfig.MdtrtareaAdmvs == "360100" {
  37147. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  37148. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  37149. saveLog(result, requestLog, "5203", "结算单")
  37150. var dat map[string]interface{}
  37151. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37152. fmt.Println(dat)
  37153. } else {
  37154. fmt.Println(err)
  37155. }
  37156. userJSONBytes, _ := json.Marshal(dat)
  37157. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37158. utils.ErrorLog("解析失败:%v", err)
  37159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37160. return
  37161. }
  37162. } else if miConfig.MdtrtareaAdmvs == "341203" {
  37163. var api string
  37164. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37165. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37166. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  37167. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37168. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37169. resp, requestErr := http.Get(api)
  37170. if requestErr != nil {
  37171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37172. return
  37173. }
  37174. body, ioErr := ioutil.ReadAll(resp.Body)
  37175. if ioErr != nil {
  37176. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37178. return
  37179. }
  37180. var respJSON map[string]interface{}
  37181. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37182. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37184. return
  37185. }
  37186. status := respJSON["data"].(map[string]interface{})["status"].(string)
  37187. if status == "0" {
  37188. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  37189. c.ServeSuccessJSON(map[string]interface{}{
  37190. "failed_code": -10,
  37191. "msg": err_msg,
  37192. })
  37193. return
  37194. }
  37195. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37196. result, _ := json.Marshal(respJSON)
  37197. fmt.Println("log")
  37198. fmt.Println(string(result))
  37199. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  37200. utils.ErrorLog("解析失败:%v", err)
  37201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37202. return
  37203. }
  37204. res.InfRefmsgid = resah.InfRefmsgid
  37205. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  37206. // 创建对应的Time类型
  37207. t := time.UnixMilli(timestamp)
  37208. // 格式化成指定的日期字符串
  37209. str := t.Format("2006-01-02 15:04:05")
  37210. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  37211. // 创建对应的Time类型
  37212. t3 := time.UnixMilli(timestamp2)
  37213. // 格式化成指定的日期字符串
  37214. str2 := t3.Format("2006-01-02 15:04:05")
  37215. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  37216. // 创建对应的Time类型
  37217. t4 := time.UnixMilli(timestamp3)
  37218. // 格式化成指定的日期字符串
  37219. str3 := t4.Format("2006-01-02 15:04:05")
  37220. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  37221. // 创建对应的Time类型
  37222. t5 := time.UnixMilli(timestamp4)
  37223. // 格式化成指定的日期字符串
  37224. str5 := t5.Format("2006-01-02 15:04:05")
  37225. res.Output.Setlinfo.Brdy = str2
  37226. res.Output.Setlinfo.SetlTime = str
  37227. res.Output.Setlinfo.Begndate = str3
  37228. res.Output.Setlinfo.Enddate = str5
  37229. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  37230. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  37231. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  37232. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  37233. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  37234. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  37235. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  37236. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  37237. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  37238. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  37239. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  37240. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  37241. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  37242. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  37243. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  37244. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  37245. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  37246. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  37247. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  37248. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  37249. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  37250. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  37251. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  37252. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  37253. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  37254. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  37255. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  37256. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  37257. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  37258. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  37259. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  37260. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  37261. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  37262. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  37263. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  37264. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  37265. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  37266. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  37267. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  37268. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  37269. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  37270. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  37271. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  37272. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  37273. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  37274. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  37275. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  37276. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  37277. //res.Output.Setldetail = resah.Output.Setldetail
  37278. res.ErrMsg = resah.ErrMsg
  37279. res.Cainfo = resah.Cainfo
  37280. res.WarnMsg = resah.WarnMsg
  37281. } else if miConfig.MdtrtareaAdmvs == "340699" {
  37282. var api string
  37283. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37284. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37285. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  37286. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37287. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37288. resp, requestErr := http.Get(api)
  37289. if requestErr != nil {
  37290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37291. return
  37292. }
  37293. body, ioErr := ioutil.ReadAll(resp.Body)
  37294. if ioErr != nil {
  37295. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37297. return
  37298. }
  37299. var respJSON map[string]interface{}
  37300. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37301. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37303. return
  37304. }
  37305. status := respJSON["data"].(map[string]interface{})["status"].(string)
  37306. if status == "0" {
  37307. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  37308. c.ServeSuccessJSON(map[string]interface{}{
  37309. "failed_code": -10,
  37310. "msg": err_msg,
  37311. })
  37312. return
  37313. }
  37314. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37315. result, _ := json.Marshal(respJSON)
  37316. fmt.Println("log")
  37317. fmt.Println(string(result))
  37318. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  37319. utils.ErrorLog("解析失败:%v", err)
  37320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37321. return
  37322. }
  37323. res.InfRefmsgid = resah.InfRefmsgid
  37324. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  37325. // 创建对应的Time类型
  37326. t := time.UnixMilli(timestamp)
  37327. // 格式化成指定的日期字符串
  37328. str := t.Format("2006-01-02 15:04:05")
  37329. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  37330. // 创建对应的Time类型
  37331. t3 := time.UnixMilli(timestamp2)
  37332. // 格式化成指定的日期字符串
  37333. str2 := t3.Format("2006-01-02 15:04:05")
  37334. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  37335. // 创建对应的Time类型
  37336. t4 := time.UnixMilli(timestamp3)
  37337. // 格式化成指定的日期字符串
  37338. str3 := t4.Format("2006-01-02 15:04:05")
  37339. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  37340. // 创建对应的Time类型
  37341. t5 := time.UnixMilli(timestamp4)
  37342. // 格式化成指定的日期字符串
  37343. str5 := t5.Format("2006-01-02 15:04:05")
  37344. res.Output.Setlinfo.Brdy = str2
  37345. res.Output.Setlinfo.SetlTime = str
  37346. res.Output.Setlinfo.Begndate = str3
  37347. res.Output.Setlinfo.Enddate = str5
  37348. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  37349. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  37350. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  37351. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  37352. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  37353. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  37354. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  37355. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  37356. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  37357. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  37358. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  37359. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  37360. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  37361. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  37362. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  37363. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  37364. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  37365. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  37366. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  37367. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  37368. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  37369. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  37370. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  37371. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  37372. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  37373. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  37374. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  37375. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  37376. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  37377. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  37378. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  37379. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  37380. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  37381. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  37382. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  37383. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  37384. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  37385. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  37386. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  37387. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  37388. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  37389. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  37390. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  37391. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  37392. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  37393. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  37394. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  37395. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  37396. //res.Output.Setldetail = resah.Output.Setldetail
  37397. res.ErrMsg = resah.ErrMsg
  37398. res.Cainfo = resah.Cainfo
  37399. res.WarnMsg = resah.WarnMsg
  37400. } else if miConfig.MdtrtareaAdmvs == "430800" {
  37401. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  37402. saveLog(result, requestLog, "5203", "结算单")
  37403. var dat map[string]interface{}
  37404. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37405. fmt.Println(dat)
  37406. } else {
  37407. fmt.Println(err)
  37408. }
  37409. userJSONBytes, _ := json.Marshal(dat)
  37410. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37411. utils.ErrorLog("解析失败:%v", err)
  37412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37413. return
  37414. }
  37415. } else if miConfig.MdtrtareaAdmvs == "150404" {
  37416. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37417. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37418. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  37419. resp, requestErr := http.Get(api)
  37420. if requestErr != nil {
  37421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37422. return
  37423. }
  37424. body, ioErr := ioutil.ReadAll(resp.Body)
  37425. if ioErr != nil {
  37426. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37428. return
  37429. }
  37430. var respJSON map[string]interface{}
  37431. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37432. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37434. return
  37435. }
  37436. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37437. result, _ := json.Marshal(respJSON)
  37438. fmt.Println("log")
  37439. fmt.Println(string(result))
  37440. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  37441. utils.ErrorLog("解析失败:%v", err)
  37442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37443. return
  37444. }
  37445. res.InfRefmsgid = resEleven10265.InfRefmsgid
  37446. res.Output = resEleven10265.Output
  37447. res.ErrMsg = resEleven10265.ErrMsg
  37448. res.Cainfo = resEleven10265.Cainfo
  37449. res.WarnMsg = resEleven10265.WarnMsg
  37450. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  37451. res.Infcode = infocode
  37452. } else if miConfig.MdtrtareaAdmvs == "441799" {
  37453. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37454. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37455. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  37456. resp, requestErr := http.Get(api)
  37457. if requestErr != nil {
  37458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37459. return
  37460. }
  37461. body, ioErr := ioutil.ReadAll(resp.Body)
  37462. if ioErr != nil {
  37463. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37465. return
  37466. }
  37467. var respJSON map[string]interface{}
  37468. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37469. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37471. return
  37472. }
  37473. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37474. result, _ := json.Marshal(respJSON)
  37475. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37476. utils.ErrorLog("解析失败:%v", err)
  37477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37478. return
  37479. }
  37480. } else if miConfig.MdtrtareaAdmvs == "450721" {
  37481. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  37482. //return
  37483. } else {
  37484. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  37485. if len(his.InsuplcAdmdvs) == 0 {
  37486. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  37487. } else {
  37488. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  37489. }
  37490. result := service.Gdyb5203(baseParams, businessParams)
  37491. //service.Gdyb5204(baseParams, businessParams)
  37492. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  37493. var dat map[string]interface{}
  37494. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37495. fmt.Println(dat)
  37496. } else {
  37497. fmt.Println(err)
  37498. }
  37499. userJSONBytes, _ := json.Marshal(dat)
  37500. if miConfig.Code == "H15049901371" {
  37501. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  37502. utils.ErrorLog("解析失败:%v", err)
  37503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37504. return
  37505. }
  37506. res.InfRefmsgid = resEleven10265.InfRefmsgid
  37507. res.Output = resEleven10265.Output
  37508. res.ErrMsg = resEleven10265.ErrMsg
  37509. res.Cainfo = resEleven10265.Cainfo
  37510. res.WarnMsg = resEleven10265.WarnMsg
  37511. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  37512. res.Infcode = infocode
  37513. } else {
  37514. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37515. utils.ErrorLog("解析失败:%v", err)
  37516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37517. return
  37518. }
  37519. }
  37520. }
  37521. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37522. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  37523. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  37524. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  37525. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  37526. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37527. var doctor_name string
  37528. if roles.ID == 0 {
  37529. doctor_name = "管理员"
  37530. } else {
  37531. doctor_name = roles.UserName
  37532. }
  37533. yiliao_leibie := ""
  37534. switch order.MedType {
  37535. case "11":
  37536. yiliao_leibie = "普通门诊"
  37537. break
  37538. case "12":
  37539. yiliao_leibie = "门诊挂号"
  37540. break
  37541. case "13":
  37542. yiliao_leibie = "急诊"
  37543. break
  37544. case "14":
  37545. yiliao_leibie = "门诊特殊病"
  37546. break
  37547. case "15":
  37548. yiliao_leibie = "门诊统筹"
  37549. break
  37550. case "16":
  37551. yiliao_leibie = "门诊慢性病"
  37552. break
  37553. case "21":
  37554. yiliao_leibie = "普通住院"
  37555. break
  37556. }
  37557. //var rf []CustomFundPay
  37558. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  37559. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  37560. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  37561. if res.Infcode == 0 {
  37562. 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 {
  37563. c.ServeSuccessJSON(map[string]interface{}{
  37564. "diagnosis": name,
  37565. "order_infos": orderInfos,
  37566. "number": order.MdtrtId,
  37567. "date": order.SettleAccountsDate,
  37568. "charge_admin": charge_admin,
  37569. "printor_admin": printor_admin,
  37570. "info": res.Output.Setlinfo,
  37571. "order": order,
  37572. "bedCostTotal": bedCostTotal,
  37573. "bedCostSelfTotal": bedCostSelfTotal,
  37574. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  37575. "bedSelfTotal": bedSelfTotal,
  37576. "bedInscpTotal": bedInscpTotal,
  37577. "operationCostTotal": operationCostTotal,
  37578. "operationCostSelfTotal": operationCostSelfTotal,
  37579. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  37580. "operationSelfTotal": operationSelfTotal,
  37581. "operationInscpTotal": operationInscpTotal,
  37582. "otherCostTotal": otherCostTotal,
  37583. "otherCostSelfTotal": otherCostSelfTotal,
  37584. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  37585. "otherSelfTotal": otherSelfTotal,
  37586. "otherInscpTotal": otherInscpTotal,
  37587. "materialCostTotal": materialCostTotal,
  37588. "materialCostSelfTotal": materialCostSelfTotal,
  37589. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  37590. "materialSelfTotal": materialSelfTotal,
  37591. "materialInscpTotal": materialInscpTotal,
  37592. "westernMedicineCostTotal": westernMedicineCostTotal,
  37593. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  37594. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  37595. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  37596. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  37597. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  37598. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  37599. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  37600. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  37601. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  37602. "checkCostTotal": checkCostTotal,
  37603. "checkCostSelfTotal": checkCostSelfTotal,
  37604. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  37605. "checkSelfTotal": checkSelfTotal,
  37606. "checkInscpTotal": checkInscpTotal,
  37607. "laboratoryCostTotal": laboratoryCostTotal,
  37608. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  37609. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  37610. "laboratorySelfTotal": laboratorySelfTotal,
  37611. "laboratoryInscpTotal": laboratoryInscpTotal,
  37612. "treatCostTotal": treatCostTotal,
  37613. "treatCostSelfTotal": treatCostSelfTotal,
  37614. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  37615. "treatSelfTotal": treatSelfTotal,
  37616. "treatInscpTotal": treatInscpTotal,
  37617. "doctor_info": doctor_info,
  37618. "doctor_code": adminRole_two.DoctorCode,
  37619. "doctor_name": doctor_name,
  37620. "health_card_no": order.PsnNo,
  37621. "department": departments.Name,
  37622. "yiliao_leibie": yiliao_leibie,
  37623. "after_money": order.AccountPrice,
  37624. "patient": patient,
  37625. "org_name": miConfig.OrgName,
  37626. "org_code": miConfig.Code,
  37627. "order_number": order.Number,
  37628. "his_hospital": his_hospital,
  37629. "his": his,
  37630. "dia_config": dia_config,
  37631. "psn_cash_pay": order.PsnCashPay,
  37632. "zcCostTotal": zcCostTotal,
  37633. "zcCostSelfTotal": zcCostSelfTotal,
  37634. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  37635. "zcSelfTotal": zcSelfTotal,
  37636. "zcInscpTotal": zcInscpTotal,
  37637. "huliCostTotal": huliCostTotal,
  37638. "huliCostSelfTotal": huliCostSelfTotal,
  37639. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  37640. "huliSelfTotal": huliSelfTotal,
  37641. "huliInscpTotal": huliInscpTotal,
  37642. //"funds": rf,
  37643. //"check_order_info": cus_slice,
  37644. })
  37645. } else {
  37646. c.ServeSuccessJSON(map[string]interface{}{
  37647. "diagnosis": name,
  37648. "order_infos": orderInfos,
  37649. "number": order.MdtrtId,
  37650. "date": order.SettleAccountsDate,
  37651. "charge_admin": charge_admin,
  37652. "printor_admin": printor_admin,
  37653. "info": order,
  37654. "order": order,
  37655. "bedCostTotal": bedCostTotal,
  37656. "bedCostSelfTotal": bedCostSelfTotal,
  37657. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  37658. "bedSelfTotal": bedSelfTotal,
  37659. "bedInscpTotal": bedInscpTotal,
  37660. "operationCostTotal": operationCostTotal,
  37661. "operationCostSelfTotal": operationCostSelfTotal,
  37662. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  37663. "operationSelfTotal": operationSelfTotal,
  37664. "operationInscpTotal": operationInscpTotal,
  37665. "otherCostTotal": otherCostTotal,
  37666. "otherCostSelfTotal": otherCostSelfTotal,
  37667. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  37668. "otherSelfTotal": otherSelfTotal,
  37669. "otherInscpTotal": otherInscpTotal,
  37670. "materialCostTotal": materialCostTotal,
  37671. "materialCostSelfTotal": materialCostSelfTotal,
  37672. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  37673. "materialSelfTotal": materialSelfTotal,
  37674. "materialInscpTotal": materialInscpTotal,
  37675. "westernMedicineCostTotal": westernMedicineCostTotal,
  37676. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  37677. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  37678. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  37679. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  37680. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  37681. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  37682. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  37683. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  37684. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  37685. "checkCostTotal": checkCostTotal,
  37686. "checkCostSelfTotal": checkCostSelfTotal,
  37687. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  37688. "checkSelfTotal": checkSelfTotal,
  37689. "checkInscpTotal": checkInscpTotal,
  37690. "laboratoryCostTotal": laboratoryCostTotal,
  37691. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  37692. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  37693. "laboratorySelfTotal": laboratorySelfTotal,
  37694. "laboratoryInscpTotal": laboratoryInscpTotal,
  37695. "treatCostTotal": treatCostTotal,
  37696. "treatCostSelfTotal": treatCostSelfTotal,
  37697. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  37698. "treatSelfTotal": treatSelfTotal,
  37699. "treatInscpTotal": treatInscpTotal,
  37700. "doctor_info": doctor_info,
  37701. "doctor_code": adminRole_two.DoctorCode,
  37702. "doctor_name": doctor_name,
  37703. "health_card_no": order.PsnNo,
  37704. "department": departments.Name,
  37705. "yiliao_leibie": yiliao_leibie,
  37706. "after_money": order.AccountPrice,
  37707. "patient": patient,
  37708. "org_name": miConfig.OrgName,
  37709. "org_code": miConfig.Code,
  37710. "order_number": order.Number,
  37711. "his_hospital": his_hospital,
  37712. "his": his,
  37713. "dia_config": dia_config,
  37714. "psn_cash_pay": order.PsnCashPay,
  37715. "zcCostTotal": zcCostTotal,
  37716. "zcCostSelfTotal": zcCostSelfTotal,
  37717. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  37718. "zcSelfTotal": zcSelfTotal,
  37719. "zcInscpTotal": zcInscpTotal,
  37720. "huliCostTotal": huliCostTotal,
  37721. "huliCostSelfTotal": huliCostSelfTotal,
  37722. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  37723. "huliSelfTotal": huliSelfTotal,
  37724. "huliInscpTotal": huliInscpTotal,
  37725. //"funds": rf,
  37726. //"check_order_info": cus_slice,
  37727. })
  37728. }
  37729. }
  37730. }
  37731. }
  37732. //func (c *HisApiController) CheckTreatment() {
  37733. // patient_id, _ := c.GetInt64("patient_id")
  37734. // id_card_no := c.GetString("id_card_no")
  37735. // insutype := c.GetString("insutype")
  37736. // med_type := c.GetString("med_type")
  37737. // admin_user_id, _ := c.GetInt64("admin_user_id")
  37738. //
  37739. // adminUser := c.GetAdminUserInfo()
  37740. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  37741. //
  37742. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37743. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37744. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37745. //
  37746. // if miConfig.MdtrtareaAdmvs == "421300" {
  37747. // var res ResultTwo
  37748. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  37749. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  37750. // "&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)
  37751. // resp, requestErr := http.Get(api)
  37752. // if requestErr != nil {
  37753. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37754. // return
  37755. // }
  37756. //
  37757. // body, ioErr := ioutil.ReadAll(resp.Body)
  37758. // if ioErr != nil {
  37759. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37760. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37761. // return
  37762. // }
  37763. // var respJSON map[string]interface{}
  37764. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37765. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37766. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37767. // return
  37768. // }
  37769. //
  37770. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37771. // result, _ := json.Marshal(respJSON)
  37772. //
  37773. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  37774. // utils.ErrorLog("解析失败:%v", err)
  37775. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37776. // return
  37777. // }
  37778. //
  37779. // if res.Infcode == 0 {
  37780. //
  37781. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  37782. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  37783. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  37784. // resp, requestErr := http.Get(api)
  37785. // if requestErr != nil {
  37786. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37787. // return
  37788. // }
  37789. //
  37790. // body, ioErr := ioutil.ReadAll(resp.Body)
  37791. // if ioErr != nil {
  37792. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37793. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37794. // return
  37795. // }
  37796. // var respJSON map[string]interface{}
  37797. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37798. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37799. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37800. // return
  37801. // }
  37802. // var res Result2001
  37803. //
  37804. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37805. // result2, _ := json.Marshal(respJSON)
  37806. //
  37807. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  37808. // utils.ErrorLog("解析失败:%v", err)
  37809. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37810. // return
  37811. // }
  37812. //
  37813. // if res.Infcode == 0 {
  37814. // c.ServeSuccessJSON(map[string]interface{}{
  37815. // "msg": res.Output.Trtinfo,
  37816. // })
  37817. // }
  37818. //
  37819. // } else {
  37820. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37821. // return
  37822. // }
  37823. //
  37824. // } else {
  37825. //
  37826. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  37827. // var dat map[string]interface{}
  37828. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37829. // fmt.Println(dat)
  37830. // } else {
  37831. // fmt.Println(err)
  37832. // }
  37833. // userJSONBytes, _ := json.Marshal(dat)
  37834. // var res ResultTwo
  37835. // var res10265 ResultTwo10265
  37836. // if miConfig.Code == "H15049901371" {
  37837. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  37838. // utils.ErrorLog("解析失败:%v", err)
  37839. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37840. // return
  37841. // }
  37842. // res.ErrMsg = res10265.ErrMsg
  37843. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37844. // res.Infcode = infocode
  37845. // res.Output = res10265.Output
  37846. // res.InfRefmsgid = res10265.InfRefmsgid
  37847. // } else {
  37848. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37849. // utils.ErrorLog("解析失败:%v", err)
  37850. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37851. // return
  37852. // }
  37853. // }
  37854. //
  37855. // var user_name string
  37856. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  37857. // if role.ID == 0 {
  37858. // user_name = "xxx"
  37859. // } else {
  37860. // user_name = role.UserName
  37861. // }
  37862. //
  37863. // baseParams := models.BaseParams{
  37864. // SecretKey: miConfig.SecretKey,
  37865. // FixmedinsCode: miConfig.Code,
  37866. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  37867. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  37868. // OrgName: miConfig.OrgName,
  37869. // Doctor: user_name,
  37870. // }
  37871. //
  37872. // if config.IsOpen == 1 {
  37873. // if miConfig.Code == "H15049901371" {
  37874. // if med_type == "14" {
  37875. // if insutype == "390" {
  37876. // med_type = "9933"
  37877. // } else if insutype == "310" {
  37878. // med_type = "990502"
  37879. // }
  37880. // } else if med_type == "11" {
  37881. // med_type = "11"
  37882. // }
  37883. // }
  37884. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  37885. // var dat map[string]interface{}
  37886. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37887. // fmt.Println(dat)
  37888. // } else {
  37889. // fmt.Println(err)
  37890. // }
  37891. // var res Result2001
  37892. // var res10265 Result2001Org10265
  37893. // if miConfig.Code == "H15049901371" {
  37894. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37895. // utils.ErrorLog("解析失败:%v", err)
  37896. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37897. // return
  37898. // }
  37899. // res.ErrMsg = res10265.ErrMsg
  37900. // res.Output = res10265.Output
  37901. // res.InfRefmsgid = res10265.InfRefmsgid
  37902. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37903. // res.Infcode = infocode
  37904. // } else {
  37905. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  37906. // utils.ErrorLog("解析失败:%v", err)
  37907. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37908. // return
  37909. // }
  37910. // }
  37911. // if res.Infcode == 0 {
  37912. // c.ServeSuccessJSON(map[string]interface{}{
  37913. // "msg": res.Output.Trtinfo,
  37914. // })
  37915. // }
  37916. // }
  37917. // }
  37918. //}
  37919. //func (c *HisApiController) PutRecord() {
  37920. // id, _ := c.GetInt64("id")
  37921. // record_time := c.GetString("record_time")
  37922. // timeLayout := "2006-01-02"
  37923. // loc, _ := time.LoadLocation("Local")
  37924. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  37925. // if err != nil {
  37926. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  37927. // return
  37928. // }
  37929. // recordDateTime := theTime.Unix()
  37930. //
  37931. // adminInfo := c.GetAdminUserInfo()
  37932. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  37933. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  37934. //
  37935. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  37936. //
  37937. // fmt.Println(miConfig.SecretKey)
  37938. //
  37939. // if patient == nil {
  37940. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  37941. // return
  37942. // }
  37943. // if len(patient.IdCardNo) == 0 {
  37944. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  37945. // return
  37946. // }
  37947. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  37948. // if config.IsOpen == 1 {
  37949. // 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
  37950. // resp, requestErr := http.Get(api)
  37951. // if requestErr != nil {
  37952. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37953. // return
  37954. // }
  37955. // defer resp.Body.Close()
  37956. // body, ioErr := ioutil.ReadAll(resp.Body)
  37957. // if ioErr != nil {
  37958. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37959. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37960. // return
  37961. // }
  37962. // var respJSON map[string]interface{}
  37963. //
  37964. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37965. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37966. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37967. // return
  37968. // }
  37969. //
  37970. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37971. // userJSONBytes, _ := json.Marshal(userJSON)
  37972. // var res ResultTwo
  37973. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37974. // utils.ErrorLog("解析失败:%v", err)
  37975. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37976. // return
  37977. // }
  37978. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37979. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37980. // infoStr := string(Iinfos)
  37981. // idetinfoStr := string(Idetinfos)
  37982. //
  37983. // if res.Infcode == 0 {
  37984. // his := models.VMHisPatient{
  37985. // Status: 1,
  37986. // Ctime: time.Now().Unix(),
  37987. // Mtime: time.Now().Unix(),
  37988. // PsnNo: res.Output.Baseinfo.PsnNo,
  37989. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  37990. // Certno: res.Output.Baseinfo.Certno,
  37991. // PsnName: res.Output.Baseinfo.PsnName,
  37992. // Gend: res.Output.Baseinfo.Gend,
  37993. // Naty: res.Output.Baseinfo.Naty,
  37994. // Brdy: res.Output.Baseinfo.Brdy,
  37995. // Age: res.Output.Baseinfo.Age,
  37996. // Iinfo: infoStr,
  37997. // Idetinfo: idetinfoStr,
  37998. // PatientId: patient.ID,
  37999. // RecordDate: theTime.Unix(),
  38000. // UserOrgId: adminInfo.CurrentOrgId,
  38001. // AdminUserId: adminInfo.AdminUser.Id,
  38002. // IsReturn: 1,
  38003. // }
  38004. //
  38005. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  38006. // //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")
  38007. // //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")
  38008. //
  38009. // //var dat map[string]interface{}
  38010. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38011. // // fmt.Println(dat)
  38012. // //} else {
  38013. // // fmt.Println(err)
  38014. // //}
  38015. //
  38016. // var dat2 map[string]interface{}
  38017. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  38018. // fmt.Println(dat2)
  38019. // } else {
  38020. // fmt.Println(err)
  38021. // }
  38022. //
  38023. // } else {
  38024. // adminUser := c.GetAdminUserInfo()
  38025. // errlog := &models.HisOrderError{
  38026. // UserOrgId: adminUser.CurrentOrgId,
  38027. // Ctime: time.Now().Unix(),
  38028. // Mtime: time.Now().Unix(),
  38029. // ErrMsg: res.ErrMsg,
  38030. // Status: 1,
  38031. // PatientId: id,
  38032. // RecordTime: recordDateTime,
  38033. // Stage: 1,
  38034. // }
  38035. // service.CreateErrMsgLog(errlog)
  38036. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  38037. // return
  38038. // }
  38039. // }
  38040. //
  38041. //}
  38042. //func (c *HisApiController) GetUploadDiag() {
  38043. // id, _ := c.GetInt64("id")
  38044. // record_time := c.GetString("record_time")
  38045. //
  38046. // diagnosis_id, _ := c.GetInt64("diagnosis")
  38047. // sick_type, _ := c.GetInt64("sick_type")
  38048. // reg_type, _ := c.GetInt64("reg_type")
  38049. //
  38050. // timeLayout := "2006-01-02"
  38051. // loc, _ := time.LoadLocation("Local")
  38052. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  38053. // if err != nil {
  38054. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  38055. // return
  38056. // }
  38057. //
  38058. // var patientPrescription models.HisPrescriptionInfo
  38059. // recordDateTime := theTime.Unix()
  38060. // adminInfo := c.GetAdminUserInfo()
  38061. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  38062. //
  38063. // if patientPrescription.ID == 0 {
  38064. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  38065. // }
  38066. //
  38067. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  38068. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  38069. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  38070. // sickConfig, _ := service.FindSickById(sick_type)
  38071. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  38072. //
  38073. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  38074. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  38075. // "&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 +
  38076. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  38077. // resp2, requestErr2 := http.Get(api2)
  38078. // if requestErr2 != nil {
  38079. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38080. // return
  38081. // }
  38082. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  38083. // if ioErr2 != nil {
  38084. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  38085. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38086. // return
  38087. // }
  38088. // var respJSON2 map[string]interface{}
  38089. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  38090. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38091. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38092. // return
  38093. // }
  38094. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38095. // userJSONBytes2, _ := json.Marshal(respJSON2)
  38096. //
  38097. // var res2 ResultSix
  38098. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  38099. // utils.ErrorLog("解析失败:%v", err)
  38100. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38101. // return
  38102. // }
  38103. // if res2.Infcode != 0 {
  38104. // adminUser := c.GetAdminUserInfo()
  38105. // errlog := &models.HisOrderError{
  38106. // UserOrgId: adminUser.CurrentOrgId,
  38107. // Ctime: time.Now().Unix(),
  38108. // Mtime: time.Now().Unix(),
  38109. // ErrMsg: res2.ErrMsg,
  38110. // Status: 1,
  38111. // PatientId: id,
  38112. // RecordTime: recordDateTime,
  38113. // Stage: 3,
  38114. // }
  38115. // service.CreateErrMsgLog(errlog)
  38116. //
  38117. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  38118. // return
  38119. // }
  38120. //
  38121. // c.ServeSuccessJSON(map[string]interface{}{
  38122. // "msg": "上传成功",
  38123. // })
  38124. //
  38125. //}
  38126. type QueryResult struct {
  38127. ID int64
  38128. Name string
  38129. Code string
  38130. List_type_code string
  38131. }
  38132. func (c *HisApiController) GetCheckCode() {
  38133. ids_str := c.GetString("ids")
  38134. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  38135. ids_arr := strings.Split(ids_str, ",")
  38136. var queryResult []QueryResult
  38137. ids := make([]int64, 0)
  38138. for _, item := range ids_arr {
  38139. id, _ := strconv.ParseInt(item, 10, 64)
  38140. ids = append(ids, id)
  38141. }
  38142. if record_type == 1 {
  38143. drugs, _ := service.GetBatchDrugList(ids)
  38144. for _, item := range drugs {
  38145. result := QueryResult{
  38146. ID: item.ID,
  38147. Name: item.DrugName,
  38148. Code: item.MedicalInsuranceNumber,
  38149. List_type_code: "101",
  38150. }
  38151. queryResult = append(queryResult, result)
  38152. }
  38153. } else if record_type == 2 {
  38154. goods, _ := service.GetBatchGoodInformationList(ids)
  38155. fmt.Println(goods)
  38156. for _, item := range goods {
  38157. result := QueryResult{
  38158. ID: item.ID,
  38159. Name: item.GoodName,
  38160. Code: item.SocialSecurityDirectoryCode,
  38161. List_type_code: "301",
  38162. }
  38163. queryResult = append(queryResult, result)
  38164. }
  38165. } else if record_type == 3 {
  38166. projects, _ := service.GetBathchMyPorjecgList(ids)
  38167. for _, item := range projects {
  38168. result := QueryResult{
  38169. ID: item.ID,
  38170. Name: item.ProjectName,
  38171. Code: item.MedicalCode,
  38172. List_type_code: "201",
  38173. }
  38174. queryResult = append(queryResult, result)
  38175. }
  38176. }
  38177. admin_user_id, _ := c.GetInt64("admin_user_id")
  38178. adminUser := c.GetAdminUserInfo()
  38179. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38180. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38181. var user_name string
  38182. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38183. if role.ID == 0 {
  38184. user_name = "管理员"
  38185. } else {
  38186. user_name = role.UserName
  38187. }
  38188. baseParams := models.BaseParams{
  38189. SecretKey: miConfig.SecretKey,
  38190. FixmedinsCode: miConfig.Code,
  38191. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  38192. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  38193. OrgName: miConfig.OrgName,
  38194. Doctor: user_name,
  38195. }
  38196. var result string
  38197. if miConfig.MdtrtareaAdmvs == "430800" {
  38198. for _, item := range queryResult {
  38199. if record_type == 1 {
  38200. 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)
  38201. } else if record_type == 2 {
  38202. fmt.Println(item.Code)
  38203. 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)
  38204. } else if record_type == 3 {
  38205. 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)
  38206. }
  38207. var dat map[string]interface{}
  38208. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38209. fmt.Println(dat)
  38210. } else {
  38211. fmt.Println(err)
  38212. }
  38213. userJSONBytes, _ := json.Marshal(dat)
  38214. var res ResultSix
  38215. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38216. utils.ErrorLog("解析失败:%v", err)
  38217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38218. return
  38219. }
  38220. if res.Infcode == 0 {
  38221. if record_type == 1 {
  38222. service.UpdateBaseDrugById(item.ID)
  38223. } else if record_type == 2 {
  38224. service.UpdateGoodInformaitonByDetail(item.ID)
  38225. } else if record_type == 3 {
  38226. service.UpdateProjectById(item.ID)
  38227. }
  38228. c.ServeSuccessJSON(map[string]interface{}{
  38229. "failed_code": 0,
  38230. "msg": "目录对照成功",
  38231. })
  38232. } else {
  38233. c.ServeSuccessJSON(map[string]interface{}{
  38234. "failed_code": -10,
  38235. "msg": res.ErrMsg,
  38236. })
  38237. }
  38238. }
  38239. } else {
  38240. for _, item := range queryResult {
  38241. var result string
  38242. if record_type == 1 {
  38243. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  38244. } else if record_type == 2 {
  38245. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  38246. } else if record_type == 3 {
  38247. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  38248. }
  38249. var dat map[string]interface{}
  38250. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38251. fmt.Println(dat)
  38252. } else {
  38253. fmt.Println(err)
  38254. }
  38255. userJSONBytes, _ := json.Marshal(dat)
  38256. var res ResultSix
  38257. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38258. utils.ErrorLog("解析失败:%v", err)
  38259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38260. return
  38261. }
  38262. if res.Infcode == 0 {
  38263. if record_type == 1 {
  38264. service.UpdateBaseDrugById(item.ID)
  38265. } else if record_type == 2 {
  38266. service.UpdateGoodInformaitonByDetail(item.ID)
  38267. } else if record_type == 3 {
  38268. service.UpdateProjectById(item.ID)
  38269. }
  38270. c.ServeSuccessJSON(map[string]interface{}{
  38271. "failed_code": 0,
  38272. "msg": "目录对照成功",
  38273. })
  38274. } else {
  38275. c.ServeSuccessJSON(map[string]interface{}{
  38276. "failed_code": -10,
  38277. "msg": res.ErrMsg,
  38278. })
  38279. }
  38280. }
  38281. }
  38282. }
  38283. func (c *HisApiController) UnCheckCode() {
  38284. ids_str := c.GetString("ids")
  38285. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  38286. admin_user_id, _ := c.GetInt64("admin_user_id")
  38287. ids_arr := strings.Split(ids_str, ",")
  38288. var queryResult []QueryResult
  38289. ids := make([]int64, 0)
  38290. for _, item := range ids_arr {
  38291. id, _ := strconv.ParseInt(item, 10, 64)
  38292. ids = append(ids, id)
  38293. }
  38294. if record_type == 1 {
  38295. drugs, _ := service.GetBatchDrugList(ids)
  38296. for _, item := range drugs {
  38297. result := QueryResult{
  38298. ID: item.ID,
  38299. Name: item.DrugName,
  38300. Code: item.MedicalInsuranceNumber,
  38301. List_type_code: "101",
  38302. }
  38303. queryResult = append(queryResult, result)
  38304. }
  38305. } else if record_type == 2 {
  38306. goods, _ := service.GetBatchGoodInformationList(ids)
  38307. for _, item := range goods {
  38308. result := QueryResult{
  38309. ID: item.ID,
  38310. Name: item.GoodName,
  38311. Code: item.SocialSecurityDirectoryCode,
  38312. List_type_code: "301",
  38313. }
  38314. queryResult = append(queryResult, result)
  38315. }
  38316. } else if record_type == 3 {
  38317. projects, _ := service.GetBathchMyPorjecgList(ids)
  38318. for _, item := range projects {
  38319. result := QueryResult{
  38320. ID: item.ID,
  38321. Name: item.ProjectName,
  38322. Code: item.MedicalCode,
  38323. List_type_code: "201",
  38324. }
  38325. queryResult = append(queryResult, result)
  38326. }
  38327. }
  38328. adminUser := c.GetAdminUserInfo()
  38329. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38330. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38331. var user_name string
  38332. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38333. if role.ID == 0 {
  38334. user_name = "xxx"
  38335. } else {
  38336. user_name = role.UserName
  38337. }
  38338. baseParams := &models.BaseParams{
  38339. SecretKey: miConfig.SecretKey,
  38340. FixmedinsCode: miConfig.Code,
  38341. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  38342. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  38343. OrgName: miConfig.OrgName,
  38344. Doctor: user_name,
  38345. }
  38346. if config.IsOpen == 1 {
  38347. if miConfig.MdtrtareaAdmvs == "430800" {
  38348. for _, item := range queryResult {
  38349. var result string
  38350. if record_type == 1 {
  38351. 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)
  38352. } else if record_type == 2 {
  38353. fmt.Println(item.Code)
  38354. 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)
  38355. } else if record_type == 3 {
  38356. 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)
  38357. }
  38358. var dat map[string]interface{}
  38359. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38360. fmt.Println(dat)
  38361. } else {
  38362. fmt.Println(err)
  38363. }
  38364. userJSONBytes, _ := json.Marshal(dat)
  38365. var res ResultSix
  38366. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38367. utils.ErrorLog("解析失败:%v", err)
  38368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38369. return
  38370. }
  38371. if res.Infcode == 0 {
  38372. if record_type == 1 {
  38373. service.UpdateBaseDrugById(item.ID)
  38374. } else if record_type == 2 {
  38375. service.UpdateGoodInformaitonByDetail(item.ID)
  38376. } else if record_type == 3 {
  38377. service.UpdateProjectById(item.ID)
  38378. }
  38379. c.ServeSuccessJSON(map[string]interface{}{
  38380. "failed_code": 0,
  38381. "msg": "目录对照成功",
  38382. })
  38383. } else {
  38384. c.ServeSuccessJSON(map[string]interface{}{
  38385. "failed_code": -10,
  38386. "msg": res.ErrMsg,
  38387. })
  38388. }
  38389. }
  38390. } else {
  38391. for _, item := range queryResult {
  38392. var result string
  38393. if record_type == 1 {
  38394. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  38395. } else if record_type == 2 {
  38396. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  38397. } else if record_type == 3 {
  38398. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  38399. }
  38400. var dat2 map[string]interface{}
  38401. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  38402. fmt.Println(dat2)
  38403. } else {
  38404. fmt.Println(err)
  38405. }
  38406. userJSONBytes, _ := json.Marshal(dat2)
  38407. var res ResultSix
  38408. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38409. utils.ErrorLog("解析失败:%v", err)
  38410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38411. return
  38412. }
  38413. if res.Infcode == 0 {
  38414. if record_type == 1 {
  38415. service.UpdateDrugByIdDetail(item.ID)
  38416. } else if record_type == 2 {
  38417. service.UpdateGoodInfoById(item.ID)
  38418. } else if record_type == 3 {
  38419. service.UpdateMyProjectById(item.ID)
  38420. }
  38421. c.ServeSuccessJSON(map[string]interface{}{
  38422. "failed_code": 0,
  38423. "msg": "撤销目录对照成功",
  38424. })
  38425. } else {
  38426. c.ServeSuccessJSON(map[string]interface{}{
  38427. "failed_code": -10,
  38428. "msg": res.ErrMsg,
  38429. })
  38430. }
  38431. }
  38432. }
  38433. }
  38434. }
  38435. func (c *HisApiController) GetPatientInfo() {
  38436. id_card_no := c.GetString("id_card_no")
  38437. admin_user_id, _ := c.GetInt64("admin_user_id")
  38438. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  38439. if patient.ID == 0 {
  38440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  38441. return
  38442. }
  38443. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  38444. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38445. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  38446. var res ResultTwo
  38447. var res10265 ResultTwo10265
  38448. if config.IsOpen == 1 {
  38449. if miConfig.MdtrtareaAdmvs == "150404" {
  38450. //请求内网数据
  38451. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  38452. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  38453. "&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
  38454. resp, requestErr := http.Get(api)
  38455. if requestErr != nil {
  38456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38457. return
  38458. }
  38459. body, ioErr := ioutil.ReadAll(resp.Body)
  38460. if ioErr != nil {
  38461. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38463. return
  38464. }
  38465. var respJSON map[string]interface{}
  38466. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38467. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38469. return
  38470. }
  38471. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38472. result_byte, _ := json.Marshal(respJSON)
  38473. result := string(result_byte)
  38474. var dat map[string]interface{}
  38475. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38476. fmt.Println(dat)
  38477. } else {
  38478. fmt.Println(err)
  38479. }
  38480. userJSONBytes, _ := json.Marshal(dat)
  38481. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  38482. utils.ErrorLog("解析失败:%v", err)
  38483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38484. return
  38485. }
  38486. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38487. res.Infcode = Infcode
  38488. res.ErrMsg = res10265.ErrMsg
  38489. res.Output = res10265.Output
  38490. res.InfRefmsgid = res10265.InfRefmsgid
  38491. res.RespondTime = res10265.RespondTime
  38492. res.WarnInfo = res10265.WarnInfo
  38493. } else {
  38494. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  38495. var dat map[string]interface{}
  38496. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38497. fmt.Println(dat)
  38498. } else {
  38499. fmt.Println(err)
  38500. }
  38501. userJSONBytes, _ := json.Marshal(dat)
  38502. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38503. utils.ErrorLog("解析失败:%v", err)
  38504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38505. return
  38506. }
  38507. }
  38508. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38509. // utils.ErrorLog("解析失败:%v", err)
  38510. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38511. // return
  38512. //}
  38513. for index, item := range res.Output.Iinfo {
  38514. if item.PsnInsuStas == "2" {
  38515. fmt.Println("--------")
  38516. res.Output.Iinfo[index].Insutype = "300"
  38517. res.Output.Iinfo[index].PsnInsuStas = "1"
  38518. }
  38519. }
  38520. fmt.Println(res.Output.Iinfo)
  38521. if res.Infcode != 0 {
  38522. c.ServeSuccessJSON(map[string]interface{}{
  38523. "failed_code": -10,
  38524. "msg": res.ErrMsg,
  38525. })
  38526. } else {
  38527. c.ServeSuccessJSON(map[string]interface{}{
  38528. "failed_code": 0,
  38529. "info": res,
  38530. })
  38531. }
  38532. }
  38533. }
  38534. func (c *HisApiController) PsnPutOnRecord() {
  38535. record_type, _ := c.GetInt64("type")
  38536. patient_id, _ := c.GetInt64("patient_id")
  38537. admin_user_id, _ := c.GetInt64("admin_user_id")
  38538. start_time := c.GetString("start_time")
  38539. end_time := c.GetString("end_time")
  38540. adminUser := c.GetAdminUserInfo()
  38541. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38542. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38543. var patients []*models.Patients
  38544. if record_type == 1 { //全部备案
  38545. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  38546. patients = append(patients, patient...)
  38547. } else { //单个备案
  38548. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  38549. patients = append(patients, patient)
  38550. }
  38551. var user_name string
  38552. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38553. if role.ID == 0 {
  38554. user_name = "xxx"
  38555. } else {
  38556. user_name = role.UserName
  38557. }
  38558. if config.IsOpen == 1 {
  38559. for _, item := range patients {
  38560. 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
  38561. resp, requestErr := http.Get(api)
  38562. if requestErr != nil {
  38563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38564. return
  38565. }
  38566. defer resp.Body.Close()
  38567. body, ioErr := ioutil.ReadAll(resp.Body)
  38568. if ioErr != nil {
  38569. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38571. return
  38572. }
  38573. var respJSON map[string]interface{}
  38574. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38575. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38577. return
  38578. }
  38579. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38580. userJSONBytes, _ := json.Marshal(userJSON)
  38581. var res ResultTwo
  38582. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38583. utils.ErrorLog("解析失败:%v", err)
  38584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38585. return
  38586. }
  38587. if res.Infcode == 0 {
  38588. 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)
  38589. var dat map[string]interface{}
  38590. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38591. fmt.Println(dat)
  38592. } else {
  38593. fmt.Println(err)
  38594. }
  38595. userJSONBytes, _ := json.Marshal(dat)
  38596. var res2 ResultThirteen
  38597. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  38598. utils.ErrorLog("解析失败:%v", err)
  38599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38600. return
  38601. }
  38602. if res2.Infcode == 0 {
  38603. psnResult := &models.GdybPsnRecord{
  38604. UserOrgId: adminUser.CurrentOrgId,
  38605. PatientId: item.ID,
  38606. PsnNo: res.Output.Baseinfo.PsnNo,
  38607. Ctime: time.Now().Unix(),
  38608. Mtime: time.Now().Unix(),
  38609. Status: 1,
  38610. IsCancel: 1,
  38611. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  38612. }
  38613. service.CreatePsnRecord(psnResult)
  38614. } else {
  38615. c.ServeSuccessJSON(map[string]interface{}{
  38616. "failed_code": -10,
  38617. "msg": res2.ErrMsg,
  38618. })
  38619. return
  38620. }
  38621. }
  38622. }
  38623. }
  38624. }
  38625. func (c *HisApiController) PsnUnPutOnRecord() {
  38626. id, _ := c.GetInt64("id")
  38627. //record_type, _ := c.GetInt64("type")
  38628. admin_user_id, _ := c.GetInt64("admin_user_id")
  38629. adminUser := c.GetAdminUserInfo()
  38630. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38631. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38632. var user_name string
  38633. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38634. if role.ID == 0 {
  38635. user_name = "xxx"
  38636. } else {
  38637. user_name = role.UserName
  38638. }
  38639. psn_record, _ := service.GetPsnRecordById(id)
  38640. if psn_record.ID == 0 {
  38641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  38642. return
  38643. }
  38644. if config.IsOpen == 1 {
  38645. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  38646. var dat map[string]interface{}
  38647. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38648. fmt.Println(dat)
  38649. } else {
  38650. fmt.Println(err)
  38651. }
  38652. userJSONBytes, _ := json.Marshal(dat)
  38653. var res ResultFourteen
  38654. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38655. utils.ErrorLog("解析失败:%v", err)
  38656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38657. return
  38658. }
  38659. if res.Infcode == 0 {
  38660. psn_record.IsCancel = 2
  38661. service.CreatePsnRecord(&psn_record)
  38662. } else {
  38663. c.ServeSuccessJSON(map[string]interface{}{
  38664. "failed_code": -10,
  38665. "msg": res.ErrMsg,
  38666. })
  38667. return
  38668. }
  38669. }
  38670. }
  38671. func (c *HisApiController) PsnPutNCDSOnRecord() {
  38672. patient_id, _ := c.GetInt64("patient_id")
  38673. insutype_two := c.GetString("insutype")
  38674. psn_no := c.GetString("psn_no")
  38675. doctor_id, _ := c.GetInt64("doctor_id")
  38676. sick_id, _ := c.GetInt64("sick_id")
  38677. department_id, _ := c.GetInt64("department_id")
  38678. start_time := c.GetString("start_time")
  38679. end_time := c.GetString("end_time")
  38680. check_time := c.GetString("check_time")
  38681. hospital_code := c.GetString("hospital_code")
  38682. hospital_name := c.GetString("hospital_name")
  38683. adminUser := c.GetAdminUserInfo()
  38684. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  38685. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38686. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38687. sick, _ := service.FindSickById(sick_id)
  38688. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  38689. if len(hospital_code) == 0 {
  38690. hospital_code = miConfig.Code
  38691. }
  38692. if len(hospital_name) == 0 {
  38693. hospital_name = miConfig.OrgName
  38694. }
  38695. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  38696. var res ResultTwo
  38697. var res10265 ResultTwo10265
  38698. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  38699. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  38700. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  38701. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  38702. "&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
  38703. resp, requestErr := http.Get(api)
  38704. if requestErr != nil {
  38705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38706. return
  38707. }
  38708. body, ioErr := ioutil.ReadAll(resp.Body)
  38709. if ioErr != nil {
  38710. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38712. return
  38713. }
  38714. var respJSON map[string]interface{}
  38715. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38716. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38718. return
  38719. }
  38720. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38721. result, _ := json.Marshal(respJSON)
  38722. fmt.Println("log")
  38723. fmt.Println(string(result))
  38724. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38725. utils.ErrorLog("解析失败:%v", err)
  38726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38727. return
  38728. }
  38729. res.ErrMsg = res10265.ErrMsg
  38730. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38731. res.Infcode = infocode
  38732. res.Output = res10265.Output
  38733. res.InfRefmsgid = res10265.InfRefmsgid
  38734. } else {
  38735. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  38736. if miConfig.Code == "H15049901371" {
  38737. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38738. utils.ErrorLog("解析失败:%v", err)
  38739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38740. return
  38741. }
  38742. res.ErrMsg = res10265.ErrMsg
  38743. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38744. res.Infcode = infocode
  38745. res.Output = res10265.Output
  38746. res.InfRefmsgid = res10265.InfRefmsgid
  38747. } else {
  38748. if err := json.Unmarshal([]byte(result), &res); err != nil {
  38749. utils.ErrorLog("解析失败:%v", err)
  38750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38751. return
  38752. }
  38753. }
  38754. }
  38755. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  38756. infoStr := string(Iinfos)
  38757. var rf []*ResultFive
  38758. json.Unmarshal([]byte(infoStr), &rf)
  38759. var insuplc_admdvs string
  38760. var insutype string
  38761. var is390 int = 0
  38762. var is310 int = 0
  38763. var insutypes []*ResultFive
  38764. for _, item := range rf {
  38765. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  38766. insutypes = append(insutypes, item)
  38767. }
  38768. }
  38769. if len(insutypes) == 1 {
  38770. insutype = insutypes[0].Insutype
  38771. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  38772. } else {
  38773. for _, i := range insutypes {
  38774. if i.Insutype == "390" {
  38775. is390 = 1
  38776. }
  38777. if i.Insutype == "310" {
  38778. is310 = 1
  38779. }
  38780. }
  38781. }
  38782. if is390 == 1 {
  38783. insutype = "390"
  38784. }
  38785. if is310 == 1 {
  38786. insutype = "310"
  38787. }
  38788. if len(insutypes) == 2 {
  38789. insutype = insutype_two
  38790. }
  38791. if len(insutypes) == 0 {
  38792. insutype = "310"
  38793. }
  38794. insutype = insutype_two
  38795. fmt.Println(insutype)
  38796. for _, item := range rf {
  38797. fmt.Println(item.Insutype)
  38798. fmt.Println(insutype)
  38799. if item.Insutype == insutype {
  38800. fmt.Println(item.Insutype)
  38801. fmt.Println(insutype)
  38802. insuplc_admdvs = item.InsuplcAdmdvs
  38803. }
  38804. }
  38805. fmt.Println(insuplc_admdvs)
  38806. var res2 ResultThirteen
  38807. var res10265_2 ResultThirteen10265
  38808. if config.IsOpen == 1 {
  38809. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  38810. } else {
  38811. if miConfig.MdtrtareaAdmvs == "150404" {
  38812. //
  38813. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  38814. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  38815. // "&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
  38816. //resp, requestErr := http.Get(api)
  38817. //if requestErr != nil {
  38818. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38819. // return
  38820. //}
  38821. //
  38822. //body, ioErr := ioutil.ReadAll(resp.Body)
  38823. //if ioErr != nil {
  38824. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38825. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38826. // return
  38827. //}
  38828. //var respJSON map[string]interface{}
  38829. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38830. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38831. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38832. // return
  38833. //}
  38834. //
  38835. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38836. //result, _ := json.Marshal(respJSON)
  38837. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  38838. // utils.ErrorLog("解析失败:%v", err)
  38839. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38840. // return
  38841. //}
  38842. //infocode = resThree.Infcode
  38843. //result, _ := json.Marshal(respJSON)
  38844. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  38845. // utils.ErrorLog("解析失败:%v", err)
  38846. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38847. // return
  38848. //}
  38849. //
  38850. //resThree.ErrMsg = resThree10265.ErrMsg
  38851. //
  38852. //resThree.Output = resThree10265.Output
  38853. //
  38854. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  38855. //
  38856. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  38857. //
  38858. } else {
  38859. 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)
  38860. var dat map[string]interface{}
  38861. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38862. fmt.Println(dat)
  38863. } else {
  38864. fmt.Println(err)
  38865. }
  38866. userJSONBytes, _ := json.Marshal(dat)
  38867. if miConfig.Code == "H15049901371" {
  38868. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  38869. utils.ErrorLog("解析失败:%v", err)
  38870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38871. return
  38872. }
  38873. res2.ErrMsg = res10265_2.ErrMsg
  38874. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  38875. res2.Infcode = infocode
  38876. res2.Output = res10265_2.Output
  38877. res2.InfRefmsgid = res10265_2.InfRefmsgid
  38878. } else {
  38879. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  38880. utils.ErrorLog("解析失败:%v", err)
  38881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38882. return
  38883. }
  38884. }
  38885. }
  38886. }
  38887. if res2.Infcode == 0 {
  38888. psnResult := &models.GdybPsnNcdsRecord{
  38889. UserOrgId: adminUser.CurrentOrgId,
  38890. PatientId: patient.ID,
  38891. PsnNo: psn_no,
  38892. DoctorId: doctor.AdminUserId,
  38893. DepartmentId: department_id,
  38894. SickType: sick_id,
  38895. Insutype: insutype,
  38896. Ctime: time.Now().Unix(),
  38897. Mtime: time.Now().Unix(),
  38898. Status: 1,
  38899. IsCancel: 1,
  38900. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  38901. }
  38902. service.CreatePsnNCDSRecord(psnResult)
  38903. c.ServeSuccessJSON(map[string]interface{}{
  38904. "failed_code": 0,
  38905. "msg": "备案成功",
  38906. "result": psnResult,
  38907. })
  38908. } else {
  38909. c.ServeSuccessJSON(map[string]interface{}{
  38910. "failed_code": -10,
  38911. "msg": res2.ErrMsg,
  38912. })
  38913. return
  38914. }
  38915. }
  38916. }
  38917. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  38918. id, _ := c.GetInt64("id")
  38919. admin_user_id, _ := c.GetInt64("admin_user_id")
  38920. adminUser := c.GetAdminUserInfo()
  38921. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38922. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38923. //config, _ := service.Ge(adminUser.CurrentOrgId)
  38924. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  38925. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38926. //var user_name string
  38927. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38928. //if role.ID == 0 {
  38929. // user_name = "xxx"
  38930. //} else {
  38931. // user_name = role.UserName
  38932. //}
  38933. psn_record, _ := service.GetPsnNCDSRecordById(id)
  38934. if psn_record.ID == 0 {
  38935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  38936. return
  38937. }
  38938. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  38939. var res ResultTwo
  38940. var res10265 ResultTwo10265
  38941. if miConfig.Code == "H15049901371" {
  38942. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38943. utils.ErrorLog("解析失败:%v", err)
  38944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38945. return
  38946. }
  38947. res.ErrMsg = res10265.ErrMsg
  38948. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38949. res.Infcode = infocode
  38950. res.Output = res10265.Output
  38951. res.InfRefmsgid = res10265.InfRefmsgid
  38952. } else {
  38953. if err := json.Unmarshal([]byte(result), &res); err != nil {
  38954. utils.ErrorLog("解析失败:%v", err)
  38955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38956. return
  38957. }
  38958. }
  38959. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  38960. infoStr := string(Iinfos)
  38961. var rf []*ResultFive
  38962. json.Unmarshal([]byte(infoStr), &rf)
  38963. var insuplc_admdvs string
  38964. var insutype string
  38965. var is390 int = 0
  38966. var is310 int = 0
  38967. var insutypes []*ResultFive
  38968. for _, item := range rf {
  38969. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  38970. insutypes = append(insutypes, item)
  38971. }
  38972. }
  38973. if len(insutypes) == 1 {
  38974. insutype = insutypes[0].Insutype
  38975. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  38976. } else {
  38977. for _, i := range insutypes {
  38978. if i.Insutype == "390" {
  38979. is390 = 1
  38980. }
  38981. if i.Insutype == "310" {
  38982. is310 = 1
  38983. }
  38984. }
  38985. }
  38986. if is390 == 1 {
  38987. insutype = "390"
  38988. }
  38989. if is310 == 1 {
  38990. insutype = "310"
  38991. }
  38992. if len(insutypes) == 0 {
  38993. insutype = "310"
  38994. }
  38995. insutype = psn_record.Insutype
  38996. for _, item := range rf {
  38997. if item.Insutype == insutype {
  38998. insuplc_admdvs = item.InsuplcAdmdvs
  38999. }
  39000. }
  39001. if config.IsOpen == 1 {
  39002. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  39003. var dat map[string]interface{}
  39004. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  39005. fmt.Println(dat)
  39006. } else {
  39007. fmt.Println(err)
  39008. }
  39009. userJSONBytes, _ := json.Marshal(dat)
  39010. var res ResultFourteen
  39011. var res10265 ResultFourteen10265
  39012. if miConfig.Code == "H15049901371" {
  39013. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  39014. utils.ErrorLog("解析失败:%v", err)
  39015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39016. return
  39017. }
  39018. res.ErrMsg = res10265.ErrMsg
  39019. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  39020. res.Infcode = infocode
  39021. res.Output = res10265.Output
  39022. res.InfRefmsgid = res10265.InfRefmsgid
  39023. } else {
  39024. if err := json.Unmarshal([]byte(result), &res); err != nil {
  39025. utils.ErrorLog("解析失败:%v", err)
  39026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39027. return
  39028. }
  39029. }
  39030. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39031. // utils.ErrorLog("解析失败:%v", err)
  39032. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39033. // return
  39034. //}
  39035. if res.Infcode == 0 {
  39036. psn_record.IsCancel = 2
  39037. service.CreatePsnNCDSRecord(&psn_record)
  39038. c.ServeSuccessJSON(map[string]interface{}{
  39039. "failed_code": 0,
  39040. "msg": "撤销备案成功",
  39041. })
  39042. } else {
  39043. c.ServeSuccessJSON(map[string]interface{}{
  39044. "failed_code": -10,
  39045. "msg": res.ErrMsg,
  39046. })
  39047. return
  39048. }
  39049. }
  39050. }
  39051. func (c *HisApiController) TestTest() {
  39052. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  39053. fmt.Println(patient.Iinfo)
  39054. }
  39055. type CustomData struct {
  39056. MsgId string
  39057. PsnNo string
  39058. Info string
  39059. }
  39060. func (c *HisApiController) ReversalData() {
  39061. var customData []*CustomData
  39062. custom := &CustomData{
  39063. MsgId: "H44022900158202103301714472004",
  39064. PsnNo: "44020000001101329945",
  39065. Info: "2207",
  39066. }
  39067. customData = append(customData, custom)
  39068. custom1 := &CustomData{
  39069. MsgId: "H4402290015820210330172057803",
  39070. PsnNo: "44020000001101161813",
  39071. Info: "2207",
  39072. }
  39073. customData = append(customData, custom1)
  39074. custom2 := &CustomData{
  39075. MsgId: "H44022900158202103301705198813",
  39076. PsnNo: "44190000133097375417",
  39077. Info: "2207",
  39078. }
  39079. customData = append(customData, custom2)
  39080. custom3 := &CustomData{
  39081. MsgId: "H44022900158202103301715524756",
  39082. PsnNo: "44020000001100187221",
  39083. Info: "2207",
  39084. }
  39085. customData = append(customData, custom3)
  39086. custom4 := &CustomData{
  39087. MsgId: "H44022900158202103301730376224",
  39088. PsnNo: "44020000001101959155",
  39089. Info: "2207",
  39090. }
  39091. customData = append(customData, custom4)
  39092. custom5 := &CustomData{
  39093. MsgId: "H44022900158202103301748008725",
  39094. PsnNo: "44020000001104246641",
  39095. Info: "2207",
  39096. }
  39097. customData = append(customData, custom5)
  39098. custom6 := &CustomData{
  39099. MsgId: "H44022900158202103301718096755",
  39100. PsnNo: "44020000001102211860",
  39101. Info: "2207",
  39102. }
  39103. customData = append(customData, custom6)
  39104. custom7 := &CustomData{
  39105. MsgId: "H44022900158202103301736551640",
  39106. PsnNo: "44020000001102687718",
  39107. Info: "2207",
  39108. }
  39109. customData = append(customData, custom7)
  39110. custom8 := &CustomData{
  39111. MsgId: "H44022900158202103301743097676",
  39112. PsnNo: "44020000001102127785",
  39113. Info: "2207",
  39114. }
  39115. customData = append(customData, custom8)
  39116. custom9 := &CustomData{
  39117. MsgId: "H44022900158202103301712304203",
  39118. PsnNo: "44020000001101518097",
  39119. Info: "2207",
  39120. }
  39121. customData = append(customData, custom9)
  39122. custom10 := &CustomData{
  39123. MsgId: "H44022900158202103301738448785",
  39124. PsnNo: "44020000001100500813",
  39125. Info: "2207",
  39126. }
  39127. customData = append(customData, custom10)
  39128. custom11 := &CustomData{
  39129. MsgId: "H44022900158202103301732455843",
  39130. PsnNo: "44020000001102690557",
  39131. Info: "2207",
  39132. }
  39133. customData = append(customData, custom11)
  39134. custom12 := &CustomData{
  39135. MsgId: "H44022900158202103301745421708",
  39136. PsnNo: "44020000001102211928",
  39137. Info: "2207",
  39138. }
  39139. customData = append(customData, custom12)
  39140. custom1212 := &CustomData{
  39141. MsgId: "H440229001582021033017351627",
  39142. PsnNo: "44020000001102481733",
  39143. Info: "2207",
  39144. }
  39145. customData = append(customData, custom1212)
  39146. custom13 := &CustomData{
  39147. MsgId: "H44022900158202103301740327951",
  39148. PsnNo: "44020000001103174866",
  39149. Info: "2207",
  39150. }
  39151. customData = append(customData, custom13)
  39152. custom14 := &CustomData{
  39153. MsgId: "H4402290015820210330174922668",
  39154. PsnNo: "44020000001102927272",
  39155. Info: "2207",
  39156. }
  39157. customData = append(customData, custom14)
  39158. custom15 := &CustomData{
  39159. MsgId: "H44022900158202103301752362273",
  39160. PsnNo: "44020000001102942890",
  39161. Info: "2207",
  39162. }
  39163. customData = append(customData, custom15)
  39164. custom16 := &CustomData{
  39165. MsgId: "H44022900158202103301751082917",
  39166. PsnNo: "44020000001101662162",
  39167. Info: "2207",
  39168. }
  39169. customData = append(customData, custom16)
  39170. custom17 := &CustomData{
  39171. MsgId: "H44022900158202103301754147728",
  39172. PsnNo: "44020000000229014511",
  39173. Info: "2207",
  39174. }
  39175. customData = append(customData, custom17)
  39176. adminUser := c.GetAdminUserInfo()
  39177. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39178. for _, item := range customData {
  39179. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  39180. fmt.Println(result)
  39181. }
  39182. }
  39183. func (c *HisApiController) GetAllopatry() {
  39184. year := c.GetString("year")
  39185. month := c.GetString("month")
  39186. admin_user_id, _ := c.GetInt64("admin_user_id")
  39187. adminUser := c.GetAdminUserInfo()
  39188. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39189. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39190. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  39191. var dat map[string]interface{}
  39192. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  39193. fmt.Println(dat)
  39194. } else {
  39195. fmt.Println(err)
  39196. }
  39197. userJSONBytes, _ := json.Marshal(dat)
  39198. var res models.Result9001
  39199. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39200. utils.ErrorLog("解析失败:%v", err)
  39201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39202. return
  39203. }
  39204. fmt.Println(res.Output.Signinoutb)
  39205. fmt.Println(res.Output.Signinoutb.SignNo)
  39206. fmt.Println(string(userJSONBytes))
  39207. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  39208. var dat3 map[string]interface{}
  39209. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  39210. fmt.Println(dat3)
  39211. } else {
  39212. fmt.Println(err)
  39213. }
  39214. userJSONBytes3, _ := json.Marshal(dat3)
  39215. var res3 models.Result3260
  39216. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  39217. utils.ErrorLog("解析失败:%v", err)
  39218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39219. return
  39220. }
  39221. var curpage int
  39222. var pagesize int = 100
  39223. var start int = 1
  39224. //var stop int
  39225. //pagecount := 10
  39226. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  39227. var res22 []models.Result3260
  39228. for curpage = 1; curpage <= pagecount; curpage++ {
  39229. if curpage == 1 {
  39230. start = 0
  39231. } else {
  39232. start = (curpage-1)*pagesize + 1
  39233. }
  39234. fmt.Println(start)
  39235. //stop = curpage * pagesize
  39236. //if stop > int(res3.Output.Totalrow) {
  39237. // stop =int(res3.Output.Totalrow)
  39238. //}
  39239. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  39240. var dat2 map[string]interface{}
  39241. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  39242. fmt.Println(dat)
  39243. } else {
  39244. fmt.Println(err)
  39245. }
  39246. userJSONBytes2, _ := json.Marshal(dat2)
  39247. var res2 models.Result3260
  39248. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  39249. utils.ErrorLog("解析失败:%v", err)
  39250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39251. return
  39252. }
  39253. if res2.Infcode == 0 {
  39254. res22 = append(res22, res2)
  39255. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  39256. //var dat2 map[string]interface{}
  39257. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  39258. // fmt.Println(dat)
  39259. //} else {
  39260. // fmt.Println(err)
  39261. //}
  39262. //c.ServeSuccessJSON(map[string]interface{}{
  39263. // "list": res2.Output.Data,
  39264. //})
  39265. //continue
  39266. }
  39267. }
  39268. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  39269. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  39270. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  39271. //var dat2 map[string]interface{}
  39272. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  39273. // fmt.Println(dat)
  39274. //} else {
  39275. // fmt.Println(err)
  39276. //}
  39277. //userJSONBytes2, _ := json.Marshal(dat2)
  39278. //var res2 models.Result3260
  39279. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  39280. // utils.ErrorLog("解析失败:%v", err)
  39281. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39282. // return
  39283. //}
  39284. //if res2.Infcode == 0 {
  39285. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  39286. // var dat2 map[string]interface{}
  39287. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  39288. // fmt.Println(dat)
  39289. // } else {
  39290. // fmt.Println(err)
  39291. // }
  39292. // c.ServeSuccessJSON(map[string]interface{}{
  39293. // "list": res2.Output.Data,
  39294. // })
  39295. //}
  39296. }
  39297. func (c *HisApiController) ComfirmAllopatry() {
  39298. year := c.GetString("year")
  39299. month := c.GetString("month")
  39300. admin_user_id, _ := c.GetInt64("admin_user_id")
  39301. adminUser := c.GetAdminUserInfo()
  39302. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39303. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39304. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  39305. var dat map[string]interface{}
  39306. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  39307. fmt.Println(dat)
  39308. } else {
  39309. fmt.Println(err)
  39310. }
  39311. userJSONBytes, _ := json.Marshal(dat)
  39312. var res models.Result9001
  39313. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39314. utils.ErrorLog("解析失败:%v", err)
  39315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39316. return
  39317. }
  39318. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  39319. var dat2 map[string]interface{}
  39320. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  39321. fmt.Println(dat)
  39322. } else {
  39323. fmt.Println(err)
  39324. }
  39325. userJSONBytes2, _ := json.Marshal(dat2)
  39326. var res2 models.Result3260
  39327. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  39328. utils.ErrorLog("解析失败:%v", err)
  39329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39330. return
  39331. }
  39332. //if res2.Infcode == 0 {
  39333. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  39334. // var dat map[string]interface{}
  39335. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  39336. // fmt.Println(dat)
  39337. // } else {
  39338. // fmt.Println(err)
  39339. // }
  39340. // userJSONBytes, _ := json.Marshal(dat)
  39341. // var res3 models.Result3261
  39342. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  39343. // utils.ErrorLog("解析失败:%v", err)
  39344. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39345. // return
  39346. // }
  39347. //
  39348. // if res3.Infcode == 0 {
  39349. // record := &models.HisYidiClearRecord{
  39350. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39351. // Ctime: time.Now().Unix(),
  39352. // Mtime: time.Now().Unix(),
  39353. // Status: 1,
  39354. // MsgId: msgId,
  39355. // }
  39356. // service.SaveClearRecord(record)
  39357. // c.ServeSuccessJSON(map[string]interface{}{
  39358. // "msg": "提取成功",
  39359. // })
  39360. // }
  39361. //}
  39362. }
  39363. func (c *HisApiController) RefundAllopatry() {
  39364. year := c.GetString("year")
  39365. month := c.GetString("month")
  39366. //id, _ := c.GetInt64("id")
  39367. admin_user_id, _ := c.GetInt64("admin_user_id")
  39368. adminUser := c.GetAdminUserInfo()
  39369. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39370. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39371. //record, _ := service.GetClearRecordById(id)
  39372. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  39373. var dat map[string]interface{}
  39374. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  39375. fmt.Println(dat)
  39376. } else {
  39377. fmt.Println(err)
  39378. }
  39379. userJSONBytes, _ := json.Marshal(dat)
  39380. var res models.Result9001
  39381. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39382. utils.ErrorLog("解析失败:%v", err)
  39383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39384. return
  39385. }
  39386. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  39387. var dat2 map[string]interface{}
  39388. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  39389. fmt.Println(dat)
  39390. } else {
  39391. fmt.Println(err)
  39392. }
  39393. userJSONBytes2, _ := json.Marshal(dat2)
  39394. var empty ResultFourteen
  39395. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  39396. utils.ErrorLog("解析失败:%v", err)
  39397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39398. return
  39399. }
  39400. if empty.Infcode == 0 {
  39401. c.ServeSuccessJSON(map[string]interface{}{
  39402. "msg": "撤销成功",
  39403. })
  39404. return
  39405. }
  39406. }
  39407. func (c *HisApiController) ReversalOtherData() {
  39408. var customData []*CustomData
  39409. custom := &CustomData{
  39410. MsgId: "H44022900158202103301714472004",
  39411. PsnNo: "44020000001101329945",
  39412. Info: "2208",
  39413. }
  39414. customData = append(customData, custom)
  39415. custom1 := &CustomData{
  39416. MsgId: "H4402290015820210330172057803",
  39417. PsnNo: "44020000001101161813",
  39418. Info: "2208",
  39419. }
  39420. customData = append(customData, custom1)
  39421. custom2 := &CustomData{
  39422. MsgId: "H44022900158202103301705198813",
  39423. PsnNo: "44190000133097375417",
  39424. Info: "2208",
  39425. }
  39426. customData = append(customData, custom2)
  39427. custom3 := &CustomData{
  39428. MsgId: "H44022900158202103301715524756",
  39429. PsnNo: "44020000001100187221",
  39430. Info: "2208",
  39431. }
  39432. customData = append(customData, custom3)
  39433. custom4 := &CustomData{
  39434. MsgId: "H44022900158202103301730376224",
  39435. PsnNo: "44020000001101959155",
  39436. Info: "2208",
  39437. }
  39438. customData = append(customData, custom4)
  39439. custom5 := &CustomData{
  39440. MsgId: "H44022900158202103301748008725",
  39441. PsnNo: "44020000001104246641",
  39442. Info: "2208",
  39443. }
  39444. customData = append(customData, custom5)
  39445. custom6 := &CustomData{
  39446. MsgId: "H44022900158202103301718096755",
  39447. PsnNo: "44020000001102211860",
  39448. Info: "2208",
  39449. }
  39450. customData = append(customData, custom6)
  39451. custom7 := &CustomData{
  39452. MsgId: "H44022900158202103301736551640",
  39453. PsnNo: "44020000001102687718",
  39454. Info: "2208",
  39455. }
  39456. customData = append(customData, custom7)
  39457. custom8 := &CustomData{
  39458. MsgId: "H44022900158202103301743097676",
  39459. PsnNo: "44020000001102127785",
  39460. Info: "2208",
  39461. }
  39462. customData = append(customData, custom8)
  39463. custom9 := &CustomData{
  39464. MsgId: "H44022900158202103301712304203",
  39465. PsnNo: "44020000001101518097",
  39466. Info: "2208",
  39467. }
  39468. customData = append(customData, custom9)
  39469. custom10 := &CustomData{
  39470. MsgId: "H44022900158202103301738448785",
  39471. PsnNo: "44020000001100500813",
  39472. Info: "2208",
  39473. }
  39474. customData = append(customData, custom10)
  39475. custom11 := &CustomData{
  39476. MsgId: "H44022900158202103301732455843",
  39477. PsnNo: "44020000001102690557",
  39478. Info: "2208",
  39479. }
  39480. customData = append(customData, custom11)
  39481. custom12 := &CustomData{
  39482. MsgId: "H44022900158202103301745421708",
  39483. PsnNo: "44020000001102211928",
  39484. Info: "2208",
  39485. }
  39486. customData = append(customData, custom12)
  39487. custom1212 := &CustomData{
  39488. MsgId: "H440229001582021033017351627",
  39489. PsnNo: "44020000001102481733",
  39490. Info: "2208",
  39491. }
  39492. customData = append(customData, custom1212)
  39493. custom13 := &CustomData{
  39494. MsgId: "H44022900158202103301740327951",
  39495. PsnNo: "44020000001103174866",
  39496. Info: "2208",
  39497. }
  39498. customData = append(customData, custom13)
  39499. custom14 := &CustomData{
  39500. MsgId: "H4402290015820210330174922668",
  39501. PsnNo: "44020000001102927272",
  39502. Info: "2208",
  39503. }
  39504. customData = append(customData, custom14)
  39505. custom15 := &CustomData{
  39506. MsgId: "H44022900158202103301752362273",
  39507. PsnNo: "44020000001102942890",
  39508. Info: "2208",
  39509. }
  39510. customData = append(customData, custom15)
  39511. custom16 := &CustomData{
  39512. MsgId: "H44022900158202103301751082917",
  39513. PsnNo: "44020000001101662162",
  39514. Info: "2208",
  39515. }
  39516. customData = append(customData, custom16)
  39517. custom17 := &CustomData{
  39518. MsgId: "H44022900158202103301754147728",
  39519. PsnNo: "44020000000229014511",
  39520. Info: "2208",
  39521. }
  39522. customData = append(customData, custom17)
  39523. adminUser := c.GetAdminUserInfo()
  39524. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39525. for _, item := range customData {
  39526. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  39527. fmt.Println(result)
  39528. }
  39529. }
  39530. func PathExists(path string) (bool, error) {
  39531. _, err := os.Stat(path)
  39532. if err == nil {
  39533. return true, nil
  39534. }
  39535. if os.IsNotExist(err) {
  39536. return false, nil
  39537. }
  39538. return false, err
  39539. }
  39540. // 创建文件夹
  39541. func Mkdir(dir string) {
  39542. // 创建文件夹
  39543. exist, err := PathExists(dir)
  39544. if err != nil {
  39545. fmt.Println(err.Error())
  39546. } else {
  39547. if exist {
  39548. fmt.Println(dir + "文件夹已存在!")
  39549. } else {
  39550. // 文件夹名称,权限
  39551. err := os.Mkdir(dir, os.ModePerm)
  39552. if err != nil {
  39553. fmt.Println(dir+"文件夹创建失败:", err.Error())
  39554. } else {
  39555. fmt.Println(dir + "文件夹创建成功!")
  39556. }
  39557. }
  39558. }
  39559. }
  39560. // 压缩文件
  39561. func Zip(srcFile string, destZip string) error {
  39562. zipfile, err := os.Create(destZip)
  39563. if err != nil {
  39564. return err
  39565. }
  39566. defer zipfile.Close()
  39567. archive := zip.NewWriter(zipfile)
  39568. defer archive.Close()
  39569. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  39570. if err != nil {
  39571. return err
  39572. }
  39573. header, err := zip.FileInfoHeader(info)
  39574. if err != nil {
  39575. return err
  39576. }
  39577. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  39578. // header.Name = path
  39579. if info.IsDir() {
  39580. header.Name += "/"
  39581. } else {
  39582. header.Method = zip.Deflate
  39583. }
  39584. writer, err := archive.CreateHeader(header)
  39585. if err != nil {
  39586. return err
  39587. }
  39588. if !info.IsDir() {
  39589. file, err := os.Open(path)
  39590. if err != nil {
  39591. return err
  39592. }
  39593. defer file.Close()
  39594. _, err = io.Copy(writer, file)
  39595. }
  39596. return err
  39597. })
  39598. return err
  39599. }
  39600. func ReadFile(filePath string) []byte {
  39601. f, err := os.Open(filePath)
  39602. if err != nil {
  39603. fmt.Println("read file fail", err)
  39604. return nil
  39605. }
  39606. defer f.Close()
  39607. fd, err := ioutil.ReadAll(f)
  39608. if err != nil {
  39609. fmt.Println("read to fd fail", err)
  39610. return nil
  39611. }
  39612. return fd
  39613. }
  39614. func saveLogq(result string, request string, infno string, desc string) {
  39615. dir := "日志"
  39616. utils.Mkdir(dir)
  39617. month := time.Unix(1557042972, 0).Format("1")
  39618. year := time.Now().Format("2006")
  39619. month = time.Now().Format("01")
  39620. day := time.Now().Format("02")
  39621. hour := time.Now().Format("15")
  39622. min := time.Now().Format("04")
  39623. sec := time.Now().Format("05")
  39624. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  39625. file := year + month + day + "_log"
  39626. file_name := file + ".txt"
  39627. file_path := "日志" + "/" + file_name
  39628. exist, _ := utils.PathExists(file_path)
  39629. if exist { //存在
  39630. fmt.Println("存在")
  39631. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  39632. if err != nil {
  39633. fmt.Println("read fail")
  39634. }
  39635. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  39636. n, _ := f.Seek(0, 2)
  39637. _, err = f.WriteAt([]byte(content), n)
  39638. } else { //不存在
  39639. fmt.Println("文件不存在,创建文件")
  39640. f, err := os.Create("日志" + "/" + file_name)
  39641. defer f.Close()
  39642. if err != nil {
  39643. } else {
  39644. _, err = f.Write([]byte("记录日志"))
  39645. }
  39646. }
  39647. }
  39648. func saveLog(result string, request string, infno string, desc string) {
  39649. org_id, _ := beego.AppConfig.Int64("org_id")
  39650. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39651. dir := miConfig.OrgName + "日志"
  39652. utils.Mkdir(dir)
  39653. month := time.Unix(1557042972, 0).Format("1")
  39654. year := time.Now().Format("2006")
  39655. month = time.Now().Format("01")
  39656. day := time.Now().Format("02")
  39657. hour := time.Now().Format("15")
  39658. min := time.Now().Format("04")
  39659. sec := time.Now().Format("05")
  39660. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  39661. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  39662. file_name := file + ".txt"
  39663. file_path := miConfig.OrgName + "日志" + "/" + file_name
  39664. exist, _ := utils.PathExists(file_path)
  39665. if exist { //存在
  39666. fmt.Println("存在")
  39667. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  39668. if err != nil {
  39669. fmt.Println("read fail")
  39670. }
  39671. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  39672. n, _ := f.Seek(0, 2)
  39673. _, err = f.WriteAt([]byte(content), n)
  39674. } else { //不存在
  39675. fmt.Println("文件不存在,创建文件")
  39676. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  39677. defer f.Close()
  39678. if err != nil {
  39679. } else {
  39680. _, err = f.Write([]byte("记录日志"))
  39681. }
  39682. }
  39683. }
  39684. type Charset string
  39685. const (
  39686. UTF8 = Charset("UTF-8")
  39687. GB18030 = Charset("GB18030")
  39688. )
  39689. func ConvertToString(src string, srcCode string, tagCode string) string {
  39690. srcCoder := mahonia.NewDecoder(srcCode)
  39691. srcResult := srcCoder.ConvertString(src)
  39692. tagCoder := mahonia.NewDecoder(tagCode)
  39693. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  39694. result := string(cdata)
  39695. return result
  39696. }
  39697. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  39698. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39699. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39700. var token string
  39701. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  39702. var api string
  39703. if miConfig.MdtrtareaAdmvs == "320830" {
  39704. api = miConfig.AppSecret + "jsyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  39705. "&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
  39706. fmt.Println(api)
  39707. } else if miConfig.MdtrtareaAdmvs == "320921" {
  39708. 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 +
  39709. "&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
  39710. fmt.Println(api)
  39711. } else {
  39712. 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 +
  39713. "&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
  39714. }
  39715. resp, requestErr := http.Get(api)
  39716. if requestErr != nil {
  39717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39718. return ""
  39719. }
  39720. body, ioErr := ioutil.ReadAll(resp.Body)
  39721. if ioErr != nil {
  39722. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39724. return ""
  39725. }
  39726. var respJSON map[string]interface{}
  39727. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  39728. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39730. return ""
  39731. }
  39732. var status string
  39733. status = respJSON["data"].(map[string]interface{})["status"].(string)
  39734. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  39735. var res ResultTwo //1101结果
  39736. var res10265 ResultTwo10265 //1101结果
  39737. if status == "0" { //读卡成功
  39738. var card_info string //卡信息
  39739. var busi_card_info string
  39740. token = respJSON["data"].(map[string]interface{})["token"].(string)
  39741. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  39742. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  39743. fmt.Println(card_info)
  39744. fmt.Println(busi_card_info)
  39745. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  39746. result, _ := json.Marshal(respJSON)
  39747. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  39748. utils.ErrorLog("解析失败:%v", err)
  39749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39750. return ""
  39751. }
  39752. res.ErrMsg = res10265.ErrMsg
  39753. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  39754. res.Infcode = infocode
  39755. res.Output = res10265.Output
  39756. res.InfRefmsgid = res10265.InfRefmsgid
  39757. if res.Infcode == 0 {
  39758. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  39759. if err == gorm.ErrRecordNotFound {
  39760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  39761. return ""
  39762. } else if err != nil {
  39763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  39764. return ""
  39765. } else {
  39766. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39767. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  39768. infoStr := string(Iinfos)
  39769. idetinfoStr := string(Idetinfos)
  39770. psn := &models.HisPsn{
  39771. PsnNo: res.Output.Baseinfo.PsnNo,
  39772. PatientId: patient.ID,
  39773. Certno: res.Output.Baseinfo.Certno,
  39774. Gend: res.Output.Baseinfo.Gend,
  39775. Naty: res.Output.Baseinfo.Naty,
  39776. PsnCertType: res.Output.Baseinfo.PsnCertType,
  39777. PsnName: res.Output.Baseinfo.PsnName,
  39778. Idetinfo: idetinfoStr,
  39779. Insuinfo: infoStr,
  39780. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39781. CardInfo: card_info,
  39782. VerifyNumber: token,
  39783. }
  39784. service.CreateHisPsn(psn)
  39785. return token
  39786. }
  39787. }
  39788. } else {
  39789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39790. return ""
  39791. }
  39792. } else { //读卡失败
  39793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39794. return ""
  39795. }
  39796. return token
  39797. }
  39798. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  39799. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39800. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39801. var token string
  39802. var api string
  39803. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  39804. "&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
  39805. fmt.Println(api)
  39806. resp, requestErr := http.Get(api)
  39807. if requestErr != nil {
  39808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39809. return ""
  39810. }
  39811. body, ioErr := ioutil.ReadAll(resp.Body)
  39812. if ioErr != nil {
  39813. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39815. return ""
  39816. }
  39817. var respJSON map[string]interface{}
  39818. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  39819. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39821. return ""
  39822. }
  39823. var status string
  39824. status = respJSON["data"].(map[string]interface{})["status"].(string)
  39825. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  39826. var res ResultTwo //1101结果
  39827. if status == "1" { //读卡成功
  39828. var card_info string //卡信息
  39829. var busi_card_info string
  39830. token = respJSON["data"].(map[string]interface{})["token"].(string)
  39831. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  39832. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  39833. fmt.Println(card_info)
  39834. fmt.Println(busi_card_info)
  39835. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  39836. result, _ := json.Marshal(respJSON)
  39837. if err := json.Unmarshal([]byte(result), &res); err != nil {
  39838. utils.ErrorLog("解析失败:%v", err)
  39839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39840. return ""
  39841. }
  39842. if res.Infcode == 0 {
  39843. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  39844. if err == gorm.ErrRecordNotFound {
  39845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  39846. return ""
  39847. } else if err != nil {
  39848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  39849. return ""
  39850. } else {
  39851. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39852. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  39853. infoStr := string(Iinfos)
  39854. idetinfoStr := string(Idetinfos)
  39855. psn := &models.HisPsn{
  39856. PsnNo: res.Output.Baseinfo.PsnNo,
  39857. PatientId: patient.ID,
  39858. Certno: res.Output.Baseinfo.Certno,
  39859. Gend: res.Output.Baseinfo.Gend,
  39860. Naty: res.Output.Baseinfo.Naty,
  39861. PsnCertType: res.Output.Baseinfo.PsnCertType,
  39862. PsnName: res.Output.Baseinfo.PsnName,
  39863. Idetinfo: idetinfoStr,
  39864. Insuinfo: infoStr,
  39865. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39866. CardInfo: card_info,
  39867. VerifyNumber: token,
  39868. }
  39869. service.CreateHisPsn(psn)
  39870. return token
  39871. }
  39872. }
  39873. } else {
  39874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39875. return ""
  39876. }
  39877. return token
  39878. }
  39879. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  39880. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39881. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39882. var token string
  39883. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  39884. var api string
  39885. if miConfig.MdtrtareaAdmvs == "320830" {
  39886. api = miConfig.AppSecret + "jsyb/readcardface?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  39887. "&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
  39888. fmt.Println(api)
  39889. } else if miConfig.MdtrtareaAdmvs == "320921" {
  39890. 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 +
  39891. "&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
  39892. fmt.Println(api)
  39893. } else {
  39894. 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 +
  39895. "&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
  39896. }
  39897. resp, requestErr := http.Get(api)
  39898. if requestErr != nil {
  39899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39900. return ""
  39901. }
  39902. body, ioErr := ioutil.ReadAll(resp.Body)
  39903. if ioErr != nil {
  39904. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39906. return ""
  39907. }
  39908. var respJSON map[string]interface{}
  39909. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  39910. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39912. return ""
  39913. }
  39914. var status string
  39915. status = respJSON["data"].(map[string]interface{})["status"].(string)
  39916. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  39917. var res ResultTwo //1101结果
  39918. var res10265 ResultTwo10265 //1101结果
  39919. if status == "0" { //读卡成功
  39920. var card_info string //卡信息
  39921. var busi_card_info string
  39922. token = respJSON["data"].(map[string]interface{})["token"].(string)
  39923. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  39924. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  39925. fmt.Println(card_info)
  39926. fmt.Println(busi_card_info)
  39927. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  39928. result, _ := json.Marshal(respJSON)
  39929. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  39930. utils.ErrorLog("解析失败:%v", err)
  39931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39932. return ""
  39933. }
  39934. res.ErrMsg = res10265.ErrMsg
  39935. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  39936. res.Infcode = infocode
  39937. res.Output = res10265.Output
  39938. res.InfRefmsgid = res10265.InfRefmsgid
  39939. if res.Infcode == 0 {
  39940. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  39941. if err == gorm.ErrRecordNotFound {
  39942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  39943. return ""
  39944. } else if err != nil {
  39945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  39946. return ""
  39947. } else {
  39948. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39949. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  39950. infoStr := string(Iinfos)
  39951. idetinfoStr := string(Idetinfos)
  39952. psn := &models.HisPsn{
  39953. PsnNo: res.Output.Baseinfo.PsnNo,
  39954. PatientId: patient.ID,
  39955. Certno: res.Output.Baseinfo.Certno,
  39956. Gend: res.Output.Baseinfo.Gend,
  39957. Naty: res.Output.Baseinfo.Naty,
  39958. PsnCertType: res.Output.Baseinfo.PsnCertType,
  39959. PsnName: res.Output.Baseinfo.PsnName,
  39960. Idetinfo: idetinfoStr,
  39961. Insuinfo: infoStr,
  39962. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39963. CardInfo: card_info,
  39964. VerifyNumber: token,
  39965. }
  39966. service.CreateHisPsn(psn)
  39967. return token
  39968. }
  39969. }
  39970. } else {
  39971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39972. return ""
  39973. }
  39974. } else { //读卡失败
  39975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39976. return ""
  39977. }
  39978. return token
  39979. }
  39980. func DeleteExtraSpaceTwo(s string) string {
  39981. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  39982. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  39983. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  39984. reg, _ := regexp.Compile(regstr) //编译正则表达式
  39985. s2 := make([]byte, len(s1)) //定义字符数组切片
  39986. copy(s2, s1) //将字符串复制到切片
  39987. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  39988. for len(spc_index) > 0 { //找到适配项
  39989. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  39990. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  39991. }
  39992. return string(s2)
  39993. }
  39994. func Remove0000(s string) string {
  39995. str := make([]rune, 0, len(s))
  39996. for _, v := range []rune(s) {
  39997. if v == 0 {
  39998. continue
  39999. }
  40000. str = append(str, v)
  40001. }
  40002. return string(str)
  40003. }
  40004. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  40005. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  40006. readCard := DllDef.MustFindProc("EcQuery")
  40007. pCardInfo := make([]byte, 8192)
  40008. pBusiCardInfo := make([]byte, 8192)
  40009. data := make(map[string]interface{})
  40010. //pData := make(map[string]interface{})
  40011. inputData := make(map[string]interface{})
  40012. inputData["orgId"] = code
  40013. inputData["businessType"] = "01101"
  40014. inputData["operatorId"] = operator_id
  40015. inputData["operatorName"] = operator_name
  40016. inputData["officeId"] = "001"
  40017. inputData["officeName"] = "血透室"
  40018. //
  40019. data["data"] = inputData
  40020. data["transType"] = "ec.query"
  40021. data["orgId"] = code
  40022. bytesData, _ := json.Marshal(data)
  40023. pCardInfo = bytesData
  40024. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  40025. fmt.Println(ret2)
  40026. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  40027. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  40028. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  40029. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  40030. if ret2 != 0 {
  40031. return "", ""
  40032. }
  40033. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  40034. }
  40035. func DeleteExtraSpace(s string) string {
  40036. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  40037. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  40038. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  40039. reg, _ := regexp.Compile(regstr) //编译正则表达式
  40040. s2 := make([]byte, len(s1)) //定义字符数组切片
  40041. copy(s2, s1) //将字符串复制到切片
  40042. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  40043. for len(spc_index) > 0 { //找到适配项
  40044. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  40045. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  40046. }
  40047. return string(s2)
  40048. }
  40049. // 对账
  40050. func (c *HisApiController) Post3202() {
  40051. start_time := c.GetString("start_time")
  40052. end_time := c.GetString("end_time")
  40053. //insutype := c.GetString("insutype")
  40054. clr_type := c.GetString("clr_type")
  40055. clr_org := c.GetString("clr_optins")
  40056. admin_user_id, _ := c.GetInt64("admin_user_id")
  40057. adminUser := c.GetAdminUserInfo()
  40058. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40059. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40060. if len(clr_org) == 0 {
  40061. clr_org = miConfig.MdtrtareaAdmvs
  40062. }
  40063. timeLayout := "2006-01-02"
  40064. loc, _ := time.LoadLocation("Local")
  40065. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  40066. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  40067. var orders []*models.HisOrder
  40068. if clr_org == "421300" {
  40069. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40070. } else if clr_org == "420902" {
  40071. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40072. } else {
  40073. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40074. }
  40075. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  40076. //fixmedins_setl_cnt := int64(len(orders))
  40077. var medfee_sumamt float64
  40078. var acct_pay float64
  40079. var fund_pay_sumamt float64
  40080. for _, item := range orders {
  40081. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  40082. acct_pay = acct_pay + item.AcctPay
  40083. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  40084. }
  40085. //var medfee_sumamt_two float64
  40086. //var acct_pay_two float64
  40087. //var fund_pay_sumamt_two float64
  40088. //for _, item := range orders_two {
  40089. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  40090. // acct_pay_two = acct_pay_two + item.AcctPay
  40091. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  40092. //}
  40093. //var user_name string
  40094. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40095. //if role.ID == 0 {
  40096. // user_name = "xxx"
  40097. //} else {
  40098. // user_name = role.UserName
  40099. //}
  40100. var res ResultSix
  40101. if config.IsOpen == 1 {
  40102. var bps []*models.BusinessParamsTwo
  40103. var bp models.BusinessParamsTwo
  40104. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  40105. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  40106. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  40107. bp.MedfeeSumamt = medfee_sumamt_str
  40108. bp.AcctPay = acct_pay_str
  40109. bp.FundPaySumamt = fund_pay_sumamt_str
  40110. bp.Insutype = ""
  40111. bp.StmtBegndate = start_time
  40112. bp.ClrType = clr_type
  40113. bp.SetlOptins = clr_org
  40114. bp.StmtEnddate = end_time
  40115. bps = append(bps, &bp)
  40116. data := make(map[string]interface{})
  40117. data["bps"] = bps
  40118. data["org_name"] = miConfig.OrgName
  40119. data["doctor"] = role.UserName
  40120. data["fixmedins_code"] = miConfig.Code
  40121. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40122. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40123. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40124. if miConfig.MdtrtareaAdmvs == "421300" {
  40125. client := &http.Client{}
  40126. bytesData, _ := json.Marshal(data)
  40127. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  40128. resp, _ := client.Do(req)
  40129. defer resp.Body.Close()
  40130. body, ioErr := ioutil.ReadAll(resp.Body)
  40131. if ioErr != nil {
  40132. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40134. return
  40135. }
  40136. var respJSON map[string]interface{}
  40137. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40138. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40140. return
  40141. }
  40142. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40143. userJSONBytes, _ := json.Marshal(respJSON)
  40144. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40145. utils.ErrorLog("解析失败:%v", err)
  40146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40147. return
  40148. }
  40149. }
  40150. if miConfig.MdtrtareaAdmvs == "420200" {
  40151. client := &http.Client{}
  40152. bytesData, _ := json.Marshal(data)
  40153. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  40154. resp, _ := client.Do(req)
  40155. defer resp.Body.Close()
  40156. body, ioErr := ioutil.ReadAll(resp.Body)
  40157. if ioErr != nil {
  40158. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40160. return
  40161. }
  40162. var respJSON map[string]interface{}
  40163. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40164. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40166. return
  40167. }
  40168. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40169. userJSONBytes, _ := json.Marshal(respJSON)
  40170. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40171. utils.ErrorLog("解析失败:%v", err)
  40172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40173. return
  40174. }
  40175. }
  40176. if miConfig.MdtrtareaAdmvs == "421182" {
  40177. client := &http.Client{}
  40178. bytesData, _ := json.Marshal(data)
  40179. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  40180. resp, _ := client.Do(req)
  40181. defer resp.Body.Close()
  40182. body, ioErr := ioutil.ReadAll(resp.Body)
  40183. if ioErr != nil {
  40184. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40186. return
  40187. }
  40188. var respJSON map[string]interface{}
  40189. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40190. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40192. return
  40193. }
  40194. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40195. userJSONBytes, _ := json.Marshal(respJSON)
  40196. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40197. utils.ErrorLog("解析失败:%v", err)
  40198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40199. return
  40200. }
  40201. }
  40202. if miConfig.MdtrtareaAdmvs == "420902" {
  40203. client := &http.Client{}
  40204. bytesData, _ := json.Marshal(data)
  40205. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  40206. resp, _ := client.Do(req)
  40207. defer resp.Body.Close()
  40208. body, ioErr := ioutil.ReadAll(resp.Body)
  40209. if ioErr != nil {
  40210. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40212. return
  40213. }
  40214. var respJSON map[string]interface{}
  40215. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40216. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40218. return
  40219. }
  40220. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40221. userJSONBytes, _ := json.Marshal(respJSON)
  40222. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40223. utils.ErrorLog("解析失败:%v", err)
  40224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40225. return
  40226. }
  40227. }
  40228. if res.Infcode == 0 {
  40229. c.ServeSuccessJSON(map[string]interface{}{
  40230. "msg": "发起成功",
  40231. })
  40232. } else {
  40233. c.ServeSuccessJSON(map[string]interface{}{
  40234. "failed_code": -10,
  40235. "msg": res.ErrMsg,
  40236. })
  40237. }
  40238. }
  40239. }
  40240. func (c *HisApiController) Post3204a() {
  40241. start_time := c.GetString("start_time")
  40242. end_time := c.GetString("end_time")
  40243. //insutype := c.GetString("insutype")
  40244. clr_type := c.GetString("clr_type")
  40245. clr_org := c.GetString("clr_optins")
  40246. admin_user_id, _ := c.GetInt64("admin_user_id")
  40247. adminUser := c.GetAdminUserInfo()
  40248. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40249. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40250. if len(clr_org) == 0 {
  40251. clr_org = miConfig.MdtrtareaAdmvs
  40252. }
  40253. timeLayout := "2006-01-02"
  40254. loc, _ := time.LoadLocation("Local")
  40255. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  40256. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  40257. var orders []*models.HisOrder
  40258. if clr_org == "421300" {
  40259. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40260. } else if clr_org == "420902" {
  40261. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40262. } else {
  40263. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40264. }
  40265. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  40266. //fixmedins_setl_cnt := int64(len(orders))
  40267. var medfee_sumamt float64
  40268. var acct_pay float64
  40269. var fund_pay_sumamt float64
  40270. for _, item := range orders {
  40271. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  40272. acct_pay = acct_pay + item.AcctPay
  40273. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  40274. }
  40275. //var medfee_sumamt_two float64
  40276. //var acct_pay_two float64
  40277. //var fund_pay_sumamt_two float64
  40278. //for _, item := range orders_two {
  40279. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  40280. // acct_pay_two = acct_pay_two + item.AcctPay
  40281. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  40282. //}
  40283. //var user_name string
  40284. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40285. //if role.ID == 0 {
  40286. // user_name = "xxx"
  40287. //} else {
  40288. // user_name = role.UserName
  40289. //}
  40290. var res ResultSix
  40291. if config.IsOpen == 1 {
  40292. var bps []*models.BusinessParamsTwo
  40293. var bp models.BusinessParamsTwo
  40294. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  40295. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  40296. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  40297. bp.MedfeeSumamt = medfee_sumamt_str
  40298. bp.AcctPay = acct_pay_str
  40299. bp.FundPaySumamt = fund_pay_sumamt_str
  40300. bp.Insutype = ""
  40301. bp.StmtBegndate = start_time
  40302. bp.ClrType = clr_type
  40303. bp.SetlOptins = clr_org
  40304. bp.StmtEnddate = end_time
  40305. bps = append(bps, &bp)
  40306. data := make(map[string]interface{})
  40307. data["bps"] = bps
  40308. data["org_name"] = miConfig.OrgName
  40309. data["doctor"] = role.UserName
  40310. data["fixmedins_code"] = miConfig.Code
  40311. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40312. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40313. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40314. if miConfig.MdtrtareaAdmvs == "421300" {
  40315. client := &http.Client{}
  40316. bytesData, _ := json.Marshal(data)
  40317. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  40318. resp, _ := client.Do(req)
  40319. defer resp.Body.Close()
  40320. body, ioErr := ioutil.ReadAll(resp.Body)
  40321. if ioErr != nil {
  40322. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40324. return
  40325. }
  40326. var respJSON map[string]interface{}
  40327. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40328. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40330. return
  40331. }
  40332. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40333. userJSONBytes, _ := json.Marshal(respJSON)
  40334. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40335. utils.ErrorLog("解析失败:%v", err)
  40336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40337. return
  40338. }
  40339. }
  40340. if miConfig.MdtrtareaAdmvs == "420200" {
  40341. client := &http.Client{}
  40342. bytesData, _ := json.Marshal(data)
  40343. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  40344. resp, _ := client.Do(req)
  40345. defer resp.Body.Close()
  40346. body, ioErr := ioutil.ReadAll(resp.Body)
  40347. if ioErr != nil {
  40348. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40350. return
  40351. }
  40352. var respJSON map[string]interface{}
  40353. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40354. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40356. return
  40357. }
  40358. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40359. userJSONBytes, _ := json.Marshal(respJSON)
  40360. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40361. utils.ErrorLog("解析失败:%v", err)
  40362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40363. return
  40364. }
  40365. }
  40366. if miConfig.MdtrtareaAdmvs == "421182" {
  40367. client := &http.Client{}
  40368. bytesData, _ := json.Marshal(data)
  40369. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  40370. resp, _ := client.Do(req)
  40371. defer resp.Body.Close()
  40372. body, ioErr := ioutil.ReadAll(resp.Body)
  40373. if ioErr != nil {
  40374. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40376. return
  40377. }
  40378. var respJSON map[string]interface{}
  40379. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40380. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40382. return
  40383. }
  40384. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40385. userJSONBytes, _ := json.Marshal(respJSON)
  40386. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40387. utils.ErrorLog("解析失败:%v", err)
  40388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40389. return
  40390. }
  40391. }
  40392. if miConfig.MdtrtareaAdmvs == "420902" {
  40393. client := &http.Client{}
  40394. bytesData, _ := json.Marshal(data)
  40395. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  40396. resp, _ := client.Do(req)
  40397. defer resp.Body.Close()
  40398. body, ioErr := ioutil.ReadAll(resp.Body)
  40399. if ioErr != nil {
  40400. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40402. return
  40403. }
  40404. var respJSON map[string]interface{}
  40405. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40406. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40408. return
  40409. }
  40410. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40411. userJSONBytes, _ := json.Marshal(respJSON)
  40412. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40413. utils.ErrorLog("解析失败:%v", err)
  40414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40415. return
  40416. }
  40417. }
  40418. if res.Infcode == 0 {
  40419. c.ServeSuccessJSON(map[string]interface{}{
  40420. "msg": "撤销成功",
  40421. })
  40422. } else {
  40423. c.ServeSuccessJSON(map[string]interface{}{
  40424. "failed_code": -10,
  40425. "msg": res.ErrMsg,
  40426. })
  40427. }
  40428. }
  40429. }
  40430. func (c *HisApiController) Post3204() {
  40431. admin_user_id, _ := c.GetInt64("admin_user_id")
  40432. id := c.GetString("id")
  40433. adminUser := c.GetAdminUserInfo()
  40434. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40435. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40436. //clr_org := miConfig.MdtrtareaAdmvs
  40437. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40438. var res ResultSix
  40439. if config.IsOpen == 1 {
  40440. data := make(map[string]interface{})
  40441. data["id"] = id
  40442. data["org_name"] = miConfig.OrgName
  40443. data["doctor"] = role.UserName
  40444. data["fixmedins_code"] = miConfig.Code
  40445. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40446. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40447. client := &http.Client{}
  40448. bytesData, _ := json.Marshal(data)
  40449. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  40450. resp, _ := client.Do(req)
  40451. defer resp.Body.Close()
  40452. body, ioErr := ioutil.ReadAll(resp.Body)
  40453. if ioErr != nil {
  40454. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40456. return
  40457. }
  40458. var respJSON map[string]interface{}
  40459. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40460. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40462. return
  40463. }
  40464. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40465. userJSONBytes, _ := json.Marshal(respJSON)
  40466. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40467. utils.ErrorLog("解析失败:%v", err)
  40468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40469. return
  40470. }
  40471. if res.Infcode == 0 {
  40472. c.ServeSuccessJSON(map[string]interface{}{
  40473. "msg": "发起成功",
  40474. })
  40475. } else {
  40476. c.ServeSuccessJSON(map[string]interface{}{
  40477. "failed_code": -10,
  40478. "msg": res.ErrMsg,
  40479. })
  40480. }
  40481. }
  40482. }
  40483. func (c *HisApiController) Post8404() {
  40484. admin_user_id, _ := c.GetInt64("admin_user_id")
  40485. month := c.GetString("month")
  40486. adminUser := c.GetAdminUserInfo()
  40487. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40488. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40489. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40490. var res ResultSix
  40491. if config.IsOpen == 1 {
  40492. data := make(map[string]interface{})
  40493. data["month"] = month
  40494. data["org_name"] = miConfig.OrgName
  40495. data["doctor"] = role.UserName
  40496. data["fixmedins_code"] = miConfig.Code
  40497. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40498. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40499. client := &http.Client{}
  40500. bytesData, _ := json.Marshal(data)
  40501. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  40502. resp, _ := client.Do(req)
  40503. defer resp.Body.Close()
  40504. body, ioErr := ioutil.ReadAll(resp.Body)
  40505. if ioErr != nil {
  40506. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40508. return
  40509. }
  40510. var respJSON map[string]interface{}
  40511. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40512. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40514. return
  40515. }
  40516. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40517. userJSONBytes, _ := json.Marshal(respJSON)
  40518. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40519. utils.ErrorLog("解析失败:%v", err)
  40520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40521. return
  40522. }
  40523. if res.Infcode == 0 {
  40524. c.ServeSuccessJSON(map[string]interface{}{
  40525. "msg": "查询成功",
  40526. })
  40527. } else {
  40528. c.ServeSuccessJSON(map[string]interface{}{
  40529. "failed_code": -10,
  40530. "msg": res.ErrMsg,
  40531. })
  40532. }
  40533. }
  40534. }
  40535. func (c *HisApiController) Post3202b() {
  40536. start_time := c.GetString("start_time")
  40537. end_time := c.GetString("end_time")
  40538. //insutype := c.GetString("insutype")
  40539. clr_type := c.GetString("clr_type")
  40540. clr_org := c.GetString("clr_optins")
  40541. admin_user_id, _ := c.GetInt64("admin_user_id")
  40542. adminUser := c.GetAdminUserInfo()
  40543. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40544. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40545. if len(clr_org) == 0 {
  40546. clr_org = miConfig.MdtrtareaAdmvs
  40547. }
  40548. timeLayout := "2006-01-02"
  40549. loc, _ := time.LoadLocation("Local")
  40550. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  40551. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  40552. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40553. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  40554. //fixmedins_setl_cnt := int64(len(orders))
  40555. var medfee_sumamt float64
  40556. var acct_pay float64
  40557. var fund_pay_sumamt float64
  40558. for _, item := range orders {
  40559. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  40560. acct_pay = acct_pay + item.AcctPay
  40561. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  40562. }
  40563. //var medfee_sumamt_two float64
  40564. //var acct_pay_two float64
  40565. //var fund_pay_sumamt_two float64
  40566. //for _, item := range orders_two {
  40567. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  40568. // acct_pay_two = acct_pay_two + item.AcctPay
  40569. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  40570. //}
  40571. //var user_name string
  40572. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40573. //if role.ID == 0 {
  40574. // user_name = "xxx"
  40575. //} else {
  40576. // user_name = role.UserName
  40577. //}
  40578. var res ResultSix
  40579. if config.IsOpen == 1 {
  40580. var bps []*models.BusinessParamsTwo
  40581. var bp models.BusinessParamsTwo
  40582. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  40583. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  40584. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  40585. bp.MedfeeSumamt = medfee_sumamt_str
  40586. bp.AcctPay = acct_pay_str
  40587. bp.FundPaySumamt = fund_pay_sumamt_str
  40588. bp.Insutype = "390"
  40589. bp.StmtBegndate = start_time
  40590. bp.ClrType = clr_type
  40591. bp.SetlOptins = clr_org
  40592. bp.StmtEnddate = end_time
  40593. bps = append(bps, &bp)
  40594. data := make(map[string]interface{})
  40595. data["bps"] = bps
  40596. data["org_name"] = miConfig.OrgName
  40597. data["doctor"] = role.UserName
  40598. data["fixmedins_code"] = miConfig.Code
  40599. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40600. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40601. if miConfig.MdtrtareaAdmvs == "421300" {
  40602. client := &http.Client{}
  40603. bytesData, _ := json.Marshal(data)
  40604. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  40605. resp, _ := client.Do(req)
  40606. defer resp.Body.Close()
  40607. body, ioErr := ioutil.ReadAll(resp.Body)
  40608. if ioErr != nil {
  40609. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40611. return
  40612. }
  40613. var respJSON map[string]interface{}
  40614. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40615. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40617. return
  40618. }
  40619. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40620. userJSONBytes, _ := json.Marshal(respJSON)
  40621. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40622. utils.ErrorLog("解析失败:%v", err)
  40623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40624. return
  40625. }
  40626. }
  40627. if miConfig.MdtrtareaAdmvs == "420200" {
  40628. client := &http.Client{}
  40629. bytesData, _ := json.Marshal(data)
  40630. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  40631. resp, _ := client.Do(req)
  40632. defer resp.Body.Close()
  40633. body, ioErr := ioutil.ReadAll(resp.Body)
  40634. if ioErr != nil {
  40635. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40637. return
  40638. }
  40639. var respJSON map[string]interface{}
  40640. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40641. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40643. return
  40644. }
  40645. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40646. userJSONBytes, _ := json.Marshal(respJSON)
  40647. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40648. utils.ErrorLog("解析失败:%v", err)
  40649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40650. return
  40651. }
  40652. }
  40653. if miConfig.MdtrtareaAdmvs == "421182" {
  40654. client := &http.Client{}
  40655. bytesData, _ := json.Marshal(data)
  40656. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  40657. resp, _ := client.Do(req)
  40658. defer resp.Body.Close()
  40659. body, ioErr := ioutil.ReadAll(resp.Body)
  40660. if ioErr != nil {
  40661. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40663. return
  40664. }
  40665. var respJSON map[string]interface{}
  40666. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40669. return
  40670. }
  40671. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40672. userJSONBytes, _ := json.Marshal(respJSON)
  40673. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40674. utils.ErrorLog("解析失败:%v", err)
  40675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40676. return
  40677. }
  40678. }
  40679. if res.Infcode == 0 {
  40680. c.ServeSuccessJSON(map[string]interface{}{
  40681. "msg": "发起成功",
  40682. })
  40683. } else {
  40684. c.ServeSuccessJSON(map[string]interface{}{
  40685. "failed_code": -10,
  40686. "msg": res.ErrMsg,
  40687. })
  40688. }
  40689. }
  40690. }
  40691. func (c *HisApiController) Post1608() {
  40692. start_time := c.GetString("start_time")
  40693. end_time := c.GetString("end_time")
  40694. admin_user_id, _ := c.GetInt64("admin_user_id")
  40695. adminUser := c.GetAdminUserInfo()
  40696. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40697. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40698. timeLayout := "2006-01-02"
  40699. loc, _ := time.LoadLocation("Local")
  40700. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  40701. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  40702. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40703. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  40704. fixmedins_setl_cnt := int64(len(orders))
  40705. var medfee_sumamt float64
  40706. var func_smamt float64
  40707. for _, item := range orders {
  40708. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  40709. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  40710. }
  40711. times := strings.Split(start_time, "-")
  40712. time_tows := strings.Split(end_time, "-")
  40713. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40714. var res ResultSix
  40715. if config.IsOpen == 1 {
  40716. //var bps []*models.BusinessParamsTwo
  40717. //var bp models.BusinessParamsTwo
  40718. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  40719. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  40720. data := make(map[string]interface{})
  40721. data["org_name"] = miConfig.OrgName
  40722. data["doctor"] = role.UserName
  40723. data["func_smamt"] = func_smamt_str
  40724. data["fixmedins_code"] = miConfig.Code
  40725. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40726. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40727. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  40728. data["medfee_sumamt"] = medfee_sumamt_str
  40729. data["start_time"] = times[0] + times[1] + times[2]
  40730. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  40731. if miConfig.MdtrtareaAdmvs == "421300" {
  40732. client := &http.Client{}
  40733. bytesData, _ := json.Marshal(data)
  40734. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  40735. resp, _ := client.Do(req)
  40736. defer resp.Body.Close()
  40737. body, ioErr := ioutil.ReadAll(resp.Body)
  40738. if ioErr != nil {
  40739. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40741. return
  40742. }
  40743. var respJSON map[string]interface{}
  40744. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40745. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40747. return
  40748. }
  40749. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40750. userJSONBytes, _ := json.Marshal(respJSON)
  40751. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40752. utils.ErrorLog("解析失败:%v", err)
  40753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40754. return
  40755. }
  40756. }
  40757. if miConfig.MdtrtareaAdmvs == "420200" {
  40758. client := &http.Client{}
  40759. bytesData, _ := json.Marshal(data)
  40760. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  40761. resp, _ := client.Do(req)
  40762. defer resp.Body.Close()
  40763. body, ioErr := ioutil.ReadAll(resp.Body)
  40764. if ioErr != nil {
  40765. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40767. return
  40768. }
  40769. var respJSON map[string]interface{}
  40770. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40771. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40773. return
  40774. }
  40775. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40776. userJSONBytes, _ := json.Marshal(respJSON)
  40777. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40778. utils.ErrorLog("解析失败:%v", err)
  40779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40780. return
  40781. }
  40782. }
  40783. if miConfig.MdtrtareaAdmvs == "421182" {
  40784. client := &http.Client{}
  40785. bytesData, _ := json.Marshal(data)
  40786. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  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. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40802. userJSONBytes, _ := json.Marshal(respJSON)
  40803. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40804. utils.ErrorLog("解析失败:%v", err)
  40805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40806. return
  40807. }
  40808. }
  40809. if res.Infcode == 0 {
  40810. c.ServeSuccessJSON(map[string]interface{}{
  40811. "msg": "发起成功",
  40812. })
  40813. } else {
  40814. c.ServeSuccessJSON(map[string]interface{}{
  40815. "failed_code": -10,
  40816. "msg": res.ErrMsg,
  40817. })
  40818. }
  40819. }
  40820. }
  40821. // 5.11.1.1【5262】结算信息按时间段查询
  40822. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  40823. admin_user_id, _ := c.GetInt64("admin_user_id")
  40824. adminUser := c.GetAdminUserInfo()
  40825. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40826. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40827. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40828. var res Result5262
  40829. if config.IsOpen == 1 {
  40830. if miConfig.MdtrtareaAdmvs == "421300" {
  40831. data := make(map[string]interface{})
  40832. data["bps"] = bp
  40833. data["org_name"] = miConfig.OrgName
  40834. data["doctor"] = role.UserName
  40835. data["fixmedins_code"] = miConfig.Code
  40836. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40837. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40838. data["page"] = strconv.FormatInt(page, 10)
  40839. data["limit"] = strconv.FormatInt(limit, 10)
  40840. fmt.Println(data)
  40841. client := &http.Client{}
  40842. bytesData, _ := json.Marshal(data)
  40843. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  40844. resp, _ := client.Do(req)
  40845. defer resp.Body.Close()
  40846. body, ioErr := ioutil.ReadAll(resp.Body)
  40847. if ioErr != nil {
  40848. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40850. return
  40851. }
  40852. var respJSON map[string]interface{}
  40853. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40854. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40856. return
  40857. }
  40858. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40859. userJSONBytes, _ := json.Marshal(respJSON)
  40860. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40861. utils.ErrorLog("解析失败:%v", err)
  40862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40863. return
  40864. }
  40865. }
  40866. if miConfig.MdtrtareaAdmvs == "420200" {
  40867. data := make(map[string]interface{})
  40868. data["bps"] = bp
  40869. data["org_name"] = miConfig.OrgName
  40870. data["doctor"] = role.UserName
  40871. data["fixmedins_code"] = miConfig.Code
  40872. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40873. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40874. data["page"] = strconv.FormatInt(page, 10)
  40875. data["limit"] = strconv.FormatInt(limit, 10)
  40876. fmt.Println(data)
  40877. client := &http.Client{}
  40878. bytesData, _ := json.Marshal(data)
  40879. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  40880. resp, _ := client.Do(req)
  40881. defer resp.Body.Close()
  40882. body, ioErr := ioutil.ReadAll(resp.Body)
  40883. if ioErr != nil {
  40884. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40886. return
  40887. }
  40888. var respJSON map[string]interface{}
  40889. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40890. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40892. return
  40893. }
  40894. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40895. userJSONBytes, _ := json.Marshal(respJSON)
  40896. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40897. utils.ErrorLog("解析失败:%v", err)
  40898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40899. return
  40900. }
  40901. }
  40902. if miConfig.MdtrtareaAdmvs == "421182" {
  40903. data := make(map[string]interface{})
  40904. data["bps"] = bp
  40905. data["org_name"] = miConfig.OrgName
  40906. data["doctor"] = role.UserName
  40907. data["fixmedins_code"] = miConfig.Code
  40908. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40909. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40910. data["page"] = strconv.FormatInt(page, 10)
  40911. data["limit"] = strconv.FormatInt(limit, 10)
  40912. fmt.Println(data)
  40913. client := &http.Client{}
  40914. bytesData, _ := json.Marshal(data)
  40915. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  40916. resp, _ := client.Do(req)
  40917. defer resp.Body.Close()
  40918. body, ioErr := ioutil.ReadAll(resp.Body)
  40919. if ioErr != nil {
  40920. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40922. return
  40923. }
  40924. var respJSON map[string]interface{}
  40925. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40926. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40928. return
  40929. }
  40930. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40931. userJSONBytes, _ := json.Marshal(respJSON)
  40932. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40933. utils.ErrorLog("解析失败:%v", err)
  40934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40935. return
  40936. }
  40937. }
  40938. if miConfig.MdtrtareaAdmvs == "420902" {
  40939. data := make(map[string]interface{})
  40940. data["bps"] = bp
  40941. data["org_name"] = miConfig.OrgName
  40942. data["doctor"] = role.UserName
  40943. data["fixmedins_code"] = miConfig.Code
  40944. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40945. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40946. data["page"] = strconv.FormatInt(page, 10)
  40947. data["limit"] = strconv.FormatInt(limit, 10)
  40948. fmt.Println(data)
  40949. client := &http.Client{}
  40950. bytesData, _ := json.Marshal(data)
  40951. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  40952. resp, _ := client.Do(req)
  40953. defer resp.Body.Close()
  40954. body, ioErr := ioutil.ReadAll(resp.Body)
  40955. if ioErr != nil {
  40956. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40958. return
  40959. }
  40960. var respJSON map[string]interface{}
  40961. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40962. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40964. return
  40965. }
  40966. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40967. userJSONBytes, _ := json.Marshal(respJSON)
  40968. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40969. utils.ErrorLog("解析失败:%v", err)
  40970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40971. return
  40972. }
  40973. }
  40974. if res.Infcode == 0 {
  40975. c.ServeSuccessJSON(map[string]interface{}{
  40976. "order": res.Output.Result,
  40977. "total": res.Output.PageInfo.RecordCounts,
  40978. })
  40979. } else {
  40980. c.ServeSuccessJSON(map[string]interface{}{
  40981. "failed_code": -10,
  40982. "msg": res.ErrMsg,
  40983. })
  40984. }
  40985. }
  40986. }
  40987. // 5.11.1.2【5267】异地结算信息时间段查询
  40988. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  40989. admin_user_id, _ := c.GetInt64("admin_user_id")
  40990. adminUser := c.GetAdminUserInfo()
  40991. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40992. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40993. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40994. var res Result5267
  40995. if config.IsOpen == 1 {
  40996. if miConfig.MdtrtareaAdmvs == "421300" {
  40997. data := make(map[string]interface{})
  40998. data["bps"] = bp
  40999. data["org_name"] = miConfig.OrgName
  41000. data["doctor"] = role.UserName
  41001. data["fixmedins_code"] = miConfig.Code
  41002. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  41003. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  41004. data["page"] = page
  41005. data["limit"] = limit
  41006. fmt.Println(data)
  41007. client := &http.Client{}
  41008. bytesData, _ := json.Marshal(data)
  41009. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  41010. resp, _ := client.Do(req)
  41011. defer resp.Body.Close()
  41012. body, ioErr := ioutil.ReadAll(resp.Body)
  41013. if ioErr != nil {
  41014. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41016. return
  41017. }
  41018. var respJSON map[string]interface{}
  41019. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41020. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41022. return
  41023. }
  41024. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  41025. userJSONBytes, _ := json.Marshal(respJSON)
  41026. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  41027. utils.ErrorLog("解析失败:%v", err)
  41028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41029. return
  41030. }
  41031. }
  41032. if miConfig.MdtrtareaAdmvs == "420200" {
  41033. data := make(map[string]interface{})
  41034. data["bps"] = bp
  41035. data["org_name"] = miConfig.OrgName
  41036. data["doctor"] = role.UserName
  41037. data["fixmedins_code"] = miConfig.Code
  41038. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  41039. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  41040. data["page"] = page
  41041. data["limit"] = limit
  41042. fmt.Println(data)
  41043. client := &http.Client{}
  41044. bytesData, _ := json.Marshal(data)
  41045. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  41046. resp, _ := client.Do(req)
  41047. defer resp.Body.Close()
  41048. body, ioErr := ioutil.ReadAll(resp.Body)
  41049. if ioErr != nil {
  41050. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41052. return
  41053. }
  41054. var respJSON map[string]interface{}
  41055. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41056. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41058. return
  41059. }
  41060. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  41061. userJSONBytes, _ := json.Marshal(respJSON)
  41062. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  41063. utils.ErrorLog("解析失败:%v", err)
  41064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41065. return
  41066. }
  41067. }
  41068. if miConfig.MdtrtareaAdmvs == "421182" {
  41069. data := make(map[string]interface{})
  41070. data["bps"] = bp
  41071. data["org_name"] = miConfig.OrgName
  41072. data["doctor"] = role.UserName
  41073. data["fixmedins_code"] = miConfig.Code
  41074. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  41075. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  41076. data["page"] = page
  41077. data["limit"] = limit
  41078. fmt.Println(data)
  41079. client := &http.Client{}
  41080. bytesData, _ := json.Marshal(data)
  41081. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  41082. resp, _ := client.Do(req)
  41083. defer resp.Body.Close()
  41084. body, ioErr := ioutil.ReadAll(resp.Body)
  41085. if ioErr != nil {
  41086. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41088. return
  41089. }
  41090. var respJSON map[string]interface{}
  41091. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41092. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41094. return
  41095. }
  41096. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  41097. userJSONBytes, _ := json.Marshal(respJSON)
  41098. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  41099. utils.ErrorLog("解析失败:%v", err)
  41100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41101. return
  41102. }
  41103. }
  41104. if res.Infcode == 0 {
  41105. c.ServeSuccessJSON(map[string]interface{}{
  41106. "order": res.Output.Result,
  41107. "total": res.Output.PageInfo.RecordCounts,
  41108. })
  41109. } else {
  41110. c.ServeSuccessJSON(map[string]interface{}{
  41111. "failed_code": -10,
  41112. "msg": res.ErrMsg,
  41113. })
  41114. }
  41115. }
  41116. }
  41117. func (c *HisApiController) Post3501() {
  41118. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41119. data := make(map[string]interface{})
  41120. var struct3501s []models.Struct3501
  41121. var struct3501 models.Struct3501
  41122. struct3501.OrgName = miConfig.OrgName
  41123. struct3501.AccessKey = miConfig.AccessKey
  41124. struct3501.RequestUrl = miConfig.Url
  41125. struct3501.SecretKey = miConfig.SecretKey
  41126. struct3501.ManuDate = "2022-08-17"
  41127. struct3501.FixmedinsBchno = ""
  41128. struct3501.ManuLotnum = ""
  41129. struct3501.RxFlag = "0"
  41130. struct3501.ExpyEnd = "2022-08-17"
  41131. struct3501.Invdate = "2022-08-17"
  41132. struct3501.InvCnt = "20.25"
  41133. struct3501.Memo = ""
  41134. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41135. struct3501.FixmedinsHilistId = miConfig.Code
  41136. struct3501.FixmedinsHilistName = miConfig.OrgName
  41137. struct3501s = append(struct3501s, struct3501)
  41138. data["struct_3501s"] = struct3501s
  41139. client := &http.Client{}
  41140. bytesData, _ := json.Marshal(data)
  41141. var req *http.Request
  41142. if miConfig.MdtrtareaAdmvs == "320830" {
  41143. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3501", bytes.NewReader(bytesData))
  41144. } else if miConfig.MdtrtareaAdmvs == "320921" {
  41145. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41146. } else {
  41147. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41148. }
  41149. resp, _ := client.Do(req)
  41150. defer resp.Body.Close()
  41151. body, ioErr := ioutil.ReadAll(resp.Body)
  41152. if ioErr != nil {
  41153. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41155. return
  41156. }
  41157. var respJSON map[string]interface{}
  41158. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41159. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41161. return
  41162. }
  41163. var res ResultSix
  41164. var resSix10265 ResultSix10265 //1101结果
  41165. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41166. result, _ := json.Marshal(respJSON)
  41167. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41168. utils.ErrorLog("解析失败:%v", err)
  41169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41170. return
  41171. }
  41172. res.InfRefmsgid = resSix10265.InfRefmsgid
  41173. res.Output = resSix10265.Output
  41174. res.ErrMsg = resSix10265.ErrMsg
  41175. res.Cainfo = resSix10265.Cainfo
  41176. res.WarnMsg = resSix10265.WarnMsg
  41177. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41178. res.Infcode = infocode
  41179. if infocode == 0 {
  41180. c.ServeSuccessJSON(map[string]interface{}{
  41181. "msg": "上传成功",
  41182. })
  41183. return
  41184. } else {
  41185. c.ServeSuccessJSON(map[string]interface{}{
  41186. "failed_code": -10,
  41187. "msg": res.ErrMsg,
  41188. })
  41189. return
  41190. }
  41191. }
  41192. func (c *HisApiController) Post3502() {
  41193. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41194. data := make(map[string]interface{})
  41195. var struct3502s []models.Struct3502
  41196. var struct3502 models.Struct3502
  41197. struct3502.OrgName = miConfig.OrgName
  41198. struct3502.AccessKey = miConfig.AccessKey
  41199. struct3502.RequestUrl = miConfig.Url
  41200. struct3502.SecretKey = miConfig.SecretKey
  41201. struct3502.ManuDate = "2022-08-15"
  41202. struct3502.FixmedinsBchno = ""
  41203. struct3502.ManuLotnum = ""
  41204. struct3502.RxFlag = "0"
  41205. struct3502.ExpyEnd = "2022-08-15"
  41206. struct3502.Invdate = "2022-08-15"
  41207. struct3502.InvCnt = "20.25"
  41208. struct3502.Memo = ""
  41209. struct3502.MedListCodg = "XB01ABD056B002020200517"
  41210. struct3502.FixmedinsHilistId = miConfig.Code
  41211. struct3502.FixmedinsHilistName = miConfig.OrgName
  41212. struct3502s = append(struct3502s, struct3502)
  41213. data["struct_3502s"] = struct3502s
  41214. client := &http.Client{}
  41215. bytesData, _ := json.Marshal(data)
  41216. var req *http.Request
  41217. if miConfig.MdtrtareaAdmvs == "320830" {
  41218. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3501", bytes.NewReader(bytesData))
  41219. } else if miConfig.MdtrtareaAdmvs == "320921" {
  41220. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41221. } else {
  41222. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41223. }
  41224. resp, _ := client.Do(req)
  41225. defer resp.Body.Close()
  41226. body, ioErr := ioutil.ReadAll(resp.Body)
  41227. if ioErr != nil {
  41228. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41230. return
  41231. }
  41232. var respJSON map[string]interface{}
  41233. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41234. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41236. return
  41237. }
  41238. var res ResultSix
  41239. var resSix10265 ResultSix10265 //1101结果
  41240. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41241. result, _ := json.Marshal(respJSON)
  41242. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41243. utils.ErrorLog("解析失败:%v", err)
  41244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41245. return
  41246. }
  41247. res.InfRefmsgid = resSix10265.InfRefmsgid
  41248. res.Output = resSix10265.Output
  41249. res.ErrMsg = resSix10265.ErrMsg
  41250. res.Cainfo = resSix10265.Cainfo
  41251. res.WarnMsg = resSix10265.WarnMsg
  41252. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41253. res.Infcode = infocode
  41254. if infocode == 0 {
  41255. c.ServeSuccessJSON(map[string]interface{}{
  41256. "msg": "上传成功",
  41257. })
  41258. return
  41259. } else {
  41260. c.ServeSuccessJSON(map[string]interface{}{
  41261. "failed_code": -10,
  41262. "msg": res.ErrMsg,
  41263. })
  41264. return
  41265. }
  41266. }
  41267. func (c *HisApiController) Post3503() {
  41268. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41269. data := make(map[string]interface{})
  41270. var struct3501s []models.Struct3501
  41271. var struct3501 models.Struct3501
  41272. struct3501.OrgName = miConfig.OrgName
  41273. struct3501.AccessKey = miConfig.AccessKey
  41274. struct3501.RequestUrl = miConfig.Url
  41275. struct3501.SecretKey = miConfig.SecretKey
  41276. struct3501.ManuDate = "2022-08-15"
  41277. struct3501.FixmedinsBchno = ""
  41278. struct3501.ManuLotnum = ""
  41279. struct3501.RxFlag = "0"
  41280. struct3501.ExpyEnd = "2022-08-15"
  41281. struct3501.Invdate = "2022-08-15"
  41282. struct3501.InvCnt = "20.25"
  41283. struct3501.Memo = ""
  41284. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41285. struct3501.FixmedinsHilistId = miConfig.Code
  41286. struct3501.FixmedinsHilistName = miConfig.OrgName
  41287. struct3501s = append(struct3501s, struct3501)
  41288. data["struct_3501s"] = struct3501s
  41289. client := &http.Client{}
  41290. bytesData, _ := json.Marshal(data)
  41291. var req *http.Request
  41292. if miConfig.MdtrtareaAdmvs == "320921" {
  41293. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41294. } else {
  41295. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41296. }
  41297. resp, _ := client.Do(req)
  41298. defer resp.Body.Close()
  41299. body, ioErr := ioutil.ReadAll(resp.Body)
  41300. if ioErr != nil {
  41301. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41303. return
  41304. }
  41305. var respJSON map[string]interface{}
  41306. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41307. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41309. return
  41310. }
  41311. var res ResultSix
  41312. var resSix10265 ResultSix10265 //1101结果
  41313. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41314. result, _ := json.Marshal(respJSON)
  41315. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41316. utils.ErrorLog("解析失败:%v", err)
  41317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41318. return
  41319. }
  41320. res.InfRefmsgid = resSix10265.InfRefmsgid
  41321. res.Output = resSix10265.Output
  41322. res.ErrMsg = resSix10265.ErrMsg
  41323. res.Cainfo = resSix10265.Cainfo
  41324. res.WarnMsg = resSix10265.WarnMsg
  41325. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41326. res.Infcode = infocode
  41327. if infocode == 0 {
  41328. c.ServeSuccessJSON(map[string]interface{}{
  41329. "msg": "上传成功",
  41330. })
  41331. return
  41332. } else {
  41333. c.ServeSuccessJSON(map[string]interface{}{
  41334. "failed_code": -10,
  41335. "msg": res.ErrMsg,
  41336. })
  41337. return
  41338. }
  41339. }
  41340. func (c *HisApiController) Post3504() {
  41341. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41342. data := make(map[string]interface{})
  41343. var struct3501s []models.Struct3501
  41344. var struct3501 models.Struct3501
  41345. struct3501.OrgName = miConfig.OrgName
  41346. struct3501.AccessKey = miConfig.AccessKey
  41347. struct3501.RequestUrl = miConfig.Url
  41348. struct3501.SecretKey = miConfig.SecretKey
  41349. struct3501.ManuDate = "2022-08-15"
  41350. struct3501.FixmedinsBchno = ""
  41351. struct3501.ManuLotnum = ""
  41352. struct3501.RxFlag = "0"
  41353. struct3501.ExpyEnd = "2022-08-15"
  41354. struct3501.Invdate = "2022-08-15"
  41355. struct3501.InvCnt = "20.25"
  41356. struct3501.Memo = ""
  41357. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41358. struct3501.FixmedinsHilistId = miConfig.Code
  41359. struct3501.FixmedinsHilistName = miConfig.OrgName
  41360. struct3501s = append(struct3501s, struct3501)
  41361. data["struct_3501s"] = struct3501s
  41362. client := &http.Client{}
  41363. bytesData, _ := json.Marshal(data)
  41364. var req *http.Request
  41365. if miConfig.MdtrtareaAdmvs == "320921" {
  41366. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41367. } else {
  41368. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41369. }
  41370. resp, _ := client.Do(req)
  41371. defer resp.Body.Close()
  41372. body, ioErr := ioutil.ReadAll(resp.Body)
  41373. if ioErr != nil {
  41374. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41376. return
  41377. }
  41378. var respJSON map[string]interface{}
  41379. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41380. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41382. return
  41383. }
  41384. var res ResultSix
  41385. var resSix10265 ResultSix10265 //1101结果
  41386. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41387. result, _ := json.Marshal(respJSON)
  41388. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41389. utils.ErrorLog("解析失败:%v", err)
  41390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41391. return
  41392. }
  41393. res.InfRefmsgid = resSix10265.InfRefmsgid
  41394. res.Output = resSix10265.Output
  41395. res.ErrMsg = resSix10265.ErrMsg
  41396. res.Cainfo = resSix10265.Cainfo
  41397. res.WarnMsg = resSix10265.WarnMsg
  41398. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41399. res.Infcode = infocode
  41400. if infocode == 0 {
  41401. c.ServeSuccessJSON(map[string]interface{}{
  41402. "msg": "上传成功",
  41403. })
  41404. return
  41405. } else {
  41406. c.ServeSuccessJSON(map[string]interface{}{
  41407. "failed_code": -10,
  41408. "msg": res.ErrMsg,
  41409. })
  41410. return
  41411. }
  41412. }
  41413. func (c *HisApiController) Post3505() {
  41414. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41415. data := make(map[string]interface{})
  41416. var struct3501s []models.Struct3501
  41417. var struct3501 models.Struct3501
  41418. struct3501.OrgName = miConfig.OrgName
  41419. struct3501.AccessKey = miConfig.AccessKey
  41420. struct3501.RequestUrl = miConfig.Url
  41421. struct3501.SecretKey = miConfig.SecretKey
  41422. struct3501.ManuDate = "2022-08-15"
  41423. struct3501.FixmedinsBchno = ""
  41424. struct3501.ManuLotnum = ""
  41425. struct3501.RxFlag = "0"
  41426. struct3501.ExpyEnd = "2022-08-15"
  41427. struct3501.Invdate = "2022-08-15"
  41428. struct3501.InvCnt = "20.25"
  41429. struct3501.Memo = ""
  41430. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41431. struct3501.FixmedinsHilistId = miConfig.Code
  41432. struct3501.FixmedinsHilistName = miConfig.OrgName
  41433. struct3501s = append(struct3501s, struct3501)
  41434. data["struct_3501s"] = struct3501s
  41435. client := &http.Client{}
  41436. bytesData, _ := json.Marshal(data)
  41437. var req *http.Request
  41438. if miConfig.MdtrtareaAdmvs == "320921" {
  41439. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41440. } else {
  41441. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41442. }
  41443. resp, _ := client.Do(req)
  41444. defer resp.Body.Close()
  41445. body, ioErr := ioutil.ReadAll(resp.Body)
  41446. if ioErr != nil {
  41447. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41449. return
  41450. }
  41451. var respJSON map[string]interface{}
  41452. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41453. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41455. return
  41456. }
  41457. var res ResultSix
  41458. var resSix10265 ResultSix10265 //1101结果
  41459. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41460. result, _ := json.Marshal(respJSON)
  41461. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41462. utils.ErrorLog("解析失败:%v", err)
  41463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41464. return
  41465. }
  41466. res.InfRefmsgid = resSix10265.InfRefmsgid
  41467. res.Output = resSix10265.Output
  41468. res.ErrMsg = resSix10265.ErrMsg
  41469. res.Cainfo = resSix10265.Cainfo
  41470. res.WarnMsg = resSix10265.WarnMsg
  41471. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41472. res.Infcode = infocode
  41473. if infocode == 0 {
  41474. c.ServeSuccessJSON(map[string]interface{}{
  41475. "msg": "上传成功",
  41476. })
  41477. return
  41478. } else {
  41479. c.ServeSuccessJSON(map[string]interface{}{
  41480. "failed_code": -10,
  41481. "msg": res.ErrMsg,
  41482. })
  41483. return
  41484. }
  41485. }
  41486. func (c *HisApiController) Post3506() {
  41487. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41488. data := make(map[string]interface{})
  41489. var struct3501s []models.Struct3501
  41490. var struct3501 models.Struct3501
  41491. struct3501.OrgName = miConfig.OrgName
  41492. struct3501.AccessKey = miConfig.AccessKey
  41493. struct3501.RequestUrl = miConfig.Url
  41494. struct3501.SecretKey = miConfig.SecretKey
  41495. struct3501.ManuDate = "2022-08-15"
  41496. struct3501.FixmedinsBchno = ""
  41497. struct3501.ManuLotnum = ""
  41498. struct3501.RxFlag = "0"
  41499. struct3501.ExpyEnd = "2022-08-15"
  41500. struct3501.Invdate = "2022-08-15"
  41501. struct3501.InvCnt = "20.25"
  41502. struct3501.Memo = ""
  41503. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41504. struct3501.FixmedinsHilistId = miConfig.Code
  41505. struct3501.FixmedinsHilistName = miConfig.OrgName
  41506. struct3501s = append(struct3501s, struct3501)
  41507. data["struct_3501s"] = struct3501s
  41508. client := &http.Client{}
  41509. bytesData, _ := json.Marshal(data)
  41510. var req *http.Request
  41511. if miConfig.MdtrtareaAdmvs == "320921" {
  41512. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41513. } else {
  41514. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41515. }
  41516. resp, _ := client.Do(req)
  41517. defer resp.Body.Close()
  41518. body, ioErr := ioutil.ReadAll(resp.Body)
  41519. if ioErr != nil {
  41520. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41522. return
  41523. }
  41524. var respJSON map[string]interface{}
  41525. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41526. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41528. return
  41529. }
  41530. var res ResultSix
  41531. var resSix10265 ResultSix10265 //1101结果
  41532. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41533. result, _ := json.Marshal(respJSON)
  41534. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41535. utils.ErrorLog("解析失败:%v", err)
  41536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41537. return
  41538. }
  41539. res.InfRefmsgid = resSix10265.InfRefmsgid
  41540. res.Output = resSix10265.Output
  41541. res.ErrMsg = resSix10265.ErrMsg
  41542. res.Cainfo = resSix10265.Cainfo
  41543. res.WarnMsg = resSix10265.WarnMsg
  41544. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41545. res.Infcode = infocode
  41546. if infocode == 0 {
  41547. c.ServeSuccessJSON(map[string]interface{}{
  41548. "msg": "上传成功",
  41549. })
  41550. return
  41551. } else {
  41552. c.ServeSuccessJSON(map[string]interface{}{
  41553. "failed_code": -10,
  41554. "msg": res.ErrMsg,
  41555. })
  41556. return
  41557. }
  41558. }
  41559. func (c *HisApiController) Post3507() {
  41560. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41561. data := make(map[string]interface{})
  41562. var struct3501s []models.Struct3501
  41563. var struct3501 models.Struct3501
  41564. struct3501.OrgName = miConfig.OrgName
  41565. struct3501.AccessKey = miConfig.AccessKey
  41566. struct3501.RequestUrl = miConfig.Url
  41567. struct3501.SecretKey = miConfig.SecretKey
  41568. struct3501.ManuDate = "2022-08-15"
  41569. struct3501.FixmedinsBchno = ""
  41570. struct3501.ManuLotnum = ""
  41571. struct3501.RxFlag = "0"
  41572. struct3501.ExpyEnd = "2022-08-15"
  41573. struct3501.Invdate = "2022-08-15"
  41574. struct3501.InvCnt = "20.25"
  41575. struct3501.Memo = ""
  41576. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41577. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  41578. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  41579. struct3501s = append(struct3501s, struct3501)
  41580. data["struct_3501s"] = struct3501s
  41581. client := &http.Client{}
  41582. bytesData, _ := json.Marshal(data)
  41583. var req *http.Request
  41584. if miConfig.MdtrtareaAdmvs == "320921" {
  41585. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41586. } else {
  41587. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41588. }
  41589. resp, _ := client.Do(req)
  41590. defer resp.Body.Close()
  41591. body, ioErr := ioutil.ReadAll(resp.Body)
  41592. if ioErr != nil {
  41593. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41595. return
  41596. }
  41597. var respJSON map[string]interface{}
  41598. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41599. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41601. return
  41602. }
  41603. var res ResultSix
  41604. var resSix10265 ResultSix10265 //1101结果
  41605. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41606. result, _ := json.Marshal(respJSON)
  41607. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41608. utils.ErrorLog("解析失败:%v", err)
  41609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41610. return
  41611. }
  41612. res.InfRefmsgid = resSix10265.InfRefmsgid
  41613. res.Output = resSix10265.Output
  41614. res.ErrMsg = resSix10265.ErrMsg
  41615. res.Cainfo = resSix10265.Cainfo
  41616. res.WarnMsg = resSix10265.WarnMsg
  41617. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41618. res.Infcode = infocode
  41619. if infocode == 0 {
  41620. c.ServeSuccessJSON(map[string]interface{}{
  41621. "msg": "上传成功",
  41622. })
  41623. return
  41624. } else {
  41625. c.ServeSuccessJSON(map[string]interface{}{
  41626. "failed_code": -10,
  41627. "msg": res.ErrMsg,
  41628. })
  41629. return
  41630. }
  41631. }
  41632. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  41633. // WebSocket服务器地址
  41634. serverURL := "ws://127.0.0.1:8899"
  41635. // 解析WebSocket服务器地址
  41636. u, err := url.Parse(serverURL)
  41637. if err != nil {
  41638. }
  41639. // 建立WebSocket连接
  41640. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41641. if err != nil {
  41642. }
  41643. defer conn.Close()
  41644. input2 := make(map[string]interface{})
  41645. input := make(map[string]interface{})
  41646. inputData := make(map[string]interface{})
  41647. inputData["orgId"] = code
  41648. inputData["businessType"] = "01101"
  41649. inputData["operatorId"] = operator_id
  41650. inputData["operatorName"] = operator_name
  41651. inputData["officeId"] = "001"
  41652. inputData["officeName"] = "血透室"
  41653. inputData["deviceType"] = ""
  41654. input["data"] = inputData
  41655. input["orgId"] = code
  41656. input["transType"] = "ec.query"
  41657. //if md == ""
  41658. if md[:4] == "4403" {
  41659. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41660. } else if md[:4] == "4401" {
  41661. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41662. } else {
  41663. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41664. }
  41665. input2["indata"] = input
  41666. fmt.Println(input2)
  41667. bytesData, _ := json.Marshal(input2)
  41668. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41669. if err != nil {
  41670. fmt.Println(err)
  41671. }
  41672. // 接收消息
  41673. _, receivedMessage, err := conn.ReadMessage()
  41674. if err != nil {
  41675. fmt.Println(err)
  41676. }
  41677. return "", string(receivedMessage)
  41678. }
  41679. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  41680. // WebSocket服务器地址
  41681. serverURL := "ws://127.0.0.1:8899"
  41682. // 解析WebSocket服务器地址
  41683. u, err := url.Parse(serverURL)
  41684. if err != nil {
  41685. }
  41686. // 建立WebSocket连接
  41687. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41688. if err != nil {
  41689. }
  41690. defer conn.Close()
  41691. input2 := make(map[string]interface{})
  41692. input := make(map[string]interface{})
  41693. inputData := make(map[string]interface{})
  41694. inputData["orgId"] = code
  41695. inputData["businessType"] = "01101"
  41696. inputData["operatorId"] = operator_id
  41697. inputData["operatorName"] = operator_name
  41698. inputData["officeId"] = "001"
  41699. inputData["officeName"] = "血透室"
  41700. inputData["deviceType"] = ""
  41701. input["data"] = inputData
  41702. input["orgId"] = code
  41703. input["transType"] = "ec.query"
  41704. //if md == ""
  41705. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  41706. input2["indata"] = input
  41707. fmt.Println(input2)
  41708. bytesData, _ := json.Marshal(input2)
  41709. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41710. if err != nil {
  41711. fmt.Println(err)
  41712. }
  41713. // 接收消息
  41714. _, receivedMessage, err := conn.ReadMessage()
  41715. if err != nil {
  41716. fmt.Println(err)
  41717. }
  41718. return "", string(receivedMessage)
  41719. }
  41720. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  41721. // WebSocket服务器地址
  41722. serverURL := "ws://127.0.0.1:8899"
  41723. // 解析WebSocket服务器地址
  41724. u, err := url.Parse(serverURL)
  41725. if err != nil {
  41726. }
  41727. // 建立WebSocket连接
  41728. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41729. if err != nil {
  41730. }
  41731. defer conn.Close()
  41732. input2 := make(map[string]interface{})
  41733. input := make(map[string]interface{})
  41734. inputData := make(map[string]interface{})
  41735. inputData["orgId"] = code
  41736. inputData["businessType"] = "01301"
  41737. inputData["operatorId"] = operator_id
  41738. inputData["operatorName"] = operator_name
  41739. inputData["officeId"] = "001"
  41740. inputData["officeName"] = "血透室"
  41741. inputData["deviceType"] = ""
  41742. input["data"] = inputData
  41743. input["orgId"] = code
  41744. input["transType"] = "ec.query"
  41745. //if md == ""
  41746. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  41747. input2["indata"] = input
  41748. fmt.Println(input2)
  41749. bytesData, _ := json.Marshal(input2)
  41750. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41751. if err != nil {
  41752. fmt.Println(err)
  41753. }
  41754. // 接收消息
  41755. _, receivedMessage, err := conn.ReadMessage()
  41756. if err != nil {
  41757. fmt.Println(err)
  41758. }
  41759. return "", string(receivedMessage)
  41760. }
  41761. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  41762. // WebSocket服务器地址
  41763. serverURL := "ws://127.0.0.1:8899"
  41764. // 解析WebSocket服务器地址
  41765. u, err := url.Parse(serverURL)
  41766. if err != nil {
  41767. }
  41768. // 建立WebSocket连接
  41769. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41770. if err != nil {
  41771. }
  41772. defer conn.Close()
  41773. input2 := make(map[string]interface{})
  41774. input := make(map[string]interface{})
  41775. inputData := make(map[string]interface{})
  41776. inputData["orgId"] = code
  41777. inputData["businessType"] = "01103"
  41778. inputData["operatorId"] = operator_id
  41779. inputData["operatorName"] = operator_name
  41780. inputData["officeId"] = "001"
  41781. inputData["officeName"] = "血透室"
  41782. inputData["deviceType"] = ""
  41783. input["data"] = inputData
  41784. input["orgId"] = code
  41785. input["transType"] = "ec.query"
  41786. //if md ==
  41787. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  41788. input2["indata"] = input
  41789. fmt.Println(input2)
  41790. bytesData, _ := json.Marshal(input2)
  41791. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41792. if err != nil {
  41793. fmt.Println(err)
  41794. }
  41795. // 接收消息
  41796. _, receivedMessage, err := conn.ReadMessage()
  41797. if err != nil {
  41798. fmt.Println(err)
  41799. }
  41800. return "", string(receivedMessage)
  41801. }
  41802. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  41803. // WebSocket服务器地址
  41804. serverURL := "ws://127.0.0.1:8899"
  41805. // 解析WebSocket服务器地址
  41806. u, err := url.Parse(serverURL)
  41807. if err != nil {
  41808. }
  41809. // 建立WebSocket连接
  41810. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41811. if err != nil {
  41812. }
  41813. defer conn.Close()
  41814. input2 := make(map[string]interface{})
  41815. input := make(map[string]interface{})
  41816. inputData := make(map[string]interface{})
  41817. inputData["orgId"] = code
  41818. inputData["businessType"] = "01101"
  41819. inputData["operatorId"] = operator_id
  41820. inputData["operatorName"] = operator_name
  41821. inputData["officeId"] = "001"
  41822. inputData["officeName"] = "血透室"
  41823. inputData["deviceType"] = ""
  41824. input["data"] = inputData
  41825. input["orgId"] = code
  41826. input["transType"] = "ec.query"
  41827. //if md == ""
  41828. if md[:4] == "4403" {
  41829. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41830. } else if md[:4] == "4401" {
  41831. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41832. } else {
  41833. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41834. }
  41835. input2["indata"] = input
  41836. fmt.Println(input2)
  41837. bytesData, _ := json.Marshal(input2)
  41838. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41839. if err != nil {
  41840. fmt.Println(err)
  41841. }
  41842. // 接收消息
  41843. _, receivedMessage, err := conn.ReadMessage()
  41844. if err != nil {
  41845. fmt.Println(err)
  41846. }
  41847. return "", string(receivedMessage)
  41848. }
  41849. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  41850. // WebSocket服务器地址
  41851. serverURL := "ws://127.0.0.1:8899"
  41852. // 解析WebSocket服务器地址
  41853. u, err := url.Parse(serverURL)
  41854. if err != nil {
  41855. }
  41856. // 建立WebSocket连接
  41857. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41858. if err != nil {
  41859. }
  41860. defer conn.Close()
  41861. input2 := make(map[string]interface{})
  41862. input := make(map[string]interface{})
  41863. inputData := make(map[string]interface{})
  41864. inputData["orgId"] = code
  41865. inputData["businessType"] = "01301"
  41866. inputData["operatorId"] = operator_id
  41867. inputData["operatorName"] = operator_name
  41868. inputData["officeId"] = "001"
  41869. inputData["officeName"] = "血透室"
  41870. inputData["deviceType"] = ""
  41871. input["data"] = inputData
  41872. input["orgId"] = code
  41873. input["transType"] = "ec.query"
  41874. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41875. input2["indata"] = input
  41876. bytesData, _ := json.Marshal(input2)
  41877. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41878. if err != nil {
  41879. fmt.Println(err)
  41880. }
  41881. // 接收消息
  41882. _, receivedMessage, err := conn.ReadMessage()
  41883. if err != nil {
  41884. fmt.Println(err)
  41885. }
  41886. return "", string(receivedMessage)
  41887. }
  41888. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  41889. newArr = make([]string, 0)
  41890. for i := 0; i < len(arr); i++ {
  41891. repeat := false
  41892. for j := i + 1; j < len(arr); j++ {
  41893. if arr[i] == arr[j] {
  41894. repeat = true
  41895. break
  41896. }
  41897. }
  41898. if !repeat {
  41899. newArr = append(newArr, arr[i])
  41900. }
  41901. }
  41902. return
  41903. }
  41904. func getBirthdateAndAge(idNumber string) (string, int, error) {
  41905. if len(idNumber) != 18 {
  41906. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  41907. }
  41908. // 提取出生日期
  41909. year, err := strconv.Atoi(idNumber[6:10])
  41910. if err != nil {
  41911. return "", 0, err
  41912. }
  41913. month, err := strconv.Atoi(idNumber[10:12])
  41914. if err != nil {
  41915. return "", 0, err
  41916. }
  41917. day, err := strconv.Atoi(idNumber[12:14])
  41918. if err != nil {
  41919. return "", 0, err
  41920. }
  41921. // 格式化生日字符串
  41922. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  41923. birthdateFormatted := birthdate.Format("2006-01-02")
  41924. // 计算年龄
  41925. today := time.Now()
  41926. age := today.Year() - birthdate.Year()
  41927. if today.YearDay() < birthdate.YearDay() {
  41928. age--
  41929. }
  41930. return birthdateFormatted, age, nil
  41931. }
  41932. // 从身份证号码中提取出生年月日
  41933. func getBirthDateFromIDCard(idCard string) (string, error) {
  41934. // 身份证号码长度应为18位
  41935. if len(idCard) != 18 {
  41936. return "", fmt.Errorf("身份证号码长度应为18位")
  41937. }
  41938. // 提取出生日期部分 (YYYYMMDD)
  41939. birthDateStr := idCard[6:14]
  41940. // 解析出生日期
  41941. birthDate, err := time.Parse("20060102", birthDateStr)
  41942. if err != nil {
  41943. return "", fmt.Errorf("解析出生日期失败: %v", err)
  41944. }
  41945. // 格式化出生日期为 YYYY-MM-DD
  41946. formattedDate := birthDate.Format("2006-01-02")
  41947. return formattedDate, nil
  41948. }