his_api_controller.go 1.7MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/base64"
  6. //"github.com/jung-kurt/gofpdf"
  7. "encoding/json"
  8. "fmt"
  9. "gdyb/controllers"
  10. "gdyb/enums"
  11. "gdyb/models"
  12. "gdyb/service"
  13. "gdyb/utils"
  14. "github.com/astaxie/beego"
  15. "github.com/axgle/mahonia"
  16. "github.com/go-ole/go-ole/oleutil"
  17. "github.com/gorilla/websocket"
  18. "github.com/jinzhu/gorm"
  19. "github.com/shopspring/decimal"
  20. "io"
  21. "io/ioutil"
  22. "math"
  23. "math/rand"
  24. "net/http"
  25. "net/url"
  26. "os"
  27. "path/filepath"
  28. "regexp"
  29. "strconv"
  30. "strings"
  31. "syscall"
  32. "time"
  33. "unsafe"
  34. )
  35. type HisApiController struct {
  36. controllers.BaseAuthAPIController
  37. }
  38. func HisManagerApiRegistRouters() {
  39. //挂号
  40. beego.Router("/test/net", &HisApiController{}, "get:TestNet")
  41. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  42. //上传就诊信息-上传明细-结算
  43. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  44. //查询
  45. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  46. //对总账
  47. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  48. //对明细
  49. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  50. //退费,退明细
  51. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  52. //退号
  53. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  54. //退明细
  55. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  56. //上传就诊信息-上传明细-预结算
  57. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  58. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  59. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  60. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  61. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  62. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  63. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  64. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  65. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  66. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  67. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  68. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  69. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  70. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  71. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  72. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  73. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  74. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  75. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  76. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  77. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  78. beego.Router("/api/check", &HisApiController{}, "get:Check")
  79. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  80. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  81. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  82. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  83. beego.Router("/api/3204a", &HisApiController{}, "get:Post3204a")
  84. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  85. beego.Router("/api/8404", &HisApiController{}, "get:Post8404")
  86. beego.Router("/api/3204", &HisApiController{}, "get:Post3204")
  87. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  88. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  89. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  90. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  91. //beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  92. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  93. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  94. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  95. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  96. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  97. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  98. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  99. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  100. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  101. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  102. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  103. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  104. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  105. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  106. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  107. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  108. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  109. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  110. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  111. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  112. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  113. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  114. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  115. beego.Router("/api/CFYLJG012", &HisApiController{}, "get:GetCFYLJG12")
  116. beego.Router("/api/CFYLJG013", &HisApiController{}, "get:GetCFYLJG13")
  117. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  118. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  119. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  120. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  121. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  122. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  123. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  124. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  125. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  126. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  127. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  128. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  129. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  130. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  131. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  132. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  133. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  134. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  135. beego.Router("/api/3103", &HisApiController{}, "get:Get3103")
  136. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  137. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  138. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  139. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  140. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  141. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  142. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  143. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  144. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  145. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  146. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  147. //beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  148. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  149. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  150. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  151. //库盘和变更
  152. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  153. //删除库盘和变更
  154. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  155. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  156. //药品变更
  157. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  158. beego.Router("/api/changedrug/two", &HisApiController{}, "get:ChangeDrugtwo")
  159. beego.Router("/api/changedrug/three", &HisApiController{}, "get:ChangeDrugthree")
  160. beego.Router("/api/changedrug/ten", &HisApiController{}, "get:ChangeDrugTen")
  161. beego.Router("/api/3508", &HisApiController{}, "get:Get3508")
  162. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  163. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  164. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  165. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  166. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  167. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  168. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  169. beego.Router("/api/changedrug/four", &HisApiController{}, "get:ChangeDrugfour")
  170. beego.Router("/api/changedrug/five", &HisApiController{}, "get:ChangeDrugFive")
  171. beego.Router("/api/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  172. beego.Router("/api/delete_xs_bg_three", &HisApiController{}, "get:DeleteXSandBGThree")
  173. beego.Router("/api/3201", &HisApiController{}, "get:Get3201")
  174. beego.Router("/api/5101", &HisApiController{}, "get:Get5101")
  175. beego.Router("/api/5102", &HisApiController{}, "get:Get5102")
  176. }
  177. func (c *HisApiController) Get5101() {
  178. adminUser := c.GetAdminUserInfo()
  179. admin_user_id, _ := c.GetInt64("admin_user_id")
  180. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  181. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  182. if miConfig.MdtrtareaAdmvs == "341203" {
  183. fmt.Println(miConfig.SecretKey)
  184. var res models.Result9001Two
  185. 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 +
  186. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  187. resp, requestErr := http.Get(api)
  188. if requestErr != nil {
  189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  190. return
  191. }
  192. body, ioErr := ioutil.ReadAll(resp.Body)
  193. if ioErr != nil {
  194. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  196. return
  197. }
  198. var respJSON map[string]interface{}
  199. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  200. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  202. return
  203. }
  204. status := respJSON["data"].(map[string]interface{})["status"].(string)
  205. if status == "0" {
  206. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  207. c.ServeSuccessJSON(map[string]interface{}{
  208. "failed_code": -10,
  209. "msg": err_msg,
  210. })
  211. return
  212. }
  213. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  214. result, _ := json.Marshal(respJSON)
  215. fmt.Println("log")
  216. fmt.Println(string(result))
  217. if err := json.Unmarshal([]byte(result), &res); err != nil {
  218. utils.ErrorLog("解析失败:%v", err)
  219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  220. return
  221. }
  222. if res.Infcode == 0 {
  223. sign := models.HisSignIn{
  224. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  225. SignNo: res.Output.Signinoutb.SignNo,
  226. SignTime: "",
  227. Ctime: time.Now().Unix(),
  228. Mtime: time.Now().Unix(),
  229. Status: 1,
  230. InputLog: "",
  231. OutputLog: "",
  232. FixmedinsCode: miConfig.Code,
  233. }
  234. err := service.CreateSignIn(&sign)
  235. if err == nil {
  236. c.ServeSuccessJSON(map[string]interface{}{
  237. "msg": "签到成功",
  238. })
  239. }
  240. } else {
  241. c.ServeSuccessJSON(map[string]interface{}{
  242. "failed_code": -10,
  243. "msg": res.ErrMsg,
  244. })
  245. return
  246. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  247. //return
  248. }
  249. } else if miConfig.MdtrtareaAdmvs == "340699" {
  250. fmt.Println(miConfig.SecretKey)
  251. var res models.Result9001Two
  252. 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 +
  253. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  254. resp, requestErr := http.Get(api)
  255. if requestErr != nil {
  256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  257. return
  258. }
  259. body, ioErr := ioutil.ReadAll(resp.Body)
  260. if ioErr != nil {
  261. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  263. return
  264. }
  265. var respJSON map[string]interface{}
  266. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  267. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  269. return
  270. }
  271. status := respJSON["data"].(map[string]interface{})["status"].(string)
  272. if status == "0" {
  273. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  274. c.ServeSuccessJSON(map[string]interface{}{
  275. "failed_code": -10,
  276. "msg": err_msg,
  277. })
  278. return
  279. }
  280. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  281. result, _ := json.Marshal(respJSON)
  282. fmt.Println("log")
  283. fmt.Println(string(result))
  284. if err := json.Unmarshal([]byte(result), &res); err != nil {
  285. utils.ErrorLog("解析失败:%v", err)
  286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  287. return
  288. }
  289. if res.Infcode == 0 {
  290. sign := models.HisSignIn{
  291. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  292. SignNo: res.Output.Signinoutb.SignNo,
  293. SignTime: "",
  294. Ctime: time.Now().Unix(),
  295. Mtime: time.Now().Unix(),
  296. Status: 1,
  297. InputLog: "",
  298. OutputLog: "",
  299. FixmedinsCode: miConfig.Code,
  300. }
  301. err := service.CreateSignIn(&sign)
  302. if err == nil {
  303. c.ServeSuccessJSON(map[string]interface{}{
  304. "msg": "查询成功",
  305. })
  306. }
  307. } else {
  308. c.ServeSuccessJSON(map[string]interface{}{
  309. "failed_code": -10,
  310. "msg": res.ErrMsg,
  311. })
  312. return
  313. }
  314. }
  315. }
  316. func (c *HisApiController) Get5102() {
  317. adminUser := c.GetAdminUserInfo()
  318. admin_user_id, _ := c.GetInt64("admin_user_id")
  319. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  320. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  321. if miConfig.MdtrtareaAdmvs == "341203" {
  322. fmt.Println(miConfig.SecretKey)
  323. var res models.Result9001Two
  324. 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 +
  325. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  326. resp, requestErr := http.Get(api)
  327. if requestErr != nil {
  328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  329. return
  330. }
  331. body, ioErr := ioutil.ReadAll(resp.Body)
  332. if ioErr != nil {
  333. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  335. return
  336. }
  337. var respJSON map[string]interface{}
  338. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  339. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  341. return
  342. }
  343. status := respJSON["data"].(map[string]interface{})["status"].(string)
  344. if status == "0" {
  345. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  346. c.ServeSuccessJSON(map[string]interface{}{
  347. "failed_code": -10,
  348. "msg": err_msg,
  349. })
  350. return
  351. }
  352. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  353. result, _ := json.Marshal(respJSON)
  354. fmt.Println("log")
  355. fmt.Println(string(result))
  356. if err := json.Unmarshal([]byte(result), &res); err != nil {
  357. utils.ErrorLog("解析失败:%v", err)
  358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  359. return
  360. }
  361. if res.Infcode == 0 {
  362. sign := models.HisSignIn{
  363. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  364. SignNo: res.Output.Signinoutb.SignNo,
  365. SignTime: "",
  366. Ctime: time.Now().Unix(),
  367. Mtime: time.Now().Unix(),
  368. Status: 1,
  369. InputLog: "",
  370. OutputLog: "",
  371. FixmedinsCode: miConfig.Code,
  372. }
  373. err := service.CreateSignIn(&sign)
  374. if err == nil {
  375. c.ServeSuccessJSON(map[string]interface{}{
  376. "msg": "签到成功",
  377. })
  378. }
  379. } else {
  380. c.ServeSuccessJSON(map[string]interface{}{
  381. "failed_code": -10,
  382. "msg": res.ErrMsg,
  383. })
  384. return
  385. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  386. //return
  387. }
  388. } else if miConfig.MdtrtareaAdmvs == "340699" {
  389. fmt.Println(miConfig.SecretKey)
  390. var res models.Result9001Two
  391. 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 +
  392. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  393. resp, requestErr := http.Get(api)
  394. if requestErr != nil {
  395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  396. return
  397. }
  398. body, ioErr := ioutil.ReadAll(resp.Body)
  399. if ioErr != nil {
  400. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  402. return
  403. }
  404. var respJSON map[string]interface{}
  405. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  406. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  408. return
  409. }
  410. status := respJSON["data"].(map[string]interface{})["status"].(string)
  411. if status == "0" {
  412. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  413. c.ServeSuccessJSON(map[string]interface{}{
  414. "failed_code": -10,
  415. "msg": err_msg,
  416. })
  417. return
  418. }
  419. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  420. result, _ := json.Marshal(respJSON)
  421. fmt.Println("log")
  422. fmt.Println(string(result))
  423. if err := json.Unmarshal([]byte(result), &res); err != nil {
  424. utils.ErrorLog("解析失败:%v", err)
  425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  426. return
  427. }
  428. if res.Infcode == 0 {
  429. sign := models.HisSignIn{
  430. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  431. SignNo: res.Output.Signinoutb.SignNo,
  432. SignTime: "",
  433. Ctime: time.Now().Unix(),
  434. Mtime: time.Now().Unix(),
  435. Status: 1,
  436. InputLog: "",
  437. OutputLog: "",
  438. FixmedinsCode: miConfig.Code,
  439. }
  440. err := service.CreateSignIn(&sign)
  441. if err == nil {
  442. c.ServeSuccessJSON(map[string]interface{}{
  443. "msg": "查询成功",
  444. })
  445. }
  446. } else {
  447. c.ServeSuccessJSON(map[string]interface{}{
  448. "failed_code": -10,
  449. "msg": res.ErrMsg,
  450. })
  451. return
  452. }
  453. }
  454. }
  455. func (c *HisApiController) Get3201() {
  456. adminUser := c.GetAdminUserInfo()
  457. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  458. 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)
  459. var response Response
  460. if err := json.Unmarshal([]byte(result), &response); err != nil {
  461. fmt.Println("Error decoding JSON:", err)
  462. return
  463. }
  464. }
  465. func (c *HisApiController) TestNet() {
  466. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  467. //return
  468. c.ServeSuccessJSON(map[string]interface{}{
  469. "msg": "成功",
  470. })
  471. }
  472. func (c *HisApiController) Get3508() {
  473. admin_user_id, _ := c.GetInt64("admin_user_id")
  474. drug_id, _ := c.GetInt64("id")
  475. start_time := c.GetString("start_time")
  476. end_time := c.GetString("end_time")
  477. adminUser := c.GetAdminUserInfo()
  478. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  479. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  480. drug, _ := service.GetDrugByID(drug_id)
  481. var struct3508 models.Struct3508
  482. struct3508.OrgName = miConfig.OrgName
  483. struct3508.FixmedinsCode = miConfig.Code
  484. struct3508.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  485. struct3508.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  486. struct3508.AccessKey = miConfig.AccessKey
  487. struct3508.Opter = curRoles.UserName
  488. struct3508.RequestUrl = miConfig.Url
  489. struct3508.Url = miConfig.Url
  490. struct3508.AppId = miConfig.Cainfo
  491. struct3508.AppSecret = miConfig.AppSecret
  492. struct3508.Enckey = miConfig.EncKey
  493. struct3508.SignKey = miConfig.SignKey
  494. struct3508.SecretKey = miConfig.SecretKey
  495. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  496. struct3508.Begndate = start_time
  497. struct3508.Enddate = end_time
  498. struct3508.Enddate = end_time
  499. struct3508.Enddate = end_time
  500. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  501. result1, result2 := service.Gdyb3508(struct3508, struct3508.SecretKey)
  502. saveLog(result1, result2, "3508", "3508")
  503. var res models.Result3508
  504. var respJSON2 map[string]interface{}
  505. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  506. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  508. return
  509. }
  510. userJSONBytes2, _ := json.Marshal(respJSON2)
  511. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  512. utils.ErrorLog("解析失败:%v", err)
  513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  514. return
  515. }
  516. if res.Infcode == -1 {
  517. c.ServeSuccessJSON(map[string]interface{}{
  518. "failed_code": -10,
  519. "msg": res.ErrMsg,
  520. })
  521. } else {
  522. c.ServeSuccessJSON(map[string]interface{}{
  523. "info": res.Output,
  524. })
  525. }
  526. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  527. result1, result2, _ := service.FJyb3508(struct3508)
  528. saveLog(result1, result2, "3508", "3508")
  529. var res models.Result3508
  530. var respJSON2 map[string]interface{}
  531. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  532. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  534. return
  535. }
  536. userJSONBytes2, _ := json.Marshal(respJSON2)
  537. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  538. utils.ErrorLog("解析失败:%v", err)
  539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  540. return
  541. }
  542. if res.Infcode == -1 {
  543. c.ServeSuccessJSON(map[string]interface{}{
  544. "failed_code": -10,
  545. "msg": res.ErrMsg,
  546. })
  547. } else {
  548. c.ServeSuccessJSON(map[string]interface{}{
  549. "info": res.Output,
  550. })
  551. }
  552. }
  553. }
  554. func (c *HisApiController) Get3509() {
  555. admin_user_id, _ := c.GetInt64("admin_user_id")
  556. drug_id, _ := c.GetInt64("id")
  557. start_time := c.GetString("start_time")
  558. end_time := c.GetString("end_time")
  559. adminUser := c.GetAdminUserInfo()
  560. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  561. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  562. drug, _ := service.GetDrugByID(drug_id)
  563. var struct3508 models.Struct3509
  564. struct3508.OrgName = miConfig.OrgName
  565. struct3508.FixmedinsCode = miConfig.Code
  566. struct3508.AccessKey = miConfig.AccessKey
  567. struct3508.Opter = curRoles.UserName
  568. struct3508.RequestUrl = miConfig.Url
  569. struct3508.Url = miConfig.Url
  570. struct3508.AppId = miConfig.Cainfo
  571. struct3508.AppSecret = miConfig.AppSecret
  572. struct3508.Enckey = miConfig.EncKey
  573. struct3508.SignKey = miConfig.SignKey
  574. struct3508.SecretKey = miConfig.SecretKey
  575. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  576. struct3508.Begndate = start_time
  577. struct3508.Enddate = end_time
  578. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  579. result1, result2 := service.Gdyb3509(struct3508, struct3508.SecretKey)
  580. saveLog(result1, result2, "3509", "3509")
  581. var res models.Result3508
  582. var respJSON2 map[string]interface{}
  583. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  584. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  586. return
  587. }
  588. userJSONBytes2, _ := json.Marshal(respJSON2)
  589. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  590. utils.ErrorLog("解析失败:%v", err)
  591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  592. return
  593. }
  594. if res.Infcode == -1 {
  595. c.ServeSuccessJSON(map[string]interface{}{
  596. "failed_code": -10,
  597. "msg": res.ErrMsg,
  598. })
  599. } else {
  600. c.ServeSuccessJSON(map[string]interface{}{
  601. "info": res.Output,
  602. })
  603. }
  604. } else {
  605. result1, result2, _ := service.FJyb3509(struct3508)
  606. saveLog(result1, result2, "3509", "3509")
  607. var res models.Result3509
  608. var respJSON2 map[string]interface{}
  609. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  610. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  612. return
  613. }
  614. userJSONBytes2, _ := json.Marshal(respJSON2)
  615. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  616. utils.ErrorLog("解析失败:%v", err)
  617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  618. return
  619. }
  620. if res.Infcode == -1 {
  621. c.ServeSuccessJSON(map[string]interface{}{
  622. "failed_code": -10,
  623. "msg": res.ErrMsg,
  624. })
  625. } else {
  626. c.ServeSuccessJSON(map[string]interface{}{
  627. "info": res.Output,
  628. })
  629. }
  630. }
  631. }
  632. func (c *HisApiController) Get3510() {
  633. admin_user_id, _ := c.GetInt64("admin_user_id")
  634. drug_id, _ := c.GetInt64("id")
  635. start_time := c.GetString("start_time")
  636. end_time := c.GetString("end_time")
  637. adminUser := c.GetAdminUserInfo()
  638. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  639. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  640. drug, _ := service.GetDrugByID(drug_id)
  641. var struct3508 models.Struct3510
  642. struct3508.FixmedinsCode = miConfig.Code
  643. struct3508.OrgName = miConfig.OrgName
  644. struct3508.AccessKey = miConfig.AccessKey
  645. struct3508.Opter = curRoles.UserName
  646. struct3508.RequestUrl = miConfig.Url
  647. struct3508.Url = miConfig.Url
  648. struct3508.AppId = miConfig.Cainfo
  649. struct3508.AppSecret = miConfig.AppSecret
  650. struct3508.Enckey = miConfig.EncKey
  651. struct3508.SignKey = miConfig.SignKey
  652. struct3508.SecretKey = miConfig.SecretKey
  653. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  654. struct3508.Begndate = start_time
  655. struct3508.Enddate = end_time
  656. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  657. result1, result2 := service.Gdyb3510(struct3508, struct3508.SecretKey)
  658. saveLog(result1, result2, "3510", "3510")
  659. var res models.Result3510
  660. var respJSON2 map[string]interface{}
  661. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  662. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  664. return
  665. }
  666. userJSONBytes2, _ := json.Marshal(respJSON2)
  667. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  668. utils.ErrorLog("解析失败:%v", err)
  669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  670. return
  671. }
  672. if res.Infcode == -1 {
  673. c.ServeSuccessJSON(map[string]interface{}{
  674. "failed_code": -10,
  675. "msg": res.ErrMsg,
  676. })
  677. } else {
  678. c.ServeSuccessJSON(map[string]interface{}{
  679. "info": res.Output,
  680. })
  681. }
  682. } else {
  683. result1, result2, _ := service.FJyb3510(struct3508)
  684. saveLog(result1, result2, "3510", "3510")
  685. var res models.Result3510
  686. var respJSON2 map[string]interface{}
  687. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  688. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  690. return
  691. }
  692. userJSONBytes2, _ := json.Marshal(respJSON2)
  693. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  694. utils.ErrorLog("解析失败:%v", err)
  695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  696. return
  697. }
  698. if res.Infcode == -1 {
  699. c.ServeSuccessJSON(map[string]interface{}{
  700. "failed_code": -10,
  701. "msg": res.ErrMsg,
  702. })
  703. } else {
  704. c.ServeSuccessJSON(map[string]interface{}{
  705. "info": res.Output,
  706. })
  707. }
  708. }
  709. }
  710. func (c *HisApiController) Get3511() {
  711. admin_user_id, _ := c.GetInt64("admin_user_id")
  712. drug_id, _ := c.GetInt64("id")
  713. start_time := c.GetString("start_time")
  714. end_time := c.GetString("end_time")
  715. adminUser := c.GetAdminUserInfo()
  716. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  717. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  718. drug, _ := service.GetDrugByID(drug_id)
  719. var struct3508 models.Struct3511
  720. struct3508.FixmedinsCode = miConfig.Code
  721. struct3508.OrgName = miConfig.OrgName
  722. struct3508.AccessKey = miConfig.AccessKey
  723. struct3508.Opter = curRoles.UserName
  724. struct3508.RequestUrl = miConfig.Url
  725. struct3508.Url = miConfig.Url
  726. struct3508.AppId = miConfig.Cainfo
  727. struct3508.AppSecret = miConfig.AppSecret
  728. struct3508.Enckey = miConfig.EncKey
  729. struct3508.SignKey = miConfig.SignKey
  730. struct3508.SecretKey = miConfig.SecretKey
  731. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  732. struct3508.Begndate = start_time
  733. struct3508.Enddate = end_time
  734. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  735. result1, result2 := service.Gdyb3511(struct3508, struct3508.SecretKey)
  736. saveLog(result1, result2, "3511", "3511")
  737. var res models.Result3511
  738. var respJSON2 map[string]interface{}
  739. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  740. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  742. return
  743. }
  744. userJSONBytes2, _ := json.Marshal(respJSON2)
  745. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  746. utils.ErrorLog("解析失败:%v", err)
  747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  748. return
  749. }
  750. if res.Infcode == -1 {
  751. c.ServeSuccessJSON(map[string]interface{}{
  752. "failed_code": -10,
  753. "msg": res.ErrMsg,
  754. })
  755. } else {
  756. c.ServeSuccessJSON(map[string]interface{}{
  757. "info": res.Output,
  758. })
  759. }
  760. } else {
  761. result1, result2, _ := service.FJyb3511(struct3508)
  762. saveLog(result1, result2, "3511", "3511")
  763. var res models.Result3511
  764. var respJSON2 map[string]interface{}
  765. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  766. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  768. return
  769. }
  770. userJSONBytes2, _ := json.Marshal(respJSON2)
  771. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  772. utils.ErrorLog("解析失败:%v", err)
  773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  774. return
  775. }
  776. if res.Infcode == -1 {
  777. c.ServeSuccessJSON(map[string]interface{}{
  778. "failed_code": -10,
  779. "msg": res.ErrMsg,
  780. })
  781. } else {
  782. c.ServeSuccessJSON(map[string]interface{}{
  783. "info": res.Output,
  784. })
  785. }
  786. }
  787. }
  788. func (c *HisApiController) Get3512() {
  789. admin_user_id, _ := c.GetInt64("admin_user_id")
  790. drug_id, _ := c.GetInt64("id")
  791. start_time := c.GetString("start_time")
  792. end_time := c.GetString("end_time")
  793. adminUser := c.GetAdminUserInfo()
  794. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  795. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  796. drug, _ := service.GetDrugByID(drug_id)
  797. var struct3508 models.Struct3512
  798. struct3508.FixmedinsCode = miConfig.Code
  799. struct3508.OrgName = miConfig.OrgName
  800. struct3508.AccessKey = miConfig.AccessKey
  801. struct3508.Opter = curRoles.UserName
  802. struct3508.RequestUrl = miConfig.Url
  803. struct3508.Url = miConfig.Url
  804. struct3508.AppId = miConfig.Cainfo
  805. struct3508.AppSecret = miConfig.AppSecret
  806. struct3508.Enckey = miConfig.EncKey
  807. struct3508.SignKey = miConfig.SignKey
  808. struct3508.SecretKey = miConfig.SecretKey
  809. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  810. struct3508.Begndate = start_time
  811. struct3508.Enddate = end_time
  812. struct3508.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  813. struct3508.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  814. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  815. result1, result2 := service.Gdyb3512(struct3508, struct3508.SecretKey)
  816. saveLog(result1, result2, "3512", "3512")
  817. var res models.Result3512
  818. var respJSON2 map[string]interface{}
  819. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  820. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  822. return
  823. }
  824. userJSONBytes2, _ := json.Marshal(respJSON2)
  825. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  826. utils.ErrorLog("解析失败:%v", err)
  827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  828. return
  829. }
  830. if res.Infcode == -1 {
  831. c.ServeSuccessJSON(map[string]interface{}{
  832. "failed_code": -10,
  833. "msg": res.ErrMsg,
  834. })
  835. } else {
  836. c.ServeSuccessJSON(map[string]interface{}{
  837. "info": res.Output,
  838. })
  839. }
  840. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  841. result1, result2, _ := service.FJyb3512(struct3508)
  842. saveLog(result1, result2, "3512", "3512")
  843. var res models.Result3512
  844. var respJSON2 map[string]interface{}
  845. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  846. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  848. return
  849. }
  850. userJSONBytes2, _ := json.Marshal(respJSON2)
  851. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  852. utils.ErrorLog("解析失败:%v", err)
  853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  854. return
  855. }
  856. if res.Infcode == -1 {
  857. c.ServeSuccessJSON(map[string]interface{}{
  858. "failed_code": -10,
  859. "msg": res.ErrMsg,
  860. })
  861. } else {
  862. c.ServeSuccessJSON(map[string]interface{}{
  863. "info": res.Output,
  864. })
  865. }
  866. }
  867. }
  868. func (c *HisApiController) Get3513() {
  869. admin_user_id, _ := c.GetInt64("admin_user_id")
  870. drug_id, _ := c.GetInt64("id")
  871. start_time := c.GetString("start_time")
  872. end_time := c.GetString("end_time")
  873. adminUser := c.GetAdminUserInfo()
  874. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  875. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  876. drug, _ := service.GetDrugByID(drug_id)
  877. var struct3508 models.Struct3513
  878. struct3508.FixmedinsCode = miConfig.Code
  879. struct3508.OrgName = miConfig.OrgName
  880. struct3508.AccessKey = miConfig.AccessKey
  881. struct3508.Opter = curRoles.UserName
  882. struct3508.RequestUrl = miConfig.Url
  883. struct3508.Url = miConfig.Url
  884. struct3508.AppId = miConfig.Cainfo
  885. struct3508.AppSecret = miConfig.AppSecret
  886. struct3508.Enckey = miConfig.EncKey
  887. struct3508.SignKey = miConfig.SignKey
  888. struct3508.SecretKey = miConfig.SecretKey
  889. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  890. struct3508.Begndate = start_time
  891. struct3508.Enddate = end_time
  892. struct3508.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  893. struct3508.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  894. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  895. result1, result2 := service.Gdyb3513(struct3508, struct3508.SecretKey)
  896. saveLog(result1, result2, "3513", "3513")
  897. var res models.Result3513
  898. var respJSON2 map[string]interface{}
  899. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  900. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  902. return
  903. }
  904. userJSONBytes2, _ := json.Marshal(respJSON2)
  905. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  906. utils.ErrorLog("解析失败:%v", err)
  907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  908. return
  909. }
  910. if res.Infcode == -1 {
  911. c.ServeSuccessJSON(map[string]interface{}{
  912. "failed_code": -10,
  913. "msg": res.ErrMsg,
  914. })
  915. } else {
  916. c.ServeSuccessJSON(map[string]interface{}{
  917. "info": res.Output,
  918. })
  919. }
  920. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  921. result1, result2, _ := service.FJyb3513(struct3508)
  922. saveLog(result1, result2, "3513", "3513")
  923. var res models.Result3513
  924. var respJSON2 map[string]interface{}
  925. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  926. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  928. return
  929. }
  930. userJSONBytes2, _ := json.Marshal(respJSON2)
  931. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  932. utils.ErrorLog("解析失败:%v", err)
  933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  934. return
  935. }
  936. if res.Infcode == -1 {
  937. c.ServeSuccessJSON(map[string]interface{}{
  938. "failed_code": -10,
  939. "msg": res.ErrMsg,
  940. })
  941. } else {
  942. c.ServeSuccessJSON(map[string]interface{}{
  943. "info": res.Output,
  944. })
  945. }
  946. }
  947. }
  948. func (c *HisApiController) Get35081() {
  949. admin_user_id, _ := c.GetInt64("admin_user_id")
  950. drug_id, _ := c.GetInt64("id")
  951. //start_time := c.GetString("start_time")
  952. //end_time := c.GetString("end_time")
  953. page, _ := c.GetInt("page")
  954. adminUser := c.GetAdminUserInfo()
  955. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  956. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  957. drug, _ := service.GetDrugByID(drug_id)
  958. var struct3508 models.Struct35081
  959. struct3508.FixmedinsCode = miConfig.Code
  960. struct3508.OrgName = miConfig.OrgName
  961. struct3508.AccessKey = miConfig.AccessKey
  962. struct3508.Opter = curRoles.UserName
  963. struct3508.RequestUrl = miConfig.Url
  964. struct3508.Url = miConfig.Url
  965. struct3508.AppId = miConfig.Cainfo
  966. struct3508.AppSecret = miConfig.AppSecret
  967. struct3508.Enckey = miConfig.EncKey
  968. struct3508.SignKey = miConfig.SignKey
  969. struct3508.SecretKey = miConfig.SecretKey
  970. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  971. struct3508.PageNum = page
  972. struct3508.PageSize = 10
  973. result1, result2, _ := service.FJyb35081(struct3508)
  974. saveLog(result1, result2, "35081", "35081")
  975. var res models.Result35081
  976. var respJSON2 map[string]interface{}
  977. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  978. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  980. return
  981. }
  982. userJSONBytes2, _ := json.Marshal(respJSON2)
  983. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  984. utils.ErrorLog("解析失败:%v", err)
  985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  986. return
  987. }
  988. if res.Infcode == -1 {
  989. c.ServeSuccessJSON(map[string]interface{}{
  990. "failed_code": -10,
  991. "msg": res.ErrMsg,
  992. })
  993. } else {
  994. c.ServeSuccessJSON(map[string]interface{}{
  995. "info": res.Output,
  996. })
  997. }
  998. }
  999. func (c *HisApiController) Get35082() {
  1000. admin_user_id, _ := c.GetInt64("admin_user_id")
  1001. drug_id, _ := c.GetInt64("id")
  1002. //start_time := c.GetString("start_time")
  1003. //end_time := c.GetString("end_time")
  1004. page, _ := c.GetInt("page")
  1005. adminUser := c.GetAdminUserInfo()
  1006. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1007. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1008. drug, _ := service.GetDrugByID(drug_id)
  1009. var struct3508 models.Struct35082
  1010. struct3508.FixmedinsCode = miConfig.Code
  1011. struct3508.OrgName = miConfig.OrgName
  1012. struct3508.AccessKey = miConfig.AccessKey
  1013. struct3508.Opter = curRoles.UserName
  1014. struct3508.RequestUrl = miConfig.Url
  1015. struct3508.Url = miConfig.Url
  1016. struct3508.AppId = miConfig.Cainfo
  1017. struct3508.AppSecret = miConfig.AppSecret
  1018. struct3508.Enckey = miConfig.EncKey
  1019. struct3508.SignKey = miConfig.SignKey
  1020. struct3508.SecretKey = miConfig.SecretKey
  1021. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  1022. struct3508.PageNum = page
  1023. struct3508.PageSize = 10
  1024. result1, result2, _ := service.FJyb35082(struct3508)
  1025. saveLog(result1, result2, "35082", "35082")
  1026. var res models.Result35082
  1027. var respJSON2 map[string]interface{}
  1028. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1029. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1031. return
  1032. }
  1033. userJSONBytes2, _ := json.Marshal(respJSON2)
  1034. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1035. utils.ErrorLog("解析失败:%v", err)
  1036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1037. return
  1038. }
  1039. if res.Infcode == -1 {
  1040. c.ServeSuccessJSON(map[string]interface{}{
  1041. "failed_code": -10,
  1042. "msg": res.ErrMsg,
  1043. })
  1044. } else {
  1045. c.ServeSuccessJSON(map[string]interface{}{
  1046. "info": res.Output,
  1047. })
  1048. }
  1049. }
  1050. func IsDigit(s string) bool {
  1051. re := regexp.MustCompile("^[0-9]+$")
  1052. return re.MatchString(s)
  1053. }
  1054. func (c *HisApiController) FJ3501AND3502() {
  1055. ids := c.GetString("ids")
  1056. admin_user_id, _ := c.GetInt64("admin_user_id")
  1057. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1058. id_arr := strings.Split(ids, ",")
  1059. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1060. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1061. //规则判断
  1062. var errs []string
  1063. for _, drug := range drugs {
  1064. if drug.IsPc == 0 {
  1065. if len(drug.DrugCode) > 0 {
  1066. codes := strings.Split(drug.DrugCode, ",")
  1067. for _, code := range codes {
  1068. if len(code) > 0 {
  1069. if len(code) != 20 {
  1070. errs = append(errs, drug.BaseDrugLib.DrugName+" 溯源码"+code+"位数不是20位")
  1071. }
  1072. if IsDigit(code) == false {
  1073. errs = append(errs, drug.BaseDrugLib.DrugName+" 溯源码"+code+"不是纯数字")
  1074. }
  1075. }
  1076. }
  1077. }
  1078. }
  1079. }
  1080. if len(errs) > 0 {
  1081. c.ServeSuccessJSON(map[string]interface{}{
  1082. "failed_code": -10,
  1083. "msg": errs,
  1084. })
  1085. return
  1086. }
  1087. //库盘
  1088. for _, drug := range drugs {
  1089. if drug.IsPc == 0 {
  1090. var res2 ResultSix
  1091. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  1092. var struct3501 models.Struct3501
  1093. struct3501.Code = miConfig.Code
  1094. struct3501.OrgName = miConfig.OrgName
  1095. struct3501.AccessKey = miConfig.AccessKey
  1096. struct3501.Opter = roles.UserName
  1097. struct3501.RequestUrl = miConfig.Url
  1098. struct3501.Url = miConfig.Url
  1099. struct3501.AppId = miConfig.Cainfo
  1100. struct3501.AppSecret = miConfig.AppSecret
  1101. struct3501.Enckey = miConfig.EncKey
  1102. struct3501.SignKey = miConfig.SignKey
  1103. struct3501.SecretKey = miConfig.SecretKey
  1104. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  1105. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  1106. struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  1107. struct3501.RxFlag = "1"
  1108. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  1109. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  1110. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1111. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1112. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  1113. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  1114. struct3501.FixmedinsBchno = number
  1115. struct3501.DrugTracCodg = drug.DrugCode
  1116. memo := make(map[string]interface{})
  1117. memo["pric"] = drug.Price
  1118. bytesData, _ := json.Marshal(memo)
  1119. struct3501.Memo = string(bytesData)
  1120. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  1121. result1, result2, _ := service.FJyb3501(struct3501)
  1122. saveLog(result1, result2, "3501", "3501")
  1123. //saveLog(result, requestLog, "2201", "挂号")
  1124. var respJSON2 map[string]interface{}
  1125. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1126. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1128. return
  1129. }
  1130. userJSONBytes2, _ := json.Marshal(respJSON2)
  1131. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1132. utils.ErrorLog("解析失败:%v", err)
  1133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1134. return
  1135. }
  1136. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  1137. data := make(map[string]interface{})
  1138. data["struct_3501s"] = struct3501
  1139. client := &http.Client{}
  1140. bytesData, _ := json.Marshal(data)
  1141. var req *http.Request
  1142. if miConfig.MdtrtareaAdmvs == "320830" {
  1143. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3501", bytes.NewReader(bytesData))
  1144. } else {
  1145. if miConfig.MdtrtareaAdmvs == "320921" {
  1146. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  1147. } else {
  1148. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  1149. }
  1150. }
  1151. resp, _ := client.Do(req)
  1152. defer resp.Body.Close()
  1153. body, ioErr := ioutil.ReadAll(resp.Body)
  1154. if ioErr != nil {
  1155. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1156. }
  1157. var respJSON map[string]interface{}
  1158. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1159. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1161. return
  1162. }
  1163. var resSix10265 ResultSix10265 //1101结果
  1164. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1165. result, _ := json.Marshal(respJSON)
  1166. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1167. utils.ErrorLog("解析失败:%v", err)
  1168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1169. return
  1170. }
  1171. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1172. res2.Output = resSix10265.Output
  1173. res2.ErrMsg = resSix10265.ErrMsg
  1174. res2.Cainfo = resSix10265.Cainfo
  1175. res2.WarnMsg = resSix10265.WarnMsg
  1176. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1177. res2.Infcode = infocode
  1178. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  1179. data := make(map[string]interface{})
  1180. data["struct_3501s"] = struct3501
  1181. client := &http.Client{}
  1182. bytesData, _ := json.Marshal(data)
  1183. var req *http.Request
  1184. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  1185. resp, _ := client.Do(req)
  1186. defer resp.Body.Close()
  1187. body, ioErr := ioutil.ReadAll(resp.Body)
  1188. if ioErr != nil {
  1189. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1190. }
  1191. var respJSON map[string]interface{}
  1192. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1193. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1195. return
  1196. }
  1197. var resSix10265 ResultSix10265 //1101结果
  1198. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1199. result, _ := json.Marshal(respJSON)
  1200. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1201. utils.ErrorLog("解析失败:%v", err)
  1202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1203. return
  1204. }
  1205. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1206. res2.Output = resSix10265.Output
  1207. res2.ErrMsg = resSix10265.ErrMsg
  1208. res2.Cainfo = resSix10265.Cainfo
  1209. res2.WarnMsg = resSix10265.WarnMsg
  1210. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1211. res2.Infcode = infocode
  1212. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  1213. data := make(map[string]interface{})
  1214. data["struct_3501s"] = struct3501
  1215. client := &http.Client{}
  1216. bytesData, _ := json.Marshal(data)
  1217. var req *http.Request
  1218. req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  1219. resp, _ := client.Do(req)
  1220. defer resp.Body.Close()
  1221. body, ioErr := ioutil.ReadAll(resp.Body)
  1222. if ioErr != nil {
  1223. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1224. }
  1225. var respJSON map[string]interface{}
  1226. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1227. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1229. return
  1230. }
  1231. var resSix10265 ResultSix10265 //1101结果
  1232. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1233. result, _ := json.Marshal(respJSON)
  1234. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1235. utils.ErrorLog("解析失败:%v", err)
  1236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1237. return
  1238. }
  1239. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1240. res2.Output = resSix10265.Output
  1241. res2.ErrMsg = resSix10265.ErrMsg
  1242. res2.Cainfo = resSix10265.Cainfo
  1243. res2.WarnMsg = resSix10265.WarnMsg
  1244. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1245. res2.Infcode = infocode
  1246. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  1247. result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  1248. saveLog(result1, result2, "3501", "3501")
  1249. //saveLog(result, requestLog, "2201", "挂号")
  1250. var respJSON2 map[string]interface{}
  1251. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1252. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1254. return
  1255. }
  1256. userJSONBytes2, _ := json.Marshal(respJSON2)
  1257. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1258. utils.ErrorLog("解析失败:%v", err)
  1259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1260. return
  1261. }
  1262. }
  1263. utils.ErrorLog("解析失败:%v", res2.Infcode)
  1264. if res2.Infcode != -1 {
  1265. drug.IsPc = 1
  1266. drug.Bchno = number
  1267. drug.PcDate = time.Now().Unix()
  1268. service.SaveW(drug)
  1269. //if err == nil {
  1270. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  1271. // var struct3502 models.Struct3502
  1272. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  1273. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  1274. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  1275. // struct3502.FixmedinsCode = miConfig.Code
  1276. // struct3502.Code = miConfig.Code
  1277. //
  1278. // struct3502.RxFlag = "0"
  1279. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  1280. // struct3502.OrgName = miConfig.OrgName
  1281. // struct3502.Opter = roles.UserName
  1282. // struct3502.AccessKey = miConfig.AccessKey
  1283. // struct3502.RequestUrl = miConfig.Url
  1284. // struct3502.SecretKey = miConfig.SecretKey
  1285. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1286. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1287. // struct3502.Url = miConfig.Url
  1288. // struct3502.AppId = miConfig.Cainfo
  1289. // struct3502.AppSecret = miConfig.AppSecret
  1290. // struct3502.Enckey = miConfig.EncKey
  1291. // struct3502.SignKey = miConfig.SignKey
  1292. // struct3502.SecretKey = miConfig.SecretKey
  1293. // struct3502.DrugTracCodg = drug.DrugCode
  1294. //
  1295. // struct3502.Memo = ""
  1296. // struct3502.InvChgType = "108"
  1297. // struct3502.FixmedinsBchno = bg_number
  1298. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  1299. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  1300. //
  1301. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  1302. // result11, result22, _ := service.FJyb3502(struct3502)
  1303. // saveLog(result11, result22, "3502", "3502")
  1304. //
  1305. // var respJSON3 map[string]interface{}
  1306. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1307. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1308. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1309. // return
  1310. // }
  1311. // userJSONBytes3, _ := json.Marshal(respJSON3)
  1312. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1313. // utils.ErrorLog("解析失败:%v", err)
  1314. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1315. // return
  1316. // }
  1317. //
  1318. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  1319. // data := make(map[string]interface{})
  1320. // data["struct_3502s"] = struct3502
  1321. // client := &http.Client{}
  1322. // bytesData, _ := json.Marshal(data)
  1323. // var req *http.Request
  1324. // if miConfig.MdtrtareaAdmvs == "320830" {
  1325. // req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3502", bytes.NewReader(bytesData))
  1326. // } else if miConfig.MdtrtareaAdmvs == "320921" {
  1327. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1328. // } else {
  1329. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1330. // }
  1331. //
  1332. // resp, _ := client.Do(req)
  1333. // defer resp.Body.Close()
  1334. // body, ioErr := ioutil.ReadAll(resp.Body)
  1335. // if ioErr != nil {
  1336. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1337. // }
  1338. // var respJSON map[string]interface{}
  1339. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1340. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1341. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1342. // return
  1343. // }
  1344. // var resSix10265 ResultSix10265 //1101结果
  1345. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1346. // result, _ := json.Marshal(respJSON)
  1347. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1348. // utils.ErrorLog("解析失败:%v", err)
  1349. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1350. // return
  1351. // }
  1352. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  1353. // res3.Output = resSix10265.Output
  1354. // res3.ErrMsg = resSix10265.ErrMsg
  1355. // res3.Cainfo = resSix10265.Cainfo
  1356. // res3.WarnMsg = resSix10265.WarnMsg
  1357. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1358. // res3.Infcode = infocode
  1359. //
  1360. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  1361. //
  1362. // data := make(map[string]interface{})
  1363. // data["struct_3502s"] = struct3502
  1364. // client := &http.Client{}
  1365. // bytesData, _ := json.Marshal(data)
  1366. // var req *http.Request
  1367. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  1368. // resp, _ := client.Do(req)
  1369. // defer resp.Body.Close()
  1370. // body, ioErr := ioutil.ReadAll(resp.Body)
  1371. // if ioErr != nil {
  1372. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1373. // }
  1374. // var respJSON map[string]interface{}
  1375. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1376. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1377. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1378. // return
  1379. // }
  1380. // var resSix10265 ResultSix10265 //1101结果
  1381. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1382. // result, _ := json.Marshal(respJSON)
  1383. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1384. // utils.ErrorLog("解析失败:%v", err)
  1385. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1386. // return
  1387. // }
  1388. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  1389. // res3.Output = resSix10265.Output
  1390. // res3.ErrMsg = resSix10265.ErrMsg
  1391. // res3.Cainfo = resSix10265.Cainfo
  1392. // res3.WarnMsg = resSix10265.WarnMsg
  1393. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1394. // res3.Infcode = infocode
  1395. //
  1396. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  1397. //
  1398. // data := make(map[string]interface{})
  1399. // data["struct_3501s"] = struct3501
  1400. // client := &http.Client{}
  1401. // bytesData, _ := json.Marshal(data)
  1402. // var req *http.Request
  1403. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  1404. // resp, _ := client.Do(req)
  1405. // defer resp.Body.Close()
  1406. // body, ioErr := ioutil.ReadAll(resp.Body)
  1407. // if ioErr != nil {
  1408. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1409. // }
  1410. // var respJSON map[string]interface{}
  1411. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1412. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1413. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1414. // return
  1415. // }
  1416. // var resSix10265 ResultSix10265 //1101结果
  1417. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1418. // result, _ := json.Marshal(respJSON)
  1419. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1420. // utils.ErrorLog("解析失败:%v", err)
  1421. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1422. // return
  1423. // }
  1424. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  1425. // res2.Output = resSix10265.Output
  1426. // res2.ErrMsg = resSix10265.ErrMsg
  1427. // res2.Cainfo = resSix10265.Cainfo
  1428. // res2.WarnMsg = resSix10265.WarnMsg
  1429. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1430. // res2.Infcode = infocode
  1431. //
  1432. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  1433. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  1434. // saveLog(result11, result22, "3502", "3502")
  1435. //
  1436. // var respJSON3 map[string]interface{}
  1437. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1438. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1439. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1440. // return
  1441. // }
  1442. // userJSONBytes3, _ := json.Marshal(respJSON3)
  1443. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1444. // utils.ErrorLog("解析失败:%v", err)
  1445. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1446. // return
  1447. // }
  1448. // }
  1449. // if res3.Infcode == -1 {
  1450. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  1451. // c.ServeSuccessJSON(map[string]interface{}{
  1452. // "failed_code": -10,
  1453. // "msg": res3.ErrMsg,
  1454. // })
  1455. // } else {
  1456. // drug.IsBg = 1
  1457. // drug.BgBchno = bg_number
  1458. // service.SaveW(drug)
  1459. // }
  1460. //}
  1461. //} else {
  1462. } else {
  1463. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  1464. }
  1465. }
  1466. //变更
  1467. }
  1468. if len(errs) == 0 {
  1469. c.ServeSuccessJSON(map[string]interface{}{
  1470. "msg": "盘存变更成功",
  1471. })
  1472. } else {
  1473. c.ServeSuccessJSON(map[string]interface{}{
  1474. "failed_code": -10,
  1475. "msg": errs,
  1476. })
  1477. }
  1478. }
  1479. func (c *HisApiController) DeletePCandBG() {
  1480. ids := c.GetString("ids")
  1481. id_arr := strings.Split(ids, ",")
  1482. admin_user_id, _ := c.GetInt64("admin_user_id")
  1483. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1484. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1485. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1486. var err []string
  1487. for _, item := range drugs {
  1488. if item.IsPc == 1 {
  1489. var res FJ3507Result
  1490. var struct3507 models.Struct3507
  1491. struct3507.FixmedinsBchno = item.Bchno
  1492. struct3507.InvDataType = "1"
  1493. struct3507.Opter = roles.UserName
  1494. struct3507.OrgName = miConfig.OrgName
  1495. struct3507.AccessKey = miConfig.AccessKey
  1496. struct3507.RequestUrl = miConfig.Url
  1497. struct3507.FixmedinsCode = miConfig.Code
  1498. struct3507.Code = miConfig.Code
  1499. struct3507.SecretKey = miConfig.SecretKey
  1500. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1501. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1502. struct3507.Url = miConfig.Url
  1503. struct3507.AppId = miConfig.Cainfo
  1504. struct3507.AppSecret = miConfig.AppSecret
  1505. struct3507.Enckey = miConfig.EncKey
  1506. struct3507.SignKey = miConfig.SignKey
  1507. struct3507.SecretKey = miConfig.SecretKey
  1508. if miConfig.MdtrtareaAdmvs == "350500" {
  1509. result, result1, _ := service.FJyb3507(struct3507)
  1510. saveLog(result, result1, "3507", "3507")
  1511. var respJSON2 map[string]interface{}
  1512. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1513. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1515. return
  1516. }
  1517. userJSONBytes2, _ := json.Marshal(respJSON2)
  1518. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1519. utils.ErrorLog("解析失败:%v", err)
  1520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1521. return
  1522. }
  1523. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  1524. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  1525. saveLog(result2, result1, "3507", "3507")
  1526. var respJSON2 map[string]interface{}
  1527. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1528. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1530. return
  1531. }
  1532. userJSONBytes2, _ := json.Marshal(respJSON2)
  1533. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1534. utils.ErrorLog("解析失败:%v", err)
  1535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1536. return
  1537. }
  1538. } else {
  1539. data := make(map[string]interface{})
  1540. data["struct_3507s"] = struct3507
  1541. client := &http.Client{}
  1542. bytesData, _ := json.Marshal(data)
  1543. var req *http.Request
  1544. if miConfig.MdtrtareaAdmvs == "320830" {
  1545. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1546. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1547. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1548. } else {
  1549. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1550. }
  1551. resp, _ := client.Do(req)
  1552. defer resp.Body.Close()
  1553. body, ioErr := ioutil.ReadAll(resp.Body)
  1554. if ioErr != nil {
  1555. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1556. }
  1557. var respJSON map[string]interface{}
  1558. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1559. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1561. return
  1562. }
  1563. var resSix10265 ResultSix10265 //1101结果
  1564. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1565. result, _ := json.Marshal(respJSON)
  1566. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1567. utils.ErrorLog("解析失败:%v", err)
  1568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1569. return
  1570. }
  1571. res.InfRefmsgid = resSix10265.InfRefmsgid
  1572. //res.Output = resSix10265.Output
  1573. res.ErrMsg = resSix10265.ErrMsg
  1574. res.Cainfo = resSix10265.Cainfo
  1575. res.WarnMsg = resSix10265.WarnMsg
  1576. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1577. res.Infcode = infocode
  1578. }
  1579. if res.Infcode == 0 {
  1580. item.IsPc = 0
  1581. service.SaveW(item)
  1582. } else {
  1583. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1584. }
  1585. }
  1586. }
  1587. if len(err) == 0 {
  1588. c.ServeSuccessJSON(map[string]interface{}{
  1589. "msg": "删除盘存变更成功",
  1590. })
  1591. } else {
  1592. c.ServeSuccessJSON(map[string]interface{}{
  1593. "failed_code": -10,
  1594. "msg": err,
  1595. })
  1596. }
  1597. }
  1598. func (c *HisApiController) DeleteXSandBG() {
  1599. ids := c.GetString("ids")
  1600. id_arr := strings.Split(ids, ",")
  1601. admin_user_id, _ := c.GetInt64("admin_user_id")
  1602. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1603. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1604. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1605. var err []string
  1606. for _, item := range flows {
  1607. if item.IsSale == 1 && item.IsChange == 1 {
  1608. var res FJ3507Result
  1609. var res2 FJ3507Result
  1610. var struct3507 models.Struct3507
  1611. struct3507.FixmedinsBchno = item.Bchno
  1612. struct3507.InvDataType = "4"
  1613. struct3507.Opter = roles.UserName
  1614. struct3507.OrgName = miConfig.OrgName
  1615. struct3507.AccessKey = miConfig.AccessKey
  1616. struct3507.RequestUrl = miConfig.Url
  1617. struct3507.FixmedinsCode = miConfig.Code
  1618. struct3507.SecretKey = miConfig.SecretKey
  1619. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1620. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1621. struct3507.Url = miConfig.Url
  1622. struct3507.AppId = miConfig.Cainfo
  1623. struct3507.AppSecret = miConfig.AppSecret
  1624. struct3507.Enckey = miConfig.EncKey
  1625. struct3507.SignKey = miConfig.SignKey
  1626. struct3507.SecretKey = miConfig.SecretKey
  1627. //result, result1, _ := service.FJyb3507(struct3507)
  1628. //saveLog(result, result1, "3507", "3507")
  1629. if miConfig.MdtrtareaAdmvs == "350500" {
  1630. result, result1, _ := service.FJyb3507(struct3507)
  1631. saveLog(result, result1, "3507", "3507")
  1632. var respJSON2 map[string]interface{}
  1633. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1634. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1636. return
  1637. }
  1638. userJSONBytes2, _ := json.Marshal(respJSON2)
  1639. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1640. utils.ErrorLog("解析失败:%v", err)
  1641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1642. return
  1643. }
  1644. } else {
  1645. data := make(map[string]interface{})
  1646. data["struct_3507s"] = struct3507
  1647. client := &http.Client{}
  1648. bytesData, _ := json.Marshal(data)
  1649. var req *http.Request
  1650. if miConfig.MdtrtareaAdmvs == "320830" {
  1651. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1652. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1653. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1654. } else {
  1655. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1656. }
  1657. resp, _ := client.Do(req)
  1658. defer resp.Body.Close()
  1659. body, ioErr := ioutil.ReadAll(resp.Body)
  1660. if ioErr != nil {
  1661. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1662. }
  1663. var respJSON map[string]interface{}
  1664. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1665. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1667. return
  1668. }
  1669. var resSix10265 ResultSix10265 //1101结果
  1670. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1671. result, _ := json.Marshal(respJSON)
  1672. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1673. utils.ErrorLog("解析失败:%v", err)
  1674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1675. return
  1676. }
  1677. res.InfRefmsgid = resSix10265.InfRefmsgid
  1678. //res.Output = resSix10265.Output
  1679. res.ErrMsg = resSix10265.ErrMsg
  1680. res.Cainfo = resSix10265.Cainfo
  1681. res.WarnMsg = resSix10265.WarnMsg
  1682. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1683. res.Infcode = infocode
  1684. }
  1685. if res.Infcode == 0 {
  1686. item.IsSale = 0
  1687. item.SaleDate = ""
  1688. item.Bchno = ""
  1689. err2 := service.SaveDF(item)
  1690. if err2 == nil {
  1691. var struct3507_2 models.Struct3507
  1692. struct3507_2.OrgName = miConfig.OrgName
  1693. struct3507_2.AccessKey = miConfig.AccessKey
  1694. struct3507_2.RequestUrl = miConfig.Url
  1695. struct3507_2.Opter = roles.UserName
  1696. struct3507_2.FixmedinsCode = miConfig.Code
  1697. struct3507_2.Code = miConfig.Code
  1698. struct3507_2.SecretKey = miConfig.SecretKey
  1699. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1700. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1701. struct3507_2.Url = miConfig.Url
  1702. struct3507_2.AppId = miConfig.Cainfo
  1703. struct3507_2.AppSecret = miConfig.AppSecret
  1704. struct3507_2.Enckey = miConfig.EncKey
  1705. struct3507_2.SignKey = miConfig.SignKey
  1706. struct3507_2.SecretKey = miConfig.SecretKey
  1707. struct3507_2.FixmedinsBchno = item.BgBchno
  1708. struct3507_2.InvDataType = "2"
  1709. if miConfig.MdtrtareaAdmvs == "350500" {
  1710. result11, result22, _ := service.FJyb3507(struct3507_2)
  1711. saveLog(result11, result22, "3507", "3507")
  1712. var respJSON3 map[string]interface{}
  1713. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1714. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1716. return
  1717. }
  1718. userJSONBytes3, _ := json.Marshal(respJSON3)
  1719. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1720. utils.ErrorLog("解析失败:%v", err)
  1721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1722. return
  1723. }
  1724. } else {
  1725. data := make(map[string]interface{})
  1726. data["struct_3507s"] = struct3507_2
  1727. client := &http.Client{}
  1728. bytesData, _ := json.Marshal(data)
  1729. var req *http.Request
  1730. if miConfig.MdtrtareaAdmvs == "320830" {
  1731. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1732. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1733. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1734. } else {
  1735. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1736. }
  1737. resp, _ := client.Do(req)
  1738. defer resp.Body.Close()
  1739. body, ioErr := ioutil.ReadAll(resp.Body)
  1740. if ioErr != nil {
  1741. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1742. }
  1743. var respJSON map[string]interface{}
  1744. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1745. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1747. return
  1748. }
  1749. var resSix10265 ResultSix10265 //1101结果
  1750. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1751. result, _ := json.Marshal(respJSON)
  1752. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1753. utils.ErrorLog("解析失败:%v", err)
  1754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1755. return
  1756. }
  1757. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1758. //res.Output = resSix10265.Output
  1759. res2.ErrMsg = resSix10265.ErrMsg
  1760. res2.Cainfo = resSix10265.Cainfo
  1761. res2.WarnMsg = resSix10265.WarnMsg
  1762. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1763. res2.Infcode = infocode
  1764. }
  1765. if res2.Infcode == 0 {
  1766. item.IsChange = 0
  1767. item.BgBchno = ""
  1768. service.SaveDF2(item)
  1769. } else {
  1770. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1771. }
  1772. }
  1773. } else {
  1774. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1775. }
  1776. }
  1777. if item.IsSale == 2 && item.IsChange == 1 {
  1778. var res FJ3507Result
  1779. var res2 FJ3507Result
  1780. var struct3507 models.Struct3507
  1781. struct3507.FixmedinsBchno = item.Bchno
  1782. struct3507.InvDataType = "4"
  1783. struct3507.Opter = roles.UserName
  1784. struct3507.OrgName = miConfig.OrgName
  1785. struct3507.AccessKey = miConfig.AccessKey
  1786. struct3507.RequestUrl = miConfig.Url
  1787. struct3507.FixmedinsCode = miConfig.Code
  1788. struct3507.Code = miConfig.Code
  1789. struct3507.SecretKey = miConfig.SecretKey
  1790. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1791. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1792. struct3507.Url = miConfig.Url
  1793. struct3507.AppId = miConfig.Cainfo
  1794. struct3507.AppSecret = miConfig.AppSecret
  1795. struct3507.Enckey = miConfig.EncKey
  1796. struct3507.SignKey = miConfig.SignKey
  1797. struct3507.SecretKey = miConfig.SecretKey
  1798. //result, result1, _ := service.FJyb3507(struct3507)
  1799. //saveLog(result, result1, "3507", "3507")
  1800. //
  1801. //var respJSON2 map[string]interface{}
  1802. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1803. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1804. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1805. // return
  1806. //}
  1807. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1808. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1809. // utils.ErrorLog("解析失败:%v", err)
  1810. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1811. // return
  1812. //}
  1813. if miConfig.MdtrtareaAdmvs == "350500" {
  1814. result, result1, _ := service.FJyb3507(struct3507)
  1815. saveLog(result, result1, "3507", "3507")
  1816. var respJSON2 map[string]interface{}
  1817. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1818. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1820. return
  1821. }
  1822. userJSONBytes2, _ := json.Marshal(respJSON2)
  1823. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1824. utils.ErrorLog("解析失败:%v", err)
  1825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1826. return
  1827. }
  1828. } else {
  1829. data := make(map[string]interface{})
  1830. data["struct_3507s"] = struct3507
  1831. client := &http.Client{}
  1832. bytesData, _ := json.Marshal(data)
  1833. var req *http.Request
  1834. if miConfig.MdtrtareaAdmvs == "320830" {
  1835. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1836. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1837. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1838. } else {
  1839. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1840. }
  1841. resp, _ := client.Do(req)
  1842. defer resp.Body.Close()
  1843. body, ioErr := ioutil.ReadAll(resp.Body)
  1844. if ioErr != nil {
  1845. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1846. }
  1847. var respJSON map[string]interface{}
  1848. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1849. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1851. return
  1852. }
  1853. var resSix10265 ResultSix10265 //1101结果
  1854. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1855. result, _ := json.Marshal(respJSON)
  1856. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1857. utils.ErrorLog("解析失败:%v", err)
  1858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1859. return
  1860. }
  1861. res.InfRefmsgid = resSix10265.InfRefmsgid
  1862. //res.Output = resSix10265.Output
  1863. res.ErrMsg = resSix10265.ErrMsg
  1864. res.Cainfo = resSix10265.Cainfo
  1865. res.WarnMsg = resSix10265.WarnMsg
  1866. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1867. res.Infcode = infocode
  1868. }
  1869. if res.Infcode == 0 {
  1870. item.IsSale = 0
  1871. item.SaleDate = ""
  1872. item.Bchno = ""
  1873. err2 := service.SaveDF(item)
  1874. if err2 == nil {
  1875. var struct3507_2 models.Struct3507
  1876. struct3507_2.OrgName = miConfig.OrgName
  1877. struct3507_2.AccessKey = miConfig.AccessKey
  1878. struct3507_2.RequestUrl = miConfig.Url
  1879. struct3507_2.Opter = roles.UserName
  1880. struct3507_2.FixmedinsCode = miConfig.Code
  1881. struct3507_2.Code = miConfig.Code
  1882. struct3507_2.SecretKey = miConfig.SecretKey
  1883. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1884. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1885. struct3507_2.Url = miConfig.Url
  1886. struct3507_2.AppId = miConfig.Cainfo
  1887. struct3507_2.AppSecret = miConfig.AppSecret
  1888. struct3507_2.Enckey = miConfig.EncKey
  1889. struct3507_2.SignKey = miConfig.SignKey
  1890. struct3507_2.SecretKey = miConfig.SecretKey
  1891. struct3507_2.FixmedinsBchno = item.BgBchno
  1892. struct3507_2.InvDataType = "2"
  1893. //result11, result22, _ := service.FJyb3507(struct3507_2)
  1894. //saveLog(result11, result22, "3507", "3507")
  1895. //var respJSON3 map[string]interface{}
  1896. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1897. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1898. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1899. // return
  1900. //}
  1901. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1902. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1903. // utils.ErrorLog("解析失败:%v", err)
  1904. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1905. // return
  1906. //}
  1907. if miConfig.MdtrtareaAdmvs == "350500" {
  1908. result11, result22, _ := service.FJyb3507(struct3507_2)
  1909. saveLog(result11, result22, "3507", "3507")
  1910. var respJSON3 map[string]interface{}
  1911. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1912. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1914. return
  1915. }
  1916. userJSONBytes3, _ := json.Marshal(respJSON3)
  1917. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1918. utils.ErrorLog("解析失败:%v", err)
  1919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1920. return
  1921. }
  1922. } else {
  1923. data := make(map[string]interface{})
  1924. data["struct_3507s"] = struct3507_2
  1925. client := &http.Client{}
  1926. bytesData, _ := json.Marshal(data)
  1927. var req *http.Request
  1928. if miConfig.MdtrtareaAdmvs == "320830" {
  1929. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1930. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1931. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1932. } else {
  1933. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1934. }
  1935. resp, _ := client.Do(req)
  1936. defer resp.Body.Close()
  1937. body, ioErr := ioutil.ReadAll(resp.Body)
  1938. if ioErr != nil {
  1939. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1940. }
  1941. var respJSON map[string]interface{}
  1942. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1943. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1945. return
  1946. }
  1947. var resSix10265 ResultSix10265 //1101结果
  1948. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1949. result, _ := json.Marshal(respJSON)
  1950. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1951. utils.ErrorLog("解析失败:%v", err)
  1952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1953. return
  1954. }
  1955. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1956. //res.Output = resSix10265.Output
  1957. res2.ErrMsg = resSix10265.ErrMsg
  1958. res2.Cainfo = resSix10265.Cainfo
  1959. res2.WarnMsg = resSix10265.WarnMsg
  1960. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1961. res2.Infcode = infocode
  1962. }
  1963. if res2.Infcode == 0 {
  1964. item.IsChange = 0
  1965. item.BgBchno = ""
  1966. service.SaveDF2(item)
  1967. } else {
  1968. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1969. }
  1970. }
  1971. } else {
  1972. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1973. }
  1974. }
  1975. if item.IsSale == 1 && item.IsChange == 0 {
  1976. var res FJ3507Result
  1977. var struct3507 models.Struct3507
  1978. struct3507.FixmedinsBchno = item.Bchno
  1979. struct3507.InvDataType = "4"
  1980. struct3507.Opter = roles.UserName
  1981. struct3507.FixmedinsCode = miConfig.Code
  1982. struct3507.Code = miConfig.Code
  1983. struct3507.OrgName = miConfig.OrgName
  1984. struct3507.AccessKey = miConfig.AccessKey
  1985. struct3507.RequestUrl = miConfig.Url
  1986. struct3507.SecretKey = miConfig.SecretKey
  1987. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1988. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1989. struct3507.Url = miConfig.Url
  1990. struct3507.AppId = miConfig.Cainfo
  1991. struct3507.AppSecret = miConfig.AppSecret
  1992. struct3507.Enckey = miConfig.EncKey
  1993. struct3507.SignKey = miConfig.SignKey
  1994. struct3507.SecretKey = miConfig.SecretKey
  1995. //result, result1, _ := service.FJyb3507(struct3507)
  1996. //saveLog(result, result1, "3507", "3507")
  1997. //
  1998. //var respJSON3 map[string]interface{}
  1999. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2000. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2001. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2002. // return
  2003. //}
  2004. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2005. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2006. // utils.ErrorLog("解析失败:%v", err)
  2007. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2008. // return
  2009. //}
  2010. if miConfig.MdtrtareaAdmvs == "350500" {
  2011. result, result1, _ := service.FJyb3507(struct3507)
  2012. saveLog(result, result1, "3507", "3507")
  2013. var respJSON2 map[string]interface{}
  2014. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2015. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2017. return
  2018. }
  2019. userJSONBytes2, _ := json.Marshal(respJSON2)
  2020. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2021. utils.ErrorLog("解析失败:%v", err)
  2022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2023. return
  2024. }
  2025. } else {
  2026. data := make(map[string]interface{})
  2027. data["struct_3507s"] = struct3507
  2028. client := &http.Client{}
  2029. bytesData, _ := json.Marshal(data)
  2030. var req *http.Request
  2031. if miConfig.MdtrtareaAdmvs == "320830" {
  2032. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2033. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2034. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2035. } else {
  2036. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2037. }
  2038. resp, _ := client.Do(req)
  2039. defer resp.Body.Close()
  2040. body, ioErr := ioutil.ReadAll(resp.Body)
  2041. if ioErr != nil {
  2042. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2043. }
  2044. var respJSON map[string]interface{}
  2045. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2046. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2048. return
  2049. }
  2050. var resSix10265 ResultSix10265 //1101结果
  2051. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2052. result, _ := json.Marshal(respJSON)
  2053. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2054. utils.ErrorLog("解析失败:%v", err)
  2055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2056. return
  2057. }
  2058. res.InfRefmsgid = resSix10265.InfRefmsgid
  2059. //res.Output = resSix10265.Output
  2060. res.ErrMsg = resSix10265.ErrMsg
  2061. res.Cainfo = resSix10265.Cainfo
  2062. res.WarnMsg = resSix10265.WarnMsg
  2063. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2064. res.Infcode = infocode
  2065. }
  2066. if res.Infcode == 0 {
  2067. item.IsSale = 0
  2068. item.SaleDate = ""
  2069. service.SaveDF(item)
  2070. } else {
  2071. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2072. }
  2073. }
  2074. if item.IsSale == 2 && item.IsChange == 0 {
  2075. var res FJ3507Result
  2076. var struct3507 models.Struct3507
  2077. struct3507.FixmedinsBchno = item.Bchno
  2078. struct3507.InvDataType = "4"
  2079. struct3507.Opter = roles.UserName
  2080. struct3507.FixmedinsCode = miConfig.Code
  2081. struct3507.Code = miConfig.Code
  2082. struct3507.OrgName = miConfig.OrgName
  2083. struct3507.AccessKey = miConfig.AccessKey
  2084. struct3507.RequestUrl = miConfig.Url
  2085. struct3507.SecretKey = miConfig.SecretKey
  2086. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2087. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2088. struct3507.Url = miConfig.Url
  2089. struct3507.AppId = miConfig.Cainfo
  2090. struct3507.AppSecret = miConfig.AppSecret
  2091. struct3507.Enckey = miConfig.EncKey
  2092. struct3507.SignKey = miConfig.SignKey
  2093. struct3507.SecretKey = miConfig.SecretKey
  2094. //result, result1, _ := service.FJyb3507(struct3507)
  2095. //saveLog(result, result1, "3507", "3507")
  2096. //
  2097. //var respJSON3 map[string]interface{}
  2098. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2099. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2100. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2101. // return
  2102. //}
  2103. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2104. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2105. // utils.ErrorLog("解析失败:%v", err)
  2106. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2107. // return
  2108. //}
  2109. if miConfig.MdtrtareaAdmvs == "350500" {
  2110. result, result1, _ := service.FJyb3507(struct3507)
  2111. saveLog(result, result1, "3507", "3507")
  2112. var respJSON2 map[string]interface{}
  2113. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2114. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2116. return
  2117. }
  2118. userJSONBytes2, _ := json.Marshal(respJSON2)
  2119. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2120. utils.ErrorLog("解析失败:%v", err)
  2121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2122. return
  2123. }
  2124. } else {
  2125. data := make(map[string]interface{})
  2126. data["struct_3507s"] = struct3507
  2127. client := &http.Client{}
  2128. bytesData, _ := json.Marshal(data)
  2129. var req *http.Request
  2130. if miConfig.MdtrtareaAdmvs == "320830" {
  2131. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2132. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2133. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2134. } else {
  2135. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2136. }
  2137. resp, _ := client.Do(req)
  2138. defer resp.Body.Close()
  2139. body, ioErr := ioutil.ReadAll(resp.Body)
  2140. if ioErr != nil {
  2141. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2142. }
  2143. var respJSON map[string]interface{}
  2144. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2145. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2147. return
  2148. }
  2149. var resSix10265 ResultSix10265 //1101结果
  2150. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2151. result, _ := json.Marshal(respJSON)
  2152. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2153. utils.ErrorLog("解析失败:%v", err)
  2154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2155. return
  2156. }
  2157. res.InfRefmsgid = resSix10265.InfRefmsgid
  2158. //res.Output = resSix10265.Output
  2159. res.ErrMsg = resSix10265.ErrMsg
  2160. res.Cainfo = resSix10265.Cainfo
  2161. res.WarnMsg = resSix10265.WarnMsg
  2162. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2163. res.Infcode = infocode
  2164. }
  2165. if res.Infcode == 0 {
  2166. item.IsSale = 0
  2167. item.SaleDate = ""
  2168. item.Bchno = ""
  2169. service.SaveDF(item)
  2170. } else {
  2171. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2172. }
  2173. }
  2174. if item.IsSale == 0 && item.IsChange == 1 {
  2175. var res FJ3507Result
  2176. var struct3507 models.Struct3507
  2177. struct3507.FixmedinsBchno = item.BgBchno
  2178. struct3507.InvDataType = "2"
  2179. struct3507.Opter = roles.UserName
  2180. struct3507.FixmedinsCode = miConfig.Code
  2181. struct3507.Code = miConfig.Code
  2182. struct3507.OrgName = miConfig.OrgName
  2183. struct3507.AccessKey = miConfig.AccessKey
  2184. struct3507.RequestUrl = miConfig.Url
  2185. struct3507.SecretKey = miConfig.SecretKey
  2186. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2187. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2188. struct3507.Url = miConfig.Url
  2189. struct3507.AppId = miConfig.Cainfo
  2190. struct3507.AppSecret = miConfig.AppSecret
  2191. struct3507.Enckey = miConfig.EncKey
  2192. struct3507.SignKey = miConfig.SignKey
  2193. struct3507.SecretKey = miConfig.SecretKey
  2194. //result, result1, _ := service.FJyb3507(struct3507)
  2195. //saveLog(result, result1, "3507", "3507")
  2196. //
  2197. //var respJSON3 map[string]interface{}
  2198. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2199. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2200. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2201. // return
  2202. //}
  2203. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2204. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2205. // utils.ErrorLog("解析失败:%v", err)
  2206. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2207. // return
  2208. //}
  2209. if miConfig.MdtrtareaAdmvs == "350500" {
  2210. result, result1, _ := service.FJyb3507(struct3507)
  2211. saveLog(result, result1, "3507", "3507")
  2212. var respJSON2 map[string]interface{}
  2213. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2214. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2216. return
  2217. }
  2218. userJSONBytes2, _ := json.Marshal(respJSON2)
  2219. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2220. utils.ErrorLog("解析失败:%v", err)
  2221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2222. return
  2223. }
  2224. } else {
  2225. data := make(map[string]interface{})
  2226. data["struct_3507s"] = struct3507
  2227. client := &http.Client{}
  2228. bytesData, _ := json.Marshal(data)
  2229. var req *http.Request
  2230. if miConfig.MdtrtareaAdmvs == "320830" {
  2231. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2232. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2233. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2234. } else {
  2235. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2236. }
  2237. resp, _ := client.Do(req)
  2238. defer resp.Body.Close()
  2239. body, ioErr := ioutil.ReadAll(resp.Body)
  2240. if ioErr != nil {
  2241. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2242. }
  2243. var respJSON map[string]interface{}
  2244. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2245. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2247. return
  2248. }
  2249. var resSix10265 ResultSix10265 //1101结果
  2250. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2251. result, _ := json.Marshal(respJSON)
  2252. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2253. utils.ErrorLog("解析失败:%v", err)
  2254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2255. return
  2256. }
  2257. res.InfRefmsgid = resSix10265.InfRefmsgid
  2258. //res.Output = resSix10265.Output
  2259. res.ErrMsg = resSix10265.ErrMsg
  2260. res.Cainfo = resSix10265.Cainfo
  2261. res.WarnMsg = resSix10265.WarnMsg
  2262. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2263. res.Infcode = infocode
  2264. }
  2265. if res.Infcode == 0 {
  2266. item.IsChange = 0
  2267. item.BgBchno = ""
  2268. service.SaveDF2(item)
  2269. } else {
  2270. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2271. }
  2272. }
  2273. }
  2274. if len(err) == 0 {
  2275. c.ServeSuccessJSON(map[string]interface{}{
  2276. "msg": "删除销售变更成功",
  2277. })
  2278. } else {
  2279. c.ServeSuccessJSON(map[string]interface{}{
  2280. "failed_code": -10,
  2281. "msg": err,
  2282. })
  2283. }
  2284. }
  2285. //func (c *HisApiController) BatchFJ3501AND3502() {
  2286. // //ids := c.GetString("ids")
  2287. // start_time := c.GetString("start_time")
  2288. // end_time := c.GetString("end_time")
  2289. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2290. //
  2291. //
  2292. // timeLayout := "2006-01-02"
  2293. // loc, _ := time.LoadLocation("Local")
  2294. // startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  2295. // endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  2296. //
  2297. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2298. // //id_arr := strings.Split(ids, ",")
  2299. // drugs, _ := service.GetNewDrugWarehouseInfobytime(c.GetAdminUserInfo().CurrentOrgId, startime,endtime)
  2300. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2301. // //库盘
  2302. // var errs []string
  2303. // for _, drug := range drugs {
  2304. // if drug.IsPc == 0 && drug.IsBg == 0 {
  2305. // var res2 ResultSix
  2306. // var res3 ResultSix
  2307. //
  2308. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  2309. // var struct3501 models.Struct3501
  2310. // struct3501.Code = miConfig.Code
  2311. // struct3501.OrgName = miConfig.OrgName
  2312. // struct3501.AccessKey = miConfig.AccessKey
  2313. // struct3501.Opter = roles.UserName
  2314. // struct3501.RequestUrl = miConfig.Url
  2315. // struct3501.Url = miConfig.Url
  2316. // struct3501.AppId = miConfig.Cainfo
  2317. // struct3501.AppSecret = miConfig.AppSecret
  2318. // struct3501.Enckey = miConfig.EncKey
  2319. // struct3501.SignKey = miConfig.SignKey
  2320. // struct3501.SecretKey = miConfig.SecretKey
  2321. // struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2322. // struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2323. // struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2324. // struct3501.RxFlag = "1"
  2325. // struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  2326. // struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  2327. //
  2328. // struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2329. // struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2330. // struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  2331. // struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  2332. // struct3501.FixmedinsBchno = number
  2333. // struct3501.DrugTracCodg = drug.DrugCode
  2334. // memo := make(map[string]interface{})
  2335. // memo["pric"] = drug.Price
  2336. // bytesData, _ := json.Marshal(memo)
  2337. // struct3501.Memo = string(bytesData)
  2338. //
  2339. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  2340. //
  2341. // result1, result2, _ := service.FJyb3501(struct3501)
  2342. // saveLog(result1, result2, "3501", "3501")
  2343. // //saveLog(result, requestLog, "2201", "挂号")
  2344. //
  2345. // var respJSON2 map[string]interface{}
  2346. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2347. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2348. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2349. // return
  2350. // }
  2351. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2352. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2353. // utils.ErrorLog("解析失败:%v", err)
  2354. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2355. // return
  2356. // }
  2357. //
  2358. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  2359. // data := make(map[string]interface{})
  2360. // data["struct_3501s"] = struct3501
  2361. // client := &http.Client{}
  2362. // bytesData, _ := json.Marshal(data)
  2363. // var req *http.Request
  2364. // if miConfig.MdtrtareaAdmvs == "320921" {
  2365. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2366. // } else {
  2367. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2368. // }
  2369. //
  2370. // resp, _ := client.Do(req)
  2371. // defer resp.Body.Close()
  2372. // body, ioErr := ioutil.ReadAll(resp.Body)
  2373. // if ioErr != nil {
  2374. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2375. // }
  2376. // var respJSON map[string]interface{}
  2377. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2378. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2379. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2380. // return
  2381. // }
  2382. // var resSix10265 ResultSix10265 //1101结果
  2383. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2384. // result, _ := json.Marshal(respJSON)
  2385. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2386. // utils.ErrorLog("解析失败:%v", err)
  2387. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2388. // return
  2389. // }
  2390. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2391. // res2.Output = resSix10265.Output
  2392. // res2.ErrMsg = resSix10265.ErrMsg
  2393. // res2.Cainfo = resSix10265.Cainfo
  2394. // res2.WarnMsg = resSix10265.WarnMsg
  2395. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2396. // res2.Infcode = infocode
  2397. //
  2398. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  2399. // data := make(map[string]interface{})
  2400. // data["struct_3501s"] = struct3501
  2401. // client := &http.Client{}
  2402. // bytesData, _ := json.Marshal(data)
  2403. // var req *http.Request
  2404. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2405. // resp, _ := client.Do(req)
  2406. // defer resp.Body.Close()
  2407. // body, ioErr := ioutil.ReadAll(resp.Body)
  2408. // if ioErr != nil {
  2409. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2410. // }
  2411. // var respJSON map[string]interface{}
  2412. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2413. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2414. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2415. // return
  2416. // }
  2417. // var resSix10265 ResultSix10265 //1101结果
  2418. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2419. // result, _ := json.Marshal(respJSON)
  2420. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2421. // utils.ErrorLog("解析失败:%v", err)
  2422. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2423. // return
  2424. // }
  2425. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2426. // res2.Output = resSix10265.Output
  2427. // res2.ErrMsg = resSix10265.ErrMsg
  2428. // res2.Cainfo = resSix10265.Cainfo
  2429. // res2.WarnMsg = resSix10265.WarnMsg
  2430. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2431. // res2.Infcode = infocode
  2432. //
  2433. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  2434. // data := make(map[string]interface{})
  2435. // data["struct_3501s"] = struct3501
  2436. // client := &http.Client{}
  2437. // bytesData, _ := json.Marshal(data)
  2438. // var req *http.Request
  2439. // req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  2440. // resp, _ := client.Do(req)
  2441. // defer resp.Body.Close()
  2442. // body, ioErr := ioutil.ReadAll(resp.Body)
  2443. // if ioErr != nil {
  2444. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2445. // }
  2446. // var respJSON map[string]interface{}
  2447. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2448. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2449. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2450. // return
  2451. // }
  2452. // var resSix10265 ResultSix10265 //1101结果
  2453. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2454. // result, _ := json.Marshal(respJSON)
  2455. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2456. // utils.ErrorLog("解析失败:%v", err)
  2457. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2458. // return
  2459. // }
  2460. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2461. // res2.Output = resSix10265.Output
  2462. // res2.ErrMsg = resSix10265.ErrMsg
  2463. // res2.Cainfo = resSix10265.Cainfo
  2464. // res2.WarnMsg = resSix10265.WarnMsg
  2465. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2466. // res2.Infcode = infocode
  2467. //
  2468. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  2469. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2470. // saveLog(result1, result2, "3501", "3501")
  2471. // //saveLog(result, requestLog, "2201", "挂号")
  2472. //
  2473. // var respJSON2 map[string]interface{}
  2474. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2475. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2476. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2477. // return
  2478. // }
  2479. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2480. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2481. // utils.ErrorLog("解析失败:%v", err)
  2482. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2483. // return
  2484. // }
  2485. //
  2486. // }
  2487. //
  2488. // if res2.Infcode != -1 {
  2489. // drug.IsPc = 1
  2490. // drug.Bchno = number
  2491. // drug.PcDate = time.Now().Unix()
  2492. // err := service.SaveW(drug)
  2493. // if err == nil {
  2494. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2495. // var struct3502 models.Struct3502
  2496. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2497. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2498. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2499. // struct3502.FixmedinsCode = miConfig.Code
  2500. // struct3502.Code = miConfig.Code
  2501. //
  2502. // struct3502.RxFlag = "0"
  2503. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2504. // struct3502.OrgName = miConfig.OrgName
  2505. // struct3502.Opter = roles.UserName
  2506. // struct3502.AccessKey = miConfig.AccessKey
  2507. // struct3502.RequestUrl = miConfig.Url
  2508. // struct3502.SecretKey = miConfig.SecretKey
  2509. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2510. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2511. // struct3502.Url = miConfig.Url
  2512. // struct3502.AppId = miConfig.Cainfo
  2513. // struct3502.AppSecret = miConfig.AppSecret
  2514. // struct3502.Enckey = miConfig.EncKey
  2515. // struct3502.SignKey = miConfig.SignKey
  2516. // struct3502.SecretKey = miConfig.SecretKey
  2517. // struct3502.DrugTracCodg = drug.DrugCode
  2518. //
  2519. // struct3502.Memo = ""
  2520. // struct3502.InvChgType = "108"
  2521. // struct3502.FixmedinsBchno = bg_number
  2522. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2523. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2524. //
  2525. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2526. // result11, result22, _ := service.FJyb3502(struct3502)
  2527. // saveLog(result11, result22, "3502", "3502")
  2528. //
  2529. // var respJSON3 map[string]interface{}
  2530. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2531. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2532. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2533. // return
  2534. // }
  2535. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2536. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2537. // utils.ErrorLog("解析失败:%v", err)
  2538. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2539. // return
  2540. // }
  2541. //
  2542. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2543. // data := make(map[string]interface{})
  2544. // data["struct_3502s"] = struct3502
  2545. // client := &http.Client{}
  2546. // bytesData, _ := json.Marshal(data)
  2547. // var req *http.Request
  2548. // if miConfig.MdtrtareaAdmvs == "320921" {
  2549. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2550. // } else {
  2551. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2552. // }
  2553. //
  2554. // resp, _ := client.Do(req)
  2555. // defer resp.Body.Close()
  2556. // body, ioErr := ioutil.ReadAll(resp.Body)
  2557. // if ioErr != nil {
  2558. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2559. // }
  2560. // var respJSON map[string]interface{}
  2561. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2562. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2563. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2564. // return
  2565. // }
  2566. // var resSix10265 ResultSix10265 //1101结果
  2567. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2568. // result, _ := json.Marshal(respJSON)
  2569. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2570. // utils.ErrorLog("解析失败:%v", err)
  2571. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2572. // return
  2573. // }
  2574. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2575. // res3.Output = resSix10265.Output
  2576. // res3.ErrMsg = resSix10265.ErrMsg
  2577. // res3.Cainfo = resSix10265.Cainfo
  2578. // res3.WarnMsg = resSix10265.WarnMsg
  2579. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2580. // res3.Infcode = infocode
  2581. //
  2582. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2583. //
  2584. // data := make(map[string]interface{})
  2585. // data["struct_3502s"] = struct3502
  2586. // client := &http.Client{}
  2587. // bytesData, _ := json.Marshal(data)
  2588. // var req *http.Request
  2589. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  2590. // resp, _ := client.Do(req)
  2591. // defer resp.Body.Close()
  2592. // body, ioErr := ioutil.ReadAll(resp.Body)
  2593. // if ioErr != nil {
  2594. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2595. // }
  2596. // var respJSON map[string]interface{}
  2597. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2598. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2599. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2600. // return
  2601. // }
  2602. // var resSix10265 ResultSix10265 //1101结果
  2603. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2604. // result, _ := json.Marshal(respJSON)
  2605. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2606. // utils.ErrorLog("解析失败:%v", err)
  2607. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2608. // return
  2609. // }
  2610. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2611. // res3.Output = resSix10265.Output
  2612. // res3.ErrMsg = resSix10265.ErrMsg
  2613. // res3.Cainfo = resSix10265.Cainfo
  2614. // res3.WarnMsg = resSix10265.WarnMsg
  2615. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2616. // res3.Infcode = infocode
  2617. //
  2618. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2619. //
  2620. // data := make(map[string]interface{})
  2621. // data["struct_3501s"] = struct3501
  2622. // client := &http.Client{}
  2623. // bytesData, _ := json.Marshal(data)
  2624. // var req *http.Request
  2625. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2626. // resp, _ := client.Do(req)
  2627. // defer resp.Body.Close()
  2628. // body, ioErr := ioutil.ReadAll(resp.Body)
  2629. // if ioErr != nil {
  2630. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2631. // }
  2632. // var respJSON map[string]interface{}
  2633. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2634. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2635. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2636. // return
  2637. // }
  2638. // var resSix10265 ResultSix10265 //1101结果
  2639. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2640. // result, _ := json.Marshal(respJSON)
  2641. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2642. // utils.ErrorLog("解析失败:%v", err)
  2643. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2644. // return
  2645. // }
  2646. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2647. // res2.Output = resSix10265.Output
  2648. // res2.ErrMsg = resSix10265.ErrMsg
  2649. // res2.Cainfo = resSix10265.Cainfo
  2650. // res2.WarnMsg = resSix10265.WarnMsg
  2651. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2652. // res2.Infcode = infocode
  2653. //
  2654. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2655. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  2656. // saveLog(result11, result22, "3502", "3502")
  2657. //
  2658. // var respJSON3 map[string]interface{}
  2659. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2660. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2661. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2662. // return
  2663. // }
  2664. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2665. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2666. // utils.ErrorLog("解析失败:%v", err)
  2667. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2668. // return
  2669. // }
  2670. // }
  2671. // if res3.Infcode == -1 {
  2672. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2673. // c.ServeSuccessJSON(map[string]interface{}{
  2674. // "failed_code": -10,
  2675. // "msg": res3.ErrMsg,
  2676. // })
  2677. // } else {
  2678. // drug.IsBg = 1
  2679. // drug.BgBchno = bg_number
  2680. // service.SaveW(drug)
  2681. // }
  2682. // }
  2683. // } else {
  2684. // errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  2685. // }
  2686. // }
  2687. // //变更
  2688. // if drug.IsPc == 1 && drug.IsBg == 0 {
  2689. // var res3 ResultSix
  2690. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2691. //
  2692. // var struct3502 models.Struct3502
  2693. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2694. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2695. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2696. // struct3502.FixmedinsCode = miConfig.Code
  2697. // struct3502.Code = miConfig.Code
  2698. //
  2699. // struct3502.Opter = roles.UserName
  2700. // struct3502.RxFlag = "0"
  2701. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2702. // struct3502.OrgName = miConfig.OrgName
  2703. // struct3502.AccessKey = miConfig.AccessKey
  2704. // struct3502.RequestUrl = miConfig.Url
  2705. // struct3502.SecretKey = miConfig.SecretKey
  2706. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2707. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2708. // struct3502.InvChgType = "108"
  2709. // struct3502.DrugTracCodg = drug.DrugCode
  2710. //
  2711. // struct3502.Url = miConfig.Url
  2712. // struct3502.AppId = miConfig.Cainfo
  2713. // struct3502.AppSecret = miConfig.AppSecret
  2714. // struct3502.Enckey = miConfig.EncKey
  2715. // struct3502.SignKey = miConfig.SignKey
  2716. // struct3502.SecretKey = miConfig.SecretKey
  2717. //
  2718. // struct3502.FixmedinsBchno = bg_number
  2719. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2720. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2721. //
  2722. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2723. // result1, result2, _ := service.FJyb3502(struct3502)
  2724. // saveLog(result1, result2, "3502", "3502")
  2725. // var respJSON3 map[string]interface{}
  2726. // if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  2727. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2728. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2729. // return
  2730. // }
  2731. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2732. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2733. // utils.ErrorLog("解析失败:%v", err)
  2734. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2735. // return
  2736. // }
  2737. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2738. // data := make(map[string]interface{})
  2739. // data["struct_3502s"] = struct3502
  2740. // client := &http.Client{}
  2741. // bytesData, _ := json.Marshal(data)
  2742. // var req *http.Request
  2743. // if miConfig.MdtrtareaAdmvs == "320921" {
  2744. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2745. // } else {
  2746. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2747. // }
  2748. // resp, _ := client.Do(req)
  2749. // defer resp.Body.Close()
  2750. // body, ioErr := ioutil.ReadAll(resp.Body)
  2751. // if ioErr != nil {
  2752. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2753. // }
  2754. // var respJSON map[string]interface{}
  2755. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2756. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2757. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2758. // return
  2759. // }
  2760. // var resSix10265 ResultSix10265 //1101结果
  2761. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2762. // result, _ := json.Marshal(respJSON)
  2763. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2764. // utils.ErrorLog("解析失败:%v", err)
  2765. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2766. // return
  2767. // }
  2768. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2769. // res3.Output = resSix10265.Output
  2770. // res3.ErrMsg = resSix10265.ErrMsg
  2771. // res3.Cainfo = resSix10265.Cainfo
  2772. // res3.WarnMsg = resSix10265.WarnMsg
  2773. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2774. // res3.Infcode = infocode
  2775. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2776. //
  2777. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2778. //
  2779. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  2780. //
  2781. // }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2782. //
  2783. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2784. // saveLog(result1, result2, "3501", "3501")
  2785. // //saveLog(result, requestLog, "2201", "挂号")
  2786. //
  2787. // var respJSON2 map[string]interface{}
  2788. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2789. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2790. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2791. // return
  2792. // }
  2793. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2794. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2795. // utils.ErrorLog("解析失败:%v", err)
  2796. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2797. // return
  2798. // }
  2799. //
  2800. // }
  2801. // if res3.Infcode == -1 {
  2802. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2803. // } else {
  2804. // drug.IsBg = 1
  2805. // drug.BgBchno = bg_number
  2806. // service.SaveW(drug)
  2807. // }
  2808. // }
  2809. // }
  2810. //
  2811. // if len(errs) == 0 {
  2812. // c.ServeSuccessJSON(map[string]interface{}{
  2813. // "msg": "盘存变更成功",
  2814. // })
  2815. // } else {
  2816. // c.ServeSuccessJSON(map[string]interface{}{
  2817. // "failed_code": -10,
  2818. // "msg": errs,
  2819. // })
  2820. // }
  2821. //}
  2822. func (c *HisApiController) DeleteXSandBGTwo() {
  2823. patient_id, _ := c.GetInt64("patient_id")
  2824. admin_user_id, _ := c.GetInt64("admin_user_id")
  2825. times := c.GetString("time", "")
  2826. timeLayout := "2006-01-02"
  2827. loc, _ := time.LoadLocation("Local")
  2828. var stime, etime int64
  2829. if times == "" {
  2830. stime, etime = GetNowTime()
  2831. } else {
  2832. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2833. stime = stmp.Unix()
  2834. etime = stime + 86399
  2835. }
  2836. advicelist, _ := service.FindUploadHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2837. var flows []*models.DrugFlow
  2838. for _, item := range advicelist {
  2839. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2840. flows = append(flows, flow...)
  2841. }
  2842. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2843. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2844. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2845. var err []string
  2846. for _, item := range flows {
  2847. if item.IsSale == 1 {
  2848. var res FJ3507Result
  2849. var struct3507 models.Struct3507
  2850. struct3507.FixmedinsBchno = item.Bchno
  2851. struct3507.InvDataType = "4"
  2852. struct3507.Opter = roles.UserName
  2853. struct3507.OrgName = miConfig.OrgName
  2854. struct3507.AccessKey = miConfig.AccessKey
  2855. struct3507.RequestUrl = miConfig.Url
  2856. struct3507.FixmedinsCode = miConfig.Code
  2857. struct3507.SecretKey = miConfig.SecretKey
  2858. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2859. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2860. struct3507.Url = miConfig.Url
  2861. struct3507.AppId = miConfig.Cainfo
  2862. struct3507.AppSecret = miConfig.AppSecret
  2863. struct3507.Enckey = miConfig.EncKey
  2864. struct3507.SignKey = miConfig.SignKey
  2865. struct3507.SecretKey = miConfig.SecretKey
  2866. if miConfig.MdtrtareaAdmvs == "350500" {
  2867. result, result1, _ := service.FJyb3507(struct3507)
  2868. saveLog(result, result1, "3507", "3507")
  2869. var respJSON2 map[string]interface{}
  2870. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2871. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2873. return
  2874. }
  2875. userJSONBytes2, _ := json.Marshal(respJSON2)
  2876. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2877. utils.ErrorLog("解析失败:%v", err)
  2878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2879. return
  2880. }
  2881. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  2882. data := make(map[string]interface{})
  2883. data["struct_3507s"] = struct3507
  2884. client := &http.Client{}
  2885. bytesData, _ := json.Marshal(data)
  2886. var req *http.Request
  2887. if miConfig.MdtrtareaAdmvs == "320830" {
  2888. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2889. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2890. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2891. } else {
  2892. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", 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. res.InfRefmsgid = resSix10265.InfRefmsgid
  2915. //res.Output = resSix10265.Output
  2916. res.ErrMsg = resSix10265.ErrMsg
  2917. res.Cainfo = resSix10265.Cainfo
  2918. res.WarnMsg = resSix10265.WarnMsg
  2919. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2920. res.Infcode = infocode
  2921. } else if miConfig.MdtrtareaAdmvs == "440100" {
  2922. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  2923. saveLog(result2, result1, "3507", "3507")
  2924. var respJSON2 map[string]interface{}
  2925. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2926. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2928. return
  2929. }
  2930. userJSONBytes2, _ := json.Marshal(respJSON2)
  2931. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2932. utils.ErrorLog("解析失败:%v", err)
  2933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2934. return
  2935. }
  2936. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2937. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  2938. saveLog(result2, result1, "3507", "3507")
  2939. var respJSON2 map[string]interface{}
  2940. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2941. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2943. return
  2944. }
  2945. userJSONBytes2, _ := json.Marshal(respJSON2)
  2946. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2947. utils.ErrorLog("解析失败:%v", err)
  2948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2949. return
  2950. }
  2951. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  2952. result1, result2 := service.Jxyb3507(struct3507)
  2953. saveLog(result2, result1, "3507", "3507")
  2954. var respJSON2 map[string]interface{}
  2955. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2956. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2958. return
  2959. }
  2960. userJSONBytes2, _ := json.Marshal(respJSON2)
  2961. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2962. utils.ErrorLog("解析失败:%v", err)
  2963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2964. return
  2965. }
  2966. } else if miConfig.MdtrtareaAdmvs == "340699" {
  2967. result1, result2 := service.AHyb3507(struct3507)
  2968. saveLog(result2, result1, "3507", "3507")
  2969. var respJSON2 map[string]interface{}
  2970. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2971. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2973. return
  2974. }
  2975. userJSONBytes2, _ := json.Marshal(respJSON2)
  2976. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2977. utils.ErrorLog("解析失败:%v", err)
  2978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2979. return
  2980. }
  2981. } else if miConfig.MdtrtareaAdmvs == "150499" {
  2982. data := make(map[string]interface{})
  2983. data["struct_3507s"] = struct3507
  2984. client := &http.Client{}
  2985. bytesData, _ := json.Marshal(data)
  2986. var req *http.Request
  2987. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  2988. resp, _ := client.Do(req)
  2989. defer resp.Body.Close()
  2990. body, ioErr := ioutil.ReadAll(resp.Body)
  2991. if ioErr != nil {
  2992. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2993. }
  2994. var respJSON map[string]interface{}
  2995. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2996. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2997. }
  2998. var resSix10265 ResultSix10265 //1101结果
  2999. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3000. result, _ := json.Marshal(respJSON)
  3001. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3002. utils.ErrorLog("解析失败:%v", err)
  3003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3004. return
  3005. }
  3006. res.InfRefmsgid = resSix10265.InfRefmsgid
  3007. res.ErrMsg = resSix10265.ErrMsg
  3008. res.Cainfo = resSix10265.Cainfo
  3009. res.WarnMsg = resSix10265.WarnMsg
  3010. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3011. res.Infcode = infocode
  3012. }
  3013. if res.Infcode == 0 {
  3014. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  3015. item.IsSale = 0
  3016. item.SaleDate = ""
  3017. item.Bchno = ""
  3018. service.SaveDF(item)
  3019. } else {
  3020. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  3021. }
  3022. }
  3023. }
  3024. c.ServeSuccessJSON(map[string]interface{}{
  3025. "msg": "删除销售数据成功",
  3026. })
  3027. }
  3028. // 删除
  3029. func (c *HisApiController) DeleteXSandBGThree() {
  3030. id, _ := c.GetInt64("id")
  3031. admin_user_id, _ := c.GetInt64("admin_user_id")
  3032. advicelist, _ := service.FinddelHisAdviceDocAdvice(id)
  3033. var flows []*models.DrugFlow
  3034. for _, item := range advicelist {
  3035. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3036. flows = append(flows, flow...)
  3037. }
  3038. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3039. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3040. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3041. var err []string
  3042. for _, item := range flows {
  3043. if item.IsSale == 1 {
  3044. var res FJ3507Result
  3045. var struct3507 models.Struct3507
  3046. struct3507.FixmedinsBchno = item.Bchno
  3047. struct3507.InvDataType = "4"
  3048. struct3507.Opter = roles.UserName
  3049. struct3507.OrgName = miConfig.OrgName
  3050. struct3507.AccessKey = miConfig.AccessKey
  3051. struct3507.RequestUrl = miConfig.Url
  3052. struct3507.FixmedinsCode = miConfig.Code
  3053. struct3507.SecretKey = miConfig.SecretKey
  3054. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3055. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3056. struct3507.Url = miConfig.Url
  3057. struct3507.AppId = miConfig.Cainfo
  3058. struct3507.AppSecret = miConfig.AppSecret
  3059. struct3507.Enckey = miConfig.EncKey
  3060. struct3507.SignKey = miConfig.SignKey
  3061. struct3507.SecretKey = miConfig.SecretKey
  3062. if miConfig.MdtrtareaAdmvs == "350500" {
  3063. result, result1, _ := service.FJyb3507(struct3507)
  3064. saveLog(result, result1, "3507", "3507")
  3065. var respJSON2 map[string]interface{}
  3066. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3067. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3069. return
  3070. }
  3071. userJSONBytes2, _ := json.Marshal(respJSON2)
  3072. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3073. utils.ErrorLog("解析失败:%v", err)
  3074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3075. return
  3076. }
  3077. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  3078. data := make(map[string]interface{})
  3079. data["struct_3507s"] = struct3507
  3080. client := &http.Client{}
  3081. bytesData, _ := json.Marshal(data)
  3082. var req *http.Request
  3083. if miConfig.MdtrtareaAdmvs == "320830" {
  3084. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  3085. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3086. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3087. } else {
  3088. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3089. }
  3090. resp, _ := client.Do(req)
  3091. defer resp.Body.Close()
  3092. body, ioErr := ioutil.ReadAll(resp.Body)
  3093. if ioErr != nil {
  3094. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3095. }
  3096. var respJSON map[string]interface{}
  3097. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3098. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3100. return
  3101. }
  3102. var resSix10265 ResultSix10265 //1101结果
  3103. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3104. result, _ := json.Marshal(respJSON)
  3105. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3106. utils.ErrorLog("解析失败:%v", err)
  3107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3108. return
  3109. }
  3110. res.InfRefmsgid = resSix10265.InfRefmsgid
  3111. //res.Output = resSix10265.Output
  3112. res.ErrMsg = resSix10265.ErrMsg
  3113. res.Cainfo = resSix10265.Cainfo
  3114. res.WarnMsg = resSix10265.WarnMsg
  3115. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3116. res.Infcode = infocode
  3117. } else if miConfig.MdtrtareaAdmvs == "440100" {
  3118. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  3119. saveLog(result2, result1, "3507", "3507")
  3120. var respJSON2 map[string]interface{}
  3121. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3122. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3124. return
  3125. }
  3126. userJSONBytes2, _ := json.Marshal(respJSON2)
  3127. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3128. utils.ErrorLog("解析失败:%v", err)
  3129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3130. return
  3131. }
  3132. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  3133. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  3134. saveLog(result2, result1, "3507", "3507")
  3135. var respJSON2 map[string]interface{}
  3136. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3137. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3139. return
  3140. }
  3141. userJSONBytes2, _ := json.Marshal(respJSON2)
  3142. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3143. utils.ErrorLog("解析失败:%v", err)
  3144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3145. return
  3146. }
  3147. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  3148. result1, result2 := service.Jxyb3507(struct3507)
  3149. saveLog(result2, result1, "3507", "3507")
  3150. var respJSON2 map[string]interface{}
  3151. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3152. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3154. return
  3155. }
  3156. userJSONBytes2, _ := json.Marshal(respJSON2)
  3157. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3158. utils.ErrorLog("解析失败:%v", err)
  3159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3160. return
  3161. }
  3162. } else if miConfig.MdtrtareaAdmvs == "340699" {
  3163. result1, result2 := service.AHyb3507(struct3507)
  3164. saveLog(result2, result1, "3507", "3507")
  3165. var respJSON2 map[string]interface{}
  3166. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3167. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3169. return
  3170. }
  3171. userJSONBytes2, _ := json.Marshal(respJSON2)
  3172. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3173. utils.ErrorLog("解析失败:%v", err)
  3174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3175. return
  3176. }
  3177. } else if miConfig.MdtrtareaAdmvs == "150499" {
  3178. data := make(map[string]interface{})
  3179. data["struct_3507s"] = struct3507
  3180. client := &http.Client{}
  3181. bytesData, _ := json.Marshal(data)
  3182. var req *http.Request
  3183. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  3184. resp, _ := client.Do(req)
  3185. defer resp.Body.Close()
  3186. body, ioErr := ioutil.ReadAll(resp.Body)
  3187. if ioErr != nil {
  3188. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3189. }
  3190. var respJSON map[string]interface{}
  3191. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3192. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3193. }
  3194. var resSix10265 ResultSix10265 //1101结果
  3195. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3196. result, _ := json.Marshal(respJSON)
  3197. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3198. utils.ErrorLog("解析失败:%v", err)
  3199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3200. return
  3201. }
  3202. res.InfRefmsgid = resSix10265.InfRefmsgid
  3203. res.ErrMsg = resSix10265.ErrMsg
  3204. res.Cainfo = resSix10265.Cainfo
  3205. res.WarnMsg = resSix10265.WarnMsg
  3206. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3207. res.Infcode = infocode
  3208. }
  3209. if res.Infcode == 0 {
  3210. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  3211. item.IsSale = 0
  3212. item.SaleDate = ""
  3213. item.Bchno = ""
  3214. service.SaveDF(item)
  3215. } else {
  3216. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  3217. }
  3218. }
  3219. }
  3220. c.ServeSuccessJSON(map[string]interface{}{
  3221. "msg": "删除销售数据成功",
  3222. })
  3223. }
  3224. // 获取当天起止时间戳
  3225. func GetNowTime() (int64, int64) {
  3226. t := time.Now()
  3227. addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
  3228. timesamp := addTime.Unix()
  3229. return timesamp, timesamp + 86399
  3230. }
  3231. func (c *HisApiController) ChangeDrugfour() {
  3232. patient_id, _ := c.GetInt64("patient_id")
  3233. admin_user_id, _ := c.GetInt64("admin_user_id")
  3234. times := c.GetString("time", "")
  3235. timeLayout := "2006-01-02"
  3236. loc, _ := time.LoadLocation("Local")
  3237. var stime, etime int64
  3238. if times == "" {
  3239. stime, etime = GetNowTime()
  3240. } else {
  3241. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3242. stime = stmp.Unix()
  3243. etime = stime + 86399
  3244. }
  3245. advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3246. var flows []*models.DrugFlow
  3247. for _, item := range advicelist {
  3248. flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  3249. flows = append(flows, flow...)
  3250. }
  3251. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3252. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3253. var err []string
  3254. for _, item := range flows {
  3255. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3256. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3257. if prescription.OrderStatus == 2 {
  3258. if item.IsSale == 0 {
  3259. var res FJ3507Result
  3260. var res3507for10188 FJ3507ResultFor10188
  3261. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3262. //进行商品销售接口
  3263. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3264. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3265. var respJSON3 map[string]interface{}
  3266. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3267. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3269. return
  3270. }
  3271. userJSONBytes3, _ := json.Marshal(respJSON3)
  3272. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3273. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3274. utils.ErrorLog("解析失败:%v", err)
  3275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3276. return
  3277. }
  3278. //if res3507for10188.Infcode
  3279. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3280. //res.Output = resSix10265.Output
  3281. res.ErrMsg = res3507for10188.ErrMsg
  3282. res.Cainfo = res3507for10188.Cainfo
  3283. res.WarnMsg = res3507for10188.WarnMsg
  3284. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3285. res.Infcode = infocode
  3286. } else {
  3287. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3288. utils.ErrorLog("解析失败:%v", err)
  3289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3290. return
  3291. }
  3292. }
  3293. if res.Infcode == 0 {
  3294. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3295. item.IsSale = 1
  3296. item.Bchno = number
  3297. item.SaleDate = time.Now().Format("2006-01-02")
  3298. service.SaveDF(item)
  3299. } else {
  3300. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3301. }
  3302. }
  3303. } else { //还没结,提示用户去结算,并药品追溯上传
  3304. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3305. }
  3306. }
  3307. }
  3308. str := strings.Join(err, " ")
  3309. saveLog(str, str, "3505", "3505自动上传日志")
  3310. c.ServeSuccessJSON(map[string]interface{}{
  3311. "status": "1",
  3312. "msg": err,
  3313. })
  3314. }
  3315. func (c *HisApiController) ChangeDrugFive() {
  3316. id := c.GetString("id")
  3317. ids := strings.Split(id, ",")
  3318. admin_user_id, _ := c.GetInt64("admin_user_id")
  3319. var errs []string
  3320. //校验gui'ge
  3321. for _, value := range ids {
  3322. intValue, _ := strconv.ParseInt(value, 10, 64)
  3323. //file := strconv.FormatInt(int64(num), 10)
  3324. advicelist, _ := service.FindHisAdviceDocAdvice(intValue)
  3325. var flows []*models.DrugFlow
  3326. for _, item := range advicelist {
  3327. flow, _ := service.GetNewDrugFlowInfoByPatient(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3328. flows = append(flows, flow...)
  3329. }
  3330. //roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3331. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3332. for _, item := range flows {
  3333. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3334. if prescription.OrderStatus != 2 {
  3335. // 将时间戳转换为time.Time类型
  3336. t := time.Unix(item.HisDoctorAdviceInfo.RecordDate, 0) // 注意第二个参数是纳秒,这里是0
  3337. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, item.HisDoctorAdviceInfo.PatientId)
  3338. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"医嘱没结算无法上传")
  3339. }
  3340. if len(item.HisDoctorAdviceInfo.DrugCode) > 0 {
  3341. t := time.Unix(item.HisDoctorAdviceInfo.RecordDate, 0) // 注意第二个参数是纳秒,这里是0
  3342. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, item.HisDoctorAdviceInfo.PatientId)
  3343. codes := strings.Split(item.HisDoctorAdviceInfo.DrugCode, ",")
  3344. for _, code := range codes {
  3345. if len(code) > 0 {
  3346. if len(code) != 20 {
  3347. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+" 溯源码"+code+"位数不是20位")
  3348. }
  3349. if IsDigit(code) == false {
  3350. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+" 溯源码"+code+"不是纯数字")
  3351. }
  3352. }
  3353. }
  3354. }
  3355. }
  3356. }
  3357. utils.ErrorLog("接口返回数据解析JSON失败: %v", errs)
  3358. if len(errs) > 0 {
  3359. c.ServeSuccessJSON(map[string]interface{}{
  3360. "failed_code": -10,
  3361. "msg": errs,
  3362. })
  3363. return
  3364. }
  3365. for _, value := range ids {
  3366. intValue, _ := strconv.ParseInt(value, 10, 64)
  3367. //file := strconv.FormatInt(int64(num), 10)
  3368. advicelist, _ := service.FindHisAdviceDocAdvice(intValue)
  3369. var flows []*models.DrugFlow
  3370. for _, item := range advicelist {
  3371. flow, _ := service.GetNewDrugFlowInfoByPatient(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3372. flows = append(flows, flow...)
  3373. }
  3374. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3375. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3376. for _, item := range flows {
  3377. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3378. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3379. if prescription.OrderStatus == 2 {
  3380. if item.IsSale == 0 {
  3381. var res FJ3507Result
  3382. var res3507for10188 FJ3507ResultFor10188
  3383. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3384. //进行商品销售接口
  3385. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3386. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3387. var respJSON3 map[string]interface{}
  3388. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3389. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3391. return
  3392. }
  3393. userJSONBytes3, _ := json.Marshal(respJSON3)
  3394. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3395. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3396. utils.ErrorLog("解析失败:%v", err)
  3397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3398. return
  3399. }
  3400. //if res3507for10188.Infcode
  3401. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3402. //res.Output = resSix10265.Output
  3403. res.ErrMsg = res3507for10188.ErrMsg
  3404. res.Cainfo = res3507for10188.Cainfo
  3405. res.WarnMsg = res3507for10188.WarnMsg
  3406. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3407. res.Infcode = infocode
  3408. } else {
  3409. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3410. utils.ErrorLog("解析失败:%v", err)
  3411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3412. return
  3413. }
  3414. }
  3415. if res.Infcode == 0 {
  3416. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3417. item.IsSale = 1
  3418. item.Bchno = number
  3419. item.SaleDate = time.Now().Format("2006-01-02")
  3420. service.SaveDF(item)
  3421. } else {
  3422. errs = append(errs, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3423. }
  3424. }
  3425. } else { //还没结,提示用户去结算,并药品追溯上传
  3426. errs = append(errs, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3427. }
  3428. }
  3429. }
  3430. str := strings.Join(errs, " ")
  3431. saveLog(str, str, "3505", "3505自动上传日志")
  3432. }
  3433. c.ServeSuccessJSON(map[string]interface{}{
  3434. "status": "1",
  3435. "msg": errs,
  3436. })
  3437. }
  3438. //func (c *HisApiController) ChangeDrugfour() {
  3439. // patient_id, _ := c.GetInt64("patient_id")
  3440. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3441. // //id_arr := strings.Split(ids, ",")
  3442. // times := c.GetString("time", "")
  3443. // timeLayout := "2006-01-02"
  3444. // loc, _ := time.LoadLocation("Local")
  3445. // var stime, etime int64
  3446. // if times == "" {
  3447. // stime, etime = GetNowTime()
  3448. // } else {
  3449. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3450. // stime = stmp.Unix()
  3451. // etime = stime + 86399
  3452. // }
  3453. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3454. // var flows []*models.DrugFlow
  3455. // for _, item := range advicelist {
  3456. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
  3457. // flows = append(flows, flow...)
  3458. // }
  3459. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3460. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3461. // var err []string
  3462. //
  3463. // for _, item := range flows {
  3464. // var res3 ResultSix
  3465. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3466. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3467. // if prescription.OrderStatus == 2 {
  3468. // //已经结算
  3469. // //判断是否已经销售
  3470. // if item.IsSale == 1 { //是否已经销售,1是 0否
  3471. // //是否已经变更 1是 0否
  3472. // if item.IsChange == 0 { //没变更,进行变更操作
  3473. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3474. //
  3475. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3476. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3477. // var respJSON3 map[string]interface{}
  3478. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3479. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3480. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3481. // return
  3482. // }
  3483. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3484. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3485. // utils.ErrorLog("解析失败:%v", err)
  3486. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3487. // return
  3488. // }
  3489. // if res3.Infcode == 0 {
  3490. // item.IsChange = 1
  3491. // item.BgBchno = bg_number
  3492. // service.SaveDF2(item)
  3493. // } else {
  3494. //
  3495. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3496. // }
  3497. // }
  3498. // } else { //没销售,
  3499. // var res FJ3507Result
  3500. // var res3507for10188 FJ3507ResultFor10188
  3501. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3502. //
  3503. // //进行商品销售接口
  3504. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3505. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3506. // var respJSON3 map[string]interface{}
  3507. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3508. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3509. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3510. // return
  3511. // }
  3512. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3513. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3514. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3515. // utils.ErrorLog("解析失败:%v", err)
  3516. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3517. // return
  3518. // }
  3519. // //if res3507for10188.Infcode
  3520. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  3521. // //res.Output = resSix10265.Output
  3522. // res.ErrMsg = res3507for10188.ErrMsg
  3523. // res.Cainfo = res3507for10188.Cainfo
  3524. // res.WarnMsg = res3507for10188.WarnMsg
  3525. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3526. // res.Infcode = infocode
  3527. // } else {
  3528. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3529. // utils.ErrorLog("解析失败:%v", err)
  3530. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3531. // return
  3532. // }
  3533. //
  3534. // }
  3535. // if res.Infcode == 0 {
  3536. // item.IsSale = 1
  3537. // item.Bchno = number
  3538. // item.SaleDate = time.Now().Format("2006-01-02")
  3539. //
  3540. // err5 := service.SaveDF(item)
  3541. // if err5 == nil {
  3542. // if item.IsChange == 0 { //没变更,进行变更操作
  3543. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3544. //
  3545. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3546. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3547. //
  3548. // var respJSON3 map[string]interface{}
  3549. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3550. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3551. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3552. // return
  3553. // }
  3554. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3555. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3556. // utils.ErrorLog("解析失败:%v", err)
  3557. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3558. // return
  3559. // }
  3560. // //if res3507for10188.Infcode
  3561. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3562. // //res.Output = resSix10265.Output
  3563. // res3.ErrMsg = res3507for10188.ErrMsg
  3564. // res3.Cainfo = res3507for10188.Cainfo
  3565. // res3.WarnMsg = res3507for10188.WarnMsg
  3566. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3567. // res3.Infcode = infocode
  3568. // } else {
  3569. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3570. // utils.ErrorLog("解析失败:%v", err)
  3571. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3572. // return
  3573. // }
  3574. // }
  3575. // if res3.Infcode == 0 {
  3576. // item.IsChange = 1
  3577. // item.BgBchno = bg_number
  3578. // service.SaveDF2(item)
  3579. // } else {
  3580. //
  3581. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3582. // }
  3583. // }
  3584. // }
  3585. // } else {
  3586. //
  3587. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3588. // }
  3589. // }
  3590. //
  3591. // } else { //还没结,提示用户去结算,并药品追溯上传
  3592. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3593. // }
  3594. // }
  3595. // }
  3596. // if len(err) == 0 {
  3597. // c.ServeSuccessJSON(map[string]interface{}{
  3598. // "msg": "销售变更成功",
  3599. // })
  3600. // } else {
  3601. // c.ServeSuccessJSON(map[string]interface{}{
  3602. // "failed_code": -10,
  3603. // "msg": err,
  3604. // })
  3605. // }
  3606. //}
  3607. func (c *HisApiController) ChangeDrug() {
  3608. ids := c.GetString("ids")
  3609. id_arr := strings.Split(ids, ",")
  3610. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3611. admin_user_id, _ := c.GetInt64("admin_user_id")
  3612. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3613. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3614. var err []string
  3615. for _, item := range flows {
  3616. var res3 ResultSix
  3617. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3618. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3619. if prescription.OrderStatus == 2 {
  3620. //已经结算
  3621. //判断是否已经销售
  3622. if item.IsSale == 1 { //是否已经销售,1是 0否
  3623. //是否已经变更 1是 0否
  3624. if item.IsChange == 0 { //没变更,进行变更操作
  3625. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3626. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3627. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3628. var respJSON3 map[string]interface{}
  3629. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3630. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3632. return
  3633. }
  3634. userJSONBytes3, _ := json.Marshal(respJSON3)
  3635. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3636. utils.ErrorLog("解析失败:%v", err)
  3637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3638. return
  3639. }
  3640. if res3.Infcode == 0 {
  3641. item.IsChange = 1
  3642. item.BgBchno = bg_number
  3643. service.SaveDF2(item)
  3644. } else {
  3645. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3646. }
  3647. }
  3648. } else { //没销售,
  3649. var res FJ3507Result
  3650. var res3507for10188 FJ3507ResultFor10188
  3651. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3652. //进行商品销售接口
  3653. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3654. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3655. var respJSON3 map[string]interface{}
  3656. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3659. return
  3660. }
  3661. userJSONBytes3, _ := json.Marshal(respJSON3)
  3662. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3663. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3664. utils.ErrorLog("解析失败:%v", err)
  3665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3666. return
  3667. }
  3668. //if res3507for10188.Infcode
  3669. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3670. //res.Output = resSix10265.Output
  3671. res.ErrMsg = res3507for10188.ErrMsg
  3672. res.Cainfo = res3507for10188.Cainfo
  3673. res.WarnMsg = res3507for10188.WarnMsg
  3674. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3675. res.Infcode = infocode
  3676. } else {
  3677. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3678. utils.ErrorLog("解析失败:%v", err)
  3679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3680. return
  3681. }
  3682. }
  3683. if res.Infcode == 0 {
  3684. item.IsSale = 1
  3685. item.Bchno = number
  3686. item.SaleDate = time.Now().Format("2006-01-02")
  3687. err5 := service.SaveDF(item)
  3688. if err5 == nil {
  3689. if item.IsChange == 0 { //没变更,进行变更操作
  3690. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3691. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3692. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3693. var respJSON3 map[string]interface{}
  3694. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3695. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3697. return
  3698. }
  3699. userJSONBytes3, _ := json.Marshal(respJSON3)
  3700. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3701. utils.ErrorLog("解析失败:%v", err)
  3702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3703. return
  3704. }
  3705. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3706. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3707. utils.ErrorLog("解析失败:%v", err)
  3708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3709. return
  3710. }
  3711. //if res3507for10188.Infcode
  3712. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3713. //res.Output = resSix10265.Output
  3714. res3.ErrMsg = res3507for10188.ErrMsg
  3715. res3.Cainfo = res3507for10188.Cainfo
  3716. res3.WarnMsg = res3507for10188.WarnMsg
  3717. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3718. res3.Infcode = infocode
  3719. } else {
  3720. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3721. utils.ErrorLog("解析失败:%v", err)
  3722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3723. return
  3724. }
  3725. }
  3726. if res3.Infcode == 0 {
  3727. item.IsChange = 1
  3728. item.BgBchno = bg_number
  3729. service.SaveDF2(item)
  3730. } else {
  3731. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3732. }
  3733. }
  3734. }
  3735. } else {
  3736. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3737. }
  3738. }
  3739. } else { //还没结算
  3740. var res3507for10188 FJ3507ResultFor10188
  3741. if item.IsChange == 0 { //没变更,进行变更操作
  3742. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3743. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3744. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3745. var respJSON3 map[string]interface{}
  3746. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3747. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3749. return
  3750. }
  3751. userJSONBytes3, _ := json.Marshal(respJSON3)
  3752. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3753. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3754. utils.ErrorLog("解析失败:%v", err)
  3755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3756. return
  3757. }
  3758. //if res3507for10188.Infcode
  3759. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3760. //res.Output = resSix10265.Output
  3761. res3.ErrMsg = res3507for10188.ErrMsg
  3762. res3.Cainfo = res3507for10188.Cainfo
  3763. res3.WarnMsg = res3507for10188.WarnMsg
  3764. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3765. res3.Infcode = infocode
  3766. } else {
  3767. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3768. utils.ErrorLog("解析失败:%v", err)
  3769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3770. return
  3771. }
  3772. }
  3773. if res3.Infcode == 0 {
  3774. item.IsChange = 1
  3775. item.BgBchno = bg_number
  3776. service.SaveDF2(item)
  3777. } else {
  3778. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3779. }
  3780. }
  3781. }
  3782. } else if item.ConsumableType == 7 {
  3783. var res3507for10188 FJ3507ResultFor10188
  3784. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3785. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3786. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3787. //判断是否已经销售
  3788. if item.IsSale == 2 { //是否已经销售,1是 0否
  3789. //是否已经变更 1是 0否
  3790. if item.IsChange == 0 { //没变更,进行变更操作
  3791. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3792. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3793. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3794. var respJSON3 map[string]interface{}
  3795. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3796. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3798. return
  3799. }
  3800. userJSONBytes3, _ := json.Marshal(respJSON3)
  3801. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3802. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3803. utils.ErrorLog("解析失败:%v", err)
  3804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3805. return
  3806. }
  3807. //if res3507for10188.Infcode
  3808. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3809. //res.Output = resSix10265.Output
  3810. res3.ErrMsg = res3507for10188.ErrMsg
  3811. res3.Cainfo = res3507for10188.Cainfo
  3812. res3.WarnMsg = res3507for10188.WarnMsg
  3813. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3814. res3.Infcode = infocode
  3815. } else {
  3816. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3817. utils.ErrorLog("解析失败:%v", err)
  3818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3819. return
  3820. }
  3821. }
  3822. if res3.Infcode == 0 {
  3823. item.IsChange = 1
  3824. item.BgBchno = bg_number
  3825. service.SaveDF2(item)
  3826. } else {
  3827. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3828. }
  3829. }
  3830. } else { //没销售,
  3831. //进行商品销售退货接口
  3832. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3833. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3834. saveLog(result111, result222, "3506", "销售退货")
  3835. var res7 FJ3507Result
  3836. //进行商品销售接口
  3837. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3838. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3839. var respJSON3 map[string]interface{}
  3840. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3841. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3843. return
  3844. }
  3845. userJSONBytes3, _ := json.Marshal(respJSON3)
  3846. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3847. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3848. utils.ErrorLog("解析失败:%v", err)
  3849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3850. return
  3851. }
  3852. //if res3507for10188.Infcode
  3853. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3854. //res.Output = resSix10265.Output
  3855. res7.ErrMsg = res3507for10188.ErrMsg
  3856. res7.Cainfo = res3507for10188.Cainfo
  3857. res7.WarnMsg = res3507for10188.WarnMsg
  3858. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3859. res7.Infcode = infocode
  3860. } else {
  3861. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3862. utils.ErrorLog("解析失败:%v", err)
  3863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3864. return
  3865. }
  3866. }
  3867. if res7.Infcode == 0 {
  3868. item.IsSale = 2
  3869. item.SaleDate = item.SaleDate
  3870. item.Bchno = number
  3871. service.SaveDF(item)
  3872. if item.IsChange == 0 { //没变更,进行变更操作
  3873. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3874. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3875. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3876. var respJSON3 map[string]interface{}
  3877. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3878. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3880. return
  3881. }
  3882. userJSONBytes3, _ := json.Marshal(respJSON3)
  3883. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3884. // utils.ErrorLog("解析失败:%v", err)
  3885. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3886. // return
  3887. //}
  3888. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3889. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3890. utils.ErrorLog("解析失败:%v", err)
  3891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3892. return
  3893. }
  3894. //if res3507for10188.Infcode
  3895. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3896. //res.Output = resSix10265.Output
  3897. res3.ErrMsg = res3507for10188.ErrMsg
  3898. res3.Cainfo = res3507for10188.Cainfo
  3899. res3.WarnMsg = res3507for10188.WarnMsg
  3900. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3901. res3.Infcode = infocode
  3902. } else {
  3903. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3904. utils.ErrorLog("解析失败:%v", err)
  3905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3906. return
  3907. }
  3908. }
  3909. if res3.Infcode == 0 {
  3910. item.IsChange = 1
  3911. item.BgBchno = bg_number
  3912. service.SaveDF2(item)
  3913. } else {
  3914. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3915. }
  3916. }
  3917. } else {
  3918. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3919. }
  3920. }
  3921. } else { //还没结算
  3922. if item.IsChange == 0 { //没变更,进行变更操作
  3923. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3924. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3925. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3926. var respJSON3 map[string]interface{}
  3927. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3928. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3930. return
  3931. }
  3932. userJSONBytes3, _ := json.Marshal(respJSON3)
  3933. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3934. // utils.ErrorLog("解析失败:%v", err)
  3935. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3936. // return
  3937. //}
  3938. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3939. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3940. utils.ErrorLog("解析失败:%v", err)
  3941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3942. return
  3943. }
  3944. //if res3507for10188.Infcode
  3945. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3946. //res.Output = resSix10265.Output
  3947. res3.ErrMsg = res3507for10188.ErrMsg
  3948. res3.Cainfo = res3507for10188.Cainfo
  3949. res3.WarnMsg = res3507for10188.WarnMsg
  3950. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3951. res3.Infcode = infocode
  3952. } else {
  3953. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3954. utils.ErrorLog("解析失败:%v", err)
  3955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3956. return
  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. }
  3968. }
  3969. }
  3970. if len(err) == 0 {
  3971. c.ServeSuccessJSON(map[string]interface{}{
  3972. "msg": "销售变更成功",
  3973. })
  3974. } else {
  3975. c.ServeSuccessJSON(map[string]interface{}{
  3976. "failed_code": -10,
  3977. "msg": err,
  3978. })
  3979. }
  3980. }
  3981. func (c *HisApiController) ChangeDrugtwo() {
  3982. //ids := c.GetString("ids")
  3983. //id_arr := strings.Split(ids, ",")
  3984. flows, _ := service.GetNewDrugFlowInfothree123()
  3985. admin_user_id, _ := c.GetInt64("admin_user_id")
  3986. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3987. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3988. var err []string
  3989. for _, item := range flows {
  3990. var res3 ResultSix
  3991. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3992. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3993. if prescription.OrderStatus == 2 {
  3994. //已经结算
  3995. //判断是否已经销售
  3996. //if item.IsSale == 1 { //是否已经销售,1是 0否
  3997. // //是否已经变更 1是 0否
  3998. // if item.IsChange == 0 { //没变更,进行变更操作
  3999. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4000. //
  4001. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4002. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4003. // var respJSON3 map[string]interface{}
  4004. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4005. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4006. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4007. // return
  4008. // }
  4009. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4010. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4011. // utils.ErrorLog("解析失败:%v", err)
  4012. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4013. // return
  4014. // }
  4015. // if res3.Infcode == 0 {
  4016. // item.IsChange = 1
  4017. // item.BgBchno = bg_number
  4018. // service.SaveDF2(item)
  4019. // } else {
  4020. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4021. // }
  4022. // }
  4023. //}
  4024. //else
  4025. { //没销售,
  4026. var res FJ3507Result
  4027. var res3507for10188 FJ3507ResultFor10188
  4028. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4029. //进行商品销售接口
  4030. result3, result4 := SaleStock10217(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4031. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4032. var respJSON3 map[string]interface{}
  4033. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4034. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4036. return
  4037. }
  4038. userJSONBytes3, _ := json.Marshal(respJSON3)
  4039. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4040. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4041. utils.ErrorLog("解析失败:%v", err)
  4042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4043. return
  4044. }
  4045. //if res3507for10188.Infcode
  4046. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4047. //res.Output = resSix10265.Output
  4048. res.ErrMsg = res3507for10188.ErrMsg
  4049. res.Cainfo = res3507for10188.Cainfo
  4050. res.WarnMsg = res3507for10188.WarnMsg
  4051. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4052. res.Infcode = infocode
  4053. } else {
  4054. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4055. utils.ErrorLog("解析失败:%v", err)
  4056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4057. return
  4058. }
  4059. }
  4060. if res.Infcode == 0 {
  4061. item.IsSale = 1
  4062. item.Bchno = number
  4063. item.SaleDate = time.Now().Format("2006-01-02")
  4064. service.SaveDF(item)
  4065. //if err5 == nil {
  4066. // if item.IsChange == 0 { //没变更,进行变更操作
  4067. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4068. //
  4069. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4070. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4071. //
  4072. // var respJSON3 map[string]interface{}
  4073. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4074. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4075. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4076. // return
  4077. // }
  4078. //
  4079. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4080. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4081. // utils.ErrorLog("解析失败:%v", err)
  4082. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4083. // return
  4084. // }
  4085. // //if res3507for10188.Infcode
  4086. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4087. // //res.Output = resSix10265.Output
  4088. // res3.ErrMsg = res3507for10188.ErrMsg
  4089. // res3.Cainfo = res3507for10188.Cainfo
  4090. // res3.WarnMsg = res3507for10188.WarnMsg
  4091. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4092. // res3.Infcode = infocode
  4093. // } else {
  4094. //
  4095. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4096. // utils.ErrorLog("解析失败:%v", err)
  4097. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4098. // return
  4099. // }
  4100. //
  4101. // }
  4102. //
  4103. // if res3.Infcode == 0 {
  4104. // item.IsChange = 1
  4105. // item.BgBchno = bg_number
  4106. // service.SaveDF2(item)
  4107. // } else {
  4108. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4109. // }
  4110. // }
  4111. //}
  4112. } else {
  4113. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4114. }
  4115. }
  4116. } else { //还没结算
  4117. var res3507for10188 FJ3507ResultFor10188
  4118. if item.IsChange == 0 { //没变更,进行变更操作
  4119. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4120. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4121. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4122. var respJSON3 map[string]interface{}
  4123. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4124. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4126. return
  4127. }
  4128. userJSONBytes3, _ := json.Marshal(respJSON3)
  4129. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4130. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4131. utils.ErrorLog("解析失败:%v", err)
  4132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4133. return
  4134. }
  4135. //if res3507for10188.Infcode
  4136. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4137. //res.Output = resSix10265.Output
  4138. res3.ErrMsg = res3507for10188.ErrMsg
  4139. res3.Cainfo = res3507for10188.Cainfo
  4140. res3.WarnMsg = res3507for10188.WarnMsg
  4141. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4142. res3.Infcode = infocode
  4143. } else {
  4144. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4145. utils.ErrorLog("解析失败:%v", err)
  4146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4147. return
  4148. }
  4149. }
  4150. if res3.Infcode == 0 {
  4151. item.IsChange = 1
  4152. item.BgBchno = bg_number
  4153. service.SaveDF2(item)
  4154. } else {
  4155. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4156. }
  4157. }
  4158. }
  4159. }
  4160. //if item.ConsumableType == 7 {
  4161. // var res3507for10188 FJ3507ResultFor10188
  4162. //
  4163. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4164. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4165. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4166. // //判断是否已经销售
  4167. // if item.IsSale == 2 { //是否已经销售,1是 0否
  4168. // //是否已经变更 1是 0否
  4169. // if item.IsChange == 0 { //没变更,进行变更操作
  4170. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4171. //
  4172. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4173. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4174. //
  4175. // var respJSON3 map[string]interface{}
  4176. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4177. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4178. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4179. // return
  4180. // }
  4181. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4182. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4183. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4184. // utils.ErrorLog("解析失败:%v", err)
  4185. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4186. // return
  4187. // }
  4188. // //if res3507for10188.Infcode
  4189. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4190. // //res.Output = resSix10265.Output
  4191. // res3.ErrMsg = res3507for10188.ErrMsg
  4192. // res3.Cainfo = res3507for10188.Cainfo
  4193. // res3.WarnMsg = res3507for10188.WarnMsg
  4194. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4195. // res3.Infcode = infocode
  4196. // } else {
  4197. //
  4198. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4199. // utils.ErrorLog("解析失败:%v", err)
  4200. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4201. // return
  4202. // }
  4203. //
  4204. // }
  4205. // if res3.Infcode == 0 {
  4206. // item.IsChange = 1
  4207. // item.BgBchno = bg_number
  4208. // service.SaveDF2(item)
  4209. // } else {
  4210. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4211. // }
  4212. // }
  4213. // } else { //没销售,
  4214. // //进行商品销售退货接口
  4215. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4216. //
  4217. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4218. // saveLog(result111, result222, "3506", "销售退货")
  4219. // var res7 FJ3507Result
  4220. //
  4221. // //进行商品销售接口
  4222. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4223. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4224. // var respJSON3 map[string]interface{}
  4225. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4226. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4227. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4228. // return
  4229. // }
  4230. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4231. //
  4232. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4233. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4234. // utils.ErrorLog("解析失败:%v", err)
  4235. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4236. // return
  4237. // }
  4238. // //if res3507for10188.Infcode
  4239. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4240. // //res.Output = resSix10265.Output
  4241. // res7.ErrMsg = res3507for10188.ErrMsg
  4242. // res7.Cainfo = res3507for10188.Cainfo
  4243. // res7.WarnMsg = res3507for10188.WarnMsg
  4244. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4245. // res7.Infcode = infocode
  4246. // } else {
  4247. //
  4248. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4249. // utils.ErrorLog("解析失败:%v", err)
  4250. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4251. // return
  4252. // }
  4253. //
  4254. // }
  4255. // if res7.Infcode == 0 {
  4256. // item.IsSale = 2
  4257. // item.SaleDate = item.SaleDate
  4258. // item.Bchno = number
  4259. // service.SaveDF(item)
  4260. // if item.IsChange == 0 { //没变更,进行变更操作
  4261. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4262. //
  4263. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4264. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4265. //
  4266. // var respJSON3 map[string]interface{}
  4267. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4268. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4269. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4270. // return
  4271. // }
  4272. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4273. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4274. // // utils.ErrorLog("解析失败:%v", err)
  4275. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4276. // // return
  4277. // //}
  4278. //
  4279. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4280. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4281. // utils.ErrorLog("解析失败:%v", err)
  4282. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4283. // return
  4284. // }
  4285. // //if res3507for10188.Infcode
  4286. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4287. // //res.Output = resSix10265.Output
  4288. // res3.ErrMsg = res3507for10188.ErrMsg
  4289. // res3.Cainfo = res3507for10188.Cainfo
  4290. // res3.WarnMsg = res3507for10188.WarnMsg
  4291. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4292. // res3.Infcode = infocode
  4293. // } else {
  4294. //
  4295. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4296. // utils.ErrorLog("解析失败:%v", err)
  4297. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4298. // return
  4299. // }
  4300. //
  4301. // }
  4302. // if res3.Infcode == 0 {
  4303. // item.IsChange = 1
  4304. // item.BgBchno = bg_number
  4305. // service.SaveDF2(item)
  4306. // } else {
  4307. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4308. // }
  4309. // }
  4310. // } else {
  4311. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4312. // }
  4313. // }
  4314. // } else { //还没结算
  4315. // if item.IsChange == 0 { //没变更,进行变更操作
  4316. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4317. //
  4318. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4319. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4320. //
  4321. // var respJSON3 map[string]interface{}
  4322. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4323. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4324. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4325. // return
  4326. // }
  4327. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4328. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4329. // // utils.ErrorLog("解析失败:%v", err)
  4330. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4331. // // return
  4332. // //}
  4333. //
  4334. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4335. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4336. // utils.ErrorLog("解析失败:%v", err)
  4337. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4338. // return
  4339. // }
  4340. // //if res3507for10188.Infcode
  4341. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4342. // //res.Output = resSix10265.Output
  4343. // res3.ErrMsg = res3507for10188.ErrMsg
  4344. // res3.Cainfo = res3507for10188.Cainfo
  4345. // res3.WarnMsg = res3507for10188.WarnMsg
  4346. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4347. // res3.Infcode = infocode
  4348. // } else {
  4349. //
  4350. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4351. // utils.ErrorLog("解析失败:%v", err)
  4352. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4353. // return
  4354. // }
  4355. //
  4356. // }
  4357. // if res3.Infcode == 0 {
  4358. // item.IsChange = 1
  4359. // item.BgBchno = bg_number
  4360. // service.SaveDF2(item)
  4361. // } else {
  4362. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4363. // }
  4364. // }
  4365. // }
  4366. //}
  4367. }
  4368. if len(err) == 0 {
  4369. c.ServeSuccessJSON(map[string]interface{}{
  4370. "msg": "销售变更成功",
  4371. })
  4372. } else {
  4373. c.ServeSuccessJSON(map[string]interface{}{
  4374. "failed_code": -10,
  4375. "msg": err,
  4376. })
  4377. }
  4378. }
  4379. func (c *HisApiController) ChangeDrugthree() {
  4380. //ids := c.GetString("ids")
  4381. //id_arr := strings.Split(ids, ",")
  4382. flows, _ := service.GetNewDrugFlowInfothree()
  4383. admin_user_id, _ := c.GetInt64("admin_user_id")
  4384. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4385. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4386. var err []string
  4387. for _, item := range flows {
  4388. var res3 ResultSix
  4389. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4390. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4391. if prescription.OrderStatus == 2 {
  4392. //已经结算
  4393. //判断是否已经销售
  4394. if item.IsSale == 1 { //是否已经销售,1是 0否
  4395. //是否已经变更 1是 0否
  4396. if item.IsChange == 0 { //没变更,进行变更操作
  4397. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4398. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4399. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4400. var respJSON3 map[string]interface{}
  4401. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4402. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4404. return
  4405. }
  4406. userJSONBytes3, _ := json.Marshal(respJSON3)
  4407. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4408. utils.ErrorLog("解析失败:%v", err)
  4409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4410. return
  4411. }
  4412. if res3.Infcode == 0 {
  4413. item.IsChange = 1
  4414. item.BgBchno = bg_number
  4415. service.SaveDF2(item)
  4416. } else {
  4417. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4418. }
  4419. }
  4420. } else { //没销售,
  4421. var res FJ3507Result
  4422. var res3507for10188 FJ3507ResultFor10188
  4423. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4424. //进行商品销售接口
  4425. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4426. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4427. var respJSON3 map[string]interface{}
  4428. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4429. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4431. return
  4432. }
  4433. userJSONBytes3, _ := json.Marshal(respJSON3)
  4434. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4435. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4436. utils.ErrorLog("解析失败:%v", err)
  4437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4438. return
  4439. }
  4440. //if res3507for10188.Infcode
  4441. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4442. //res.Output = resSix10265.Output
  4443. res.ErrMsg = res3507for10188.ErrMsg
  4444. res.Cainfo = res3507for10188.Cainfo
  4445. res.WarnMsg = res3507for10188.WarnMsg
  4446. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4447. res.Infcode = infocode
  4448. } else {
  4449. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4450. utils.ErrorLog("解析失败:%v", err)
  4451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4452. return
  4453. }
  4454. }
  4455. if res.Infcode == 0 {
  4456. item.IsSale = 1
  4457. item.Bchno = number
  4458. item.SaleDate = time.Now().Format("2006-01-02")
  4459. err5 := service.SaveDF(item)
  4460. if err5 == nil {
  4461. if item.IsChange == 0 { //没变更,进行变更操作
  4462. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4463. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4464. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4465. var respJSON3 map[string]interface{}
  4466. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4467. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4469. return
  4470. }
  4471. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4472. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4473. utils.ErrorLog("解析失败:%v", err)
  4474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4475. return
  4476. }
  4477. //if res3507for10188.Infcode
  4478. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4479. //res.Output = resSix10265.Output
  4480. res3.ErrMsg = res3507for10188.ErrMsg
  4481. res3.Cainfo = res3507for10188.Cainfo
  4482. res3.WarnMsg = res3507for10188.WarnMsg
  4483. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4484. res3.Infcode = infocode
  4485. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4486. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4487. utils.ErrorLog("解析失败:%v", err)
  4488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4489. return
  4490. }
  4491. //if res3507for10188.Infcode
  4492. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4493. //res.Output = resSix10265.Output
  4494. res3.ErrMsg = res3507for10188.ErrMsg
  4495. res3.Cainfo = res3507for10188.Cainfo
  4496. res3.WarnMsg = res3507for10188.WarnMsg
  4497. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4498. res3.Infcode = infocode
  4499. } else {
  4500. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4501. utils.ErrorLog("解析失败:%v", err)
  4502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4503. return
  4504. }
  4505. }
  4506. if res3.Infcode == 0 {
  4507. item.IsChange = 1
  4508. item.BgBchno = bg_number
  4509. service.SaveDF2(item)
  4510. } else {
  4511. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4512. }
  4513. }
  4514. }
  4515. } else {
  4516. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4517. }
  4518. }
  4519. } else { //还没结算
  4520. var res3507for10188 FJ3507ResultFor10188
  4521. if item.IsChange == 0 { //没变更,进行变更操作
  4522. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4523. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4524. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4525. var respJSON3 map[string]interface{}
  4526. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4527. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4529. return
  4530. }
  4531. userJSONBytes3, _ := json.Marshal(respJSON3)
  4532. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4533. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4534. utils.ErrorLog("解析失败:%v", err)
  4535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4536. return
  4537. }
  4538. //if res3507for10188.Infcode
  4539. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4540. //res.Output = resSix10265.Output
  4541. res3.ErrMsg = res3507for10188.ErrMsg
  4542. res3.Cainfo = res3507for10188.Cainfo
  4543. res3.WarnMsg = res3507for10188.WarnMsg
  4544. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4545. res3.Infcode = infocode
  4546. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4547. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4548. utils.ErrorLog("解析失败:%v", err)
  4549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4550. return
  4551. }
  4552. //if res3507for10188.Infcode
  4553. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4554. //res.Output = resSix10265.Output
  4555. res3.ErrMsg = res3507for10188.ErrMsg
  4556. res3.Cainfo = res3507for10188.Cainfo
  4557. res3.WarnMsg = res3507for10188.WarnMsg
  4558. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4559. res3.Infcode = infocode
  4560. } else {
  4561. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4562. utils.ErrorLog("解析失败:%v", err)
  4563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4564. return
  4565. }
  4566. }
  4567. if res3.Infcode == 0 {
  4568. item.IsChange = 1
  4569. item.BgBchno = bg_number
  4570. service.SaveDF2(item)
  4571. } else {
  4572. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4573. }
  4574. }
  4575. }
  4576. } else if item.ConsumableType == 7 {
  4577. var res3507for10188 FJ3507ResultFor10188
  4578. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4579. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4580. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4581. //判断是否已经销售
  4582. if item.IsSale == 2 { //是否已经销售,1是 0否
  4583. //是否已经变更 1是 0否
  4584. if item.IsChange == 0 { //没变更,进行变更操作
  4585. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4586. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4587. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4588. var respJSON3 map[string]interface{}
  4589. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4590. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4592. return
  4593. }
  4594. userJSONBytes3, _ := json.Marshal(respJSON3)
  4595. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4596. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4597. utils.ErrorLog("解析失败:%v", err)
  4598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4599. return
  4600. }
  4601. //if res3507for10188.Infcode
  4602. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4603. //res.Output = resSix10265.Output
  4604. res3.ErrMsg = res3507for10188.ErrMsg
  4605. res3.Cainfo = res3507for10188.Cainfo
  4606. res3.WarnMsg = res3507for10188.WarnMsg
  4607. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4608. res3.Infcode = infocode
  4609. } else {
  4610. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4611. utils.ErrorLog("解析失败:%v", err)
  4612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4613. return
  4614. }
  4615. }
  4616. if res3.Infcode == 0 {
  4617. item.IsChange = 1
  4618. item.BgBchno = bg_number
  4619. service.SaveDF2(item)
  4620. } else {
  4621. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4622. }
  4623. }
  4624. } else { //没销售,
  4625. //进行商品销售退货接口
  4626. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4627. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4628. saveLog(result111, result222, "3506", "销售退货")
  4629. var res7 FJ3507Result
  4630. //进行商品销售接口
  4631. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4632. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4633. var respJSON3 map[string]interface{}
  4634. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4635. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4637. return
  4638. }
  4639. userJSONBytes3, _ := json.Marshal(respJSON3)
  4640. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4641. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4642. utils.ErrorLog("解析失败:%v", err)
  4643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4644. return
  4645. }
  4646. //if res3507for10188.Infcode
  4647. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4648. //res.Output = resSix10265.Output
  4649. res7.ErrMsg = res3507for10188.ErrMsg
  4650. res7.Cainfo = res3507for10188.Cainfo
  4651. res7.WarnMsg = res3507for10188.WarnMsg
  4652. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4653. res7.Infcode = infocode
  4654. } else {
  4655. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4656. utils.ErrorLog("解析失败:%v", err)
  4657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4658. return
  4659. }
  4660. }
  4661. if res7.Infcode == 0 {
  4662. item.IsSale = 2
  4663. item.SaleDate = item.SaleDate
  4664. item.Bchno = number
  4665. service.SaveDF(item)
  4666. if item.IsChange == 0 { //没变更,进行变更操作
  4667. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4668. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4669. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4670. var respJSON3 map[string]interface{}
  4671. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4672. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4674. return
  4675. }
  4676. userJSONBytes3, _ := json.Marshal(respJSON3)
  4677. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4678. // utils.ErrorLog("解析失败:%v", err)
  4679. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4680. // return
  4681. //}
  4682. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4683. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4684. utils.ErrorLog("解析失败:%v", err)
  4685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4686. return
  4687. }
  4688. //if res3507for10188.Infcode
  4689. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4690. //res.Output = resSix10265.Output
  4691. res3.ErrMsg = res3507for10188.ErrMsg
  4692. res3.Cainfo = res3507for10188.Cainfo
  4693. res3.WarnMsg = res3507for10188.WarnMsg
  4694. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4695. res3.Infcode = infocode
  4696. } else {
  4697. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4698. utils.ErrorLog("解析失败:%v", err)
  4699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4700. return
  4701. }
  4702. }
  4703. if res3.Infcode == 0 {
  4704. item.IsChange = 1
  4705. item.BgBchno = bg_number
  4706. service.SaveDF2(item)
  4707. } else {
  4708. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4709. }
  4710. }
  4711. } else {
  4712. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4713. }
  4714. }
  4715. } else { //还没结算
  4716. if item.IsChange == 0 { //没变更,进行变更操作
  4717. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4718. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4719. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4720. var respJSON3 map[string]interface{}
  4721. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4722. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4724. return
  4725. }
  4726. userJSONBytes3, _ := json.Marshal(respJSON3)
  4727. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4728. // utils.ErrorLog("解析失败:%v", err)
  4729. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4730. // return
  4731. //}
  4732. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4733. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4734. utils.ErrorLog("解析失败:%v", err)
  4735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4736. return
  4737. }
  4738. //if res3507for10188.Infcode
  4739. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4740. //res.Output = resSix10265.Output
  4741. res3.ErrMsg = res3507for10188.ErrMsg
  4742. res3.Cainfo = res3507for10188.Cainfo
  4743. res3.WarnMsg = res3507for10188.WarnMsg
  4744. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4745. res3.Infcode = infocode
  4746. } else {
  4747. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4748. utils.ErrorLog("解析失败:%v", err)
  4749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4750. return
  4751. }
  4752. }
  4753. if res3.Infcode == 0 {
  4754. item.IsChange = 1
  4755. item.BgBchno = bg_number
  4756. service.SaveDF2(item)
  4757. } else {
  4758. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4759. }
  4760. }
  4761. }
  4762. }
  4763. }
  4764. if len(err) == 0 {
  4765. c.ServeSuccessJSON(map[string]interface{}{
  4766. "msg": "销售变更成功",
  4767. })
  4768. } else {
  4769. c.ServeSuccessJSON(map[string]interface{}{
  4770. "failed_code": -10,
  4771. "msg": err,
  4772. })
  4773. }
  4774. }
  4775. func (c *HisApiController) ChangeDrugTen() {
  4776. start_time_str := c.GetString("start_time")
  4777. end_time_str := c.GetString("end_time")
  4778. //ids := c.GetString("ids")
  4779. //id_arr := strings.Split(ids, ",")
  4780. timeLayout := "2006-01-02"
  4781. loc, _ := time.LoadLocation("Local")
  4782. theStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4783. recordStartTime := theStartTime.Unix()
  4784. theEndTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4785. recordEndTime := theEndTime.Unix()
  4786. //timestamp := int64(1729612800)
  4787. flows, _ := service.GetNewDrugFlowInforTenone(recordStartTime, recordEndTime, c.GetAdminUserInfo().CurrentOrgId)
  4788. admin_user_id, _ := c.GetInt64("admin_user_id")
  4789. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4790. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4791. var err []string
  4792. for _, item := range flows {
  4793. var res3 ResultSix
  4794. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4795. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4796. continue
  4797. }
  4798. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4799. continue
  4800. }
  4801. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4802. if prescription.OrderStatus == 2 {
  4803. //已经结算
  4804. //判断 是否已经销售
  4805. //if item.IsSale == 1 { //是否已经销售,1是 0否
  4806. ////是否已经变更 1是 0否
  4807. //if item.IsChange == 0 { //没变更,进行变更操作
  4808. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4809. //
  4810. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4811. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4812. // var respJSON3 map[string]interface{}
  4813. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4814. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4815. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4816. // return
  4817. // }
  4818. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4819. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4820. // utils.ErrorLog("解析失败:%v", err)
  4821. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4822. // return
  4823. // }
  4824. // if res3.Infcode == 0 {
  4825. // item.IsChange = 1
  4826. // item.BgBchno = bg_number
  4827. // service.SaveDF2(item)
  4828. // } else {
  4829. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4830. // }
  4831. //}
  4832. //} else
  4833. if item.IsSale == 0 { //没销售,
  4834. var res FJ3507Result
  4835. var res3507for10188 FJ3507ResultFor10188
  4836. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4837. //进行商品销售接口
  4838. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4839. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4840. var respJSON3 map[string]interface{}
  4841. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4842. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4844. return
  4845. }
  4846. userJSONBytes3, _ := json.Marshal(respJSON3)
  4847. if c.GetAdminUserInfo().CurrentOrgId == 10265 || c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4848. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4849. utils.ErrorLog("解析失败:%v", err)
  4850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4851. return
  4852. }
  4853. //if res3507for10188.Infcode
  4854. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4855. //res.Output = resSix10265.Output
  4856. res.ErrMsg = res3507for10188.ErrMsg
  4857. res.Cainfo = res3507for10188.Cainfo
  4858. res.WarnMsg = res3507for10188.WarnMsg
  4859. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4860. res.Infcode = infocode
  4861. } else if c.GetAdminUserInfo().CurrentOrgId == 10480 {
  4862. } else {
  4863. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4864. utils.ErrorLog("解析失败:%v", err)
  4865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4866. return
  4867. }
  4868. }
  4869. if res.Infcode == 0 {
  4870. item.IsSale = 1
  4871. item.Bchno = number
  4872. item.SaleDate = time.Now().Format("2006-01-02")
  4873. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  4874. err5 := service.SaveDF(item)
  4875. utils.ErrorLog("接口返回数据解析JSON失败: %v", err5)
  4876. //if err5 == nil {
  4877. //
  4878. // if item.IsChange == 1 { //没变更,进行变更操作
  4879. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4880. //
  4881. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4882. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4883. //
  4884. // var respJSON3 map[string]interface{}
  4885. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4886. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4887. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4888. // return
  4889. // }
  4890. //
  4891. // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4892. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4893. // utils.ErrorLog("解析失败:%v", err)
  4894. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4895. // return
  4896. // }
  4897. // //if res3507for10188.Infcode
  4898. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4899. // //res.Output = resSix10265.Output
  4900. // res3.ErrMsg = res3507for10188.ErrMsg
  4901. // res3.Cainfo = res3507for10188.Cainfo
  4902. // res3.WarnMsg = res3507for10188.WarnMsg
  4903. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4904. // res3.Infcode = infocode
  4905. // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4906. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4907. // utils.ErrorLog("解析失败:%v", err)
  4908. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4909. // return
  4910. // }
  4911. // //if res3507for10188.Infcode
  4912. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4913. // //res.Output = resSix10265.Output
  4914. // res3.ErrMsg = res3507for10188.ErrMsg
  4915. // res3.Cainfo = res3507for10188.Cainfo
  4916. // res3.WarnMsg = res3507for10188.WarnMsg
  4917. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4918. // res3.Infcode = infocode
  4919. //
  4920. // } else {
  4921. //
  4922. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4923. // utils.ErrorLog("解析失败:%v", err)
  4924. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4925. // return
  4926. // }
  4927. //
  4928. // }
  4929. //
  4930. // if res3.Infcode == 0 {
  4931. // item.IsChange = 1
  4932. // item.BgBchno = bg_number
  4933. // service.SaveDF2(item)
  4934. // return
  4935. // } else {
  4936. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4937. // }
  4938. // }
  4939. //}
  4940. } else {
  4941. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4942. }
  4943. }
  4944. }
  4945. } else if item.ConsumableType == 7 {
  4946. var res3507for10188 FJ3507ResultFor10188
  4947. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4948. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4949. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4950. //判断是否已经销售
  4951. if item.IsSale == 2 { //是否已经销售,1是 0否
  4952. //是否已经变更 1是 0否
  4953. if item.IsChange == 0 { //没变更,进行变更操作
  4954. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4955. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4956. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4957. var respJSON3 map[string]interface{}
  4958. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4959. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4961. return
  4962. }
  4963. userJSONBytes3, _ := json.Marshal(respJSON3)
  4964. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4965. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4966. utils.ErrorLog("解析失败:%v", err)
  4967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4968. return
  4969. }
  4970. //if res3507for10188.Infcode
  4971. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4972. //res.Output = resSix10265.Output
  4973. res3.ErrMsg = res3507for10188.ErrMsg
  4974. res3.Cainfo = res3507for10188.Cainfo
  4975. res3.WarnMsg = res3507for10188.WarnMsg
  4976. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4977. res3.Infcode = infocode
  4978. } else {
  4979. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4980. utils.ErrorLog("解析失败:%v", err)
  4981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4982. return
  4983. }
  4984. }
  4985. if res3.Infcode == 0 {
  4986. item.IsChange = 1
  4987. item.BgBchno = bg_number
  4988. service.SaveDF2(item)
  4989. } else {
  4990. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4991. }
  4992. }
  4993. } else { //没销售,
  4994. //进行商品销售退货接口
  4995. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4996. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4997. saveLog(result111, result222, "3506", "销售退货")
  4998. var res7 FJ3507Result
  4999. //进行商品销售接口
  5000. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  5001. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  5002. var respJSON3 map[string]interface{}
  5003. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  5004. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5006. return
  5007. }
  5008. userJSONBytes3, _ := json.Marshal(respJSON3)
  5009. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5010. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5011. utils.ErrorLog("解析失败:%v", err)
  5012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5013. return
  5014. }
  5015. //if res3507for10188.Infcode
  5016. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  5017. //res.Output = resSix10265.Output
  5018. res7.ErrMsg = res3507for10188.ErrMsg
  5019. res7.Cainfo = res3507for10188.Cainfo
  5020. res7.WarnMsg = res3507for10188.WarnMsg
  5021. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5022. res7.Infcode = infocode
  5023. } else {
  5024. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  5025. utils.ErrorLog("解析失败:%v", err)
  5026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5027. return
  5028. }
  5029. }
  5030. if res7.Infcode == 0 {
  5031. item.IsSale = 2
  5032. item.SaleDate = item.SaleDate
  5033. item.Bchno = number
  5034. service.SaveDF(item)
  5035. if item.IsChange == 0 { //没变更,进行变更操作
  5036. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5037. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  5038. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  5039. var respJSON3 map[string]interface{}
  5040. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5041. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5043. return
  5044. }
  5045. userJSONBytes3, _ := json.Marshal(respJSON3)
  5046. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5047. // utils.ErrorLog("解析失败:%v", err)
  5048. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5049. // return
  5050. //}
  5051. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5052. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5053. utils.ErrorLog("解析失败:%v", err)
  5054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5055. return
  5056. }
  5057. //if res3507for10188.Infcode
  5058. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5059. //res.Output = resSix10265.Output
  5060. res3.ErrMsg = res3507for10188.ErrMsg
  5061. res3.Cainfo = res3507for10188.Cainfo
  5062. res3.WarnMsg = res3507for10188.WarnMsg
  5063. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5064. res3.Infcode = infocode
  5065. } else {
  5066. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5067. utils.ErrorLog("解析失败:%v", err)
  5068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5069. return
  5070. }
  5071. }
  5072. if res3.Infcode == 0 {
  5073. item.IsChange = 1
  5074. item.BgBchno = bg_number
  5075. service.SaveDF2(item)
  5076. } else {
  5077. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5078. }
  5079. }
  5080. } else {
  5081. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  5082. }
  5083. }
  5084. } else { //还没结算
  5085. if item.IsChange == 0 { //没变更,进行变更操作
  5086. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5087. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  5088. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  5089. var respJSON3 map[string]interface{}
  5090. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5091. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5093. return
  5094. }
  5095. userJSONBytes3, _ := json.Marshal(respJSON3)
  5096. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5097. // utils.ErrorLog("解析失败:%v", err)
  5098. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5099. // return
  5100. //}
  5101. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5102. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5103. utils.ErrorLog("解析失败:%v", err)
  5104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5105. return
  5106. }
  5107. //if res3507for10188.Infcode
  5108. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5109. //res.Output = resSix10265.Output
  5110. res3.ErrMsg = res3507for10188.ErrMsg
  5111. res3.Cainfo = res3507for10188.Cainfo
  5112. res3.WarnMsg = res3507for10188.WarnMsg
  5113. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5114. res3.Infcode = infocode
  5115. } else {
  5116. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5117. utils.ErrorLog("解析失败:%v", err)
  5118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5119. return
  5120. }
  5121. }
  5122. if res3.Infcode == 0 {
  5123. item.IsChange = 1
  5124. item.BgBchno = bg_number
  5125. service.SaveDF2(item)
  5126. } else {
  5127. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5128. }
  5129. }
  5130. }
  5131. }
  5132. }
  5133. if len(err) == 0 {
  5134. c.ServeSuccessJSON(map[string]interface{}{
  5135. "msg": "销售变更成功",
  5136. })
  5137. } else {
  5138. c.ServeSuccessJSON(map[string]interface{}{
  5139. "failed_code": -10,
  5140. "msg": err,
  5141. })
  5142. }
  5143. }
  5144. func ChangeDrugTenone() {
  5145. //ids := c.GetString("ids")
  5146. //id_arr := strings.Split(ids, ",")
  5147. now := time.Now()
  5148. timestamp := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
  5149. //timestamp := int64(1729612800)
  5150. flows, _ := service.GetNewDrugFlowInforTen(timestamp, 10188)
  5151. admin_user_id := int64(2463)
  5152. roles, _ := service.GetAdminUserInfoByID(10188, admin_user_id)
  5153. miConfig, _ := service.FindMedicalInsuranceInfo(10188)
  5154. var err []string
  5155. for _, item := range flows {
  5156. var res3 ResultSix
  5157. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  5158. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  5159. continue
  5160. }
  5161. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  5162. continue
  5163. }
  5164. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  5165. if prescription.OrderStatus == 2 {
  5166. //已经结算
  5167. //判断是否已经销售
  5168. if item.IsSale == 1 { //是否已经销售,1是 0否
  5169. //是否已经变更 1是 0否
  5170. if item.IsChange == 0 { //没变更,进行变更操作
  5171. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5172. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  5173. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  5174. var respJSON3 map[string]interface{}
  5175. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5176. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5177. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5178. return
  5179. }
  5180. userJSONBytes3, _ := json.Marshal(respJSON3)
  5181. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5182. utils.ErrorLog("解析失败:%v", err)
  5183. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5184. return
  5185. }
  5186. if res3.Infcode == 0 {
  5187. item.IsChange = 1
  5188. item.BgBchno = bg_number
  5189. service.SaveDF2(item)
  5190. } else {
  5191. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5192. }
  5193. }
  5194. } else { //没销售,
  5195. var res FJ3507Result
  5196. var res3507for10188 FJ3507ResultFor10188
  5197. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  5198. //进行商品销售接口
  5199. result3, result4 := SaleStock(10188, prescription, item, miConfig, "", roles, number)
  5200. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  5201. var respJSON3 map[string]interface{}
  5202. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  5203. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5204. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5205. return
  5206. }
  5207. userJSONBytes3, _ := json.Marshal(respJSON3)
  5208. {
  5209. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5210. utils.ErrorLog("解析失败:%v", err)
  5211. return
  5212. }
  5213. //if res3507for10188.Infcode
  5214. res.InfRefmsgid = res3507for10188.InfRefmsgid
  5215. //res.Output = resSix10265.Output
  5216. res.ErrMsg = res3507for10188.ErrMsg
  5217. res.Cainfo = res3507for10188.Cainfo
  5218. res.WarnMsg = res3507for10188.WarnMsg
  5219. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5220. res.Infcode = infocode
  5221. }
  5222. if res.Infcode == 0 {
  5223. item.IsSale = 1
  5224. item.Bchno = number
  5225. item.SaleDate = time.Now().Format("2006-01-02")
  5226. err5 := service.SaveDF(item)
  5227. if err5 == nil {
  5228. if item.IsChange == 1 { //没变更,进行变更操作
  5229. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5230. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  5231. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  5232. var respJSON3 map[string]interface{}
  5233. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5234. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5235. return
  5236. }
  5237. {
  5238. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5239. utils.ErrorLog("解析失败:%v", err)
  5240. return
  5241. }
  5242. //if res3507for10188.Infcode
  5243. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5244. //res.Output = resSix10265.Output
  5245. res3.ErrMsg = res3507for10188.ErrMsg
  5246. res3.Cainfo = res3507for10188.Cainfo
  5247. res3.WarnMsg = res3507for10188.WarnMsg
  5248. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5249. res3.Infcode = infocode
  5250. }
  5251. if res3.Infcode == 0 {
  5252. item.IsChange = 1
  5253. item.BgBchno = bg_number
  5254. service.SaveDF2(item)
  5255. } else {
  5256. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5257. }
  5258. }
  5259. }
  5260. } else {
  5261. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  5262. }
  5263. }
  5264. }
  5265. }
  5266. }
  5267. }
  5268. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5269. var struct3502 models.Struct3502
  5270. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5271. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5272. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5273. struct3502.FixmedinsCode = miConfig.Code
  5274. struct3502.Code = miConfig.Code
  5275. struct3502.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5276. struct3502.Opter = role.UserName
  5277. struct3502.RxFlag = "1"
  5278. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  5279. struct3502.OrgName = miConfig.OrgName
  5280. struct3502.AccessKey = miConfig.AccessKey
  5281. struct3502.RequestUrl = miConfig.Url
  5282. struct3502.SecretKey = miConfig.SecretKey
  5283. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5284. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5285. struct3502.Url = miConfig.Url
  5286. struct3502.AppId = miConfig.Cainfo
  5287. struct3502.AppSecret = miConfig.AppSecret
  5288. struct3502.Enckey = miConfig.EncKey
  5289. struct3502.SignKey = miConfig.SignKey
  5290. struct3502.SecretKey = miConfig.SecretKey
  5291. struct3502.InvChgType = chgType
  5292. struct3502.FixmedinsBchno = number
  5293. struct3502.Cnt = strconv.FormatInt(count, 10)
  5294. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  5295. //result1, result2, _ := service.FJyb3502(struct3502)
  5296. if miConfig.MdtrtareaAdmvs == "350500" {
  5297. result1, result2, _ := service.FJyb3502(struct3502)
  5298. //saveLog(result1, result2, "3502", "3502")
  5299. return result1, result2
  5300. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5301. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  5302. return result1, result2
  5303. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5304. result1, result2 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  5305. return result1, result2
  5306. } else {
  5307. data := make(map[string]interface{})
  5308. data["struct_3502s"] = struct3502
  5309. client := &http.Client{}
  5310. bytesData, _ := json.Marshal(data)
  5311. var req *http.Request
  5312. if miConfig.MdtrtareaAdmvs == "320830" {
  5313. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3502", bytes.NewReader(bytesData))
  5314. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5315. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  5316. } else {
  5317. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  5318. }
  5319. resp, _ := client.Do(req)
  5320. defer resp.Body.Close()
  5321. body, ioErr := ioutil.ReadAll(resp.Body)
  5322. if ioErr != nil {
  5323. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5324. }
  5325. var respJSON map[string]interface{}
  5326. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5327. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5328. }
  5329. //var resSix10265 ResultSix10265 //1101结果
  5330. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5331. result, _ := json.Marshal(respJSON)
  5332. return string(result), ""
  5333. }
  5334. }
  5335. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5336. var struct3505 models.Struct3505
  5337. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5338. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5339. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5340. struct3505.FixmedinsBchno = number
  5341. struct3505.Opter = role.UserName
  5342. struct3505.Bchno = "---"
  5343. struct3505.FixmedinsCode = miConfig.Code
  5344. struct3505.Code = miConfig.Code
  5345. struct3505.FinlTrnsPric = strconv.FormatFloat(drug.HisDoctorAdviceInfo.Price, 'f', -1, 64)
  5346. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5347. struct3505.PrscDrName = roles.UserName
  5348. if org_id == 10191 {
  5349. struct3505.PharName = "刘水山"
  5350. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5351. }
  5352. if org_id == 10188 {
  5353. struct3505.PharName = "李汉清"
  5354. struct3505.PharPracCertNo = "30220200932022010034"
  5355. }
  5356. if org_id == 10217 {
  5357. struct3505.PharName = "张敏"
  5358. struct3505.PharPracCertNo = "30220230432090100108"
  5359. }
  5360. if org_id == 10318 {
  5361. struct3505.PharName = "邹刘阳"
  5362. struct3505.PharPracCertNo = "210441200001378"
  5363. }
  5364. if org_id == 10402 {
  5365. struct3505.PharName = "刘韶健"
  5366. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5367. }
  5368. if org_id == 9919 {
  5369. struct3505.PharName = "周君权"
  5370. struct3505.PharPracCertNo = "089644396094401375"
  5371. }
  5372. if org_id == 10644 {
  5373. struct3505.PharName = "陈金娣"
  5374. struct3505.PharPracCertNo = "20181441500320100066"
  5375. }
  5376. if org_id == 10567 {
  5377. struct3505.PharName = "范小兰"
  5378. struct3505.PharPracCertNo = "0200102079485"
  5379. }
  5380. if org_id == 10721 {
  5381. struct3505.PharName = "孙莉侠"
  5382. struct3505.PharPracCertNo = "060399"
  5383. }
  5384. if org_id == 10726 {
  5385. struct3505.PharName = "彭建福"
  5386. struct3505.PharPracCertNo = "D445281006261"
  5387. }
  5388. if org_id == 10697 {
  5389. struct3505.PharName = "陶海兰"
  5390. struct3505.PharPracCertNo = "0010933"
  5391. }
  5392. if org_id == 10265 {
  5393. struct3505.PharName = "李彩星"
  5394. struct3505.PharPracCertNo = "20171110600110100019"
  5395. }
  5396. if org_id == 10028 {
  5397. struct3505.PharName = "曾细平"
  5398. struct3505.PharPracCertNo = "D440307022134"
  5399. }
  5400. if org_id == 10138 {
  5401. struct3505.PharName = "彭斯遥"
  5402. struct3505.PharPracCertNo = "30220200943042010052"
  5403. }
  5404. if org_id == 10278 {
  5405. struct3505.PharName = "彭斯遥"
  5406. struct3505.PharPracCertNo = "30220200943042010052"
  5407. }
  5408. if org_id == 10610 {
  5409. struct3505.PharName = "彭斯遥"
  5410. struct3505.PharPracCertNo = "30220200943042010052"
  5411. }
  5412. if org_id == 10537 {
  5413. struct3505.PharName = "彭斯遥"
  5414. struct3505.PharPracCertNo = "30220200943042010052"
  5415. }
  5416. if org_id == 9504 {
  5417. struct3505.PharName = "资美红"
  5418. struct3505.PharPracCertNo = "D440904006635"
  5419. }
  5420. if org_id == 10480 {
  5421. struct3505.PharName = "陈思"
  5422. struct3505.PharPracCertNo = "30220240434110010470"
  5423. }
  5424. if org_id == 10653 {
  5425. struct3505.PharName = "邓树英"
  5426. struct3505.PharPracCertNo = "201910026440004734"
  5427. }
  5428. if org_id == 10571 {
  5429. struct3505.PharName = "廖志平"
  5430. struct3505.PharPracCertNo = "0136425"
  5431. }
  5432. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5433. struct3505.SetlId = order.SetlId
  5434. struct3505.MdtrtSn = order.MdtrtId
  5435. struct3505.ManuLotnum = drug.BatchNumber
  5436. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5437. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5438. struct3505.RxFlag = "1"
  5439. if drug.HisDoctorAdviceInfo.PrescribingNumberUnit != drug.HisDoctorAdviceInfo.BaseDrugLib.MinUnit {
  5440. struct3505.TrdnFlag = "0"
  5441. } else {
  5442. struct3505.TrdnFlag = "1"
  5443. }
  5444. if drug.HisDoctorAdviceInfo.ZeroFlag == 1 {
  5445. struct3505.TrdnFlag = "1"
  5446. }
  5447. if drug.HisDoctorAdviceInfo.ZeroFlag == 2 {
  5448. struct3505.TrdnFlag = "0"
  5449. }
  5450. if org_id == 10610 || org_id == 10278 || org_id == 10138 || org_id == 10537 || org_id == 10028 {
  5451. if drug.HisDoctorAdviceInfo.BaseDrugLib.IsZeroFlag == 1 {
  5452. struct3505.TrdnFlag = "1"
  5453. }
  5454. if drug.HisDoctorAdviceInfo.BaseDrugLib.IsZeroFlag == 2 {
  5455. struct3505.TrdnFlag = "0"
  5456. }
  5457. }
  5458. struct3505.RtalDocno = order.Number
  5459. struct3505.PsnCertType = "01"
  5460. struct3505.CertNo = order.Certno
  5461. struct3505.PsnNo = order.PsnNo
  5462. struct3505.PsnName = order.PsnName
  5463. struct3505.Url = miConfig.Url
  5464. struct3505.AppId = miConfig.Cainfo
  5465. struct3505.AppSecret = miConfig.AppSecret
  5466. struct3505.Enckey = miConfig.EncKey
  5467. struct3505.SignKey = miConfig.SignKey
  5468. struct3505.SecretKey = miConfig.SecretKey
  5469. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5470. struct3505.SelRetnCnt = strValue
  5471. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5472. struct3505.SelRetnOpterName = role.UserName
  5473. if order.IsMedicineInsurance == 1 {
  5474. struct3505.MdtrtSetlType = "1"
  5475. } else {
  5476. struct3505.MdtrtSetlType = "2"
  5477. }
  5478. struct3505.OrgName = miConfig.OrgName
  5479. struct3505.AccessKey = miConfig.AccessKey
  5480. struct3505.RequestUrl = miConfig.Url
  5481. struct3505.SecretKey = miConfig.SecretKey
  5482. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5483. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5484. struct3505.Cainfo = miConfig.Cainfo
  5485. struct3505.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5486. if miConfig.MdtrtareaAdmvs == "350500" {
  5487. result1, result2, _ := service.FJyb3505(struct3505)
  5488. return result1, result2
  5489. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5490. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5491. return result1, result2
  5492. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5493. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5494. return result1, result2
  5495. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5496. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5497. return result1, result2
  5498. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "360") {
  5499. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5500. return result1, result2
  5501. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5502. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5503. return result1, result2
  5504. } else if miConfig.MdtrtareaAdmvs == "150499" {
  5505. data := make(map[string]interface{})
  5506. data["struct_3505s"] = struct3505
  5507. client := &http.Client{}
  5508. bytesData, _ := json.Marshal(data)
  5509. var req *http.Request
  5510. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3505", bytes.NewReader(bytesData))
  5511. resp, _ := client.Do(req)
  5512. defer resp.Body.Close()
  5513. body, ioErr := ioutil.ReadAll(resp.Body)
  5514. if ioErr != nil {
  5515. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5516. }
  5517. var respJSON map[string]interface{}
  5518. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5519. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5520. }
  5521. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5522. result, _ := json.Marshal(respJSON)
  5523. return string(result), ""
  5524. } else if miConfig.MdtrtareaAdmvs == "341203" {
  5525. data := make(map[string]interface{})
  5526. data["struct_3505s"] = struct3505
  5527. client := &http.Client{}
  5528. bytesData, _ := json.Marshal(data)
  5529. var req *http.Request
  5530. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3505", bytes.NewReader(bytesData))
  5531. resp, _ := client.Do(req)
  5532. defer resp.Body.Close()
  5533. body, ioErr := ioutil.ReadAll(resp.Body)
  5534. if ioErr != nil {
  5535. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5536. }
  5537. var respJSON map[string]interface{}
  5538. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5539. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5540. }
  5541. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5542. if status == "0" {
  5543. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5544. utils.ErrorLog("接口返回数据读取失败: %v", err_msg)
  5545. }
  5546. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5547. result, _ := json.Marshal(respJSON)
  5548. return string(result), ""
  5549. } else {
  5550. data := make(map[string]interface{})
  5551. data["struct_3505s"] = struct3505
  5552. client := &http.Client{}
  5553. bytesData, _ := json.Marshal(data)
  5554. var req *http.Request
  5555. if miConfig.MdtrtareaAdmvs == "320830" {
  5556. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3505", bytes.NewReader(bytesData))
  5557. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5558. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5559. } else {
  5560. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5561. }
  5562. resp, _ := client.Do(req)
  5563. defer resp.Body.Close()
  5564. body, ioErr := ioutil.ReadAll(resp.Body)
  5565. if ioErr != nil {
  5566. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5567. }
  5568. var respJSON map[string]interface{}
  5569. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5570. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5571. }
  5572. //var resSix10265 ResultSix10265 //1101结果
  5573. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5574. result, _ := json.Marshal(respJSON)
  5575. return string(result), ""
  5576. }
  5577. }
  5578. func SaleStock10217(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5579. var struct3505 models.Struct3505
  5580. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5581. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5582. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5583. struct3505.FixmedinsBchno = number
  5584. struct3505.Opter = role.UserName
  5585. struct3505.FixmedinsCode = miConfig.Code
  5586. struct3505.Code = miConfig.Code
  5587. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5588. struct3505.PrscDrName = roles.UserName
  5589. if org_id == 10191 {
  5590. struct3505.PharName = "刘水山"
  5591. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5592. }
  5593. if org_id == 10188 {
  5594. struct3505.PharName = "李汉清"
  5595. struct3505.PharPracCertNo = "30220200932022010034"
  5596. }
  5597. if org_id == 10217 {
  5598. struct3505.PharName = "张敏"
  5599. struct3505.PharPracCertNo = "30220230432090100108"
  5600. }
  5601. if org_id == 10318 {
  5602. struct3505.PharName = "邹刘阳"
  5603. struct3505.PharPracCertNo = "210441200001378"
  5604. }
  5605. if org_id == 10402 {
  5606. struct3505.PharName = "刘韶健"
  5607. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5608. }
  5609. if org_id == 9919 {
  5610. struct3505.PharName = "周君权"
  5611. struct3505.PharPracCertNo = "089644396094401375"
  5612. }
  5613. if org_id == 10644 {
  5614. struct3505.PharName = "陈金娣"
  5615. struct3505.PharPracCertNo = "20181441500320100066"
  5616. }
  5617. if org_id == 10567 {
  5618. struct3505.PharName = "范小兰"
  5619. struct3505.PharPracCertNo = "0200102079485"
  5620. }
  5621. if org_id == 10721 {
  5622. struct3505.PharName = "孙莉侠"
  5623. struct3505.PharPracCertNo = "060399"
  5624. }
  5625. if org_id == 10726 {
  5626. struct3505.PharName = "彭建福"
  5627. struct3505.PharPracCertNo = "D445281006261"
  5628. }
  5629. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5630. struct3505.SetlId = order.SetlId
  5631. struct3505.MdtrtSn = order.MdtrtId
  5632. struct3505.ManuLotnum = drug.Number
  5633. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5634. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5635. struct3505.RxFlag = "1"
  5636. struct3505.TrdnFlag = "0"
  5637. struct3505.RtalDocno = order.Number
  5638. struct3505.PsnCertType = "01"
  5639. struct3505.CertNo = order.Certno
  5640. struct3505.PsnNo = order.PsnNo
  5641. struct3505.PsnName = order.PsnName
  5642. struct3505.Url = miConfig.Url
  5643. struct3505.AppId = miConfig.Cainfo
  5644. struct3505.AppSecret = miConfig.AppSecret
  5645. struct3505.Enckey = miConfig.EncKey
  5646. struct3505.SignKey = miConfig.SignKey
  5647. struct3505.SecretKey = miConfig.SecretKey
  5648. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5649. struct3505.SelRetnCnt = strValue
  5650. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5651. struct3505.SelRetnOpterName = role.UserName
  5652. if order.IsMedicineInsurance == 1 {
  5653. struct3505.MdtrtSetlType = "1"
  5654. } else {
  5655. struct3505.MdtrtSetlType = "2"
  5656. }
  5657. struct3505.OrgName = miConfig.OrgName
  5658. struct3505.AccessKey = miConfig.AccessKey
  5659. struct3505.RequestUrl = miConfig.Url
  5660. struct3505.SecretKey = miConfig.SecretKey
  5661. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5662. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5663. struct3505.Cainfo = miConfig.Cainfo
  5664. struct3505.DrugTracCodg = drug.DrugCode
  5665. if miConfig.MdtrtareaAdmvs == "350500" {
  5666. result1, result2, _ := service.FJyb3505(struct3505)
  5667. return result1, result2
  5668. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5669. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5670. return result1, result2
  5671. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5672. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5673. return result1, result2
  5674. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5675. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5676. return result1, result2
  5677. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5678. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5679. return result1, result2
  5680. } else {
  5681. data := make(map[string]interface{})
  5682. data["struct_3505s"] = struct3505
  5683. client := &http.Client{}
  5684. bytesData, _ := json.Marshal(data)
  5685. var req *http.Request
  5686. if miConfig.MdtrtareaAdmvs == "320830" {
  5687. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3505", bytes.NewReader(bytesData))
  5688. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5689. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5690. } else {
  5691. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5692. }
  5693. resp, _ := client.Do(req)
  5694. defer resp.Body.Close()
  5695. body, ioErr := ioutil.ReadAll(resp.Body)
  5696. if ioErr != nil {
  5697. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5698. }
  5699. var respJSON map[string]interface{}
  5700. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5701. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5702. }
  5703. //var resSix10265 ResultSix10265 //1101结果
  5704. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5705. result, _ := json.Marshal(respJSON)
  5706. return string(result), ""
  5707. }
  5708. }
  5709. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5710. var struct3506 models.Struct3506
  5711. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5712. struct3506.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5713. struct3506.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5714. struct3506.FixmedinsCode = miConfig.Code
  5715. struct3506.Code = miConfig.Code
  5716. struct3506.FixmedinsBchno = number
  5717. struct3506.Opter = role.UserName
  5718. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5719. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  5720. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5721. struct3506.MdtrtSn = order.MdtrtId
  5722. struct3506.ExpyEnd = ""
  5723. struct3506.RxFlag = "0"
  5724. struct3506.TrdnFlag = "1"
  5725. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5726. struct3506.SelRetnCnt = strValue
  5727. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5728. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  5729. struct3506.SelRetnOpterName = role.UserName
  5730. struct3506.OrgName = miConfig.OrgName
  5731. struct3506.AccessKey = miConfig.AccessKey
  5732. struct3506.RequestUrl = miConfig.Url
  5733. struct3506.SecretKey = miConfig.SecretKey
  5734. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5735. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5736. struct3506.Url = miConfig.Url
  5737. struct3506.AppId = miConfig.Cainfo
  5738. struct3506.AppSecret = miConfig.AppSecret
  5739. struct3506.Enckey = miConfig.EncKey
  5740. struct3506.SignKey = miConfig.SignKey
  5741. struct3506.SecretKey = miConfig.SecretKey
  5742. struct3506.DrugTracCodg = drug.DrugCode
  5743. if miConfig.MdtrtareaAdmvs == "350500" {
  5744. result1, result2, _ := service.FJyb3506(struct3506)
  5745. return result1, result2
  5746. } else {
  5747. data := make(map[string]interface{})
  5748. data["struct_3506s"] = struct3506
  5749. client := &http.Client{}
  5750. bytesData, _ := json.Marshal(data)
  5751. var req *http.Request
  5752. if miConfig.MdtrtareaAdmvs == "320830" {
  5753. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3506", bytes.NewReader(bytesData))
  5754. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5755. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5756. } else {
  5757. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5758. }
  5759. resp, _ := client.Do(req)
  5760. defer resp.Body.Close()
  5761. body, ioErr := ioutil.ReadAll(resp.Body)
  5762. if ioErr != nil {
  5763. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5764. }
  5765. var respJSON map[string]interface{}
  5766. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5767. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5768. }
  5769. //var resSix10265 ResultSix10265 //1101结果
  5770. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5771. result, _ := json.Marshal(respJSON)
  5772. return string(result), ""
  5773. }
  5774. }
  5775. func (c *HisApiController) Get1318() {
  5776. adminUser := c.GetAdminUserInfo()
  5777. admin_user_id, _ := c.GetInt64("admin_user_id")
  5778. code := c.GetString("code")
  5779. code = ""
  5780. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5781. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5782. api := ""
  5783. if miConfig.MdtrtareaAdmvs == "320830" {
  5784. api = miConfig.AppSecret + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5785. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5786. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5787. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5788. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5789. } else {
  5790. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5791. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5792. }
  5793. resp, requestErr := http.Get(api)
  5794. if requestErr != nil {
  5795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5796. return
  5797. }
  5798. body, ioErr := ioutil.ReadAll(resp.Body)
  5799. if ioErr != nil {
  5800. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5802. return
  5803. }
  5804. var respJSON map[string]interface{}
  5805. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5806. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5808. return
  5809. }
  5810. //var res Result2406
  5811. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5812. result, _ := json.Marshal(respJSON)
  5813. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5814. utils.ErrorLog("解析失败:%v", err)
  5815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5816. return
  5817. }
  5818. if res.Infcode == "0" {
  5819. c.ServeSuccessJSON(map[string]interface{}{
  5820. "result": "",
  5821. })
  5822. } else {
  5823. c.ServeSuccessJSON(map[string]interface{}{
  5824. "failed_code": -10,
  5825. "msg": res.ErrMsg,
  5826. })
  5827. */return
  5828. //}
  5829. }
  5830. func (c *HisApiController) Get2503() {
  5831. adminUser := c.GetAdminUserInfo()
  5832. admin_user_id, _ := c.GetInt64("admin_user_id")
  5833. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5834. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5835. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  5836. }
  5837. func (c *HisApiController) Get2406() {
  5838. id, _ := c.GetInt64("id")
  5839. record_time := c.GetString("record_time")
  5840. his_patient_id, _ := c.GetInt64("his_patient_id")
  5841. admin_user_id, _ := c.GetInt64("admin_user_id")
  5842. diagnosis_id := c.GetString("diagnosis")
  5843. timeLayout := "2006-01-02"
  5844. loc, _ := time.LoadLocation("Local")
  5845. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5846. if err != nil {
  5847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5848. return
  5849. }
  5850. recordDateTime := theTime.Unix()
  5851. adminUser := c.GetAdminUserInfo()
  5852. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5853. var config []*models.HisXtDiagnoseConfig
  5854. for _, item := range diagnosis_ids {
  5855. id, _ := strconv.ParseInt(item, 10, 64)
  5856. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5857. config = append(config, &diagnosisConfig)
  5858. }
  5859. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5860. fmt.Println(his_patient_id)
  5861. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5862. //timestamp := time.Now().Unix()
  5863. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5864. var patientPrescription models.HisPrescriptionInfo
  5865. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5866. if patientPrescription.ID == 0 {
  5867. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5868. }
  5869. var res2 Result2406
  5870. if miConfig.MdtrtareaAdmvs == "341203" {
  5871. data := make(map[string]interface{})
  5872. client := &http.Client{}
  5873. data["psn_no"] = his.PsnNo
  5874. data["mdtrt_id"] = his.Number
  5875. data["operator"] = roles.UserName
  5876. data["cert_no"] = his.IdCardNo
  5877. data["org_name"] = miConfig.OrgName
  5878. data["psn_name"] = his.Name
  5879. data["ipt_otp_no"] = his.IptOtpNo
  5880. data["ipt_psn_sp_flag_type"] = "0901"
  5881. data["ipt_psn_sp_flag"] = "1"
  5882. data["fixmedins_code"] = miConfig.Code
  5883. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5884. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5885. data["url"] = miConfig.Url
  5886. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5887. bytesData, _ := json.Marshal(data)
  5888. var req *http.Request
  5889. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5890. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5891. resp, _ := client.Do(req)
  5892. defer resp.Body.Close()
  5893. body, ioErr := ioutil.ReadAll(resp.Body)
  5894. if ioErr != nil {
  5895. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5897. return
  5898. }
  5899. var respJSON map[string]interface{}
  5900. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5901. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5903. return
  5904. }
  5905. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5906. if status == "0" {
  5907. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5908. c.ServeSuccessJSON(map[string]interface{}{
  5909. "failed_code": -10,
  5910. "msg": err_msg,
  5911. })
  5912. return
  5913. }
  5914. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5915. userJSONBytes, _ := json.Marshal(respJSON)
  5916. fmt.Println("log")
  5917. fmt.Println(string(userJSONBytes))
  5918. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5919. utils.ErrorLog("解析失败:%v", err)
  5920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5921. return
  5922. }
  5923. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5924. data := make(map[string]interface{})
  5925. client := &http.Client{}
  5926. data["psn_no"] = his.PsnNo
  5927. data["mdtrt_id"] = his.Number
  5928. data["operator"] = roles.UserName
  5929. data["cert_no"] = his.IdCardNo
  5930. data["org_name"] = miConfig.OrgName
  5931. data["psn_name"] = his.Name
  5932. data["ipt_otp_no"] = his.IptOtpNo
  5933. data["ipt_psn_sp_flag_type"] = "0901"
  5934. data["ipt_psn_sp_flag"] = "1"
  5935. data["fixmedins_code"] = miConfig.Code
  5936. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5937. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5938. data["url"] = miConfig.Url
  5939. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5940. bytesData, _ := json.Marshal(data)
  5941. var req *http.Request
  5942. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5943. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5944. resp, _ := client.Do(req)
  5945. defer resp.Body.Close()
  5946. body, ioErr := ioutil.ReadAll(resp.Body)
  5947. if ioErr != nil {
  5948. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5950. return
  5951. }
  5952. var respJSON map[string]interface{}
  5953. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5954. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5956. return
  5957. }
  5958. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5959. if status == "0" {
  5960. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5961. c.ServeSuccessJSON(map[string]interface{}{
  5962. "failed_code": -10,
  5963. "msg": err_msg,
  5964. })
  5965. return
  5966. }
  5967. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5968. userJSONBytes, _ := json.Marshal(respJSON)
  5969. fmt.Println("log")
  5970. fmt.Println(string(userJSONBytes))
  5971. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5972. utils.ErrorLog("解析失败:%v", err)
  5973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5974. return
  5975. }
  5976. }
  5977. if res2.Infcode != 0 {
  5978. adminUser := c.GetAdminUserInfo()
  5979. errlog := &models.HisOrderError{
  5980. UserOrgId: adminUser.CurrentOrgId,
  5981. Ctime: time.Now().Unix(),
  5982. Mtime: time.Now().Unix(),
  5983. ErrMsg: res2.ErrMsg,
  5984. Status: 1,
  5985. PatientId: id,
  5986. RecordTime: recordDateTime,
  5987. Stage: 3,
  5988. }
  5989. service.CreateErrMsgLog(errlog)
  5990. c.ServeSuccessJSON(map[string]interface{}{
  5991. "failed_code": -10,
  5992. "msg": res2.ErrMsg,
  5993. })
  5994. return
  5995. } else {
  5996. c.ServeSuccessJSON(map[string]interface{}{
  5997. "msg": "上传成功",
  5998. })
  5999. return
  6000. }
  6001. }
  6002. func (c *HisApiController) Get4105() {
  6003. }
  6004. func (c *HisApiController) Post5302() {
  6005. patient_id, _ := c.GetInt64("id")
  6006. admin_user_id, _ := c.GetInt64("admin_user_id")
  6007. p, _ := service.GetHisPatientById(patient_id)
  6008. adminUser := c.GetAdminUserInfo()
  6009. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6010. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6011. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  6012. }
  6013. func (c *HisApiController) Get4104() {
  6014. }
  6015. type Output struct {
  6016. CertNo string `json:"certno"`
  6017. PsnName string `json:"psn_name"`
  6018. CardNo string `json:"card_no"`
  6019. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  6020. CardSN string `json:"card_sn"`
  6021. PsnCertType string `json:"psn_cert_type"`
  6022. MdtrtCertNo string `json:"mdtrt_cert_no"`
  6023. MdtrtCertType string `json:"mdtrt_cert_type"`
  6024. QRCode string `json:"qrCode"`
  6025. EcToken string `json:"ecToken"`
  6026. }
  6027. type AHResponse struct {
  6028. Body AHBody `json:"body"`
  6029. Code int `json:"code"`
  6030. CSBCode int `json:"csbCode"`
  6031. Message string `json:"message"`
  6032. RequestID string `json:"requestId"`
  6033. State struct{} `json:"state"`
  6034. }
  6035. type AHBody struct {
  6036. ErrMsg string `json:"err_msg"`
  6037. InfRefMsgID string `json:"inf_refmsgid"`
  6038. InfCode int `json:"infcode"`
  6039. Output struct {
  6040. Result []struct {
  6041. BasMednFlag string `json:"bas_medn_flag"`
  6042. ChldMedcFlag string `json:"chld_medc_flag"`
  6043. ChrgitmLv string `json:"chrgitm_lv"`
  6044. Cnt float64 `json:"cnt"`
  6045. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  6046. DrtReimFlag string `json:"drt_reim_flag"`
  6047. FeedetlSn string `json:"feedetl_sn"`
  6048. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6049. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  6050. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6051. ListSpItemFlag string `json:"list_sp_item_flag"`
  6052. LmtUsedFlag string `json:"lmt_used_flag"`
  6053. MedChrgitmType string `json:"med_chrgitm_type"`
  6054. Memo string `json:"memo"`
  6055. OverlmtAmt float64 `json:"overlmt_amt"`
  6056. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6057. Pric float64 `json:"pric"`
  6058. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  6059. SelfpayProp float64 `json:"selfpay_prop"`
  6060. } `json:"result"`
  6061. } `json:"output"`
  6062. }
  6063. type Response struct {
  6064. Output Output `json:"output"`
  6065. Infcode int `json:"infcode"`
  6066. InfRefMsgID string `json:"inf_refmsgid"`
  6067. RefMsgTime string `json:"refmsg_time"`
  6068. RespondTime string `json:"respond_time"`
  6069. ErrMsg string `json:"err_msg"`
  6070. WarnMsg string `json:"warn_msg"`
  6071. SignType string `json:"signtype"`
  6072. CAInfo string `json:"cainfo"`
  6073. }
  6074. func (c *HisApiController) Getquerydata() {
  6075. query_type, _ := c.GetInt64("type")
  6076. refd_setl_flag := c.GetString("refd_setl_flag")
  6077. med_type := c.GetString("med_type")
  6078. //admin_user_id,_ := c.GetInt64("admin_user_id")
  6079. cert_no := c.GetString("cert_no")
  6080. psn_no := c.GetString("psn_no")
  6081. start_time := c.GetString("start_time")
  6082. end_time := c.GetString("end_time")
  6083. page, _ := c.GetInt64("page")
  6084. limit, _ := c.GetInt64("limit")
  6085. var bp models.BusinessParams5262
  6086. bp.RefdSetlFlag = refd_setl_flag
  6087. bp.MedType = med_type
  6088. bp.Certno = cert_no
  6089. bp.Psnno = psn_no
  6090. bp.QBegntime = start_time
  6091. bp.QEndtime = end_time
  6092. if query_type == 1 { //本地
  6093. Post5262(c, bp, page, limit)
  6094. } else { //异地
  6095. Post5267(c, bp, page, limit)
  6096. }
  6097. }
  6098. func (c *HisApiController) Drugscheck() {
  6099. admin_user_id, _ := c.GetInt64("admin_user_id")
  6100. adminUser := c.GetAdminUserInfo()
  6101. var queryResult []QueryResult
  6102. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  6103. for _, item := range drugs {
  6104. result := QueryResult{
  6105. ID: item.ID,
  6106. Name: item.DrugName,
  6107. Code: item.MedicalInsuranceNumber,
  6108. List_type_code: "101",
  6109. }
  6110. queryResult = append(queryResult, result)
  6111. }
  6112. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6113. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6114. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6115. for _, item := range queryResult {
  6116. 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)
  6117. }
  6118. }
  6119. func (c *HisApiController) Goodcheck() {
  6120. admin_user_id, _ := c.GetInt64("admin_user_id")
  6121. adminUser := c.GetAdminUserInfo()
  6122. var queryResult []QueryResult
  6123. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  6124. for _, item := range goods {
  6125. result := QueryResult{
  6126. ID: item.ID,
  6127. Name: item.GoodName,
  6128. Code: item.SocialSecurityDirectoryCode,
  6129. List_type_code: "301",
  6130. }
  6131. queryResult = append(queryResult, result)
  6132. }
  6133. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6134. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6135. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6136. for _, item := range queryResult {
  6137. 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)
  6138. //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)
  6139. }
  6140. }
  6141. func (c *HisApiController) Projectcheck() {
  6142. admin_user_id, _ := c.GetInt64("admin_user_id")
  6143. adminUser := c.GetAdminUserInfo()
  6144. var queryResult []QueryResult
  6145. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  6146. for _, item := range projects {
  6147. result := QueryResult{
  6148. ID: item.ID,
  6149. Name: item.ProjectName,
  6150. Code: item.MedicalCode,
  6151. List_type_code: "201",
  6152. }
  6153. queryResult = append(queryResult, result)
  6154. }
  6155. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6156. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6157. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6158. for _, item := range queryResult {
  6159. 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)
  6160. }
  6161. }
  6162. //func (c *HisApiController)CancleDia(){
  6163. //
  6164. // id, _ := c.GetInt64("id")
  6165. // record_time := c.GetString("record_time")
  6166. // his_patient_id, _ := c.GetInt64("his_patient_id")
  6167. //
  6168. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6169. //
  6170. // diagnosis_id := c.GetString("diagnosis")
  6171. // sick_type, _ := c.GetInt64("sick_type")
  6172. // reg_type, _ := c.GetInt64("p_type")
  6173. // begin_time := c.GetString("begin_time")
  6174. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  6175. //
  6176. //
  6177. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  6178. //
  6179. // fmt.Println(acct_used_flag)
  6180. //
  6181. //
  6182. // timeLayout := "2006-01-02"
  6183. // loc, _ := time.LoadLocation("Local")
  6184. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6185. // if err != nil {
  6186. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6187. // return
  6188. // }
  6189. // recordDateTime := theTime.Unix()
  6190. // adminUser := c.GetAdminUserInfo()
  6191. //
  6192. //
  6193. //
  6194. //
  6195. //
  6196. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6197. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6198. // var patientPrescription models.HisPrescriptionInfo
  6199. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6200. // if patientPrescription.ID == 0 {
  6201. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6202. // }
  6203. // //if patientPrescription.Do
  6204. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6205. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6206. //
  6207. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6208. //
  6209. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  6210. //
  6211. // var config []*models.HisXtDiagnoseConfig
  6212. // for _, item := range diagnosis_ids {
  6213. // id, _ := strconv.ParseInt(item, 10, 64)
  6214. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  6215. // config = append(config, &diagnosisConfig)
  6216. // }
  6217. //
  6218. // sickConfig, _ := service.FindSickById(sick_type)
  6219. //
  6220. //
  6221. // data := make(map[string]interface{})
  6222. // client := &http.Client{}
  6223. // data["psn_no"] = his.PsnNo
  6224. // data["mdtrt_id"] = his.Number
  6225. // data["doctor"] = roles.UserName
  6226. // data["department"] = department.Name
  6227. // data["org_name"] = miConfig.OrgName
  6228. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  6229. // data["doctor_id"] = doctor_info.DoctorNumber
  6230. // data["new_doctor_name"] = doctor_info.UserName
  6231. // data["fixmedins_code"] = miConfig.Code
  6232. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6233. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6234. // data["secret_key"] = miConfig.SecretKey
  6235. // data["sick_code"] = sickConfig.CountryCode
  6236. // data["sick_name"] = sickConfig.ClassName
  6237. // data["url"] = miConfig.Url
  6238. // data["ak"] = miConfig.AccessKey
  6239. // data["begin_time"] = begin_time
  6240. // data["cainfo"] = miConfig.Cainfo
  6241. // data["is_vaild"] = "0"
  6242. //
  6243. // data["dept"] = strconv.FormatInt(department.ID, 10)
  6244. // data["config"] = config
  6245. // bytesData, _ := json.Marshal(data)
  6246. //
  6247. // var req *http.Request
  6248. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  6249. // resp, _ := client.Do(req)
  6250. // defer resp.Body.Close()
  6251. // body, ioErr := ioutil.ReadAll(resp.Body)
  6252. // if ioErr != nil {
  6253. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6254. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6255. // return
  6256. // }
  6257. // var respJSON map[string]interface{}
  6258. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6259. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6260. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6261. // return
  6262. // }
  6263. //
  6264. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6265. // userJSONBytes, _ := json.Marshal(respJSON)
  6266. // fmt.Println("log")
  6267. // fmt.Println(string(userJSONBytes))
  6268. //
  6269. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  6270. // utils.ErrorLog("解析失败:%v", err)
  6271. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6272. // return
  6273. // }
  6274. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  6275. // res2.Output = ressix10265.Output
  6276. // res2.ErrMsg = ressix10265.ErrMsg
  6277. // res2.Cainfo = ressix10265.Cainfo
  6278. // res2.WarnMsg = ressix10265.WarnMsg
  6279. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  6280. // res2.Infcode = infocode
  6281. //
  6282. //}
  6283. func (c *HisApiController) Get4102() {
  6284. order_id, _ := c.GetInt64("order_id")
  6285. admin_user_id, _ := c.GetInt64("admin_user_id")
  6286. stas_type := c.GetString("stas_type")
  6287. order, _ := service.GetHisOrderByIDTwo(order_id)
  6288. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6289. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6290. var pp models.PublicParams
  6291. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6292. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6293. pp.FixmedinsName = miConfig.OrgName
  6294. pp.FixmedinsCode = miConfig.Code
  6295. pp.RequestUrl = miConfig.Url
  6296. pp.Cainfo = miConfig.Cainfo
  6297. pp.SecretKey = miConfig.SecretKey
  6298. pp.AccessKey = miConfig.AccessKey
  6299. pp.OpterName = curRoles.UserName
  6300. if miConfig.MdtrtareaAdmvs == "350500" {
  6301. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  6302. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  6303. saveLog(result, request, "4102", "清单确认")
  6304. var dat map[string]interface{}
  6305. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6306. fmt.Println(dat)
  6307. } else {
  6308. fmt.Println(err)
  6309. }
  6310. var empty ResultFourteen
  6311. userJSONBytes, _ := json.Marshal(dat)
  6312. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  6313. utils.ErrorLog("解析失败:%v", err)
  6314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6315. return
  6316. }
  6317. if empty.Infcode == 0 {
  6318. c.ServeSuccessJSON(map[string]interface{}{
  6319. "msg": "确认成功",
  6320. })
  6321. return
  6322. }
  6323. } else {
  6324. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  6325. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  6326. result3, request3 := service.Jxyb4105(pp)
  6327. saveLog(result, request, "4102", "清单确认")
  6328. saveLog(result2, request2, "4103", "清单确认")
  6329. saveLog(result3, request3, "4105", "清单统计")
  6330. var dat map[string]interface{}
  6331. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6332. fmt.Println(dat)
  6333. } else {
  6334. fmt.Println(err)
  6335. }
  6336. var empty ResultFourteen
  6337. userJSONBytes, _ := json.Marshal(dat)
  6338. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  6339. utils.ErrorLog("解析失败:%v", err)
  6340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6341. return
  6342. }
  6343. if empty.Infcode == 0 {
  6344. c.ServeSuccessJSON(map[string]interface{}{
  6345. "msg": "确认成功",
  6346. })
  6347. return
  6348. }
  6349. }
  6350. }
  6351. // 对账权限查询
  6352. func (c *HisApiController) Get3260() {
  6353. admin_user_id, _ := c.GetInt64("admin_user_id")
  6354. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6355. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6356. var api string
  6357. var res models.JSResult3260
  6358. if miConfig.MdtrtareaAdmvs == "320830" {
  6359. api = miConfig.AppSecret + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6360. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6361. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6362. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6363. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6364. } else {
  6365. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6366. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6367. }
  6368. resp, requestErr := http.Get(api)
  6369. if requestErr != nil {
  6370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6371. return
  6372. }
  6373. body, ioErr := ioutil.ReadAll(resp.Body)
  6374. if ioErr != nil {
  6375. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6377. return
  6378. }
  6379. var respJSON map[string]interface{}
  6380. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6381. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6383. return
  6384. }
  6385. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6386. result, _ := json.Marshal(respJSON)
  6387. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6388. utils.ErrorLog("解析失败:%v", err)
  6389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6390. return
  6391. }
  6392. if res.Infcode == "0" {
  6393. c.ServeSuccessJSON(map[string]interface{}{
  6394. "result": res.Output.Data,
  6395. })
  6396. } else {
  6397. c.ServeSuccessJSON(map[string]interface{}{
  6398. "failed_code": -10,
  6399. "msg": res.ErrMsg,
  6400. })
  6401. return
  6402. }
  6403. }
  6404. func (c *HisApiController) Get3261() {
  6405. admin_user_id, _ := c.GetInt64("admin_user_id")
  6406. //month := c.GetString("month")
  6407. startTime := c.GetString("start_time")
  6408. //endTime, _ := c.GetString("end_time")
  6409. times := strings.Split(startTime, "-")
  6410. stmt_mon := times[0] + times[1]
  6411. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6412. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6413. var api string
  6414. var res models.JSResult3261
  6415. //var res10265 Result5301For10265
  6416. if miConfig.MdtrtareaAdmvs == "320830" {
  6417. api = miConfig.AppSecret + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6418. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6419. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6420. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6421. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6422. } else {
  6423. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6424. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6425. }
  6426. resp, requestErr := http.Get(api)
  6427. if requestErr != nil {
  6428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6429. return
  6430. }
  6431. body, ioErr := ioutil.ReadAll(resp.Body)
  6432. if ioErr != nil {
  6433. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6435. return
  6436. }
  6437. var respJSON map[string]interface{}
  6438. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6439. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6441. return
  6442. }
  6443. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6444. result, _ := json.Marshal(respJSON)
  6445. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6446. utils.ErrorLog("解析失败:%v", err)
  6447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6448. return
  6449. }
  6450. if res.Infcode == "0" {
  6451. c.ServeSuccessJSON(map[string]interface{}{
  6452. "result": res.Output,
  6453. })
  6454. } else {
  6455. c.ServeSuccessJSON(map[string]interface{}{
  6456. "failed_code": -10,
  6457. "msg": res.ErrMsg,
  6458. })
  6459. return
  6460. }
  6461. }
  6462. type TempFun struct {
  6463. FundKey string
  6464. FundCode string
  6465. }
  6466. func (c *HisApiController) Get3262() {
  6467. admin_user_id, _ := c.GetInt64("admin_user_id")
  6468. startTime := c.GetString("start_time")
  6469. endTime := c.GetString("end_time")
  6470. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6471. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6472. //timeLayout := "2006-01-02"
  6473. //loc, _ := time.LoadLocation("Local")
  6474. //var theStartTIme int64
  6475. //if len(startTime) > 0 {
  6476. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  6477. // if err != nil {
  6478. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6479. // return
  6480. // }
  6481. // theStartTIme = theTime.Unix()
  6482. //}
  6483. //var theEndtTIme int64
  6484. //if len(endTime) > 0 {
  6485. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  6486. // if err != nil {
  6487. // utils.ErrorLog(err.Error())
  6488. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6489. // return
  6490. // }
  6491. // theEndtTIme = theTime.Unix()
  6492. //}
  6493. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6494. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6495. for _, team := range datas {
  6496. fmt.Println(team.PsnTime)
  6497. for _, team_two := range datas_two {
  6498. fmt.Println(team_two.PsnTime)
  6499. if team.FundKey == team_two.FundKey {
  6500. fmt.Println(team_two.PsnTime)
  6501. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  6502. fmt.Println(team.PsnTime)
  6503. }
  6504. }
  6505. }
  6506. fmt.Println("1111")
  6507. fmt.Println(datas)
  6508. fmt.Println("1111")
  6509. var twos []models.FixMonRecDetailFileInTwo
  6510. for _, team := range datas {
  6511. var two models.FixMonRecDetailFileInTwo
  6512. two.MedType = team.MedType
  6513. two.Insutype = team.Insutype
  6514. two.PsnType = team.PsnType
  6515. two.MedType = team.MedType
  6516. two.FixBlngAdmdvs = "999999"
  6517. two.InsuAdmdvs = "555555"
  6518. two.PsnTime = team.PsnTime
  6519. two.PsnCnt = team.PsnCnt
  6520. two.FundKey = team.FundKey
  6521. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6522. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6523. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6524. two.MedfeeSumAmt = ms
  6525. two.InscpAmt = ia
  6526. two.FundPaySumAmt = fps
  6527. twos = append(twos, two)
  6528. }
  6529. //startTime := c.GetString("start_time")
  6530. //endTime, _ := c.GetString("end_time")
  6531. times := strings.Split(startTime, "-")
  6532. stmt_mon := times[0] + times[1]
  6533. var funs []models.FundDetail
  6534. for _, item := range datas {
  6535. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6536. funs = append(funs, fun...)
  6537. }
  6538. var funInfos []models.Fund
  6539. //for _, item := range funs {
  6540. // var rf []models.FundInfo
  6541. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6542. // for _, subitem := range rf {
  6543. // var fund models.Fund
  6544. // fund.FundCode = subitem.FundPayType
  6545. // fund.FundName = subitem.FundPayTypeName
  6546. // fund.FundAmt = subitem.FundPayAmt
  6547. // fund.FundKey = item.FundKey
  6548. // fund.InsuAdmdvs = "555555"
  6549. // fund.FixBlngAdmdvs = "999999"
  6550. // funInfos = append(funInfos, fund)
  6551. // }
  6552. //}
  6553. var tempFuns []TempFun
  6554. for _, funInfo := range funInfos {
  6555. var tempFun TempFun
  6556. tempFun.FundKey = funInfo.FundKey
  6557. tempFun.FundCode = funInfo.FundCode
  6558. tempFuns = append(tempFuns, tempFun)
  6559. }
  6560. tempFuns = RemoveRepeatedFunElement(tempFuns)
  6561. fmt.Println(tempFuns)
  6562. var funInfosTwo []models.Fund
  6563. decimal.DivisionPrecision = 2
  6564. for _, item := range tempFuns {
  6565. var fund models.Fund
  6566. for _, subItem := range funInfos {
  6567. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  6568. fund.FundKey = subItem.FundKey
  6569. fund.InsuAdmdvs = subItem.InsuAdmdvs
  6570. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  6571. fund.FundName = subItem.FundName
  6572. fund.FundCode = subItem.FundCode
  6573. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  6574. }
  6575. }
  6576. funInfosTwo = append(funInfosTwo, fund)
  6577. }
  6578. fmt.Println("funInfosTwo")
  6579. fmt.Println(funInfosTwo)
  6580. var upld_btch string
  6581. var empty models.JSResultEmpty
  6582. data := make(map[string]interface{})
  6583. data["org_name"] = miConfig.OrgName
  6584. data["doctor"] = curRoles.UserName
  6585. data["doctor_name"] = curRoles.UserName
  6586. data["fixmedins_code"] = miConfig.Code
  6587. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6588. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6589. data["secret_key"] = miConfig.SecretKey
  6590. data["url"] = miConfig.Url
  6591. data["ak"] = miConfig.AccessKey
  6592. data["cainfo"] = miConfig.Cainfo
  6593. data["datas"] = twos
  6594. data["fund"] = funInfosTwo
  6595. fmt.Println(twos)
  6596. month := time.Unix(1557042972, 0).Format("1")
  6597. year := time.Now().Format("2006")
  6598. month = time.Now().Format("01")
  6599. day := time.Now().Format("02")
  6600. hour := time.Now().Format("15")
  6601. min := time.Now().Format("04")
  6602. sec := time.Now().Format("05")
  6603. fix_fill_date := year + month + day + hour + min + sec
  6604. data["fix_fill_dept"] = miConfig.OrgName
  6605. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6606. data["fix_fill_psn"] = curRoles.UserName
  6607. data["fix_fill_date"] = fix_fill_date
  6608. data["stmt_loc"] = "2"
  6609. data["setl_mon"] = stmt_mon
  6610. upld_btch = "0"
  6611. data["upld_btch"] = upld_btch
  6612. //fmt.Println(data)
  6613. client := &http.Client{}
  6614. bytesData, _ := json.Marshal(data)
  6615. var req *http.Request
  6616. if miConfig.MdtrtareaAdmvs == "320830" {
  6617. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3262", bytes.NewReader(bytesData))
  6618. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6619. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6620. } else {
  6621. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6622. }
  6623. resp, _ := client.Do(req)
  6624. defer resp.Body.Close()
  6625. body, ioErr := ioutil.ReadAll(resp.Body)
  6626. if ioErr != nil {
  6627. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6629. }
  6630. var respJSON map[string]interface{}
  6631. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6632. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6634. }
  6635. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6636. //fmt.Println(respJSON)
  6637. result, _ := json.Marshal(respJSON)
  6638. //fmt.Println(result)
  6639. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6640. utils.ErrorLog("解析失败:%v", err)
  6641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6642. }
  6643. if empty.Infcode != "0" {
  6644. c.ServeSuccessJSON(map[string]interface{}{
  6645. "failed_code": -10,
  6646. "msg": empty.ErrMsg,
  6647. })
  6648. return
  6649. } else {
  6650. c.ServeSuccessJSON(map[string]interface{}{
  6651. "msg": "上传成功",
  6652. })
  6653. return
  6654. }
  6655. }
  6656. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  6657. newArr = make([]TempFun, 0)
  6658. for i := 0; i < len(arr); i++ {
  6659. repeat := false
  6660. for j := i + 1; j < len(arr); j++ {
  6661. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  6662. repeat = true
  6663. break
  6664. }
  6665. }
  6666. if !repeat {
  6667. newArr = append(newArr, arr[i])
  6668. }
  6669. }
  6670. return
  6671. }
  6672. func (c *HisApiController) Get3263() {
  6673. admin_user_id, _ := c.GetInt64("admin_user_id")
  6674. startTime := c.GetString("start_time")
  6675. //endTime, _ := c.GetString("end_time")
  6676. times := strings.Split(startTime, "-")
  6677. setl_mon := times[0] + times[1]
  6678. upld_btch := "0"
  6679. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6680. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6681. var result3263 models.JSResult3263
  6682. data := make(map[string]interface{})
  6683. data["org_name"] = miConfig.OrgName
  6684. data["doctor"] = curRoles.UserName
  6685. data["doctor_name"] = curRoles.UserName
  6686. data["fixmedins_code"] = miConfig.Code
  6687. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6688. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6689. data["secret_key"] = miConfig.SecretKey
  6690. data["url"] = miConfig.Url
  6691. data["ak"] = miConfig.AccessKey
  6692. data["cainfo"] = miConfig.Cainfo
  6693. data["setl_mon"] = setl_mon
  6694. data["stmt_loc"] = "2"
  6695. data["upld_btch"] = upld_btch
  6696. client := &http.Client{}
  6697. bytesData, _ := json.Marshal(data)
  6698. var req *http.Request
  6699. if miConfig.MdtrtareaAdmvs == "320830" {
  6700. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3263", bytes.NewReader(bytesData))
  6701. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6702. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6703. } else {
  6704. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6705. }
  6706. resp, _ := client.Do(req)
  6707. defer resp.Body.Close()
  6708. body, ioErr := ioutil.ReadAll(resp.Body)
  6709. if ioErr != nil {
  6710. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6712. }
  6713. var respJSON map[string]interface{}
  6714. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6715. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6717. }
  6718. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6719. fmt.Println(respJSON)
  6720. result, _ := json.Marshal(respJSON)
  6721. fmt.Println(result)
  6722. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6723. utils.ErrorLog("解析失败:%v", err)
  6724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6725. }
  6726. if result3263.Infcode != "0" {
  6727. c.ServeSuccessJSON(map[string]interface{}{
  6728. "failed_code": -10,
  6729. "msg": result3263.ErrMsg,
  6730. })
  6731. return
  6732. } else {
  6733. c.ServeSuccessJSON(map[string]interface{}{
  6734. "list": result3263.Output,
  6735. })
  6736. return
  6737. }
  6738. }
  6739. func (c *HisApiController) Get3264() {
  6740. admin_user_id, _ := c.GetInt64("admin_user_id")
  6741. startTime := c.GetString("start_time")
  6742. //endTime, _ := c.GetString("end_time")
  6743. times := strings.Split(startTime, "-")
  6744. setl_mon := times[0] + times[1]
  6745. upld_btch := "0"
  6746. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6747. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6748. //solidify_id := []
  6749. var result3263 models.JSResult3263
  6750. data := make(map[string]interface{})
  6751. data["org_name"] = miConfig.OrgName
  6752. data["doctor"] = curRoles.UserName
  6753. data["doctor_name"] = curRoles.UserName
  6754. data["fixmedins_code"] = miConfig.Code
  6755. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6756. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6757. data["secret_key"] = miConfig.SecretKey
  6758. data["url"] = miConfig.Url
  6759. data["ak"] = miConfig.AccessKey
  6760. data["cainfo"] = miConfig.Cainfo
  6761. data["setl_mon"] = setl_mon
  6762. data["stmt_loc"] = "2"
  6763. data["upld_btch"] = upld_btch
  6764. client := &http.Client{}
  6765. bytesData, _ := json.Marshal(data)
  6766. var req3263 *http.Request
  6767. if miConfig.MdtrtareaAdmvs == "320830" {
  6768. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3263", bytes.NewReader(bytesData))
  6769. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6770. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6771. } else {
  6772. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6773. }
  6774. resp, _ := client.Do(req3263)
  6775. defer resp.Body.Close()
  6776. body, ioErr := ioutil.ReadAll(resp.Body)
  6777. if ioErr != nil {
  6778. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6780. }
  6781. var respJSON3263 map[string]interface{}
  6782. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  6783. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6785. }
  6786. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6787. fmt.Println(respJSON3263)
  6788. result, _ := json.Marshal(respJSON3263)
  6789. fmt.Println(result)
  6790. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6791. utils.ErrorLog("解析失败:%v", err)
  6792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6793. }
  6794. var ids []string
  6795. for _, item := range result3263.Output {
  6796. ids = append(ids, item.SolidifyID)
  6797. }
  6798. var empty models.JSResultEmpty
  6799. data2 := make(map[string]interface{})
  6800. data2["org_name"] = miConfig.OrgName
  6801. data2["doctor"] = curRoles.UserName
  6802. data2["doctor_name"] = curRoles.UserName
  6803. data2["fixmedins_code"] = miConfig.Code
  6804. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6805. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6806. data2["secret_key"] = miConfig.SecretKey
  6807. data2["url"] = miConfig.Url
  6808. data2["ak"] = miConfig.AccessKey
  6809. data2["cainfo"] = miConfig.Cainfo
  6810. data2["setl_mon"] = setl_mon
  6811. data2["stmt_loc"] = "2"
  6812. data2["upld_btch"] = upld_btch
  6813. data2["solidify_id"] = ids
  6814. client2 := &http.Client{}
  6815. bytesData2, _ := json.Marshal(data2)
  6816. var req *http.Request
  6817. if miConfig.MdtrtareaAdmvs == "320830" {
  6818. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3264", bytes.NewReader(bytesData))
  6819. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6820. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6821. } else {
  6822. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6823. }
  6824. resp2, _ := client2.Do(req)
  6825. defer resp.Body.Close()
  6826. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6827. if ioErr2 != nil {
  6828. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6830. }
  6831. var respJSON map[string]interface{}
  6832. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  6833. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6835. }
  6836. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6837. fmt.Println(respJSON)
  6838. result2, _ := json.Marshal(respJSON)
  6839. fmt.Println(result2)
  6840. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  6841. utils.ErrorLog("解析失败:%v", err)
  6842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6843. }
  6844. if empty.Infcode != "0" {
  6845. c.ServeSuccessJSON(map[string]interface{}{
  6846. "failed_code": -10,
  6847. "msg": empty.ErrMsg,
  6848. })
  6849. return
  6850. } else {
  6851. c.ServeSuccessJSON(map[string]interface{}{
  6852. "msg": "",
  6853. })
  6854. return
  6855. }
  6856. }
  6857. func (c *HisApiController) Get3265() {
  6858. admin_user_id, _ := c.GetInt64("admin_user_id")
  6859. startTime := c.GetString("start_time")
  6860. //endTime, _ := c.GetString("end_time")
  6861. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6862. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6863. times := strings.Split(startTime, "-")
  6864. setl_mon := times[0] + times[1]
  6865. var upld_btch string
  6866. upld_btch = "0"
  6867. //var empty models.JSResultEmpty
  6868. var result3265 models.JSResult3264
  6869. var result3263 models.JSResult3263
  6870. data2 := make(map[string]interface{})
  6871. data2["org_name"] = miConfig.OrgName
  6872. data2["doctor"] = curRoles.UserName
  6873. data2["doctor_name"] = curRoles.UserName
  6874. data2["fixmedins_code"] = miConfig.Code
  6875. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6876. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6877. data2["secret_key"] = miConfig.SecretKey
  6878. data2["url"] = miConfig.Url
  6879. data2["ak"] = miConfig.AccessKey
  6880. data2["cainfo"] = miConfig.Cainfo
  6881. data2["setl_mon"] = setl_mon
  6882. data2["stmt_loc"] = "2"
  6883. data2["upld_btch"] = upld_btch
  6884. client2 := &http.Client{}
  6885. bytesData2, _ := json.Marshal(data2)
  6886. var req3263 *http.Request
  6887. if miConfig.MdtrtareaAdmvs == "320830" {
  6888. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3263", bytes.NewReader(bytesData2))
  6889. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6890. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6891. } else {
  6892. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6893. }
  6894. resp2, _ := client2.Do(req3263)
  6895. defer resp2.Body.Close()
  6896. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6897. if ioErr2 != nil {
  6898. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6900. }
  6901. var respJSON3263 map[string]interface{}
  6902. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6903. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6905. }
  6906. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6907. fmt.Println(respJSON3263)
  6908. result2, _ := json.Marshal(respJSON3263)
  6909. fmt.Println(result2)
  6910. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6911. utils.ErrorLog("解析失败:%v", err)
  6912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6913. }
  6914. var ids []string
  6915. for _, item := range result3263.Output {
  6916. ids = append(ids, item.SolidifyID)
  6917. }
  6918. data := make(map[string]interface{})
  6919. data["org_name"] = miConfig.OrgName
  6920. data["doctor"] = curRoles.UserName
  6921. data["doctor_name"] = curRoles.UserName
  6922. data["fixmedins_code"] = miConfig.Code
  6923. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6924. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6925. data["secret_key"] = miConfig.SecretKey
  6926. data["url"] = miConfig.Url
  6927. data["ak"] = miConfig.AccessKey
  6928. data["cainfo"] = miConfig.Cainfo
  6929. data["setl_mon"] = setl_mon
  6930. data["solidify_id"] = ids
  6931. month := time.Unix(1557042972, 0).Format("1")
  6932. year := time.Now().Format("2006")
  6933. month = time.Now().Format("01")
  6934. day := time.Now().Format("02")
  6935. hour := time.Now().Format("15")
  6936. min := time.Now().Format("04")
  6937. sec := time.Now().Format("05")
  6938. fix_fill_date := year + month + day + hour + min + sec
  6939. data["fix_fill_dept"] = miConfig.OrgName
  6940. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6941. data["fix_fill_psn"] = curRoles.UserName
  6942. data["fix_fill_date"] = fix_fill_date
  6943. data["stmt_loc"] = "2"
  6944. data["upld_btch"] = upld_btch
  6945. client := &http.Client{}
  6946. bytesData, _ := json.Marshal(data)
  6947. var req *http.Request
  6948. if miConfig.MdtrtareaAdmvs == "320830" {
  6949. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3265", bytes.NewReader(bytesData2))
  6950. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6951. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6952. } else {
  6953. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6954. }
  6955. resp, _ := client.Do(req)
  6956. defer resp.Body.Close()
  6957. body, ioErr := ioutil.ReadAll(resp.Body)
  6958. if ioErr != nil {
  6959. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6961. }
  6962. var respJSON map[string]interface{}
  6963. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6964. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6966. }
  6967. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6968. fmt.Println(respJSON)
  6969. result, _ := json.Marshal(respJSON)
  6970. fmt.Println(result)
  6971. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6972. utils.ErrorLog("解析失败:%v", err)
  6973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6974. }
  6975. if result3265.Infcode != "0" {
  6976. c.ServeSuccessJSON(map[string]interface{}{
  6977. "failed_code": -10,
  6978. "msg": result3265.ErrMsg,
  6979. })
  6980. return
  6981. } else {
  6982. c.ServeSuccessJSON(map[string]interface{}{
  6983. "info": result3265.Output,
  6984. })
  6985. return
  6986. }
  6987. }
  6988. func (c *HisApiController) Get3266() {
  6989. admin_user_id, _ := c.GetInt64("admin_user_id")
  6990. startTime := c.GetString("start_time")
  6991. //endTime, _ := c.GetString("end_time")
  6992. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6993. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6994. times := strings.Split(startTime, "-")
  6995. stmt_mon := times[0] + times[1]
  6996. var upld_btch string
  6997. //var empty models.JSResultEmpty
  6998. var result3265 models.JSResult3264
  6999. data := make(map[string]interface{})
  7000. data["org_name"] = miConfig.OrgName
  7001. data["doctor"] = curRoles.UserName
  7002. data["doctor_name"] = curRoles.UserName
  7003. data["fixmedins_code"] = miConfig.Code
  7004. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7005. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7006. data["secret_key"] = miConfig.SecretKey
  7007. data["url"] = miConfig.Url
  7008. data["ak"] = miConfig.AccessKey
  7009. data["cainfo"] = miConfig.Cainfo
  7010. data["setl_mon"] = stmt_mon
  7011. month := time.Unix(1557042972, 0).Format("1")
  7012. year := time.Now().Format("2006")
  7013. month = time.Now().Format("01")
  7014. day := time.Now().Format("02")
  7015. hour := time.Now().Format("15")
  7016. min := time.Now().Format("04")
  7017. sec := time.Now().Format("05")
  7018. fix_fill_date := year + month + day + hour + min + sec
  7019. data["fix_fill_dept"] = miConfig.OrgName
  7020. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7021. data["fix_fill_psn"] = curRoles.UserName
  7022. data["fix_fill_date"] = fix_fill_date
  7023. data["stmt_loc"] = "2"
  7024. upld_btch = "0"
  7025. data["upld_btch"] = upld_btch
  7026. client := &http.Client{}
  7027. bytesData, _ := json.Marshal(data)
  7028. var req *http.Request
  7029. if miConfig.MdtrtareaAdmvs == "320830" {
  7030. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3266", bytes.NewReader(bytesData))
  7031. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7032. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  7033. } else {
  7034. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  7035. }
  7036. resp, _ := client.Do(req)
  7037. defer resp.Body.Close()
  7038. body, ioErr := ioutil.ReadAll(resp.Body)
  7039. if ioErr != nil {
  7040. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7042. }
  7043. var respJSON map[string]interface{}
  7044. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7045. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7047. }
  7048. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7049. fmt.Println(respJSON)
  7050. result, _ := json.Marshal(respJSON)
  7051. fmt.Println(result)
  7052. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7053. utils.ErrorLog("解析失败:%v", err)
  7054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7055. }
  7056. if result3265.Infcode != "0" {
  7057. c.ServeSuccessJSON(map[string]interface{}{
  7058. "failed_code": -10,
  7059. "msg": result3265.ErrMsg,
  7060. })
  7061. return
  7062. } else {
  7063. c.ServeSuccessJSON(map[string]interface{}{
  7064. "info": result3265.Output,
  7065. })
  7066. return
  7067. }
  7068. }
  7069. func (c *HisApiController) Get3267() {
  7070. admin_user_id, _ := c.GetInt64("admin_user_id")
  7071. startTime := c.GetString("start_time")
  7072. //endTime, _ := c.GetString("end_time")
  7073. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7074. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7075. times := strings.Split(startTime, "-")
  7076. setl_mon := times[0] + times[1]
  7077. var upld_btch string
  7078. //var empty models.JSResultEmpty
  7079. var result3265 models.JSResult3264
  7080. upld_btch = "0"
  7081. data := make(map[string]interface{})
  7082. data["org_name"] = miConfig.OrgName
  7083. data["doctor"] = curRoles.UserName
  7084. data["doctor_name"] = curRoles.UserName
  7085. data["fixmedins_code"] = miConfig.Code
  7086. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7087. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7088. data["secret_key"] = miConfig.SecretKey
  7089. data["url"] = miConfig.Url
  7090. data["ak"] = miConfig.AccessKey
  7091. data["cainfo"] = miConfig.Cainfo
  7092. data["setl_mon"] = setl_mon
  7093. data["stmt_loc"] = "2"
  7094. data["upld_btch"] = upld_btch
  7095. client := &http.Client{}
  7096. bytesData, _ := json.Marshal(data)
  7097. var req *http.Request
  7098. if miConfig.MdtrtareaAdmvs == "320830" {
  7099. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3267", bytes.NewReader(bytesData))
  7100. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7101. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  7102. } else {
  7103. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  7104. }
  7105. resp, _ := client.Do(req)
  7106. defer resp.Body.Close()
  7107. body, ioErr := ioutil.ReadAll(resp.Body)
  7108. if ioErr != nil {
  7109. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7111. }
  7112. var respJSON map[string]interface{}
  7113. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7114. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7116. }
  7117. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7118. fmt.Println(respJSON)
  7119. result, _ := json.Marshal(respJSON)
  7120. fmt.Println(result)
  7121. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7122. utils.ErrorLog("解析失败:%v", err)
  7123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7124. }
  7125. if result3265.Infcode != "0" {
  7126. c.ServeSuccessJSON(map[string]interface{}{
  7127. "failed_code": -10,
  7128. "msg": result3265.ErrMsg,
  7129. })
  7130. return
  7131. } else {
  7132. c.ServeSuccessJSON(map[string]interface{}{
  7133. "info": result3265.Output.Data,
  7134. })
  7135. return
  7136. }
  7137. }
  7138. func (c *HisApiController) Get3268() {
  7139. admin_user_id, _ := c.GetInt64("admin_user_id")
  7140. startTime := c.GetString("start_time")
  7141. endTime := c.GetString("end_time")
  7142. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7143. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7144. times := strings.Split(startTime, "-")
  7145. setl_mon := times[0] + times[1]
  7146. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  7147. var twos []models.FixMonRecDetailFileInTwo
  7148. var funs []models.FundDetail
  7149. for _, item := range datas {
  7150. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  7151. funs = append(funs, fun...)
  7152. }
  7153. var funInfos []models.Fund
  7154. //for _, item := range funs {
  7155. // var rf []models.FundInfo
  7156. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  7157. // for _, subitem := range rf {
  7158. // var fund models.Fund
  7159. // fund.FundCode = subitem.FundPayType
  7160. // fund.FundName = subitem.FundPayTypeName
  7161. // fund.FundAmt = subitem.FundPayAmt
  7162. // fund.FundKey = item.FundKey
  7163. // fund.InsuAdmdvs = "555555"
  7164. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  7165. // funInfos = append(funInfos, fund)
  7166. // }
  7167. //}
  7168. for _, team := range datas {
  7169. var two models.FixMonRecDetailFileInTwo
  7170. two.SetlDate = time.Now().Format("2006-01-02")
  7171. two.MedType = team.MedType
  7172. two.Insutype = team.Insutype
  7173. two.PsnType = team.PsnType
  7174. two.MedType = team.MedType
  7175. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  7176. two.InsuAdmdvs = team.InsuAdmdvs
  7177. two.PsnTime = team.PsnTime
  7178. two.PsnCnt = team.PsnCnt
  7179. two.FundKey = team.FundKey
  7180. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  7181. fps, _ := strconv.ParseFloat(team.Fund, 64)
  7182. ia, _ := strconv.ParseFloat(team.Amt, 64)
  7183. two.MedfeeSumAmt = ms
  7184. two.InscpAmt = ia
  7185. two.FundPaySumAmt = fps
  7186. twos = append(twos, two)
  7187. }
  7188. var upld_btch string
  7189. upld_btch = "0"
  7190. var empty models.JSResultEmpty
  7191. data := make(map[string]interface{})
  7192. data["org_name"] = miConfig.OrgName
  7193. data["doctor"] = curRoles.UserName
  7194. data["doctor_name"] = curRoles.UserName
  7195. data["fixmedins_code"] = miConfig.Code
  7196. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7197. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7198. data["secret_key"] = miConfig.SecretKey
  7199. data["url"] = miConfig.Url
  7200. data["ak"] = miConfig.AccessKey
  7201. data["cainfo"] = miConfig.Cainfo
  7202. data["datas"] = twos
  7203. data["fund"] = funInfos
  7204. data["setl_mon"] = setl_mon
  7205. month := time.Unix(1557042972, 0).Format("1")
  7206. year := time.Now().Format("2006")
  7207. month = time.Now().Format("01")
  7208. day := time.Now().Format("02")
  7209. hour := time.Now().Format("15")
  7210. min := time.Now().Format("04")
  7211. sec := time.Now().Format("05")
  7212. fix_fill_date := year + month + day + hour + min + sec
  7213. data["fix_fill_dept"] = miConfig.OrgName
  7214. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7215. data["fix_fill_psn"] = curRoles.UserName
  7216. data["fix_fill_date"] = fix_fill_date
  7217. data["stmt_loc"] = "2"
  7218. data["upld_btch"] = upld_btch
  7219. client := &http.Client{}
  7220. bytesData, _ := json.Marshal(data)
  7221. var req *http.Request
  7222. if miConfig.MdtrtareaAdmvs == "320830" {
  7223. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3268", bytes.NewReader(bytesData))
  7224. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7225. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  7226. } else {
  7227. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  7228. }
  7229. resp, _ := client.Do(req)
  7230. defer resp.Body.Close()
  7231. body, ioErr := ioutil.ReadAll(resp.Body)
  7232. if ioErr != nil {
  7233. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7235. }
  7236. var respJSON map[string]interface{}
  7237. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7238. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7240. }
  7241. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7242. fmt.Println(respJSON)
  7243. result, _ := json.Marshal(respJSON)
  7244. fmt.Println(result)
  7245. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  7246. utils.ErrorLog("解析失败:%v", err)
  7247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7248. }
  7249. if empty.Infcode != "0" {
  7250. c.ServeSuccessJSON(map[string]interface{}{
  7251. "failed_code": -10,
  7252. "msg": empty.ErrMsg,
  7253. })
  7254. return
  7255. } else {
  7256. c.ServeSuccessJSON(map[string]interface{}{
  7257. "msg": "上传成功",
  7258. })
  7259. return
  7260. }
  7261. }
  7262. func (c *HisApiController) Get3269() {
  7263. admin_user_id, _ := c.GetInt64("admin_user_id")
  7264. startTime := c.GetString("start_time")
  7265. //endTime, _ := c.GetString("end_time")
  7266. times := strings.Split(startTime, "-")
  7267. setl_mon := times[0] + times[1]
  7268. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7269. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7270. var result3263 models.JSResult3263
  7271. data := make(map[string]interface{})
  7272. data["org_name"] = miConfig.OrgName
  7273. data["doctor"] = curRoles.UserName
  7274. data["doctor_name"] = curRoles.UserName
  7275. data["fixmedins_code"] = miConfig.Code
  7276. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7277. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7278. data["secret_key"] = miConfig.SecretKey
  7279. data["url"] = miConfig.Url
  7280. data["ak"] = miConfig.AccessKey
  7281. data["cainfo"] = miConfig.Cainfo
  7282. data["setl_mon"] = setl_mon
  7283. data["stmt_loc"] = "2"
  7284. client := &http.Client{}
  7285. bytesData, _ := json.Marshal(data)
  7286. var req *http.Request
  7287. if miConfig.MdtrtareaAdmvs == "320830" {
  7288. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3269", bytes.NewReader(bytesData))
  7289. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7290. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  7291. } else {
  7292. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  7293. }
  7294. resp, _ := client.Do(req)
  7295. defer resp.Body.Close()
  7296. body, ioErr := ioutil.ReadAll(resp.Body)
  7297. if ioErr != nil {
  7298. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7300. }
  7301. var respJSON map[string]interface{}
  7302. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7303. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7305. }
  7306. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7307. fmt.Println(respJSON)
  7308. result, _ := json.Marshal(respJSON)
  7309. fmt.Println(result)
  7310. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  7311. utils.ErrorLog("解析失败:%v", err)
  7312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7313. }
  7314. if result3263.Infcode != "0" {
  7315. c.ServeSuccessJSON(map[string]interface{}{
  7316. "failed_code": -10,
  7317. "msg": result3263.ErrMsg,
  7318. })
  7319. return
  7320. } else {
  7321. c.ServeSuccessJSON(map[string]interface{}{
  7322. "msg": "上传成功",
  7323. })
  7324. return
  7325. }
  7326. }
  7327. func (c *HisApiController) Get3270() {
  7328. admin_user_id, _ := c.GetInt64("admin_user_id")
  7329. startTime := c.GetString("start_time")
  7330. //endTime, _ := c.GetString("end_time")
  7331. times := strings.Split(startTime, "-")
  7332. setl_mon := times[0] + times[1]
  7333. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7334. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7335. var result3263 models.JSResult3263
  7336. data2 := make(map[string]interface{})
  7337. data2["org_name"] = miConfig.OrgName
  7338. data2["doctor"] = curRoles.UserName
  7339. data2["doctor_name"] = curRoles.UserName
  7340. data2["fixmedins_code"] = miConfig.Code
  7341. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7342. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7343. data2["secret_key"] = miConfig.SecretKey
  7344. data2["url"] = miConfig.Url
  7345. data2["ak"] = miConfig.AccessKey
  7346. data2["cainfo"] = miConfig.Cainfo
  7347. data2["setl_mon"] = setl_mon
  7348. data2["stmt_loc"] = "2"
  7349. client2 := &http.Client{}
  7350. bytesData2, _ := json.Marshal(data2)
  7351. var req3263 *http.Request
  7352. if miConfig.MdtrtareaAdmvs == "320830" {
  7353. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3269", bytes.NewReader(bytesData2))
  7354. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7355. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7356. } else {
  7357. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7358. }
  7359. resp2, _ := client2.Do(req3263)
  7360. defer resp2.Body.Close()
  7361. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7362. if ioErr2 != nil {
  7363. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7365. }
  7366. var respJSON3263 map[string]interface{}
  7367. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7368. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7370. }
  7371. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7372. fmt.Println(respJSON3263)
  7373. result2, _ := json.Marshal(respJSON3263)
  7374. fmt.Println(result2)
  7375. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7376. utils.ErrorLog("解析失败:%v", err)
  7377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7378. }
  7379. var ids []string
  7380. for _, item := range result3263.Output {
  7381. ids = append(ids, item.SolidifyID)
  7382. }
  7383. var result3264 models.JSResult3264
  7384. data := make(map[string]interface{})
  7385. data["org_name"] = miConfig.OrgName
  7386. data["doctor"] = curRoles.UserName
  7387. data["doctor_name"] = curRoles.UserName
  7388. data["fixmedins_code"] = miConfig.Code
  7389. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7390. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7391. data["secret_key"] = miConfig.SecretKey
  7392. data["url"] = miConfig.Url
  7393. data["ak"] = miConfig.AccessKey
  7394. data["cainfo"] = miConfig.Cainfo
  7395. data["setl_mon"] = setl_mon
  7396. data["stmt_loc"] = "2"
  7397. data["solidify_id"] = ids
  7398. client := &http.Client{}
  7399. bytesData, _ := json.Marshal(data)
  7400. var req *http.Request
  7401. if miConfig.MdtrtareaAdmvs == "320830" {
  7402. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3270", bytes.NewReader(bytesData))
  7403. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7404. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7405. } else {
  7406. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7407. }
  7408. resp, _ := client.Do(req)
  7409. defer resp.Body.Close()
  7410. body, ioErr := ioutil.ReadAll(resp.Body)
  7411. if ioErr != nil {
  7412. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7414. }
  7415. var respJSON map[string]interface{}
  7416. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7417. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7419. }
  7420. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7421. fmt.Println(respJSON)
  7422. result, _ := json.Marshal(respJSON)
  7423. fmt.Println(result)
  7424. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  7425. utils.ErrorLog("解析失败:%v", err)
  7426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7427. }
  7428. if result3264.Infcode != "0" {
  7429. c.ServeSuccessJSON(map[string]interface{}{
  7430. "failed_code": -10,
  7431. "msg": result3264.ErrMsg,
  7432. })
  7433. return
  7434. } else {
  7435. c.ServeSuccessJSON(map[string]interface{}{
  7436. "info": result3264.Output,
  7437. })
  7438. return
  7439. }
  7440. }
  7441. func (c *HisApiController) Get3271() {
  7442. admin_user_id, _ := c.GetInt64("admin_user_id")
  7443. startTime := c.GetString("start_time")
  7444. //endTime, _ := c.GetString("end_time")
  7445. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7446. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7447. times := strings.Split(startTime, "-")
  7448. setl_mon := times[0] + times[1]
  7449. //var empty models.JSResultEmpty
  7450. var result3265 models.JSResult3264
  7451. var result3263 models.JSResult3263
  7452. data2 := make(map[string]interface{})
  7453. data2["org_name"] = miConfig.OrgName
  7454. data2["doctor"] = curRoles.UserName
  7455. data2["doctor_name"] = curRoles.UserName
  7456. data2["fixmedins_code"] = miConfig.Code
  7457. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7458. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7459. data2["secret_key"] = miConfig.SecretKey
  7460. data2["url"] = miConfig.Url
  7461. data2["ak"] = miConfig.AccessKey
  7462. data2["cainfo"] = miConfig.Cainfo
  7463. data2["setl_mon"] = setl_mon
  7464. data2["stmt_loc"] = "2"
  7465. client2 := &http.Client{}
  7466. bytesData2, _ := json.Marshal(data2)
  7467. var req3263 *http.Request
  7468. if miConfig.MdtrtareaAdmvs == "320830" {
  7469. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3269", bytes.NewReader(bytesData2))
  7470. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7471. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7472. } else {
  7473. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7474. }
  7475. resp2, _ := client2.Do(req3263)
  7476. defer resp2.Body.Close()
  7477. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7478. if ioErr2 != nil {
  7479. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7481. }
  7482. var respJSON3263 map[string]interface{}
  7483. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7484. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7486. }
  7487. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7488. fmt.Println(respJSON3263)
  7489. result2, _ := json.Marshal(respJSON3263)
  7490. fmt.Println(result2)
  7491. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7492. utils.ErrorLog("解析失败:%v", err)
  7493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7494. }
  7495. var ids []string
  7496. for _, item := range result3263.Output {
  7497. ids = append(ids, item.SolidifyID)
  7498. }
  7499. data := make(map[string]interface{})
  7500. data["org_name"] = miConfig.OrgName
  7501. data["doctor"] = curRoles.UserName
  7502. data["doctor_name"] = curRoles.UserName
  7503. data["fixmedins_code"] = miConfig.Code
  7504. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7505. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7506. data["secret_key"] = miConfig.SecretKey
  7507. data["url"] = miConfig.Url
  7508. data["ak"] = miConfig.AccessKey
  7509. data["cainfo"] = miConfig.Cainfo
  7510. data["setl_mon"] = setl_mon
  7511. data["solidify_id"] = ids
  7512. month := time.Unix(1557042972, 0).Format("1")
  7513. year := time.Now().Format("2006")
  7514. month = time.Now().Format("01")
  7515. day := time.Now().Format("02")
  7516. hour := time.Now().Format("15")
  7517. min := time.Now().Format("04")
  7518. sec := time.Now().Format("05")
  7519. fix_fill_date := year + month + day + hour + min + sec
  7520. data["fix_fill_dept"] = miConfig.OrgName
  7521. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7522. data["fix_fill_psn"] = curRoles.UserName
  7523. data["fix_fill_date"] = fix_fill_date
  7524. data["stmt_loc"] = "2"
  7525. client := &http.Client{}
  7526. bytesData, _ := json.Marshal(data)
  7527. var req *http.Request
  7528. if miConfig.MdtrtareaAdmvs == "320830" {
  7529. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3271", bytes.NewReader(bytesData2))
  7530. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7531. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7532. } else {
  7533. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7534. }
  7535. resp, _ := client.Do(req)
  7536. defer resp.Body.Close()
  7537. body, ioErr := ioutil.ReadAll(resp.Body)
  7538. if ioErr != nil {
  7539. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7541. }
  7542. var respJSON map[string]interface{}
  7543. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7544. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7546. }
  7547. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7548. fmt.Println(respJSON)
  7549. result, _ := json.Marshal(respJSON)
  7550. fmt.Println(result)
  7551. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7552. utils.ErrorLog("解析失败:%v", err)
  7553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7554. }
  7555. if result3265.Infcode != "0" {
  7556. c.ServeSuccessJSON(map[string]interface{}{
  7557. "failed_code": -10,
  7558. "msg": result3265.ErrMsg,
  7559. })
  7560. return
  7561. } else {
  7562. c.ServeSuccessJSON(map[string]interface{}{
  7563. "info": result3265.Output.Data,
  7564. })
  7565. return
  7566. }
  7567. }
  7568. func (c *HisApiController) Get3272() {
  7569. admin_user_id, _ := c.GetInt64("admin_user_id")
  7570. startTime := c.GetString("start_time")
  7571. //endTime, _ := c.GetString("end_time")
  7572. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7573. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7574. times := strings.Split(startTime, "-")
  7575. setl_mon := times[0] + times[1]
  7576. var upld_btch string
  7577. //var empty models.JSResultEmpty
  7578. var result3265 models.JSResult3264
  7579. data := make(map[string]interface{})
  7580. data["org_name"] = miConfig.OrgName
  7581. data["doctor"] = curRoles.UserName
  7582. data["doctor_name"] = curRoles.UserName
  7583. data["fixmedins_code"] = miConfig.Code
  7584. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7585. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7586. data["secret_key"] = miConfig.SecretKey
  7587. data["url"] = miConfig.Url
  7588. data["ak"] = miConfig.AccessKey
  7589. data["cainfo"] = miConfig.Cainfo
  7590. data["setl_mon"] = setl_mon
  7591. month := time.Unix(1557042972, 0).Format("1")
  7592. year := time.Now().Format("2006")
  7593. month = time.Now().Format("01")
  7594. day := time.Now().Format("02")
  7595. hour := time.Now().Format("15")
  7596. min := time.Now().Format("04")
  7597. sec := time.Now().Format("05")
  7598. fix_fill_date := year + month + day + hour + min + sec
  7599. data["fix_fill_dept"] = miConfig.OrgName
  7600. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7601. data["fix_fill_psn"] = curRoles.UserName
  7602. data["fix_fill_date"] = fix_fill_date
  7603. data["stmt_loc"] = "2"
  7604. data["upld_btch"] = upld_btch
  7605. client := &http.Client{}
  7606. bytesData, _ := json.Marshal(data)
  7607. var req *http.Request
  7608. if miConfig.MdtrtareaAdmvs == "320830" {
  7609. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3272", bytes.NewReader(bytesData))
  7610. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7611. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7612. } else {
  7613. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7614. }
  7615. resp, _ := client.Do(req)
  7616. defer resp.Body.Close()
  7617. body, ioErr := ioutil.ReadAll(resp.Body)
  7618. if ioErr != nil {
  7619. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7621. }
  7622. var respJSON map[string]interface{}
  7623. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7624. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7626. }
  7627. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7628. fmt.Println(respJSON)
  7629. result, _ := json.Marshal(respJSON)
  7630. fmt.Println(result)
  7631. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7632. utils.ErrorLog("解析失败:%v", err)
  7633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7634. }
  7635. if result3265.Infcode != "0" {
  7636. c.ServeSuccessJSON(map[string]interface{}{
  7637. "failed_code": -10,
  7638. "msg": result3265.ErrMsg,
  7639. })
  7640. return
  7641. } else {
  7642. c.ServeSuccessJSON(map[string]interface{}{
  7643. "info": result3265.Output,
  7644. })
  7645. return
  7646. }
  7647. }
  7648. func (c *HisApiController) Get3273() {
  7649. admin_user_id, _ := c.GetInt64("admin_user_id")
  7650. startTime := c.GetString("start_time")
  7651. //endTime, _ := c.GetString("end_time")
  7652. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7653. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7654. times := strings.Split(startTime, "-")
  7655. setl_mon := times[0] + times[1]
  7656. var result3265 models.JSResult3264
  7657. data := make(map[string]interface{})
  7658. data["org_name"] = miConfig.OrgName
  7659. data["doctor"] = curRoles.UserName
  7660. data["doctor_name"] = curRoles.UserName
  7661. data["fixmedins_code"] = miConfig.Code
  7662. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7663. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7664. data["secret_key"] = miConfig.SecretKey
  7665. data["url"] = miConfig.Url
  7666. data["ak"] = miConfig.AccessKey
  7667. data["cainfo"] = miConfig.Cainfo
  7668. data["setl_mon"] = setl_mon
  7669. data["stmt_loc"] = "2"
  7670. client := &http.Client{}
  7671. bytesData, _ := json.Marshal(data)
  7672. var req *http.Request
  7673. if miConfig.MdtrtareaAdmvs == "320921" {
  7674. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7675. } else {
  7676. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7677. }
  7678. resp, _ := client.Do(req)
  7679. defer resp.Body.Close()
  7680. body, ioErr := ioutil.ReadAll(resp.Body)
  7681. if ioErr != nil {
  7682. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7684. }
  7685. var respJSON map[string]interface{}
  7686. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7687. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7689. }
  7690. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7691. fmt.Println(respJSON)
  7692. result, _ := json.Marshal(respJSON)
  7693. fmt.Println(result)
  7694. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7695. utils.ErrorLog("解析失败:%v", err)
  7696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7697. }
  7698. if result3265.Infcode != "0" {
  7699. c.ServeSuccessJSON(map[string]interface{}{
  7700. "failed_code": -10,
  7701. "msg": result3265.ErrMsg,
  7702. })
  7703. return
  7704. } else {
  7705. c.ServeSuccessJSON(map[string]interface{}{
  7706. "info": result3265.Output.Data,
  7707. })
  7708. return
  7709. }
  7710. }
  7711. func (c *HisApiController) Get3274() {
  7712. //if miConfig.MdtrtareaAdmvs == "320921" {
  7713. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7714. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7715. // "&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
  7716. //
  7717. //} else {
  7718. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7719. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7720. // "&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
  7721. //
  7722. //}
  7723. }
  7724. func (c *HisApiController) Get3275() {
  7725. //if miConfig.MdtrtareaAdmvs == "320921" {
  7726. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7727. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7728. // "&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
  7729. //
  7730. //} else {
  7731. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7732. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7733. // "&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
  7734. //
  7735. //}
  7736. }
  7737. func (c *HisApiController) Get3276() {
  7738. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7739. //month := c.GetString("month")
  7740. //
  7741. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7742. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7743. //var api string
  7744. //var res Result5301
  7745. //
  7746. //if miConfig.MdtrtareaAdmvs == "320921" {
  7747. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7748. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7749. //} else {
  7750. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7751. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7752. //}
  7753. //
  7754. //resp, requestErr := http.Get(api)
  7755. //if requestErr != nil {
  7756. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7757. // return
  7758. //}
  7759. //
  7760. //body, ioErr := ioutil.ReadAll(resp.Body)
  7761. //if ioErr != nil {
  7762. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7763. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7764. // return
  7765. //}
  7766. //var respJSON map[string]interface{}
  7767. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7768. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7769. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7770. // return
  7771. //}
  7772. //
  7773. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7774. //result, _ := json.Marshal(respJSON)
  7775. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7776. // utils.ErrorLog("解析失败:%v", err)
  7777. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7778. // return
  7779. //}
  7780. }
  7781. func (c *HisApiController) Get3277() {
  7782. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7783. //month := c.GetString("month")
  7784. //
  7785. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7786. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7787. //var api string
  7788. //var res Result5301
  7789. //
  7790. //if miConfig.MdtrtareaAdmvs == "320921" {
  7791. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7792. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7793. //} else {
  7794. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7795. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7796. //}
  7797. //
  7798. //resp, requestErr := http.Get(api)
  7799. //if requestErr != nil {
  7800. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7801. // return
  7802. //}
  7803. //
  7804. //body, ioErr := ioutil.ReadAll(resp.Body)
  7805. //if ioErr != nil {
  7806. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7807. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7808. // return
  7809. //}
  7810. //var respJSON map[string]interface{}
  7811. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7812. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7813. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7814. // return
  7815. //}
  7816. //
  7817. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7818. //result, _ := json.Marshal(respJSON)
  7819. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7820. // utils.ErrorLog("解析失败:%v", err)
  7821. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7822. // return
  7823. //}
  7824. }
  7825. func (c *HisApiController) GetCFYLJG001() {
  7826. admin_user_id, _ := c.GetInt64("admin_user_id")
  7827. patient_id, _ := c.GetInt64("patient_id")
  7828. his_patient_id, _ := c.GetInt64("his_patient_id")
  7829. record_time := c.GetString("record_time")
  7830. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7831. psn, _ := service.GetPsnByPatientId(patient_id)
  7832. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7833. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7834. var cFYLJG001 models.CFYLJG001
  7835. timeLayout := "2006-01-02"
  7836. loc, _ := time.LoadLocation("Local")
  7837. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7838. if err != nil {
  7839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7840. return
  7841. }
  7842. recordDateTime := theTime.Unix()
  7843. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7844. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7845. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7846. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7847. //dept, _ := service.GetDepartMentDetail(info.Departments)
  7848. for _, item := range prescriptions {
  7849. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  7850. if his.IdCardType == 1 {
  7851. bas := strings.Split(psn.CardInfo, "|")
  7852. basNumber := bas[1]
  7853. fmt.Println(basNumber)
  7854. card_sn := bas[3]
  7855. card_no := bas[2]
  7856. cFYLJG001.MdtrtCertType = "03"
  7857. cFYLJG001.CardSn = card_sn
  7858. cFYLJG001.MdtrtCertNo = card_no
  7859. cFYLJG001.EcToken = ""
  7860. cFYLJG001.AuthNo = ""
  7861. } else if his.IdCardType == 2 {
  7862. cFYLJG001.MdtrtCertType = "02"
  7863. cFYLJG001.CardSn = ""
  7864. cFYLJG001.MdtrtCertNo = his.IdCardNo
  7865. cFYLJG001.EcToken = ""
  7866. cFYLJG001.AuthNo = ""
  7867. } else if his.IdCardType == 4 {
  7868. cFYLJG001.MdtrtCertType = "01"
  7869. cFYLJG001.CardSn = ""
  7870. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  7871. cFYLJG001.EcToken = psn.VerifyNumber
  7872. cFYLJG001.AuthNo = ""
  7873. }
  7874. cFYLJG001.BizTypeCode = "01"
  7875. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  7876. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  7877. cFYLJG001.RxTypeCode = "1"
  7878. tempTime := time.Unix(item.PreTime, 0)
  7879. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  7880. cFYLJG001.PrscTime = timeFormatOne
  7881. var count float64
  7882. if item.Type == 1 {
  7883. for _, sumItem := range item.HisDoctorAdviceInfo {
  7884. count = count + sumItem.PrescribingNumber
  7885. }
  7886. }
  7887. cFYLJG001.RxDrugCnt = count
  7888. cFYLJG001.ValiDays = "2"
  7889. ts := time.Unix(item.PreTime, 0)
  7890. record_time2 := ts.AddDate(0, 0, int(2)).Unix()
  7891. tempTime3 := time.Unix(record_time2, 0)
  7892. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  7893. cFYLJG001.ValiEndTime = timeFormat3
  7894. cFYLJG001.RxCotnFlag = "0"
  7895. for _, subItem := range item.HisDoctorAdviceInfo {
  7896. var drug models.RxDrug
  7897. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7898. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7899. drug.RxItemTypeCode = "11"
  7900. drug.DrugDosform = "剂" //TODO
  7901. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  7902. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7903. }
  7904. drug.MedcWayDscr = subItem.DeliveryWay
  7905. tempTime2 := time.Unix(subItem.StartTime, 0)
  7906. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7907. drug.MedcBegntime = timeFormatTwo
  7908. if subItem.Day > 0 {
  7909. ts := time.Unix(subItem.StartTime, 0)
  7910. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  7911. tempTime4 := time.Unix(record_time, 0)
  7912. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  7913. drug.MedcEndtime = timeFormat5
  7914. } else {
  7915. tempTime2 := time.Unix(subItem.StartTime, 0)
  7916. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7917. drug.MedcEndtime = timeFormatTwo
  7918. }
  7919. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  7920. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  7921. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  7922. drug.DrugCnt = subItem.PrescribingNumber
  7923. drug.DrugDosunt = subItem.PrescribingNumberUnit
  7924. drug.DrugGenname = subItem.AdviceName
  7925. drug.MedcWayCodg = subItem.DeliveryWay
  7926. //drug.DrugTotlcnt = subItem.PrescribingNumber
  7927. drug.SinDoscnt = subItem.SingleDose
  7928. drug.SinDosunt = subItem.SingleDoseUnit
  7929. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  7930. drug.UsedFrquName = subItem.ExecutionFrequency
  7931. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7932. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  7933. drug.HospApprFlag = "1"
  7934. cFYLJG001.List = append(cFYLJG001.List, drug)
  7935. }
  7936. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  7937. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.OrgName
  7938. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  7939. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  7940. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  7941. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  7942. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  7943. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  7944. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  7945. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  7946. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7947. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  7948. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  7949. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  7950. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7951. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  7952. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  7953. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  7954. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  7955. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  7956. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  7957. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  7958. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  7959. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  7960. tempTime2 := time.Now().Unix()
  7961. tempTime6 := time.Unix(tempTime2, 0)
  7962. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  7963. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  7964. cFYLJG001.Mdtrtinfo.DiseCodg = ""
  7965. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  7966. cFYLJG001.Mdtrtinfo.MaindiagCode = "I10.x00x002"
  7967. cFYLJG001.Mdtrtinfo.MaindiagName = "高血压"
  7968. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  7969. var config []*models.HisXtDiagnoseConfig
  7970. for _, item := range diagnosis_ids {
  7971. id, _ := strconv.ParseInt(item, 10, 64)
  7972. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7973. config = append(config, &diagnosisConfig)
  7974. }
  7975. for index, subitem := range config {
  7976. if index == 0 {
  7977. var dia models.DiseInfo
  7978. dia.DiagType = "1"
  7979. dia.MaindiagFlag = "1"
  7980. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7981. dia.DiagCode = subitem.CountryCode
  7982. dia.DiagName = subitem.ClassName
  7983. dia.DiagDept = "肾内科"
  7984. dia.DiagDrNo = doctor.DoctorNumber
  7985. dia.DiagDrName = doctor.UserName
  7986. tempTime3 := time.Unix(item.PreTime, 0)
  7987. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7988. dia.DiagTime = timeFormatTwo
  7989. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7990. } else {
  7991. var dia models.DiseInfo
  7992. dia.DiagType = "1"
  7993. dia.MaindiagFlag = "0"
  7994. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7995. dia.DiagCode = subitem.CountryCode
  7996. dia.DiagName = subitem.ClassName
  7997. dia.DiagDept = "肾内科"
  7998. dia.DiagDrNo = doctor.DoctorNumber
  7999. dia.DiagDrName = doctor.UserName
  8000. tempTime3 := time.Unix(item.PreTime, 0)
  8001. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  8002. dia.DiagTime = timeFormatTwo
  8003. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  8004. }
  8005. }
  8006. if miConfig.MdtrtareaAdmvs == "340699" {
  8007. result, request := service.GetAHCFYLJG001("http://10.66.149.64:8080/epc/api", cFYLJG001, his.Insutype)
  8008. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  8009. var res ResultCFYLJG001AH
  8010. var respJSON2 map[string]interface{}
  8011. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8012. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8014. return
  8015. }
  8016. userJSONBytes2, _ := json.Marshal(respJSON2)
  8017. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8018. utils.ErrorLog("解析失败:%v", err)
  8019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8020. return
  8021. }
  8022. var flow models.HisPrescriptionFlow
  8023. flow.Ctime = time.Now().Unix()
  8024. flow.SignDigest = ""
  8025. flow.RxTraceCode = res.RxTraceCode
  8026. flow.HiRxno = res.HiRxno
  8027. flow.MID = his.Number
  8028. flow.Status = 1
  8029. flow.DCode = doctor_info.DoctorNumber
  8030. flow.OriginalRxFile = ""
  8031. flow.OriginalValue = ""
  8032. flow.SignCertDn = ""
  8033. flow.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  8034. flow.SignCertSn = ""
  8035. flow.Mtime = time.Now().Unix()
  8036. service.Createflow(&flow)
  8037. c.ServeSuccessJSON(map[string]interface{}{
  8038. "msg": "上传成功",
  8039. })
  8040. } else {
  8041. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  8042. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  8043. var res ResultCFYLJG001
  8044. var respJSON2 map[string]interface{}
  8045. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8046. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8048. return
  8049. }
  8050. userJSONBytes2, _ := json.Marshal(respJSON2)
  8051. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8052. utils.ErrorLog("解析失败:%v", err)
  8053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8054. return
  8055. }
  8056. if res.Infcode == -1 {
  8057. c.ServeSuccessJSON(map[string]interface{}{
  8058. "failed_code": -10,
  8059. "msg": res.ErrMsg,
  8060. })
  8061. return
  8062. } else {
  8063. var flow models.HisPrescriptionFlow
  8064. flow.Ctime = time.Now().Unix()
  8065. flow.SignDigest = ""
  8066. flow.RxTraceCode = res.Output.RxTraceCode
  8067. flow.HiRxno = res.Output.HiRxno
  8068. flow.MID = his.Number
  8069. flow.Status = 1
  8070. flow.DCode = doctor_info.DoctorNumber
  8071. flow.OriginalRxFile = ""
  8072. flow.OriginalValue = ""
  8073. flow.SignCertDn = ""
  8074. flow.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  8075. flow.SignCertSn = ""
  8076. flow.Mtime = time.Now().Unix()
  8077. service.Createflow(&flow)
  8078. c.ServeSuccessJSON(map[string]interface{}{
  8079. "msg": "上传成功",
  8080. })
  8081. }
  8082. }
  8083. }
  8084. }
  8085. func (c *HisApiController) GetCFYLJG12() {
  8086. admin_user_id, _ := c.GetInt64("admin_user_id")
  8087. his_patient_id, _ := c.GetInt64("his_patient_id")
  8088. record_time := c.GetString("record_time")
  8089. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8090. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8091. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8092. flow, _ := service.Getflowtwo(his.Number)
  8093. patient_id, _ := c.GetInt64("patient_id")
  8094. timeLayout := "2006-01-02"
  8095. loc, _ := time.LoadLocation("Local")
  8096. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8097. if err != nil {
  8098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8099. return
  8100. }
  8101. recordDateTime := theTime.Unix()
  8102. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8103. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8104. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8105. dept, _ := service.GetDepartMentDetail(info.Departments)
  8106. inputData := make(map[string]interface{})
  8107. inputData["rxTraceCode"] = flow.RxTraceCode
  8108. inputData["hiRxno"] = flow.HiRxno
  8109. inputData["mdtrtId"] = flow.MID
  8110. inputData["patnName"] = his.PsnName
  8111. inputData["psnCertType"] = his.PsnCertType
  8112. inputData["certno"] = his.Certno
  8113. inputData["fixmedinsName"] = miConfig.OrgName
  8114. inputData["fixmedinsCode"] = miConfig.Code
  8115. inputData["drCode"] = doctor_info.DoctorNumber
  8116. inputData["prscDrName"] = doctor_info.UserName
  8117. inputData["pharDeptName"] = dept.Name
  8118. inputData["pharDeptCode"] = dept.Number
  8119. inputData["pharProfttlCodg"] = ""
  8120. inputData["pharProfttlName"] = ""
  8121. inputData["pharCode"] = "HY340621000425"
  8122. inputData["pharCertType"] = "01"
  8123. inputData["pharCertno"] = ""
  8124. inputData["pharName"] = "孙莉侠"
  8125. inputData["pharPracCertNo"] = ""
  8126. tempTime2 := time.Unix(info.Ctime, 0)
  8127. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8128. inputData["pharChkTime"] = timeFormatTwo
  8129. bytesData, _ := json.Marshal(inputData)
  8130. fmt.Println(string(bytesData))
  8131. encoded := base64.StdEncoding.EncodeToString(bytesData)
  8132. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  8133. if err != nil {
  8134. fmt.Println("Error reading PDF file:", err)
  8135. return
  8136. }
  8137. // 将 PDF 文件内容进行 Base64 编码
  8138. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  8139. fmt.Println(err)
  8140. if miConfig.MdtrtareaAdmvs == "340699" {
  8141. data := make(map[string]interface{})
  8142. data["rx_encoded"] = rx_encoded
  8143. data["code"] = miConfig.Code
  8144. data["url"] = "http://10.66.149.64:8080/epc/api"
  8145. data["encoded"] = encoded
  8146. client := &http.Client{}
  8147. bytesData, _ := json.Marshal(data)
  8148. var req *http.Request
  8149. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/02", bytes.NewReader(bytesData))
  8150. resp, _ := client.Do(req)
  8151. defer resp.Body.Close()
  8152. body, ioErr := ioutil.ReadAll(resp.Body)
  8153. if ioErr != nil {
  8154. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8155. }
  8156. var respJSON map[string]interface{}
  8157. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8158. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8160. return
  8161. }
  8162. var resSix10265 ResultSix10265 //1101结果
  8163. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8164. result, _ := json.Marshal(respJSON)
  8165. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  8166. utils.ErrorLog("解析失败:%v", err)
  8167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8168. return
  8169. }
  8170. utils.ErrorLog("接口返回数据解析JSON失败: %v", result)
  8171. //saveLog(result, "", "GetCFYLJG002", "GetCFYLJG002")
  8172. } else {
  8173. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8174. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  8175. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8176. var res2 AhResult002
  8177. var respJSON2 map[string]interface{}
  8178. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8179. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8181. return
  8182. }
  8183. userJSONBytes2, _ := json.Marshal(respJSON2)
  8184. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8185. utils.ErrorLog("解析失败:%v", err)
  8186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8187. return
  8188. }
  8189. flow.Ctime = time.Now().Unix()
  8190. flow.SignDigest = res2.SignDigest
  8191. flow.RxFile = res2.RxFile
  8192. flow.MID = his.Number
  8193. flow.Status = 1
  8194. flow.DCode = doctor_info.DoctorNumber
  8195. flow.OriginalRxFile = rx_encoded
  8196. flow.OriginalValue = encoded
  8197. flow.SignCertDn = res2.SignCertDn
  8198. flow.SignCertSn = res2.SignCertSn
  8199. flow.Mtime = time.Now().Unix()
  8200. service.Saveflow(flow)
  8201. c.ServeSuccessJSON(map[string]interface{}{
  8202. "msg": "预签名成功",
  8203. })
  8204. }
  8205. }
  8206. func (c *HisApiController) GetCFYLJG13() {
  8207. admin_user_id, _ := c.GetInt64("admin_user_id")
  8208. his_patient_id, _ := c.GetInt64("his_patient_id")
  8209. record_time := c.GetString("record_time")
  8210. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8211. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8212. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8213. flow, _ := service.Getflowtwo(his.Number)
  8214. patient_id, _ := c.GetInt64("patient_id")
  8215. timeLayout := "2006-01-02"
  8216. loc, _ := time.LoadLocation("Local")
  8217. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8218. if err != nil {
  8219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8220. return
  8221. }
  8222. recordDateTime := theTime.Unix()
  8223. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8224. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8225. dept, _ := service.GetDepartMentDetail(info.Departments)
  8226. var cFYLJG003 models.CFYLJG003
  8227. cFYLJG003.RxTraceCode = flow.RxTraceCode
  8228. cFYLJG003.HiRxno = flow.HiRxno
  8229. cFYLJG003.MdtrtID = flow.MID
  8230. cFYLJG003.PatnName = his.Name
  8231. cFYLJG003.Certno = his.Certno
  8232. cFYLJG003.FixmedinsName = miConfig.OrgName
  8233. cFYLJG003.FixmedinsCode = miConfig.Code
  8234. cFYLJG003.DrCode = doctor_info.DoctorNumber
  8235. cFYLJG003.PrscDrName = doctor_info.UserName
  8236. cFYLJG003.PharDeptName = dept.Name
  8237. cFYLJG003.PharDeptCode = dept.Number
  8238. if c.GetAdminUserInfo().CurrentOrgId == 10721 {
  8239. cFYLJG003.PharName = "孙莉侠"
  8240. cFYLJG003.PharPracCertNo = "060399"
  8241. cFYLJG003.PharCode = "HY340621000425"
  8242. cFYLJG003.PharCertType = "01"
  8243. cFYLJG003.PharCertno = ""
  8244. } else {
  8245. cFYLJG003.PharName = "彭斯遥"
  8246. cFYLJG003.PharPracCertNo = "30220200943042010052"
  8247. cFYLJG003.PharCode = "HY440309002107"
  8248. cFYLJG003.PharCertType = "01"
  8249. cFYLJG003.PharCertno = "430482199408260023"
  8250. }
  8251. cFYLJG003.PsnCertType = "01"
  8252. cFYLJG003.RxFile = flow.RxFile
  8253. cFYLJG003.SignDigest = flow.SignDigest
  8254. cFYLJG003.FixmedinsCode = miConfig.Code
  8255. cFYLJG003.PsnCertType = "01"
  8256. cFYLJG003.PharProfttlCodg = dept.Name
  8257. tempTime2 := time.Unix(info.Ctime, 0)
  8258. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8259. cFYLJG003.PharChkTime = timeFormatTwo
  8260. if miConfig.MdtrtareaAdmvs == "340699" {
  8261. data := make(map[string]interface{})
  8262. data["url"] = "http://10.66.149.64:8080/epc/api"
  8263. data["13"] = cFYLJG003
  8264. client := &http.Client{}
  8265. bytesData, _ := json.Marshal(data)
  8266. var req *http.Request
  8267. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/03", bytes.NewReader(bytesData))
  8268. resp, _ := client.Do(req)
  8269. defer resp.Body.Close()
  8270. body, ioErr := ioutil.ReadAll(resp.Body)
  8271. if ioErr != nil {
  8272. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8273. }
  8274. var respJSON map[string]interface{}
  8275. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8276. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8278. return
  8279. }
  8280. var resSix10265 ResultSix10265 //1101结果
  8281. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8282. result, _ := json.Marshal(respJSON)
  8283. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  8284. utils.ErrorLog("解析失败:%v", err)
  8285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8286. return
  8287. }
  8288. utils.ErrorLog("接口返回数据解析JSON失败: %v", result)
  8289. //saveLog(result, "", "GetCFYLJG013", "GetCFYLJG013")
  8290. } else {
  8291. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8292. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  8293. var res ResultCFYLJG003
  8294. var respJSON2 map[string]interface{}
  8295. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8296. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8298. return
  8299. }
  8300. userJSONBytes2, _ := json.Marshal(respJSON2)
  8301. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8302. utils.ErrorLog("解析失败:%v", err)
  8303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8304. return
  8305. }
  8306. if res.Infcode == -1 {
  8307. c.ServeSuccessJSON(map[string]interface{}{
  8308. "failed_code": -10,
  8309. "msg": res.ErrMsg,
  8310. })
  8311. return
  8312. } else {
  8313. c.ServeSuccessJSON(map[string]interface{}{
  8314. "info": res.Output,
  8315. })
  8316. }
  8317. }
  8318. }
  8319. func (c *HisApiController) GetCFYLJG002() {
  8320. admin_user_id, _ := c.GetInt64("admin_user_id")
  8321. his_patient_id, _ := c.GetInt64("his_patient_id")
  8322. record_time := c.GetString("record_time")
  8323. admin_user_id = 3626
  8324. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8325. //id, _ := c.GetInt64("id")
  8326. admin_user_id = 3626
  8327. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8328. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8329. flow, _ := service.Getflowtwo(his.Number)
  8330. //his, _ := service.GetHisPatientByNumber(flow.MID)
  8331. //record_time := c.GetString("record_time")
  8332. patient_id, _ := c.GetInt64("patient_id")
  8333. //patient_id = 23834
  8334. //record_time = "2023-09-18"
  8335. timeLayout := "2006-01-02"
  8336. loc, _ := time.LoadLocation("Local")
  8337. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8338. if err != nil {
  8339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8340. return
  8341. }
  8342. recordDateTime := theTime.Unix()
  8343. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8344. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8345. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8346. dept, _ := service.GetDepartMentDetail(info.Departments)
  8347. inputData := make(map[string]interface{})
  8348. inputData["rxTraceCode"] = flow.RxTraceCode
  8349. inputData["hiRxno"] = flow.HiRxno
  8350. inputData["mdtrtId"] = flow.MID
  8351. inputData["patnName"] = his.PsnName
  8352. inputData["psnCertType"] = his.PsnCertType
  8353. inputData["certno"] = his.Certno
  8354. inputData["fixmedinsName"] = miConfig.OrgName
  8355. inputData["fixmedinsCode"] = miConfig.Code
  8356. inputData["drCode"] = doctor_info.DoctorNumber
  8357. inputData["prscDrName"] = doctor_info.UserName
  8358. inputData["pharDeptName"] = dept.Name
  8359. inputData["pharDeptCode"] = dept.Number
  8360. inputData["pharProfttlCodg"] = ""
  8361. inputData["pharProfttlName"] = ""
  8362. inputData["pharCode"] = "HY340621000425"
  8363. inputData["pharCertType"] = "01"
  8364. inputData["pharCertno"] = ""
  8365. inputData["pharName"] = "孙莉侠"
  8366. inputData["pharPracCertNo"] = "060399"
  8367. tempTime2 := time.Unix(info.Ctime, 0)
  8368. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8369. inputData["pharChkTime"] = timeFormatTwo
  8370. bytesData, _ := json.Marshal(inputData)
  8371. fmt.Println(string(bytesData))
  8372. encoded := base64.StdEncoding.EncodeToString(bytesData)
  8373. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  8374. if err != nil {
  8375. fmt.Println("Error reading PDF file:", err)
  8376. return
  8377. }
  8378. // 将 PDF 文件内容进行 Base64 编码
  8379. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  8380. fmt.Println(err)
  8381. if miConfig.MdtrtareaAdmvs == "340699" {
  8382. result, request := service.GetAHCFYLJG002(miConfig.Code, "http://10.66.149.64:8080/epc/api", encoded, rx_encoded, "")
  8383. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8384. var res2 AhResult002
  8385. var respJSON2 map[string]interface{}
  8386. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8387. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8389. return
  8390. }
  8391. userJSONBytes2, _ := json.Marshal(respJSON2)
  8392. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8393. utils.ErrorLog("解析失败:%v", err)
  8394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8395. return
  8396. }
  8397. flow.Ctime = time.Now().Unix()
  8398. flow.SignDigest = res2.SignDigest
  8399. flow.RxFile = res2.RxFile
  8400. flow.MID = his.Number
  8401. flow.Status = 1
  8402. flow.DCode = doctor_info.DoctorNumber
  8403. flow.OriginalRxFile = rx_encoded
  8404. flow.OriginalValue = encoded
  8405. flow.SignCertDn = res2.SignCertDn
  8406. flow.SignCertSn = res2.SignCertSn
  8407. flow.Mtime = time.Now().Unix()
  8408. service.Saveflow(flow)
  8409. c.ServeSuccessJSON(map[string]interface{}{
  8410. "msg": "预签名成功",
  8411. })
  8412. } else {
  8413. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8414. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  8415. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8416. var res2 Result002
  8417. var respJSON2 map[string]interface{}
  8418. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8419. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8421. return
  8422. }
  8423. userJSONBytes2, _ := json.Marshal(respJSON2)
  8424. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8425. utils.ErrorLog("解析失败:%v", err)
  8426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8427. return
  8428. }
  8429. if res2.Infcode == 0 {
  8430. flow.Ctime = time.Now().Unix()
  8431. flow.SignDigest = res2.Output.SignDigest
  8432. flow.RxFile = res2.Output.RxFile
  8433. flow.MID = his.Number
  8434. flow.Status = 1
  8435. flow.DCode = doctor_info.DoctorNumber
  8436. flow.OriginalRxFile = rx_encoded
  8437. flow.OriginalValue = encoded
  8438. flow.SignCertDn = res2.Output.SignCertDn
  8439. flow.SignCertSn = res2.Output.SignCertSn
  8440. flow.Mtime = time.Now().Unix()
  8441. service.Saveflow(flow)
  8442. c.ServeSuccessJSON(map[string]interface{}{
  8443. "msg": "预签名成功",
  8444. })
  8445. } else {
  8446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8447. return
  8448. }
  8449. }
  8450. }
  8451. func (c *HisApiController) GetCFYLJG003() {
  8452. admin_user_id, _ := c.GetInt64("admin_user_id")
  8453. his_patient_id, _ := c.GetInt64("his_patient_id")
  8454. record_time := c.GetString("record_time")
  8455. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8456. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8457. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8458. flow, _ := service.Getflowtwo(his.Number)
  8459. patient_id, _ := c.GetInt64("patient_id")
  8460. timeLayout := "2006-01-02"
  8461. loc, _ := time.LoadLocation("Local")
  8462. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8463. if err != nil {
  8464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8465. return
  8466. }
  8467. recordDateTime := theTime.Unix()
  8468. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8469. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8470. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8471. dept, _ := service.GetDepartMentDetail(info.Departments)
  8472. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  8473. var cFYLJG003 models.CFYLJG003
  8474. cFYLJG003.RxTraceCode = flow.RxTraceCode
  8475. cFYLJG003.HiRxno = flow.HiRxno
  8476. cFYLJG003.MdtrtID = flow.MID
  8477. cFYLJG003.PatnName = his.PsnName
  8478. cFYLJG003.Certno = his.Certno
  8479. cFYLJG003.FixmedinsName = miConfig.OrgName
  8480. cFYLJG003.FixmedinsCode = miConfig.Code
  8481. cFYLJG003.DrCode = doctor_info.DoctorNumber
  8482. cFYLJG003.PrscDrName = doctor_info.UserName
  8483. cFYLJG003.PharDeptName = dept.Name
  8484. cFYLJG003.PharDeptCode = dept.Number
  8485. if c.GetAdminUserInfo().CurrentOrgId == 10721 {
  8486. cFYLJG003.PharName = "孙莉侠"
  8487. cFYLJG003.PharPracCertNo = "060399"
  8488. cFYLJG003.PharCode = "HY340621000425"
  8489. cFYLJG003.PharCertType = "01"
  8490. cFYLJG003.PharCertno = ""
  8491. } else {
  8492. cFYLJG003.PharName = "彭斯遥"
  8493. cFYLJG003.PharPracCertNo = "30220200943042010052"
  8494. cFYLJG003.PharCode = "HY440309002107"
  8495. cFYLJG003.PharCertType = "01"
  8496. cFYLJG003.PharCertno = "430482199408260023"
  8497. }
  8498. cFYLJG003.RxFile = flow.RxFile
  8499. cFYLJG003.SignDigest = flow.SignDigest
  8500. cFYLJG003.FixmedinsCode = miConfig.Code
  8501. cFYLJG003.PsnCertType = his.PsnCertType
  8502. tempTime2 := time.Unix(info.Ctime, 0)
  8503. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8504. cFYLJG003.PharChkTime = timeFormatTwo
  8505. if miConfig.MdtrtareaAdmvs == "340699" {
  8506. result, request := service.GetAHCFYLJG003("http://10.66.149.64:8080/epc/api", cFYLJG003)
  8507. saveLog(result, request, "GetAHCFYLJG003", "GetAHCFYLJG003")
  8508. var res AHResult003
  8509. var respJSON2 map[string]interface{}
  8510. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8511. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8513. return
  8514. }
  8515. userJSONBytes2, _ := json.Marshal(respJSON2)
  8516. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8517. utils.ErrorLog("解析失败:%v", err)
  8518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8519. return
  8520. }
  8521. {
  8522. c.ServeSuccessJSON(map[string]interface{}{
  8523. "info": res,
  8524. })
  8525. }
  8526. } else {
  8527. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8528. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  8529. var res ResultCFYLJG003
  8530. var respJSON2 map[string]interface{}
  8531. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8532. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8534. return
  8535. }
  8536. userJSONBytes2, _ := json.Marshal(respJSON2)
  8537. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8538. utils.ErrorLog("解析失败:%v", err)
  8539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8540. return
  8541. }
  8542. if res.Infcode == -1 {
  8543. c.ServeSuccessJSON(map[string]interface{}{
  8544. "failed_code": -10,
  8545. "msg": res.ErrMsg,
  8546. })
  8547. return
  8548. } else {
  8549. c.ServeSuccessJSON(map[string]interface{}{
  8550. "info": res.Output,
  8551. })
  8552. }
  8553. }
  8554. }
  8555. func (c *HisApiController) GetCFYLJG004() {
  8556. admin_user_id, _ := c.GetInt64("admin_user_id")
  8557. his_patient_id, _ := c.GetInt64("his_patient_id")
  8558. record_time := c.GetString("record_time")
  8559. admin_user_id = 3626
  8560. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8561. //id, _ := c.GetInt64("id")
  8562. admin_user_id = 3626
  8563. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8564. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8565. flow, _ := service.Getflowtwo(his.Number)
  8566. //id = 3
  8567. patient_id, _ := c.GetInt64("patient_id")
  8568. //patient_id = 23834
  8569. //record_time = "2023-09-18"
  8570. timeLayout := "2006-01-02"
  8571. loc, _ := time.LoadLocation("Local")
  8572. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8573. if err != nil {
  8574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8575. return
  8576. }
  8577. recordDateTime := theTime.Unix()
  8578. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8579. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8580. var cFYLJG004 models.CFYLJG004
  8581. cFYLJG004.HiRxno = flow.HiRxno
  8582. cFYLJG004.FixmedinsCode = miConfig.Code
  8583. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  8584. cFYLJG004.UndoDrCertType = "01"
  8585. cFYLJG004.UndoRea = "撤销处方"
  8586. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  8587. cFYLJG004.UndoDrName = doctor_info.UserName
  8588. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  8589. if miConfig.MdtrtareaAdmvs == "340699" {
  8590. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8591. //result, request := service.GetAHCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8592. //saveLog(result, request, "GetAHCFYLJG004", "GetAHCFYLJG004")
  8593. } else {
  8594. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  8595. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  8596. var res ResultCFYLJG004
  8597. var respJSON2 map[string]interface{}
  8598. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8599. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8601. return
  8602. }
  8603. userJSONBytes2, _ := json.Marshal(respJSON2)
  8604. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8605. utils.ErrorLog("解析失败:%v", err)
  8606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8607. return
  8608. }
  8609. if res.Infcode == -1 {
  8610. c.ServeSuccessJSON(map[string]interface{}{
  8611. "failed_code": -10,
  8612. "msg": res.ErrMsg,
  8613. })
  8614. return
  8615. } else {
  8616. flow.Status = 0
  8617. service.Saveflow(flow)
  8618. c.ServeSuccessJSON(map[string]interface{}{
  8619. "msg": "撤销成功",
  8620. })
  8621. return
  8622. }
  8623. }
  8624. }
  8625. func (c *HisApiController) GetCFYLJG005() {
  8626. admin_user_id, _ := c.GetInt64("admin_user_id")
  8627. his_patient_id, _ := c.GetInt64("his_patient_id")
  8628. //record_time := c.GetString("record_time")
  8629. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8630. //id, _ := c.GetInt64("id")
  8631. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8632. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8633. flow, _ := service.Getflowtwo(his.Number)
  8634. //id = 3
  8635. var cFYLJG005 models.CFYLJG005
  8636. //patient_id, _ := c.GetInt64("patient_id")
  8637. cFYLJG005.HiRxno = flow.HiRxno
  8638. cFYLJG005.MdtrtID = flow.MID
  8639. cFYLJG005.EcToken = ""
  8640. cFYLJG005.PsnName = his.Name
  8641. cFYLJG005.PsnCertType = "01"
  8642. cFYLJG005.Certno = his.IdCardNo
  8643. if miConfig.MdtrtareaAdmvs == "340699" {
  8644. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8645. result, request := service.GetAHCFYLJG005(miConfig.Code, cFYLJG005)
  8646. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  8647. } else {
  8648. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  8649. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  8650. var res ResultCFYLJG005
  8651. var respJSON2 map[string]interface{}
  8652. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8653. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8655. return
  8656. }
  8657. userJSONBytes2, _ := json.Marshal(respJSON2)
  8658. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8659. utils.ErrorLog("解析失败:%v", err)
  8660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8661. return
  8662. }
  8663. if res.Infcode == -1 {
  8664. c.ServeSuccessJSON(map[string]interface{}{
  8665. "failed_code": -10,
  8666. "msg": res.ErrMsg,
  8667. })
  8668. return
  8669. } else {
  8670. c.ServeSuccessJSON(map[string]interface{}{
  8671. "info": res.Output,
  8672. })
  8673. return
  8674. }
  8675. }
  8676. }
  8677. func (c *HisApiController) GetCFYLJG006() {
  8678. admin_user_id, _ := c.GetInt64("admin_user_id")
  8679. his_patient_id, _ := c.GetInt64("his_patient_id")
  8680. admin_user_id = 3626
  8681. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8682. //id, _ := c.GetInt64("id")
  8683. admin_user_id = 3626
  8684. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8685. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8686. flow, _ := service.Getflowtwo(his.Number)
  8687. //id = 3
  8688. patient_id, _ := c.GetInt64("patient_id")
  8689. var cFYLJG006 models.CFYLJG006
  8690. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8691. cFYLJG006.HiRxno = flow.HiRxno
  8692. cFYLJG006.MdtrtID = flow.MID
  8693. cFYLJG006.PsnName = patient.Name
  8694. cFYLJG006.PsnCertType = "01"
  8695. cFYLJG006.Certno = patient.IdCardNo
  8696. if miConfig.MdtrtareaAdmvs == "340699" {
  8697. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8698. //result, request := service.GetAHCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8699. //saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8700. } else {
  8701. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8702. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8703. var res ResultCFYLJG006
  8704. var respJSON2 map[string]interface{}
  8705. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8706. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8708. return
  8709. }
  8710. userJSONBytes2, _ := json.Marshal(respJSON2)
  8711. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8712. utils.ErrorLog("解析失败:%v", err)
  8713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8714. return
  8715. }
  8716. if res.Infcode == -1 {
  8717. c.ServeSuccessJSON(map[string]interface{}{
  8718. "failed_code": -10,
  8719. "msg": res.ErrMsg,
  8720. })
  8721. return
  8722. } else {
  8723. c.ServeSuccessJSON(map[string]interface{}{
  8724. "info": res.Output,
  8725. })
  8726. return
  8727. }
  8728. }
  8729. }
  8730. func (c *HisApiController) GetCFYLJG007() {
  8731. admin_user_id, _ := c.GetInt64("admin_user_id")
  8732. his_patient_id, _ := c.GetInt64("his_patient_id")
  8733. admin_user_id = 3626
  8734. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8735. //id, _ := c.GetInt64("id")
  8736. admin_user_id = 3626
  8737. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8738. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8739. flow, _ := service.Getflowtwo(his.Number)
  8740. //id = 3
  8741. patient_id, _ := c.GetInt64("patient_id")
  8742. var cFYLJG007 models.CFYLJG007
  8743. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8744. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8745. cFYLJG007.HiRxno = flow.HiRxno
  8746. cFYLJG007.MdtrtID = flow.MID
  8747. cFYLJG007.PsnNo = his.PsnNo
  8748. cFYLJG007.PsnCertType = "01"
  8749. cFYLJG007.Certno = patient.IdCardNo
  8750. cFYLJG007.PsnName = patient.Name
  8751. if miConfig.MdtrtareaAdmvs == "340699" {
  8752. //result, request := service.GetAHCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8753. //saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8754. } else {
  8755. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8756. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8757. var res ResultCFYLJG007
  8758. var respJSON2 map[string]interface{}
  8759. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8760. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8762. return
  8763. }
  8764. userJSONBytes2, _ := json.Marshal(respJSON2)
  8765. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8766. utils.ErrorLog("解析失败:%v", err)
  8767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8768. return
  8769. }
  8770. if res.Infcode == -1 {
  8771. c.ServeSuccessJSON(map[string]interface{}{
  8772. "failed_code": -10,
  8773. "msg": res.ErrMsg,
  8774. })
  8775. return
  8776. } else {
  8777. c.ServeSuccessJSON(map[string]interface{}{
  8778. "info": res,
  8779. })
  8780. return
  8781. }
  8782. }
  8783. }
  8784. func (c *HisApiController) GetCFYLJG008() {
  8785. admin_user_id, _ := c.GetInt64("admin_user_id")
  8786. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8787. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8788. var cFYLJG008 models.CFYLJG008
  8789. //id, _ := c.GetInt64("id")
  8790. patient_id, _ := c.GetInt64("patient_id")
  8791. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8792. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8793. //id = 3
  8794. //flow, _ := service.Getflow(id)
  8795. //his, _ := service.GetHisPatientByNumber(flow.MID)
  8796. //
  8797. //admin_user_id, _ := c.GetInt64("admin_user_id")
  8798. //patient_id, _ := c.GetInt64("patient_id")
  8799. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8800. record_time := c.GetString("record_time")
  8801. admin_user_id = 3626
  8802. patient_id = 19424
  8803. //his_patient_id = 263947
  8804. record_time = "2023-08-29"
  8805. timeLayout := "2006-01-02"
  8806. loc, _ := time.LoadLocation("Local")
  8807. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8808. if err != nil {
  8809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8810. return
  8811. }
  8812. recordDateTime := theTime.Unix()
  8813. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8814. cFYLJG008.FixmedinsName = ""
  8815. cFYLJG008.Lat = ""
  8816. cFYLJG008.Lng = ""
  8817. cFYLJG008.OrderType = "1"
  8818. cFYLJG008.PoolareaNo = ""
  8819. cFYLJG008.Lng = ""
  8820. cFYLJG008.PageNum = 1
  8821. cFYLJG008.PageSize = 10
  8822. var MPI models.MedinsProdInvChgDDTO
  8823. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  8824. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  8825. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  8826. if miConfig.MdtrtareaAdmvs == "340699" {
  8827. //result, request := service.GetAHCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8828. //saveLog(result, request, "GetAHCFYLJG008", "GetAHCFYLJG008")
  8829. } else {
  8830. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8831. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  8832. var res ResultCFYLJG008
  8833. var respJSON2 map[string]interface{}
  8834. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8835. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8837. return
  8838. }
  8839. userJSONBytes2, _ := json.Marshal(respJSON2)
  8840. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8841. utils.ErrorLog("解析失败:%v", err)
  8842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8843. return
  8844. }
  8845. if res.Infcode == -1 {
  8846. c.ServeSuccessJSON(map[string]interface{}{
  8847. "failed_code": -10,
  8848. "msg": res.ErrMsg,
  8849. })
  8850. return
  8851. } else {
  8852. c.ServeSuccessJSON(map[string]interface{}{
  8853. "info": res.Output,
  8854. })
  8855. return
  8856. }
  8857. }
  8858. }
  8859. func (c *HisApiController) GetBL4201A() {
  8860. order_id, _ := c.GetInt64("order_id")
  8861. admin_user_id, _ := c.GetInt64("admin_user_id")
  8862. order, _ := service.GetHisOrderByIDTwo(order_id)
  8863. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8864. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8865. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8866. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8867. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8868. department, _ := service.GetDepartMentDetail(his.Departments)
  8869. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8870. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8871. if order.ID == 0 {
  8872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8873. return
  8874. }
  8875. var struct4201A models.Struct4201A
  8876. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8877. for _, items := range order_info {
  8878. memo := make(map[string]interface{})
  8879. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8880. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8881. fsiOPFLD.MedType = "14"
  8882. fsiOPFLD.BkkpSn = items.FeedetlSn
  8883. fsiOPFLD.FixmedinsCode = miConfig.Code
  8884. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8885. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8886. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8887. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8888. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8889. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8890. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8891. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8892. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8893. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8894. fsiOPFLD.BilgDeptName = department.Name
  8895. fsiOPFLD.BilgDeptCodg = department.Number
  8896. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8897. fsiOPFLD.BilgDrName = doctor.UserName
  8898. fsiOPFLD.MedChrgitmType = "09"
  8899. memo["hosp_appr_flag"] = "1"
  8900. memo["invoice_no"] = order.MdtrtId
  8901. memo["memo"] = "自费"
  8902. bytesData, _ := json.Marshal(memo)
  8903. fsiOPFLD.Memo = string(bytesData)
  8904. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8905. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8906. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8907. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8908. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8909. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8910. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8911. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8912. fsiOPFLD.BilgDeptName = department.Name
  8913. fsiOPFLD.BilgDeptCodg = department.Number
  8914. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8915. fsiOPFLD.BilgDrName = doctor.UserName
  8916. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8917. case 0:
  8918. break
  8919. case 1:
  8920. fsiOPFLD.MedChrgitmType = "14"
  8921. break
  8922. case 2:
  8923. fsiOPFLD.MedChrgitmType = "05"
  8924. break
  8925. case 3:
  8926. fsiOPFLD.MedChrgitmType = "03"
  8927. break
  8928. case 4:
  8929. fsiOPFLD.MedChrgitmType = "03"
  8930. break
  8931. case 5:
  8932. fsiOPFLD.MedChrgitmType = "08"
  8933. break
  8934. case 6:
  8935. fsiOPFLD.MedChrgitmType = "14"
  8936. break
  8937. case 7:
  8938. fsiOPFLD.MedChrgitmType = "14"
  8939. break
  8940. case 8:
  8941. fsiOPFLD.MedChrgitmType = "03"
  8942. break
  8943. case 9:
  8944. fsiOPFLD.MedChrgitmType = "14"
  8945. break
  8946. case 10:
  8947. fsiOPFLD.MedChrgitmType = "14"
  8948. break
  8949. case 11:
  8950. fsiOPFLD.MedChrgitmType = "06"
  8951. break
  8952. case 12:
  8953. fsiOPFLD.MedChrgitmType = "12"
  8954. break
  8955. case 13:
  8956. fsiOPFLD.MedChrgitmType = "01"
  8957. break
  8958. case 14:
  8959. fsiOPFLD.MedChrgitmType = "04"
  8960. break
  8961. case 15:
  8962. fsiOPFLD.MedChrgitmType = "14"
  8963. break
  8964. }
  8965. memo["hosp_appr_flag"] = "1"
  8966. memo["invoice_no"] = order.MdtrtId
  8967. memo["memo"] = "自费"
  8968. bytesData, _ := json.Marshal(memo)
  8969. fsiOPFLD.Memo = string(bytesData)
  8970. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8971. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8972. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8973. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8974. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8975. fsiOPFLD.BilgDeptName = department.Name
  8976. fsiOPFLD.BilgDeptCodg = department.Number
  8977. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8978. fsiOPFLD.BilgDrName = doctor.UserName
  8979. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8980. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8981. fsiOPFLD.MedChrgitmType = "08"
  8982. memo["hosp_appr_flag"] = "1"
  8983. memo["invoice_no"] = order.MdtrtId
  8984. memo["memo"] = "自费"
  8985. bytesData, _ := json.Marshal(memo)
  8986. fsiOPFLD.Memo = string(bytesData)
  8987. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8988. }
  8989. }
  8990. }
  8991. for _, items := range order_info_two {
  8992. memo := make(map[string]interface{})
  8993. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8994. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8995. fsiOPFLD.MedType = "14"
  8996. fsiOPFLD.BkkpSn = items.FeedetlSn
  8997. fsiOPFLD.FixmedinsCode = miConfig.Code
  8998. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8999. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9000. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9001. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9002. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9003. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9004. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9005. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9006. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9007. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9008. fsiOPFLD.BilgDeptName = department.Name
  9009. fsiOPFLD.BilgDeptCodg = department.Number
  9010. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9011. fsiOPFLD.BilgDrName = doctor.UserName
  9012. fsiOPFLD.MedChrgitmType = "09"
  9013. memo["hosp_appr_flag"] = "1"
  9014. memo["invoice_no"] = order.MdtrtId
  9015. memo["memo"] = "自费"
  9016. bytesData, _ := json.Marshal(memo)
  9017. fsiOPFLD.Memo = string(bytesData)
  9018. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9019. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9020. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9021. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9022. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9023. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9024. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9025. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9026. fsiOPFLD.BilgDeptName = department.Name
  9027. fsiOPFLD.BilgDeptCodg = department.Number
  9028. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9029. fsiOPFLD.BilgDrName = doctor.UserName
  9030. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9031. case 0:
  9032. break
  9033. case 1:
  9034. fsiOPFLD.MedChrgitmType = "14"
  9035. break
  9036. case 2:
  9037. fsiOPFLD.MedChrgitmType = "05"
  9038. break
  9039. case 3:
  9040. fsiOPFLD.MedChrgitmType = "03"
  9041. break
  9042. case 4:
  9043. fsiOPFLD.MedChrgitmType = "03"
  9044. break
  9045. case 5:
  9046. fsiOPFLD.MedChrgitmType = "08"
  9047. break
  9048. case 6:
  9049. fsiOPFLD.MedChrgitmType = "14"
  9050. break
  9051. case 7:
  9052. fsiOPFLD.MedChrgitmType = "14"
  9053. break
  9054. case 8:
  9055. fsiOPFLD.MedChrgitmType = "03"
  9056. break
  9057. case 9:
  9058. fsiOPFLD.MedChrgitmType = "14"
  9059. break
  9060. case 10:
  9061. fsiOPFLD.MedChrgitmType = "14"
  9062. break
  9063. case 11:
  9064. fsiOPFLD.MedChrgitmType = "06"
  9065. break
  9066. case 12:
  9067. fsiOPFLD.MedChrgitmType = "12"
  9068. break
  9069. case 13:
  9070. fsiOPFLD.MedChrgitmType = "01"
  9071. break
  9072. case 14:
  9073. fsiOPFLD.MedChrgitmType = "04"
  9074. break
  9075. case 15:
  9076. fsiOPFLD.MedChrgitmType = "14"
  9077. break
  9078. }
  9079. memo["hosp_appr_flag"] = "1"
  9080. memo["invoice_no"] = order.MdtrtId
  9081. memo["memo"] = "自费"
  9082. bytesData, _ := json.Marshal(memo)
  9083. fsiOPFLD.Memo = string(bytesData)
  9084. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9085. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9086. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9087. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9088. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9089. fsiOPFLD.BilgDeptName = department.Name
  9090. fsiOPFLD.BilgDeptCodg = department.Number
  9091. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9092. fsiOPFLD.BilgDrName = doctor.UserName
  9093. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9094. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9095. fsiOPFLD.MedChrgitmType = "08"
  9096. memo["hosp_appr_flag"] = "1"
  9097. memo["invoice_no"] = order.MdtrtId
  9098. memo["memo"] = "自费"
  9099. bytesData, _ := json.Marshal(memo)
  9100. fsiOPFLD.Memo = string(bytesData)
  9101. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9102. }
  9103. }
  9104. }
  9105. fmt.Println(fsiOPFLDs)
  9106. struct4201A.Fopfd = fsiOPFLDs
  9107. fmt.Println(struct4201A.Fopfd)
  9108. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  9109. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  9110. var res2 ResultSix
  9111. var respJSON2 map[string]interface{}
  9112. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9115. return
  9116. }
  9117. userJSONBytes2, _ := json.Marshal(respJSON2)
  9118. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9119. utils.ErrorLog("解析失败:%v", err)
  9120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9121. return
  9122. }
  9123. if res2.Infcode != 0 {
  9124. c.ServeSuccessJSON(map[string]interface{}{
  9125. "failed_code": -10,
  9126. "msg": res2.ErrMsg,
  9127. })
  9128. return
  9129. } else {
  9130. order.IsUploadOrderInfo = 1
  9131. service.UpdateOrder(order)
  9132. c.ServeSuccessJSON(map[string]interface{}{
  9133. "msg": "上传成功",
  9134. })
  9135. }
  9136. }
  9137. func (c *HisApiController) Get3103() {
  9138. admin_user_id, _ := c.GetInt64("admin_user_id")
  9139. warm_type, _ := c.GetInt64("warm_type")
  9140. fk_state, _ := c.GetInt64("fk_state")
  9141. warm_ids := c.GetString("warm_ids")
  9142. desc := c.GetString("desc")
  9143. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9144. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9145. result, requestLog := service.Gdyb3103(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, warm_type, warm_ids, fk_state, desc)
  9146. saveLog(result, requestLog, "3103", "反馈")
  9147. var res2 ResultSix3103
  9148. var respJSON2 map[string]interface{}
  9149. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9150. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9152. return
  9153. }
  9154. userJSONBytes2, _ := json.Marshal(respJSON2)
  9155. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9156. utils.ErrorLog("解析失败:%v", err)
  9157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9158. return
  9159. }
  9160. if res2.Infcode != 0 {
  9161. c.ServeSuccessJSON(map[string]interface{}{
  9162. "failed_code": -10,
  9163. "msg": res2.ErrMsg,
  9164. })
  9165. return
  9166. } else {
  9167. c.ServeSuccessJSON(map[string]interface{}{
  9168. "msg": "反馈成功",
  9169. })
  9170. return
  9171. }
  9172. }
  9173. func (c *HisApiController) Get4201A() {
  9174. order_id, _ := c.GetInt64("order_id")
  9175. admin_user_id, _ := c.GetInt64("admin_user_id")
  9176. order, _ := service.GetHisOrderByIDTwo(order_id)
  9177. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9178. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  9179. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  9180. //order_info = append(order_info, order_info_two...)
  9181. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9182. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9183. department, _ := service.GetDepartMentDetail(his.Departments)
  9184. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  9185. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  9186. if order.ID == 0 {
  9187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9188. return
  9189. }
  9190. var struct4201A models.Struct4201A
  9191. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  9192. for _, items := range order_info {
  9193. memo := make(map[string]interface{})
  9194. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9195. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9196. fsiOPFLD.MedType = "14"
  9197. fsiOPFLD.BkkpSn = items.FeedetlSn
  9198. fsiOPFLD.FixmedinsCode = miConfig.Code
  9199. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9200. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9201. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9202. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9203. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9204. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9205. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9206. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9207. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9208. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9209. fsiOPFLD.BilgDeptName = department.Name
  9210. fsiOPFLD.BilgDeptCodg = department.Number
  9211. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9212. fsiOPFLD.BilgDrName = doctor.UserName
  9213. fsiOPFLD.MedChrgitmType = "09"
  9214. memo["hosp_appr_flag"] = "1"
  9215. memo["invoice_no"] = order.MdtrtId
  9216. memo["memo"] = "自费"
  9217. bytesData, _ := json.Marshal(memo)
  9218. fsiOPFLD.Memo = string(bytesData)
  9219. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9220. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9221. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9222. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9223. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9224. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9225. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9226. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9227. fsiOPFLD.BilgDeptName = department.Name
  9228. fsiOPFLD.BilgDeptCodg = department.Number
  9229. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9230. fsiOPFLD.BilgDrName = doctor.UserName
  9231. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9232. case 0:
  9233. break
  9234. case 1:
  9235. fsiOPFLD.MedChrgitmType = "14"
  9236. break
  9237. case 2:
  9238. fsiOPFLD.MedChrgitmType = "05"
  9239. break
  9240. case 3:
  9241. fsiOPFLD.MedChrgitmType = "03"
  9242. break
  9243. case 4:
  9244. fsiOPFLD.MedChrgitmType = "03"
  9245. break
  9246. case 5:
  9247. fsiOPFLD.MedChrgitmType = "08"
  9248. break
  9249. case 6:
  9250. fsiOPFLD.MedChrgitmType = "14"
  9251. break
  9252. case 7:
  9253. fsiOPFLD.MedChrgitmType = "14"
  9254. break
  9255. case 8:
  9256. fsiOPFLD.MedChrgitmType = "03"
  9257. break
  9258. case 9:
  9259. fsiOPFLD.MedChrgitmType = "14"
  9260. break
  9261. case 10:
  9262. fsiOPFLD.MedChrgitmType = "14"
  9263. break
  9264. case 11:
  9265. fsiOPFLD.MedChrgitmType = "06"
  9266. break
  9267. case 12:
  9268. fsiOPFLD.MedChrgitmType = "12"
  9269. break
  9270. case 13:
  9271. fsiOPFLD.MedChrgitmType = "01"
  9272. break
  9273. case 14:
  9274. fsiOPFLD.MedChrgitmType = "04"
  9275. break
  9276. case 15:
  9277. fsiOPFLD.MedChrgitmType = "14"
  9278. break
  9279. }
  9280. memo["hosp_appr_flag"] = "1"
  9281. memo["invoice_no"] = order.MdtrtId
  9282. memo["memo"] = "自费"
  9283. bytesData, _ := json.Marshal(memo)
  9284. fsiOPFLD.Memo = string(bytesData)
  9285. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9286. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9287. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9288. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9289. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9290. fsiOPFLD.BilgDeptName = department.Name
  9291. fsiOPFLD.BilgDeptCodg = department.Number
  9292. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9293. fsiOPFLD.BilgDrName = doctor.UserName
  9294. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9295. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9296. fsiOPFLD.MedChrgitmType = "08"
  9297. memo["hosp_appr_flag"] = "1"
  9298. memo["invoice_no"] = order.MdtrtId
  9299. memo["memo"] = "自费"
  9300. bytesData, _ := json.Marshal(memo)
  9301. fsiOPFLD.Memo = string(bytesData)
  9302. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9303. }
  9304. }
  9305. }
  9306. for _, items := range order_info_two {
  9307. memo := make(map[string]interface{})
  9308. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9309. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9310. fsiOPFLD.MedType = "14"
  9311. fsiOPFLD.BkkpSn = items.FeedetlSn
  9312. fsiOPFLD.FixmedinsCode = miConfig.Code
  9313. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9314. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9315. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9316. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9317. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9318. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9319. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9320. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9321. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9322. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9323. fsiOPFLD.BilgDeptName = department.Name
  9324. fsiOPFLD.BilgDeptCodg = department.Number
  9325. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9326. fsiOPFLD.BilgDrName = doctor.UserName
  9327. fsiOPFLD.MedChrgitmType = "09"
  9328. memo["hosp_appr_flag"] = "1"
  9329. memo["invoice_no"] = order.MdtrtId
  9330. memo["memo"] = "自费"
  9331. bytesData, _ := json.Marshal(memo)
  9332. fsiOPFLD.Memo = string(bytesData)
  9333. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9334. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9335. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9336. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9337. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9338. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9339. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9340. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9341. fsiOPFLD.BilgDeptName = department.Name
  9342. fsiOPFLD.BilgDeptCodg = department.Number
  9343. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9344. fsiOPFLD.BilgDrName = doctor.UserName
  9345. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9346. case 0:
  9347. break
  9348. case 1:
  9349. fsiOPFLD.MedChrgitmType = "14"
  9350. break
  9351. case 2:
  9352. fsiOPFLD.MedChrgitmType = "05"
  9353. break
  9354. case 3:
  9355. fsiOPFLD.MedChrgitmType = "03"
  9356. break
  9357. case 4:
  9358. fsiOPFLD.MedChrgitmType = "03"
  9359. break
  9360. case 5:
  9361. fsiOPFLD.MedChrgitmType = "08"
  9362. break
  9363. case 6:
  9364. fsiOPFLD.MedChrgitmType = "14"
  9365. break
  9366. case 7:
  9367. fsiOPFLD.MedChrgitmType = "14"
  9368. break
  9369. case 8:
  9370. fsiOPFLD.MedChrgitmType = "03"
  9371. break
  9372. case 9:
  9373. fsiOPFLD.MedChrgitmType = "14"
  9374. break
  9375. case 10:
  9376. fsiOPFLD.MedChrgitmType = "14"
  9377. break
  9378. case 11:
  9379. fsiOPFLD.MedChrgitmType = "06"
  9380. break
  9381. case 12:
  9382. fsiOPFLD.MedChrgitmType = "12"
  9383. break
  9384. case 13:
  9385. fsiOPFLD.MedChrgitmType = "01"
  9386. break
  9387. case 14:
  9388. fsiOPFLD.MedChrgitmType = "04"
  9389. break
  9390. case 15:
  9391. fsiOPFLD.MedChrgitmType = "14"
  9392. break
  9393. }
  9394. memo["hosp_appr_flag"] = "1"
  9395. memo["invoice_no"] = order.MdtrtId
  9396. memo["memo"] = "自费"
  9397. bytesData, _ := json.Marshal(memo)
  9398. fsiOPFLD.Memo = string(bytesData)
  9399. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9400. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9401. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9402. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9403. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9404. fsiOPFLD.BilgDeptName = department.Name
  9405. fsiOPFLD.BilgDeptCodg = department.Number
  9406. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9407. fsiOPFLD.BilgDrName = doctor.UserName
  9408. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9409. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9410. fsiOPFLD.MedChrgitmType = "08"
  9411. memo["hosp_appr_flag"] = "1"
  9412. memo["invoice_no"] = order.MdtrtId
  9413. memo["memo"] = "自费"
  9414. bytesData, _ := json.Marshal(memo)
  9415. fsiOPFLD.Memo = string(bytesData)
  9416. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9417. }
  9418. }
  9419. }
  9420. fmt.Println(fsiOPFLDs)
  9421. struct4201A.Fopfd = fsiOPFLDs
  9422. fmt.Println(struct4201A.Fopfd)
  9423. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  9424. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  9425. var res2 ResultSix
  9426. var respJSON2 map[string]interface{}
  9427. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9428. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9430. return
  9431. }
  9432. userJSONBytes2, _ := json.Marshal(respJSON2)
  9433. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9434. utils.ErrorLog("解析失败:%v", err)
  9435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9436. return
  9437. }
  9438. if res2.Infcode != 0 {
  9439. c.ServeSuccessJSON(map[string]interface{}{
  9440. "failed_code": -10,
  9441. "msg": res2.ErrMsg,
  9442. })
  9443. return
  9444. } else {
  9445. order.IsUploadOrderInfo = 1
  9446. service.UpdateOrder(order)
  9447. c.ServeSuccessJSON(map[string]interface{}{
  9448. "msg": "上传成功",
  9449. })
  9450. }
  9451. }
  9452. func (c *HisApiController) Get4202() {
  9453. order_id, _ := c.GetInt64("order_id")
  9454. admin_user_id, _ := c.GetInt64("admin_user_id")
  9455. order, _ := service.GetHisOrderByIDTwo(order_id)
  9456. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9457. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9458. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9459. if order.ID == 0 {
  9460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9461. return
  9462. }
  9463. var struct4202 models.Struct4202
  9464. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9465. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9466. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9467. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9468. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9469. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9470. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  9471. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  9472. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9473. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9474. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9475. var config []*models.HisXtDiagnoseConfig
  9476. for _, item := range diagnosis_ids {
  9477. id, _ := strconv.ParseInt(item, 10, 64)
  9478. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9479. config = append(config, &diagnosisConfig)
  9480. }
  9481. var tempDiaginfos []models.OwnPayPatnDiagListD
  9482. for index, item := range config {
  9483. if index == 0 {
  9484. var tempDiaginfo models.OwnPayPatnDiagListD
  9485. tempDiaginfo.InoutDiagType = "1"
  9486. tempDiaginfo.DiagCode = item.CountryCode
  9487. tempDiaginfo.DiagName = item.CountryContentName
  9488. tempDiaginfo.DiagType = "1"
  9489. tempDiaginfo.DiagSrtNo = "1"
  9490. tempDiaginfo.MaindiagFlag = "1"
  9491. tempDiaginfo.ValiFlag = "1"
  9492. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9493. } else {
  9494. var tempDiaginfo models.OwnPayPatnDiagListD
  9495. tempDiaginfo.DiagCode = item.CountryCode
  9496. tempDiaginfo.DiagName = item.CountryContentName
  9497. tempDiaginfo.DiagType = "2"
  9498. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9499. tempDiaginfo.MaindiagFlag = "0"
  9500. tempDiaginfo.ValiFlag = "1"
  9501. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9502. }
  9503. }
  9504. struct4202.ODiagListD = tempDiaginfos
  9505. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  9506. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  9507. var res2 ResultSix
  9508. var respJSON2 map[string]interface{}
  9509. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9510. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9512. return
  9513. }
  9514. userJSONBytes2, _ := json.Marshal(respJSON2)
  9515. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9516. utils.ErrorLog("解析失败:%v", err)
  9517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9518. return
  9519. }
  9520. if res2.Infcode != 0 {
  9521. c.ServeSuccessJSON(map[string]interface{}{
  9522. "failed_code": -10,
  9523. "msg": res2.ErrMsg,
  9524. })
  9525. return
  9526. } else {
  9527. order.IsUploadDiagnose = 1
  9528. service.UpdateOrder(order)
  9529. c.ServeSuccessJSON(map[string]interface{}{
  9530. "msg": "上传成功",
  9531. })
  9532. }
  9533. }
  9534. func (c *HisApiController) Get4203() {
  9535. admin_user_id, _ := c.GetInt64("admin_user_id")
  9536. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9537. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9538. order_id, _ := c.GetInt64("order_id")
  9539. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  9540. number := ""
  9541. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9542. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9543. if his.ID == 0 {
  9544. number = hospital.Number
  9545. } else {
  9546. number = his.Number
  9547. }
  9548. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  9549. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  9550. var res2 ResultSix
  9551. var respJSON2 map[string]interface{}
  9552. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9553. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9555. return
  9556. }
  9557. userJSONBytes2, _ := json.Marshal(respJSON2)
  9558. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9559. utils.ErrorLog("解析失败:%v", err)
  9560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9561. return
  9562. }
  9563. if res2.Infcode != 0 {
  9564. c.ServeSuccessJSON(map[string]interface{}{
  9565. "failed_code": -10,
  9566. "msg": res2.ErrMsg,
  9567. })
  9568. return
  9569. } else {
  9570. order.IsUploadSuccess = 1
  9571. service.UpdateOrderTwo(order)
  9572. c.ServeSuccessJSON(map[string]interface{}{
  9573. "msg": "上传成功",
  9574. })
  9575. }
  9576. }
  9577. func (c *HisApiController) Get4205() {
  9578. order_id, _ := c.GetInt64("order_id")
  9579. admin_user_id, _ := c.GetInt64("admin_user_id")
  9580. fapiao_code := c.GetString("fapiao_code")
  9581. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  9582. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9583. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9584. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9585. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  9586. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  9587. //order_info = append(order_info, order_info_two...)
  9588. department, _ := service.GetDepartMentDetail(his.Departments)
  9589. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  9590. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  9591. if order.ID == 0 {
  9592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9593. return
  9594. }
  9595. var struct4201A models.Struct4201A
  9596. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  9597. for _, items := range order_info {
  9598. memo := make(map[string]interface{})
  9599. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9600. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9601. fsiOPFLD.MedType = pre.MedType
  9602. fsiOPFLD.FixmedinsCode = miConfig.Code
  9603. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9604. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9605. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9606. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9607. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9608. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.StartTime, 0).Format("2006-01-02 15:04:05")
  9609. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9610. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  9611. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9612. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9613. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9614. fsiOPFLD.BilgDeptName = department.Name
  9615. fsiOPFLD.BilgDeptCodg = department.Number
  9616. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9617. fsiOPFLD.BilgDrName = doctor.UserName
  9618. fsiOPFLD.MedChrgitmType = "09"
  9619. memo["hosp_appr_flag"] = "1"
  9620. memo["invoice_no"] = fapiao_code
  9621. memo["memo"] = "自费"
  9622. bytesData, _ := json.Marshal(memo)
  9623. fsiOPFLD.Memo = string(bytesData)
  9624. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9625. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9626. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9627. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9628. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.StartTime, 0).Format("2006-01-02 15:04:05")
  9629. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9630. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9631. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9632. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9633. fsiOPFLD.BilgDeptName = department.Name
  9634. fsiOPFLD.BilgDeptCodg = department.Number
  9635. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9636. fsiOPFLD.BilgDrName = doctor.UserName
  9637. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9638. case 0:
  9639. break
  9640. case 1:
  9641. fsiOPFLD.MedChrgitmType = "14"
  9642. break
  9643. case 2:
  9644. fsiOPFLD.MedChrgitmType = "05"
  9645. break
  9646. case 3:
  9647. fsiOPFLD.MedChrgitmType = "03"
  9648. break
  9649. case 4:
  9650. fsiOPFLD.MedChrgitmType = "03"
  9651. break
  9652. case 5:
  9653. fsiOPFLD.MedChrgitmType = "08"
  9654. break
  9655. case 6:
  9656. fsiOPFLD.MedChrgitmType = "14"
  9657. break
  9658. case 7:
  9659. fsiOPFLD.MedChrgitmType = "14"
  9660. break
  9661. case 8:
  9662. fsiOPFLD.MedChrgitmType = "03"
  9663. break
  9664. case 9:
  9665. fsiOPFLD.MedChrgitmType = "14"
  9666. break
  9667. case 10:
  9668. fsiOPFLD.MedChrgitmType = "14"
  9669. break
  9670. case 11:
  9671. fsiOPFLD.MedChrgitmType = "06"
  9672. break
  9673. case 12:
  9674. fsiOPFLD.MedChrgitmType = "12"
  9675. break
  9676. case 13:
  9677. fsiOPFLD.MedChrgitmType = "01"
  9678. break
  9679. case 14:
  9680. fsiOPFLD.MedChrgitmType = "04"
  9681. break
  9682. case 15:
  9683. fsiOPFLD.MedChrgitmType = "14"
  9684. break
  9685. }
  9686. memo["hosp_appr_flag"] = "1"
  9687. memo["invoice_no"] = fapiao_code
  9688. memo["memo"] = "自费"
  9689. bytesData, _ := json.Marshal(memo)
  9690. fsiOPFLD.Memo = string(bytesData)
  9691. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9692. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9693. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9694. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9695. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9696. fsiOPFLD.BilgDeptName = department.Name
  9697. fsiOPFLD.BilgDeptCodg = department.Number
  9698. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9699. fsiOPFLD.BilgDrName = doctor.UserName
  9700. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9701. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9702. fsiOPFLD.MedChrgitmType = "08"
  9703. memo["hosp_appr_flag"] = "1"
  9704. memo["invoice_no"] = fapiao_code
  9705. memo["memo"] = "自费"
  9706. bytesData, _ := json.Marshal(memo)
  9707. fsiOPFLD.Memo = string(bytesData)
  9708. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9709. }
  9710. }
  9711. }
  9712. for _, items := range order_info_two {
  9713. memo := make(map[string]interface{})
  9714. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9715. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9716. fsiOPFLD.MedType = pre.MedType
  9717. fsiOPFLD.BkkpSn = items.FeedetlSn
  9718. fsiOPFLD.FixmedinsCode = miConfig.Code
  9719. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9720. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9721. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9722. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9723. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9724. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9725. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9726. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9727. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9728. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9729. fsiOPFLD.BilgDeptName = department.Name
  9730. fsiOPFLD.BilgDeptCodg = department.Number
  9731. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9732. fsiOPFLD.BilgDrName = doctor.UserName
  9733. fsiOPFLD.MedChrgitmType = "09"
  9734. memo["hosp_appr_flag"] = "1"
  9735. memo["invoice_no"] = fapiao_code
  9736. memo["memo"] = "自费"
  9737. bytesData, _ := json.Marshal(memo)
  9738. fsiOPFLD.Memo = string(bytesData)
  9739. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9740. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9741. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9742. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9743. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9744. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9745. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9746. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9747. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9748. fsiOPFLD.BilgDeptName = department.Name
  9749. fsiOPFLD.BilgDeptCodg = department.Number
  9750. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9751. fsiOPFLD.BilgDrName = doctor.UserName
  9752. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9753. case 0:
  9754. break
  9755. case 1:
  9756. fsiOPFLD.MedChrgitmType = "14"
  9757. break
  9758. case 2:
  9759. fsiOPFLD.MedChrgitmType = "05"
  9760. break
  9761. case 3:
  9762. fsiOPFLD.MedChrgitmType = "03"
  9763. break
  9764. case 4:
  9765. fsiOPFLD.MedChrgitmType = "03"
  9766. break
  9767. case 5:
  9768. fsiOPFLD.MedChrgitmType = "08"
  9769. break
  9770. case 6:
  9771. fsiOPFLD.MedChrgitmType = "14"
  9772. break
  9773. case 7:
  9774. fsiOPFLD.MedChrgitmType = "14"
  9775. break
  9776. case 8:
  9777. fsiOPFLD.MedChrgitmType = "03"
  9778. break
  9779. case 9:
  9780. fsiOPFLD.MedChrgitmType = "14"
  9781. break
  9782. case 10:
  9783. fsiOPFLD.MedChrgitmType = "14"
  9784. break
  9785. case 11:
  9786. fsiOPFLD.MedChrgitmType = "06"
  9787. break
  9788. case 12:
  9789. fsiOPFLD.MedChrgitmType = "12"
  9790. break
  9791. case 13:
  9792. fsiOPFLD.MedChrgitmType = "01"
  9793. break
  9794. case 14:
  9795. fsiOPFLD.MedChrgitmType = "04"
  9796. break
  9797. case 15:
  9798. fsiOPFLD.MedChrgitmType = "14"
  9799. break
  9800. }
  9801. memo["hosp_appr_flag"] = "1"
  9802. memo["invoice_no"] = fapiao_code
  9803. memo["memo"] = "自费"
  9804. bytesData, _ := json.Marshal(memo)
  9805. fsiOPFLD.Memo = string(bytesData)
  9806. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9807. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9808. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9809. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9810. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9811. fsiOPFLD.BilgDeptName = department.Name
  9812. fsiOPFLD.BilgDeptCodg = department.Number
  9813. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9814. fsiOPFLD.BilgDrName = doctor.UserName
  9815. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9816. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9817. fsiOPFLD.MedChrgitmType = "08"
  9818. memo["hosp_appr_flag"] = "1"
  9819. memo["invoice_no"] = fapiao_code
  9820. memo["memo"] = "自费"
  9821. bytesData, _ := json.Marshal(memo)
  9822. fsiOPFLD.Memo = string(bytesData)
  9823. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9824. }
  9825. }
  9826. }
  9827. fmt.Println(fsiOPFLDs)
  9828. struct4201A.Fopfd = fsiOPFLDs
  9829. fmt.Println(struct4201A.Fopfd)
  9830. var struct4202 models.Struct4202
  9831. timeLayout := "2006-01-02 15:04:05"
  9832. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  9833. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9834. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9835. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9836. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9837. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9838. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9839. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  9840. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  9841. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9842. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9843. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9844. var config []*models.HisXtDiagnoseConfig
  9845. for _, item := range diagnosis_ids {
  9846. id, _ := strconv.ParseInt(item, 10, 64)
  9847. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9848. config = append(config, &diagnosisConfig)
  9849. }
  9850. var tempDiaginfos []models.OwnPayPatnDiagListD
  9851. for index, item := range config {
  9852. if index == 0 {
  9853. var tempDiaginfo models.OwnPayPatnDiagListD
  9854. tempDiaginfo.InoutDiagType = "1"
  9855. tempDiaginfo.DiagCode = item.CountryCode
  9856. tempDiaginfo.DiagName = item.CountryContentName
  9857. tempDiaginfo.DiagType = "1"
  9858. tempDiaginfo.DiagSrtNo = "1"
  9859. tempDiaginfo.MaindiagFlag = "1"
  9860. tempDiaginfo.ValiFlag = "1"
  9861. tempDiaginfo.DiagDrName = doctor.UserName
  9862. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9863. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9864. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9865. } else {
  9866. var tempDiaginfo models.OwnPayPatnDiagListD
  9867. tempDiaginfo.DiagCode = item.CountryCode
  9868. tempDiaginfo.DiagName = item.CountryContentName
  9869. tempDiaginfo.DiagType = "2"
  9870. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9871. tempDiaginfo.MaindiagFlag = "0"
  9872. tempDiaginfo.ValiFlag = "1"
  9873. tempDiaginfo.DiagDrName = doctor.UserName
  9874. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9875. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9876. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9877. }
  9878. }
  9879. struct4202.ODiagListD = tempDiaginfos
  9880. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  9881. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  9882. var res2 ResultSix
  9883. var respJSON2 map[string]interface{}
  9884. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9885. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9887. return
  9888. }
  9889. userJSONBytes2, _ := json.Marshal(respJSON2)
  9890. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9891. utils.ErrorLog("解析失败:%v", err)
  9892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9893. return
  9894. }
  9895. if res2.Infcode != 0 {
  9896. c.ServeSuccessJSON(map[string]interface{}{
  9897. "failed_code": -10,
  9898. "msg": res2.ErrMsg,
  9899. })
  9900. return
  9901. } else {
  9902. order.IsUploadDiagnose = 1
  9903. order.IsUploadOrderInfo = 1
  9904. service.UpdateOrderTwo(order)
  9905. c.ServeSuccessJSON(map[string]interface{}{
  9906. "msg": "上传成功",
  9907. })
  9908. }
  9909. }
  9910. func (c *HisApiController) Get4207() {
  9911. admin_user_id, _ := c.GetInt64("admin_user_id")
  9912. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9913. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9914. order_id, _ := c.GetInt64("order_id")
  9915. order, _ := service.GetHisOrderByIDTwo(order_id)
  9916. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9917. var struct4207 models.Struct4207
  9918. struct4207.PageNum = "1"
  9919. struct4207.PageSize = "1000"
  9920. struct4207.FixmedinsCode = miConfig.Code
  9921. struct4207.FixmedinsMdtrtID = order.Number
  9922. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  9923. saveLog(result, requestLog, "4207", "查询")
  9924. var res2 ResultSix
  9925. var respJSON2 map[string]interface{}
  9926. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9927. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9929. return
  9930. }
  9931. userJSONBytes2, _ := json.Marshal(respJSON2)
  9932. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9933. utils.ErrorLog("解析失败:%v", err)
  9934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9935. return
  9936. }
  9937. if res2.Infcode != 0 {
  9938. c.ServeSuccessJSON(map[string]interface{}{
  9939. "failed_code": -10,
  9940. "msg": res2.ErrMsg,
  9941. })
  9942. return
  9943. } else {
  9944. c.ServeSuccessJSON(map[string]interface{}{
  9945. "msg": "查询成功",
  9946. })
  9947. }
  9948. }
  9949. func (c *HisApiController) Get4208() {
  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 struct4208 models.Struct4208
  9957. struct4208.PageNum = "1"
  9958. struct4208.PageSize = "1000"
  9959. struct4208.PsnCertType = "01"
  9960. struct4208.Certno = his.Certno
  9961. struct4208.MedType = order.MedType
  9962. struct4208.PsnName = his.Name
  9963. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  9964. saveLog(result, requestLog, "4208", "查询")
  9965. var res2 ResultSix
  9966. var respJSON2 map[string]interface{}
  9967. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9968. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9970. return
  9971. }
  9972. userJSONBytes2, _ := json.Marshal(respJSON2)
  9973. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9974. utils.ErrorLog("解析失败:%v", err)
  9975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9976. return
  9977. }
  9978. if res2.Infcode != 0 {
  9979. c.ServeSuccessJSON(map[string]interface{}{
  9980. "failed_code": -10,
  9981. "msg": res2.ErrMsg,
  9982. })
  9983. return
  9984. } else {
  9985. c.ServeSuccessJSON(map[string]interface{}{
  9986. "msg": "查询成功",
  9987. })
  9988. }
  9989. }
  9990. func (c *HisApiController) Get4209() {
  9991. admin_user_id, _ := c.GetInt64("admin_user_id")
  9992. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9993. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9994. order_id, _ := c.GetInt64("order_id")
  9995. order, _ := service.GetHisOrderByIDTwo(order_id)
  9996. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9997. var struct4209 models.Struct4209
  9998. struct4209.FixmedinsMdtrtID = order.Number
  9999. struct4209.FixmedinsCode = miConfig.Code
  10000. struct4209.PageSize = "1000"
  10001. struct4209.PageNum = "1"
  10002. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  10003. saveLog(result, requestLog, "4209", "查询")
  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. type Result3101 struct {
  10030. Infcode string `json:"infcode"`
  10031. InfRefmsgid string `json:"inf_refmsgid"`
  10032. RefmsgTime string `json:"refmsg_time"`
  10033. RespondTime string `json:"respond_time"`
  10034. Enctype string `json:"enctype"`
  10035. Signtype string `json:"signtype"`
  10036. ErrMsg string `json:"err_msg"`
  10037. Output struct {
  10038. Result []struct {
  10039. JudgeResultDetailDtos []struct {
  10040. VolaItemType string `json:"vola_item_type"`
  10041. MdtrtID string `json:"mdtrt_id"`
  10042. JrdID string `json:"jrd_id"`
  10043. PatnID string `json:"patn_id"`
  10044. RxID string `json:"rx_id"`
  10045. VolaAmt interface{} `json:"vola_amt"`
  10046. } `json:"judge_result_detail_dtos"`
  10047. RuleID string `json:"rule_id"`
  10048. VolaEvid string `json:"vola_evid"`
  10049. MdtrtID string `json:"mdtrt_id"`
  10050. RuleName string `json:"rule_name"`
  10051. VolaAmtStas string `json:"vola_amt_stas"`
  10052. JrID string `json:"jr_id"`
  10053. PatnID string `json:"patn_id"`
  10054. SevDeg string `json:"sev_deg"`
  10055. VolaAmt float64 `json:"vola_amt"`
  10056. VolaBhvrType string `json:"vola_bhvr_type"`
  10057. VolaCont string `json:"vola_cont"`
  10058. } `json:"result"`
  10059. } `json:"output"`
  10060. }
  10061. type Resultgd3101 struct {
  10062. Infcode int64 `json:"infcode"`
  10063. InfRefmsgid string `json:"inf_refmsgid"`
  10064. RefmsgTime string `json:"refmsg_time"`
  10065. RespondTime string `json:"respond_time"`
  10066. Enctype string `json:"enctype"`
  10067. Signtype string `json:"signtype"`
  10068. ErrMsg string `json:"err_msg"`
  10069. Output struct {
  10070. Result []struct {
  10071. JudgeResultDetailDtos []struct {
  10072. VolaItemType string `json:"vola_item_type"`
  10073. MdtrtID string `json:"mdtrt_id"`
  10074. JrdID string `json:"jrd_id"`
  10075. PatnID string `json:"patn_id"`
  10076. RxID string `json:"rx_id"`
  10077. VolaAmt interface{} `json:"vola_amt"`
  10078. } `json:"judge_result_detail_dtos"`
  10079. RuleID string `json:"rule_id"`
  10080. VolaEvid string `json:"vola_evid"`
  10081. MdtrtID string `json:"mdtrt_id"`
  10082. RuleName string `json:"rule_name"`
  10083. VolaAmtStas string `json:"vola_amt_stas"`
  10084. JrID string `json:"jr_id"`
  10085. PatnID string `json:"patn_id"`
  10086. SevDeg string `json:"sev_deg"`
  10087. VolaAmt float64 `json:"vola_amt"`
  10088. VolaBhvrType string `json:"vola_bhvr_type"`
  10089. VolaCont string `json:"vola_cont"`
  10090. } `json:"result"`
  10091. } `json:"output"`
  10092. }
  10093. func (c *HisApiController) ReadEleToken() {
  10094. admin_user_id, _ := c.GetInt64("admin_user_id")
  10095. his_patient_id, _ := c.GetInt64("his_patient_id")
  10096. adminUser := c.GetAdminUserInfo()
  10097. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10098. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10099. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10100. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  10101. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10102. if len(tokens) > 0 {
  10103. c.ServeSuccessJSON(map[string]interface{}{
  10104. "msg": "读取成功",
  10105. })
  10106. } else {
  10107. c.ServeSuccessJSON(map[string]interface{}{
  10108. "failed_code": -10,
  10109. "msg": "读取失败",
  10110. })
  10111. }
  10112. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10113. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10114. if len(tokens) > 0 {
  10115. c.ServeSuccessJSON(map[string]interface{}{
  10116. "msg": "读取成功",
  10117. })
  10118. } else {
  10119. c.ServeSuccessJSON(map[string]interface{}{
  10120. "failed_code": -10,
  10121. "msg": "读取失败",
  10122. })
  10123. }
  10124. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10125. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10126. if len(tokens) > 0 {
  10127. c.ServeSuccessJSON(map[string]interface{}{
  10128. "msg": "读取成功",
  10129. })
  10130. } else {
  10131. c.ServeSuccessJSON(map[string]interface{}{
  10132. "failed_code": -10,
  10133. "msg": "读取失败",
  10134. })
  10135. }
  10136. } else if miConfig.MdtrtareaAdmvs == "150499" {
  10137. var api string
  10138. 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 +
  10139. "&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"
  10140. resp, requestErr := http.Get(api)
  10141. if requestErr != nil {
  10142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10143. }
  10144. body, ioErr := ioutil.ReadAll(resp.Body)
  10145. if ioErr != nil {
  10146. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10148. }
  10149. var respJSON map[string]interface{}
  10150. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10151. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10153. return
  10154. }
  10155. var status string
  10156. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10157. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10158. var token string
  10159. var res ResultTwo //1101结果
  10160. var res10265 ResultTwo10265 //1101结果
  10161. if status == "0" { //读卡成功
  10162. var card_info string //卡信息
  10163. var busi_card_info string
  10164. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10165. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10166. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10167. fmt.Println(card_info)
  10168. fmt.Println(busi_card_info)
  10169. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10170. result, _ := json.Marshal(respJSON)
  10171. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10172. utils.ErrorLog("解析失败:%v", err)
  10173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10174. return
  10175. }
  10176. res.ErrMsg = res10265.ErrMsg
  10177. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10178. res.Infcode = infocode
  10179. res.Output = res10265.Output
  10180. res.InfRefmsgid = res10265.InfRefmsgid
  10181. if res.Infcode == 0 {
  10182. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10183. if err == gorm.ErrRecordNotFound {
  10184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10185. return
  10186. } else if err != nil {
  10187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10188. return
  10189. } else {
  10190. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10191. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10192. infoStr := string(Iinfos)
  10193. idetinfoStr := string(Idetinfos)
  10194. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  10195. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  10196. psn := &models.HisPsn{
  10197. PsnNo: res.Output.Baseinfo.PsnNo,
  10198. PatientId: patient.ID,
  10199. Certno: res.Output.Baseinfo.Certno,
  10200. Gend: res.Output.Baseinfo.Gend,
  10201. Naty: res.Output.Baseinfo.Naty,
  10202. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10203. PsnName: res.Output.Baseinfo.PsnName,
  10204. Age: float64(age),
  10205. Brdy: b,
  10206. Idetinfo: idetinfoStr,
  10207. Insuinfo: infoStr,
  10208. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10209. CardInfo: card_info,
  10210. VerifyNumber: token,
  10211. IdCardType: 4,
  10212. }
  10213. var rf []*ResultFive
  10214. json.Unmarshal([]byte(infoStr), &rf)
  10215. var insutypes []*ResultFive
  10216. var insutype string
  10217. var is390 int = 0
  10218. var is310 int = 0
  10219. for _, item := range rf {
  10220. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10221. insutypes = append(insutypes, item)
  10222. }
  10223. }
  10224. if len(insutypes) == 1 {
  10225. insutype = insutypes[0].Insutype
  10226. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10227. } else {
  10228. for _, i := range insutypes {
  10229. if i.Insutype == "390" {
  10230. is390 = 1
  10231. }
  10232. if i.Insutype == "310" {
  10233. is310 = 1
  10234. }
  10235. }
  10236. }
  10237. if is390 == 1 {
  10238. insutype = "390"
  10239. }
  10240. if is310 == 1 {
  10241. insutype = "310"
  10242. }
  10243. if len(insutypes) == 0 {
  10244. insutype = "310"
  10245. }
  10246. service.CreateHisPsn(psn)
  10247. c.ServeSuccessJSON(map[string]interface{}{
  10248. "patient": patient,
  10249. "number": token,
  10250. "insutype": insutype,
  10251. })
  10252. }
  10253. } else {
  10254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10255. return
  10256. }
  10257. } else { //读卡失败
  10258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10259. return
  10260. }
  10261. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10262. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  10263. if len(errMsg) == 0 {
  10264. type ELeData struct {
  10265. Data struct {
  10266. IdNo string `json:"idNo"`
  10267. IdType string `json:"idType"`
  10268. UserName string `json:"userName"`
  10269. EcToken string `json:"ecToken"`
  10270. InsuOrg string `json:"insuOrg"`
  10271. Gender string `json:"gender"`
  10272. Birthday string `json:"birthday"`
  10273. Nationality string `json:"nationality"`
  10274. Email string `json:"email"`
  10275. Extra string `json:"extra"`
  10276. } `json:"data"`
  10277. Code int `json:"code"`
  10278. Message string `json:"message"`
  10279. }
  10280. var ele ELeData
  10281. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10282. if err != nil {
  10283. utils.ErrorLog("解析失败:%v", err)
  10284. }
  10285. token := ele.Data.EcToken
  10286. if len(token) > 0 {
  10287. psn := &models.HisPsn{
  10288. PsnNo: his.PsnNo,
  10289. Age: 0,
  10290. PatientId: his.PatientId,
  10291. Certno: his.Certno,
  10292. Brdy: his.Brdy,
  10293. Gend: his.Gend,
  10294. Naty: his.Naty,
  10295. PsnCertType: his.PsnCertType,
  10296. PsnName: his.PsnName,
  10297. Idetinfo: his.Idetinfo,
  10298. Insuinfo: his.Iinfo,
  10299. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10300. CardInfo: outPutInfo,
  10301. VerifyNumber: token,
  10302. }
  10303. service.CreateHisPsn(psn)
  10304. }
  10305. if len(token) > 0 {
  10306. c.ServeSuccessJSON(map[string]interface{}{
  10307. "msg": "读取成功",
  10308. })
  10309. } else {
  10310. c.ServeSuccessJSON(map[string]interface{}{
  10311. "failed_code": -10,
  10312. "msg": "读取失败",
  10313. })
  10314. }
  10315. }
  10316. } else if miConfig.MdtrtareaAdmvs == "360302" {
  10317. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10318. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10319. type ELeData struct {
  10320. Data struct {
  10321. IdNo string `json:"idNo"`
  10322. IdType string `json:"idType"`
  10323. UserName string `json:"userName"`
  10324. EcToken string `json:"ecToken"`
  10325. InsuOrg string `json:"insuOrg"`
  10326. Gender string `json:"gender"`
  10327. Birthday string `json:"birthday"`
  10328. Nationality string `json:"nationality"`
  10329. Email string `json:"email"`
  10330. Extra string `json:"extra"`
  10331. } `json:"data"`
  10332. Code int `json:"code"`
  10333. Message string `json:"message"`
  10334. }
  10335. var ele ELeData
  10336. err := json.Unmarshal([]byte(result), &ele)
  10337. if err != nil {
  10338. utils.ErrorLog("解析失败:%v", err)
  10339. }
  10340. token := ele.Data.EcToken
  10341. token = Remove0000(token)
  10342. fmt.Println(ele.Data.UserName)
  10343. 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)
  10344. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10345. var res ResultTwo
  10346. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10347. utils.ErrorLog("解析失败:%v", err)
  10348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10349. return
  10350. }
  10351. if res.Infcode == 0 {
  10352. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10353. if err == gorm.ErrRecordNotFound {
  10354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10355. return
  10356. } else if err != nil {
  10357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10358. return
  10359. } else {
  10360. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10361. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10362. infoStr := string(Iinfos)
  10363. idetinfoStr := string(Idetinfos)
  10364. psn := &models.HisPsn{
  10365. PsnNo: res.Output.Baseinfo.PsnNo,
  10366. PatientId: patient.ID,
  10367. Certno: res.Output.Baseinfo.Certno,
  10368. Gend: res.Output.Baseinfo.Gend,
  10369. Naty: res.Output.Baseinfo.Naty,
  10370. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10371. PsnName: res.Output.Baseinfo.PsnName,
  10372. Idetinfo: idetinfoStr,
  10373. Insuinfo: infoStr,
  10374. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10375. CardInfo: "",
  10376. VerifyNumber: token,
  10377. }
  10378. service.CreateHisPsn(psn)
  10379. c.ServeSuccessJSON(map[string]interface{}{
  10380. "patient": patient,
  10381. "number": token,
  10382. })
  10383. }
  10384. } else {
  10385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10386. return
  10387. }
  10388. } else if miConfig.MdtrtareaAdmvs == "361025" {
  10389. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10390. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10391. type ELeData struct {
  10392. Data struct {
  10393. IdNo string `json:"idNo"`
  10394. IdType string `json:"idType"`
  10395. UserName string `json:"userName"`
  10396. EcToken string `json:"ecToken"`
  10397. InsuOrg string `json:"insuOrg"`
  10398. Gender string `json:"gender"`
  10399. Birthday string `json:"birthday"`
  10400. Nationality string `json:"nationality"`
  10401. Email string `json:"email"`
  10402. Extra string `json:"extra"`
  10403. } `json:"data"`
  10404. Code int `json:"code"`
  10405. Message string `json:"message"`
  10406. }
  10407. var ele ELeData
  10408. err := json.Unmarshal([]byte(result), &ele)
  10409. if err != nil {
  10410. utils.ErrorLog("解析失败:%v", err)
  10411. }
  10412. token := ele.Data.EcToken
  10413. token = Remove0000(token)
  10414. fmt.Println(ele.Data.UserName)
  10415. 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)
  10416. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10417. var res ResultTwo
  10418. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10419. utils.ErrorLog("解析失败:%v", err)
  10420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10421. return
  10422. }
  10423. if res.Infcode == 0 {
  10424. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10425. if err == gorm.ErrRecordNotFound {
  10426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10427. return
  10428. } else if err != nil {
  10429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10430. return
  10431. } else {
  10432. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10433. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10434. infoStr := string(Iinfos)
  10435. idetinfoStr := string(Idetinfos)
  10436. psn := &models.HisPsn{
  10437. PsnNo: res.Output.Baseinfo.PsnNo,
  10438. PatientId: patient.ID,
  10439. Certno: res.Output.Baseinfo.Certno,
  10440. Gend: res.Output.Baseinfo.Gend,
  10441. Naty: res.Output.Baseinfo.Naty,
  10442. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10443. PsnName: res.Output.Baseinfo.PsnName,
  10444. Idetinfo: idetinfoStr,
  10445. Insuinfo: infoStr,
  10446. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10447. CardInfo: "",
  10448. VerifyNumber: token,
  10449. }
  10450. service.CreateHisPsn(psn)
  10451. c.ServeSuccessJSON(map[string]interface{}{
  10452. "patient": patient,
  10453. "number": token,
  10454. })
  10455. }
  10456. } else {
  10457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10458. return
  10459. }
  10460. } else if miConfig.MdtrtareaAdmvs == "360100" {
  10461. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10462. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10463. type ELeData struct {
  10464. Data struct {
  10465. IdNo string `json:"idNo"`
  10466. IdType string `json:"idType"`
  10467. UserName string `json:"userName"`
  10468. EcToken string `json:"ecToken"`
  10469. InsuOrg string `json:"insuOrg"`
  10470. Gender string `json:"gender"`
  10471. Birthday string `json:"birthday"`
  10472. Nationality string `json:"nationality"`
  10473. Email string `json:"email"`
  10474. Extra string `json:"extra"`
  10475. } `json:"data"`
  10476. Code int `json:"code"`
  10477. Message string `json:"message"`
  10478. }
  10479. var ele ELeData
  10480. err := json.Unmarshal([]byte(result), &ele)
  10481. if err != nil {
  10482. utils.ErrorLog("解析失败:%v", err)
  10483. }
  10484. token := ele.Data.EcToken
  10485. token = Remove0000(token)
  10486. fmt.Println(ele.Data.UserName)
  10487. 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)
  10488. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10489. var res ResultTwo
  10490. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10491. utils.ErrorLog("解析失败:%v", err)
  10492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10493. return
  10494. }
  10495. if res.Infcode == 0 {
  10496. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10497. if err == gorm.ErrRecordNotFound {
  10498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10499. return
  10500. } else if err != nil {
  10501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10502. return
  10503. } else {
  10504. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10505. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10506. infoStr := string(Iinfos)
  10507. idetinfoStr := string(Idetinfos)
  10508. psn := &models.HisPsn{
  10509. PsnNo: res.Output.Baseinfo.PsnNo,
  10510. PatientId: patient.ID,
  10511. Certno: res.Output.Baseinfo.Certno,
  10512. Gend: res.Output.Baseinfo.Gend,
  10513. Naty: res.Output.Baseinfo.Naty,
  10514. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10515. PsnName: res.Output.Baseinfo.PsnName,
  10516. Idetinfo: idetinfoStr,
  10517. Insuinfo: infoStr,
  10518. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10519. CardInfo: "",
  10520. VerifyNumber: token,
  10521. }
  10522. service.CreateHisPsn(psn)
  10523. c.ServeSuccessJSON(map[string]interface{}{
  10524. "patient": patient,
  10525. "number": token,
  10526. })
  10527. }
  10528. } else {
  10529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10530. return
  10531. }
  10532. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10533. //if initFlag == 0 {
  10534. //c.TestGetJiangXiBasBaseInit()
  10535. //}
  10536. //if initEleFlag == 0 {
  10537. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  10538. //}
  10539. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  10540. utils.ErrorLog("解析失败:%v", json_result)
  10541. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10542. type ELeData struct {
  10543. Data struct {
  10544. IdNo string `json:"idNo"`
  10545. IdType string `json:"idType"`
  10546. UserName string `json:"userName"`
  10547. EcToken string `json:"ecToken"`
  10548. InsuOrg string `json:"insuOrg"`
  10549. Gender string `json:"gender"`
  10550. Birthday string `json:"birthday"`
  10551. Nationality string `json:"nationality"`
  10552. Email string `json:"email"`
  10553. Extra string `json:"extra"`
  10554. } `json:"data"`
  10555. Code int `json:"code"`
  10556. Message string `json:"message"`
  10557. }
  10558. var ele ELeData
  10559. err := json.Unmarshal([]byte(json_result), &ele)
  10560. if err != nil {
  10561. utils.ErrorLog("解析失败:%v", err)
  10562. }
  10563. token := ele.Data.EcToken
  10564. token = Remove0000(token)
  10565. //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)
  10566. 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)
  10567. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  10568. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10569. var res ResultTwo
  10570. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10571. utils.ErrorLog("解析失败:%v", err)
  10572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10573. return
  10574. }
  10575. if res.Infcode == 0 {
  10576. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10577. if err == gorm.ErrRecordNotFound {
  10578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10579. return
  10580. } else if err != nil {
  10581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10582. return
  10583. } else {
  10584. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10585. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10586. infoStr := string(Iinfos)
  10587. idetinfoStr := string(Idetinfos)
  10588. psn := &models.HisPsn{
  10589. PsnNo: res.Output.Baseinfo.PsnNo,
  10590. PatientId: patient.ID,
  10591. Certno: res.Output.Baseinfo.Certno,
  10592. Gend: res.Output.Baseinfo.Gend,
  10593. Naty: res.Output.Baseinfo.Naty,
  10594. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10595. PsnName: res.Output.Baseinfo.PsnName,
  10596. Idetinfo: idetinfoStr,
  10597. Insuinfo: infoStr,
  10598. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10599. CardInfo: "",
  10600. VerifyNumber: token,
  10601. InsuplcAdmdvs: ele.Data.InsuOrg,
  10602. }
  10603. service.CreateHisPsn(psn)
  10604. c.ServeSuccessJSON(map[string]interface{}{
  10605. "patient": patient,
  10606. "number": token,
  10607. })
  10608. }
  10609. } else {
  10610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10611. return
  10612. }
  10613. } else if miConfig.MdtrtareaAdmvs == "450721" {
  10614. res := c.GetoleInfo()
  10615. if res.Infcode == 0 {
  10616. var result string
  10617. if res.Output.MdtrtCertType == "01" {
  10618. 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)
  10619. } else if res.Output.MdtrtCertType == "02" {
  10620. 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)
  10621. } else if res.Output.MdtrtCertType == "03" {
  10622. 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)
  10623. }
  10624. var dat map[string]interface{}
  10625. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10626. fmt.Println(dat)
  10627. } else {
  10628. fmt.Println(err)
  10629. }
  10630. userJSONBytes, _ := json.Marshal(dat)
  10631. var res2 ResultTwo
  10632. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10633. utils.ErrorLog("解析失败:%v", err)
  10634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10635. return
  10636. }
  10637. if res2.Infcode == 0 {
  10638. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  10639. if err == gorm.ErrRecordNotFound {
  10640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10641. return
  10642. } else if err != nil {
  10643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10644. return
  10645. } else {
  10646. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  10647. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  10648. infoStr := string(Iinfos)
  10649. idetinfoStr := string(Idetinfos)
  10650. var rf []*ResultFive
  10651. json.Unmarshal([]byte(infoStr), &rf)
  10652. var insutypes []*ResultFive
  10653. var insutype string
  10654. var is390 int = 0
  10655. var is310 int = 0
  10656. //var insuplc_admdvs string
  10657. for _, item := range rf {
  10658. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10659. insutypes = append(insutypes, item)
  10660. }
  10661. }
  10662. if len(insutypes) == 1 {
  10663. insutype = insutypes[0].Insutype
  10664. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10665. } else {
  10666. for _, i := range insutypes {
  10667. if i.Insutype == "390" {
  10668. is390 = 1
  10669. }
  10670. if i.Insutype == "310" {
  10671. is310 = 1
  10672. }
  10673. }
  10674. }
  10675. if is390 == 1 {
  10676. insutype = "390"
  10677. }
  10678. if is310 == 1 {
  10679. insutype = "310"
  10680. }
  10681. if len(insutypes) == 0 {
  10682. insutype = "310"
  10683. }
  10684. psn := &models.HisPsn{
  10685. PsnNo: res2.Output.Baseinfo.PsnNo,
  10686. PatientId: patient.ID,
  10687. Certno: res2.Output.Baseinfo.Certno,
  10688. Gend: res2.Output.Baseinfo.Gend,
  10689. Naty: res2.Output.Baseinfo.Naty,
  10690. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  10691. PsnName: res2.Output.Baseinfo.PsnName,
  10692. Idetinfo: idetinfoStr,
  10693. Insuinfo: infoStr,
  10694. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10695. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  10696. VerifyNumber: res.Output.EcToken,
  10697. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  10698. }
  10699. service.CreateHisPsn(psn)
  10700. c.ServeSuccessJSON(map[string]interface{}{
  10701. "patient": patient,
  10702. "number": res.Output.CardNo,
  10703. "insutype": insutype,
  10704. })
  10705. }
  10706. } else {
  10707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10708. return
  10709. }
  10710. } else {
  10711. c.ServeSuccessJSON(map[string]interface{}{
  10712. "failed_code": -10,
  10713. "msg": res.ErrMsg,
  10714. })
  10715. }
  10716. } else {
  10717. //if initFlag == 0 {
  10718. // c.TestGetBasBaseInit()
  10719. //}
  10720. //token := c.GetEleBaseInfo()
  10721. //token = Remove0000(token)
  10722. type ELeData struct {
  10723. Code string `json:"code"`
  10724. Data struct {
  10725. Aac002 string `json:"aac002"`
  10726. Aaz500 string `json:"aaz500"`
  10727. ActCardNo string `json:"actCardNo"`
  10728. Bab520 string `json:"bab520"`
  10729. Bkz543 string `json:"bkz543"`
  10730. BusinessType string `json:"businessType"`
  10731. CertfCodg string `json:"certfCodg"`
  10732. EcIndexNo string `json:"ecIndexNo"`
  10733. EcToken string `json:"ecToken"`
  10734. ID0000 string `json:"id0000"`
  10735. IDNo string `json:"idNo"`
  10736. IDType string `json:"idType"`
  10737. Idcode string `json:"idcode"`
  10738. IdentityToken string `json:"identity_token"`
  10739. InsuOrg string `json:"insuOrg"`
  10740. OfficeID string `json:"officeId"`
  10741. OfficeName string `json:"officeName"`
  10742. OperatorID string `json:"operatorId"`
  10743. OperatorName string `json:"operatorName"`
  10744. OrgID string `json:"orgId"`
  10745. UserName string `json:"userName"`
  10746. } `json:"data"`
  10747. Infno interface{} `json:"infno"`
  10748. Message string `json:"message"`
  10749. OrgID string `json:"orgId"`
  10750. TransType string `json:"transType"`
  10751. }
  10752. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10753. fmt.Println(result)
  10754. outPutInfo := Remove0000(result)
  10755. fmt.Println(outPutInfo)
  10756. var ele ELeData
  10757. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10758. if err != nil {
  10759. utils.ErrorLog("解析失败:%v", err)
  10760. }
  10761. token := ele.Data.EcToken
  10762. var result2 string
  10763. var requestLog2 string
  10764. if len(token) > 0 {
  10765. if strings.Contains(ele.Data.IDNo, "HKG") {
  10766. 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)
  10767. } else {
  10768. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  10769. }
  10770. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10771. var res ResultTwo
  10772. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10773. utils.ErrorLog("解析失败:%v", err)
  10774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10775. return
  10776. }
  10777. if res.Infcode == 0 {
  10778. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10779. if err == gorm.ErrRecordNotFound {
  10780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10781. return
  10782. } else if err != nil {
  10783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10784. return
  10785. } else {
  10786. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10787. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10788. infoStr := string(Iinfos)
  10789. idetinfoStr := string(Idetinfos)
  10790. psn := &models.HisPsn{
  10791. PsnNo: res.Output.Baseinfo.PsnNo,
  10792. PatientId: patient.ID,
  10793. Certno: res.Output.Baseinfo.Certno,
  10794. Gend: res.Output.Baseinfo.Gend,
  10795. Naty: res.Output.Baseinfo.Naty,
  10796. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10797. PsnName: res.Output.Baseinfo.PsnName,
  10798. Idetinfo: idetinfoStr,
  10799. Insuinfo: infoStr,
  10800. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10801. CardInfo: "",
  10802. VerifyNumber: token,
  10803. }
  10804. service.CreateHisPsn(psn)
  10805. c.ServeSuccessJSON(map[string]interface{}{
  10806. "msg": "读取成功",
  10807. })
  10808. }
  10809. } else {
  10810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10811. return
  10812. }
  10813. } else {
  10814. c.ServeSuccessJSON(map[string]interface{}{
  10815. "failed_code": -10,
  10816. "msg": "读取失败",
  10817. })
  10818. }
  10819. }
  10820. }
  10821. func (c *HisApiController) ReadEleFace() {
  10822. admin_user_id, _ := c.GetInt64("admin_user_id")
  10823. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10824. adminUser := c.GetAdminUserInfo()
  10825. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10826. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10827. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10828. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  10829. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10830. if len(tokens) > 0 {
  10831. c.ServeSuccessJSON(map[string]interface{}{
  10832. "msg": "读取成功",
  10833. })
  10834. } else {
  10835. c.ServeSuccessJSON(map[string]interface{}{
  10836. "failed_code": -10,
  10837. "msg": "读取失败",
  10838. })
  10839. }
  10840. }
  10841. }
  10842. func timestampToBirthdayString(timestamp int64) string {
  10843. // 将时间戳转换为 time.Time
  10844. t := time.Unix(timestamp, 0)
  10845. // 格式化时间为生日字符串,例如 "2006-01-02"
  10846. birthday := t.Format("2006-01-02")
  10847. return birthday
  10848. }
  10849. func (c *HisApiController) Get9001() {
  10850. adminUser := c.GetAdminUserInfo()
  10851. admin_user_id, _ := c.GetInt64("admin_user_id")
  10852. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10853. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10854. if miConfig.MdtrtareaAdmvs == "350500" {
  10855. service.GetFjAuthorizationInfo(miConfig.Code)
  10856. } else if miConfig.MdtrtareaAdmvs == "131023" {
  10857. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10858. var dat map[string]interface{}
  10859. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10860. fmt.Println(dat)
  10861. } else {
  10862. fmt.Println(err)
  10863. }
  10864. userJSONBytes, _ := json.Marshal(dat)
  10865. var res models.Result9001
  10866. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10867. utils.ErrorLog("解析失败:%v", err)
  10868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10869. return
  10870. }
  10871. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10872. fmt.Println(miConfig.SecretKey)
  10873. var res models.Result9001Two
  10874. 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 +
  10875. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10876. resp, requestErr := http.Get(api)
  10877. if requestErr != nil {
  10878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10879. return
  10880. }
  10881. body, ioErr := ioutil.ReadAll(resp.Body)
  10882. if ioErr != nil {
  10883. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10885. return
  10886. }
  10887. var respJSON map[string]interface{}
  10888. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10889. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10891. return
  10892. }
  10893. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10894. if status == "0" {
  10895. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10896. c.ServeSuccessJSON(map[string]interface{}{
  10897. "failed_code": -10,
  10898. "msg": err_msg,
  10899. })
  10900. return
  10901. }
  10902. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10903. result, _ := json.Marshal(respJSON)
  10904. fmt.Println("log")
  10905. fmt.Println(string(result))
  10906. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10907. utils.ErrorLog("解析失败:%v", err)
  10908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10909. return
  10910. }
  10911. if res.Infcode == 0 {
  10912. sign := models.HisSignIn{
  10913. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10914. SignNo: res.Output.Signinoutb.SignNo,
  10915. SignTime: "",
  10916. Ctime: time.Now().Unix(),
  10917. Mtime: time.Now().Unix(),
  10918. Status: 1,
  10919. InputLog: "",
  10920. OutputLog: "",
  10921. FixmedinsCode: miConfig.Code,
  10922. }
  10923. err := service.CreateSignIn(&sign)
  10924. if err == nil {
  10925. c.ServeSuccessJSON(map[string]interface{}{
  10926. "msg": "签到成功",
  10927. })
  10928. }
  10929. } else {
  10930. c.ServeSuccessJSON(map[string]interface{}{
  10931. "failed_code": -10,
  10932. "msg": res.ErrMsg,
  10933. })
  10934. return
  10935. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10936. //return
  10937. }
  10938. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10939. fmt.Println(miConfig.SecretKey)
  10940. var res models.Result9001Two
  10941. 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 +
  10942. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10943. resp, requestErr := http.Get(api)
  10944. if requestErr != nil {
  10945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10946. return
  10947. }
  10948. body, ioErr := ioutil.ReadAll(resp.Body)
  10949. if ioErr != nil {
  10950. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10952. return
  10953. }
  10954. var respJSON map[string]interface{}
  10955. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10956. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10958. return
  10959. }
  10960. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10961. if status == "0" {
  10962. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10963. c.ServeSuccessJSON(map[string]interface{}{
  10964. "failed_code": -10,
  10965. "msg": err_msg,
  10966. })
  10967. return
  10968. }
  10969. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10970. result, _ := json.Marshal(respJSON)
  10971. fmt.Println("log")
  10972. fmt.Println(string(result))
  10973. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10974. utils.ErrorLog("解析失败:%v", err)
  10975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10976. return
  10977. }
  10978. if res.Infcode == 0 {
  10979. sign := models.HisSignIn{
  10980. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10981. SignNo: res.Output.Signinoutb.SignNo,
  10982. SignTime: "",
  10983. Ctime: time.Now().Unix(),
  10984. Mtime: time.Now().Unix(),
  10985. Status: 1,
  10986. InputLog: "",
  10987. OutputLog: "",
  10988. FixmedinsCode: miConfig.Code,
  10989. }
  10990. err := service.CreateSignIn(&sign)
  10991. if err == nil {
  10992. c.ServeSuccessJSON(map[string]interface{}{
  10993. "msg": "签到成功",
  10994. })
  10995. }
  10996. } else {
  10997. c.ServeSuccessJSON(map[string]interface{}{
  10998. "failed_code": -10,
  10999. "msg": res.ErrMsg,
  11000. })
  11001. return
  11002. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11003. //return
  11004. }
  11005. } else {
  11006. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  11007. var dat map[string]interface{}
  11008. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11009. fmt.Println(dat)
  11010. } else {
  11011. fmt.Println(err)
  11012. }
  11013. userJSONBytes, _ := json.Marshal(dat)
  11014. var res models.Result9001
  11015. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11016. utils.ErrorLog("解析失败:%v", err)
  11017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11018. return
  11019. }
  11020. if res.Infcode == 0 {
  11021. sign := models.HisSignIn{
  11022. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11023. SignNo: res.Output.Signinoutb.SignNo,
  11024. SignTime: res.Output.Signinoutb.SignTime,
  11025. Ctime: time.Now().Unix(),
  11026. Mtime: time.Now().Unix(),
  11027. Status: 1,
  11028. InputLog: "",
  11029. OutputLog: "",
  11030. FixmedinsCode: miConfig.Code,
  11031. }
  11032. err := service.CreateSignIn(&sign)
  11033. if err == nil {
  11034. c.ServeSuccessJSON(map[string]interface{}{
  11035. "msg": "签到成功",
  11036. })
  11037. }
  11038. }
  11039. }
  11040. }
  11041. 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) {
  11042. var res Result3101
  11043. adminUser := c.GetAdminUserInfo()
  11044. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11045. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11046. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11047. //record_time := c.GetString("record_time")
  11048. //trig_scen := c.GetString("trig_scen")
  11049. timeLayout := "2006-01-02"
  11050. loc, _ := time.LoadLocation("Local")
  11051. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11052. if err != nil {
  11053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11054. return res
  11055. }
  11056. recordDateTime := theTime.Unix()
  11057. var patientPrescription models.HisPrescriptionInfo
  11058. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11059. //if patientPrescription.ID == 0 {
  11060. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11061. //}
  11062. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11063. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11064. //
  11065. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11066. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11067. var pp models.PublicParams
  11068. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11069. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11070. pp.FixmedinsName = miConfig.OrgName
  11071. pp.FixmedinsCode = miConfig.Code
  11072. pp.RequestUrl = miConfig.Url
  11073. pp.Cainfo = miConfig.Cainfo
  11074. pp.SecretKey = miConfig.SecretKey
  11075. pp.AccessKey = miConfig.AccessKey
  11076. pp.OpterName = roles.UserName
  11077. var config []*models.HisXtDiagnoseConfig
  11078. for _, item := range diagnosis_ids {
  11079. id, _ := strconv.ParseInt(item, 10, 64)
  11080. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11081. config = append(config, &diagnosisConfig)
  11082. }
  11083. var pd models.PatientDtos
  11084. pd.PatnID = his.PsnNo
  11085. pd.PatnName = his.Name
  11086. pd.Gend = his.Gend
  11087. pd.Brdy = his.Brdy
  11088. pd.Poolarea = miConfig.MdtrtareaAdmvs
  11089. pd.CurrMdtrtID = his.Number
  11090. var fed models.FsiEncounterDtos
  11091. fed.MdtrtID = his.Number
  11092. fed.MedinsID = miConfig.Code
  11093. fed.MedinsName = miConfig.OrgName
  11094. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11095. fed.MedMdtrtType = "1"
  11096. fed.MedinsType = "1"
  11097. fed.MedinsLv = "11"
  11098. tm := time.Unix(his.RecordDate, 0)
  11099. s_tm := tm.Format("2006-01-02 15:04:05")
  11100. fed.AdmDate = s_tm
  11101. fed.DscgDate = s_tm
  11102. fed.DscgMainDiseCodg = config[0].CountryCode
  11103. fed.DscgMainDiseName = config[0].CountryContentName
  11104. //诊断信息
  11105. var fdds []*models.FsiDiagnoseDtos
  11106. for index, item := range config {
  11107. if index == 0 {
  11108. var fdd models.FsiDiagnoseDtos
  11109. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11110. fdd.InoutDiseType = "1"
  11111. fdd.MaindiseFlag = "1"
  11112. fdd.DiseDate = s_tm
  11113. fdd.DiasSrtNo = "1"
  11114. fdd.DiseName = item.CountryContentName
  11115. fdd.DiseCodg = item.CountryCode
  11116. fdds = append(fdds, &fdd)
  11117. } else {
  11118. var fdd models.FsiDiagnoseDtos
  11119. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11120. fdd.InoutDiseType = "1"
  11121. fdd.MaindiseFlag = "1"
  11122. fdd.DiseDate = s_tm
  11123. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11124. fdd.DiseName = item.CountryContentName
  11125. fdd.DiseCodg = item.CountryCode
  11126. fdds = append(fdds, &fdd)
  11127. }
  11128. }
  11129. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11130. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  11131. fed.AdmDeptName = de.Name
  11132. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  11133. fed.DscgDeptName = de.Name
  11134. fed.MedMdtrtType = "1"
  11135. fed.MedType = "11"
  11136. //if his.Insutype == "390" {
  11137. // fed.MedType = "1402"
  11138. //} else {
  11139. // fed.MedType = "9933"
  11140. //}
  11141. var orders []*models.FsiOrderDtos
  11142. if trig_scen == "2" {
  11143. //处方医嘱信息
  11144. for _, item := range prescriptions {
  11145. for _, subItem := range item.HisDoctorAdviceInfo {
  11146. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11147. var order models.FsiOrderDtos
  11148. order.RxID = strconv.FormatInt(item.ID, 10)
  11149. order.Rxno = strconv.FormatInt(item.ID, 10)
  11150. order.LongDrordFlag = "0"
  11151. order.HilistType = "1"
  11152. order.ChrgType = "1"
  11153. order.DrordBhvr = "-"
  11154. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11155. order.HosplistName = subItem.BaseDrugLib.DrugName
  11156. order.HilistLv = "1"
  11157. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11158. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11159. order.HosplistName = subItem.BaseDrugLib.DrugName
  11160. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11161. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11162. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11163. order.OwnpayAmt = ""
  11164. order.SelfpayAmt = ""
  11165. order.Spec = ""
  11166. order.SpecUnt = ""
  11167. order.DrordBegnDate = s_tm
  11168. order.DrordStopDate = ""
  11169. order.DrordDrCodg = doctor_info.DoctorNumber
  11170. order.DrordDeptName = department.Name
  11171. order.DrordDeptCodg = department.Number
  11172. order.DrordDrName = doctor_info.UserName
  11173. order.DrordDrProfttl = "234"
  11174. order.CurrDrordFlag = "1"
  11175. orders = append(orders, &order)
  11176. }
  11177. }
  11178. for _, subItem := range item.HisPrescriptionProject {
  11179. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11180. var order models.FsiOrderDtos
  11181. order.RxID = strconv.FormatInt(item.ID, 10)
  11182. order.Rxno = strconv.FormatInt(item.ID, 10)
  11183. order.LongDrordFlag = "0"
  11184. order.HilistType = "1"
  11185. order.ChrgType = "1"
  11186. order.DrordBhvr = "-"
  11187. order.HilistCode = subItem.HisProject.MedicalCode
  11188. order.HosplistName = subItem.HisProject.ProjectName
  11189. order.HilistLv = "1"
  11190. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11191. order.HosplistCode = subItem.HisProject.MedicalCode
  11192. order.HosplistName = subItem.HisProject.ProjectName
  11193. order.Cnt = subItem.Count
  11194. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11195. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11196. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11197. order.OwnpayAmt = ""
  11198. order.SelfpayAmt = ""
  11199. order.Spec = ""
  11200. order.SpecUnt = ""
  11201. order.DrordBegnDate = s_tm
  11202. order.DrordStopDate = ""
  11203. order.DrordDrCodg = doctor_info.DoctorNumber
  11204. order.DrordDeptName = department.Name
  11205. order.DrordDeptCodg = department.Number
  11206. order.DrordDrName = doctor_info.UserName
  11207. order.DrordDrProfttl = "234"
  11208. order.CurrDrordFlag = "1"
  11209. orders = append(orders, &order)
  11210. }
  11211. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11212. var order models.FsiOrderDtos
  11213. order.RxID = strconv.FormatInt(item.ID, 10)
  11214. order.Rxno = strconv.FormatInt(item.ID, 10)
  11215. order.LongDrordFlag = "0"
  11216. order.HilistType = "1"
  11217. order.ChrgType = "1"
  11218. order.DrordBhvr = "-"
  11219. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11220. order.HosplistName = subItem.GoodInfo.GoodName
  11221. order.HilistLv = "1"
  11222. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11223. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11224. order.HosplistName = subItem.GoodInfo.GoodName
  11225. order.Cnt = subItem.Count
  11226. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11227. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11228. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11229. order.OwnpayAmt = ""
  11230. order.SelfpayAmt = ""
  11231. order.Spec = ""
  11232. order.SpecUnt = ""
  11233. order.DrordBegnDate = s_tm
  11234. order.DrordStopDate = ""
  11235. order.DrordDrCodg = doctor_info.DoctorNumber
  11236. order.DrordDeptName = department.Name
  11237. order.DrordDeptCodg = department.Number
  11238. order.DrordDrName = doctor_info.UserName
  11239. order.DrordDrProfttl = "234"
  11240. order.CurrDrordFlag = "1"
  11241. orders = append(orders, &order)
  11242. }
  11243. }
  11244. }
  11245. //处方医嘱信息
  11246. }
  11247. fed.MatnStas = "0"
  11248. fed.MedfeeSumamt = "0"
  11249. fed.OwnpayAmt = "0"
  11250. fed.SelfpayAmt = "0"
  11251. fed.AcctPayamt = "0"
  11252. fed.MaAmt = "0"
  11253. fed.HifpPayamt = "0"
  11254. fed.SetlTotlnum = "1"
  11255. fed.Insutype = his.Insutype
  11256. fed.ReimFlag = "0"
  11257. fed.OutSetlFlag = "0"
  11258. var fopd []*models.FsiOperationDtosData
  11259. data := make(map[string]interface{})
  11260. data["fed"] = fed
  11261. data["fdd"] = fdds
  11262. data["fod"] = orders
  11263. data["pd"] = pd
  11264. data["pp"] = pp
  11265. data["fopd"] = fopd
  11266. data["trig_scen"] = trig_scen
  11267. fmt.Println(data)
  11268. fmt.Println(fed)
  11269. fmt.Println(fdds)
  11270. fmt.Println(orders)
  11271. fmt.Println(pd)
  11272. fmt.Println(pp)
  11273. fmt.Println(fopd)
  11274. client := &http.Client{}
  11275. bytesData, _ := json.Marshal(data)
  11276. var req *http.Request
  11277. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  11278. if miConfig.MdtrtareaAdmvs == "320830" {
  11279. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  11280. } else if miConfig.MdtrtareaAdmvs == "320921" {
  11281. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11282. } else {
  11283. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11284. }
  11285. resp, _ := client.Do(req)
  11286. defer resp.Body.Close()
  11287. body, ioErr := ioutil.ReadAll(resp.Body)
  11288. if ioErr != nil {
  11289. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11291. return res
  11292. }
  11293. var respJSON map[string]interface{}
  11294. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11295. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11297. return res
  11298. }
  11299. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11300. fmt.Println(respJSON)
  11301. result, _ := json.Marshal(respJSON)
  11302. fmt.Println(result)
  11303. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11304. utils.ErrorLog("解析失败:%v", err)
  11305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11306. return res
  11307. }
  11308. return res
  11309. } else {
  11310. //if miConfig.MdtrtareaAdmvs == "441202" {
  11311. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11312. saveLog(output, input, "3101", "事前")
  11313. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11314. utils.ErrorLog("解析失败:%v", err)
  11315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11316. return
  11317. }
  11318. return res
  11319. //}
  11320. }
  11321. }
  11322. 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) {
  11323. adminUser := c.GetAdminUserInfo()
  11324. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11325. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11326. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11327. //record_time := c.GetString("record_time")
  11328. //trig_scen := c.GetString("trig_scen")
  11329. timeLayout := "2006-01-02"
  11330. loc, _ := time.LoadLocation("Local")
  11331. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11332. if err != nil {
  11333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11334. return res
  11335. }
  11336. recordDateTime := theTime.Unix()
  11337. var patientPrescription models.HisPrescriptionInfo
  11338. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11339. if patientPrescription.ID == 0 {
  11340. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11341. }
  11342. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11343. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11344. //
  11345. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11346. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11347. var pp models.PublicParams
  11348. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11349. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11350. pp.FixmedinsName = miConfig.OrgName
  11351. pp.FixmedinsCode = miConfig.Code
  11352. pp.RequestUrl = miConfig.Url
  11353. pp.Cainfo = miConfig.Cainfo
  11354. pp.SecretKey = miConfig.SecretKey
  11355. pp.AccessKey = miConfig.AccessKey
  11356. pp.OpterName = roles.UserName
  11357. var config []*models.HisXtDiagnoseConfig
  11358. for _, item := range diagnosis_ids {
  11359. id, _ := strconv.ParseInt(item, 10, 64)
  11360. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11361. config = append(config, &diagnosisConfig)
  11362. }
  11363. var pd models.PatientDtos
  11364. pd.PatnID = his.PsnNo
  11365. pd.PatnName = his.Name
  11366. pd.Gend = his.Gend
  11367. pd.Brdy = his.Brdy
  11368. pd.Poolarea = his.InsuplcAdmdvs
  11369. pd.CurrMdtrtID = his.Number
  11370. var fed models.FsiEncounterDtos
  11371. fed.MdtrtID = his.Number
  11372. fed.MedinsID = miConfig.Code
  11373. fed.MedinsName = miConfig.OrgName
  11374. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11375. fed.MedMdtrtType = "1"
  11376. fed.MedinsType = "1"
  11377. fed.MedinsLv = "11"
  11378. tm := time.Unix(his.RecordDate, 0)
  11379. s_tm := tm.Format("2006-01-02 15:04:05")
  11380. fed.AdmDate = s_tm
  11381. fed.DscgDate = s_tm
  11382. fed.DscgMainDiseCodg = config[0].CountryCode
  11383. fed.DscgMainDiseName = config[0].CountryContentName
  11384. //诊断信息
  11385. var fdds []*models.FsiDiagnoseDtos
  11386. for index, item := range config {
  11387. if index == 0 {
  11388. var fdd models.FsiDiagnoseDtos
  11389. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11390. fdd.InoutDiseType = "1"
  11391. fdd.MaindiseFlag = "1"
  11392. fdd.DiseDate = s_tm
  11393. fdd.DiasSrtNo = "1"
  11394. fdd.DiseName = item.CountryContentName
  11395. fdd.DiseCodg = item.CountryCode
  11396. fdds = append(fdds, &fdd)
  11397. } else {
  11398. var fdd models.FsiDiagnoseDtos
  11399. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11400. fdd.InoutDiseType = "1"
  11401. fdd.MaindiseFlag = "1"
  11402. fdd.DiseDate = s_tm
  11403. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11404. fdd.DiseName = item.CountryContentName
  11405. fdd.DiseCodg = item.CountryCode
  11406. fdds = append(fdds, &fdd)
  11407. }
  11408. }
  11409. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11410. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11411. fed.AdmDeptName = department.Name
  11412. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11413. fed.DscgDeptName = department.Name
  11414. fed.MedMdtrtType = "1"
  11415. fed.MedType = "11"
  11416. //if his.Insutype == "390" {
  11417. // fed.MedType = "1402"
  11418. //} else {
  11419. // fed.MedType = "9933"
  11420. //}
  11421. var orders []*models.FsiOrderDtos
  11422. if trig_scen == "2" {
  11423. //处方医嘱信息
  11424. for _, item := range prescriptions {
  11425. for _, subItem := range item.HisDoctorAdviceInfo {
  11426. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11427. var order models.FsiOrderDtos
  11428. order.RxID = strconv.FormatInt(item.ID, 10)
  11429. order.Rxno = strconv.FormatInt(item.ID, 10)
  11430. order.LongDrordFlag = "0"
  11431. order.HilistType = "1"
  11432. order.ChrgType = "1"
  11433. order.DrordBhvr = "-"
  11434. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11435. order.HosplistName = subItem.BaseDrugLib.DrugName
  11436. order.HilistLv = "1"
  11437. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11438. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11439. order.HosplistName = subItem.BaseDrugLib.DrugName
  11440. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11441. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11442. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11443. order.OwnpayAmt = ""
  11444. order.SelfpayAmt = ""
  11445. order.Spec = ""
  11446. order.SpecUnt = ""
  11447. order.DrordBegnDate = s_tm
  11448. order.DrordStopDate = ""
  11449. order.DrordDrCodg = doctor_info.DoctorNumber
  11450. order.DrordDeptName = department.Name
  11451. order.DrordDeptCodg = department.Number
  11452. order.DrordDrName = doctor_info.UserName
  11453. order.DrordDrProfttl = "234"
  11454. order.CurrDrordFlag = "1"
  11455. orders = append(orders, &order)
  11456. }
  11457. }
  11458. for _, subItem := range item.HisPrescriptionProject {
  11459. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11460. var order models.FsiOrderDtos
  11461. order.RxID = strconv.FormatInt(item.ID, 10)
  11462. order.Rxno = strconv.FormatInt(item.ID, 10)
  11463. order.LongDrordFlag = "0"
  11464. order.HilistType = "1"
  11465. order.ChrgType = "1"
  11466. order.DrordBhvr = "-"
  11467. order.HilistCode = subItem.HisProject.MedicalCode
  11468. order.HosplistName = subItem.HisProject.ProjectName
  11469. order.HilistLv = "1"
  11470. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11471. order.HosplistCode = subItem.HisProject.MedicalCode
  11472. order.HosplistName = subItem.HisProject.ProjectName
  11473. order.Cnt = subItem.Count
  11474. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11475. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11476. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11477. order.OwnpayAmt = ""
  11478. order.SelfpayAmt = ""
  11479. order.Spec = ""
  11480. order.SpecUnt = ""
  11481. order.DrordBegnDate = s_tm
  11482. order.DrordStopDate = ""
  11483. order.DrordDrCodg = doctor_info.DoctorNumber
  11484. order.DrordDeptName = department.Name
  11485. order.DrordDeptCodg = department.Number
  11486. order.DrordDrName = doctor_info.UserName
  11487. order.DrordDrProfttl = "234"
  11488. order.CurrDrordFlag = "1"
  11489. orders = append(orders, &order)
  11490. }
  11491. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11492. var order models.FsiOrderDtos
  11493. order.RxID = strconv.FormatInt(item.ID, 10)
  11494. order.Rxno = strconv.FormatInt(item.ID, 10)
  11495. order.LongDrordFlag = "0"
  11496. order.HilistType = "1"
  11497. order.ChrgType = "1"
  11498. order.DrordBhvr = "-"
  11499. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11500. order.HosplistName = subItem.GoodInfo.GoodName
  11501. order.HilistLv = "1"
  11502. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11503. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11504. order.HosplistName = subItem.GoodInfo.GoodName
  11505. order.Cnt = subItem.Count
  11506. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11507. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11508. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11509. order.OwnpayAmt = ""
  11510. order.SelfpayAmt = ""
  11511. order.Spec = ""
  11512. order.SpecUnt = ""
  11513. order.DrordBegnDate = s_tm
  11514. order.DrordStopDate = ""
  11515. order.DrordDrCodg = doctor_info.DoctorNumber
  11516. order.DrordDeptName = department.Name
  11517. order.DrordDeptCodg = department.Number
  11518. order.DrordDrName = doctor_info.UserName
  11519. order.DrordDrProfttl = "234"
  11520. order.CurrDrordFlag = "1"
  11521. orders = append(orders, &order)
  11522. }
  11523. }
  11524. }
  11525. //处方医嘱信息
  11526. }
  11527. fed.MatnStas = "0"
  11528. fed.MedfeeSumamt = "0"
  11529. fed.OwnpayAmt = "0"
  11530. fed.SelfpayAmt = "0"
  11531. fed.AcctPayamt = "0"
  11532. fed.MaAmt = "0"
  11533. fed.HifpPayamt = "0"
  11534. fed.SetlTotlnum = "1"
  11535. fed.Insutype = his.Insutype
  11536. fed.ReimFlag = "0"
  11537. fed.OutSetlFlag = "0"
  11538. var fopd []*models.FsiOperationDtosData
  11539. data := make(map[string]interface{})
  11540. data["fed"] = fed
  11541. data["fdd"] = fdds
  11542. data["fod"] = orders
  11543. data["pd"] = pd
  11544. data["pp"] = pp
  11545. data["fopd"] = fopd
  11546. data["trig_scen"] = trig_scen
  11547. fmt.Println(data)
  11548. fmt.Println(fed)
  11549. fmt.Println(fdds)
  11550. fmt.Println(orders)
  11551. fmt.Println(pd)
  11552. fmt.Println(pp)
  11553. fmt.Println(fopd)
  11554. client := &http.Client{}
  11555. bytesData, _ := json.Marshal(data)
  11556. var req *http.Request
  11557. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  11558. if miConfig.MdtrtareaAdmvs == "320830" {
  11559. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  11560. } else if miConfig.MdtrtareaAdmvs == "320921" {
  11561. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11562. } else {
  11563. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11564. }
  11565. resp, _ := client.Do(req)
  11566. defer resp.Body.Close()
  11567. body, ioErr := ioutil.ReadAll(resp.Body)
  11568. if ioErr != nil {
  11569. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11571. return res
  11572. }
  11573. var respJSON map[string]interface{}
  11574. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11575. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11577. return res
  11578. }
  11579. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11580. fmt.Println(respJSON)
  11581. result, _ := json.Marshal(respJSON)
  11582. fmt.Println(result)
  11583. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11584. utils.ErrorLog("解析失败:%v", err)
  11585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11586. return res
  11587. }
  11588. return res
  11589. } else {
  11590. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11591. saveLog(output, input, "3101", "事前")
  11592. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11593. utils.ErrorLog("解析失败:%v", err)
  11594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11595. return
  11596. }
  11597. return res
  11598. }
  11599. return res
  11600. }
  11601. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  11602. ////patient_id, _ := c.GetInt64("patient_id")
  11603. //order_id, _ := c.GetInt64("order_id")
  11604. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  11605. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  11606. //trig_scen := c.GetString("trig_scen")
  11607. adminUser := c.GetAdminUserInfo()
  11608. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11609. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11610. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11611. record_time := c.GetString("record_time")
  11612. order, _ := service.GetHisOrderByID(order_id)
  11613. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11614. timeLayout := "2006-01-02"
  11615. loc, _ := time.LoadLocation("Local")
  11616. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11617. if err != nil {
  11618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11619. return
  11620. }
  11621. recordDateTime := theTime.Unix()
  11622. var patientPrescription models.HisPrescriptionInfo
  11623. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11624. if patientPrescription.ID == 0 {
  11625. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11626. }
  11627. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11628. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11629. //
  11630. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11631. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11632. var pp models.PublicParams
  11633. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11634. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11635. pp.FixmedinsName = miConfig.OrgName
  11636. pp.FixmedinsCode = miConfig.Code
  11637. pp.RequestUrl = miConfig.Url
  11638. pp.Cainfo = miConfig.Cainfo
  11639. pp.SecretKey = miConfig.SecretKey
  11640. pp.AccessKey = miConfig.AccessKey
  11641. pp.OpterName = roles.UserName
  11642. var config []*models.HisXtDiagnoseConfig
  11643. for _, item := range diagnosis_ids {
  11644. id, _ := strconv.ParseInt(item, 10, 64)
  11645. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11646. config = append(config, &diagnosisConfig)
  11647. }
  11648. var pd models.PatientDtos
  11649. pd.PatnID = his.PsnNo
  11650. pd.PatnName = his.Name
  11651. pd.Gend = his.Gend
  11652. pd.Brdy = psn_info.Brdy
  11653. pd.Poolarea = his.InsuplcAdmdvs
  11654. pd.CurrMdtrtID = his.Number
  11655. var fed models.FsiEncounterDtos
  11656. fed.MdtrtID = his.Number
  11657. fed.MedinsID = miConfig.Code
  11658. fed.MedinsName = miConfig.OrgName
  11659. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11660. fed.MedMdtrtType = "1"
  11661. fed.MedinsType = "1"
  11662. fed.MedinsLv = "11"
  11663. tm := time.Unix(his.RecordDate, 0)
  11664. s_tm := tm.Format("2006-01-02 15:04:05")
  11665. fed.AdmDate = s_tm
  11666. fed.DscgDate = s_tm
  11667. fed.DscgMainDiseCodg = config[0].CountryCode
  11668. fed.DscgMainDiseName = config[0].CountryContentName
  11669. //诊断信息
  11670. var fdds []*models.FsiDiagnoseDtos
  11671. for index, item := range config {
  11672. if index == 0 {
  11673. var fdd models.FsiDiagnoseDtos
  11674. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11675. fdd.InoutDiseType = "1"
  11676. fdd.MaindiseFlag = "1"
  11677. fdd.DiseDate = s_tm
  11678. fdd.DiasSrtNo = "1"
  11679. fdd.DiseName = item.CountryContentName
  11680. fdd.DiseCodg = item.CountryCode
  11681. fdds = append(fdds, &fdd)
  11682. } else {
  11683. var fdd models.FsiDiagnoseDtos
  11684. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11685. fdd.InoutDiseType = "1"
  11686. fdd.MaindiseFlag = "1"
  11687. fdd.DiseDate = s_tm
  11688. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11689. fdd.DiseName = item.CountryContentName
  11690. fdd.DiseCodg = item.CountryCode
  11691. fdds = append(fdds, &fdd)
  11692. }
  11693. }
  11694. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11695. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11696. fed.AdmDeptName = department.Name
  11697. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11698. fed.DscgDeptName = department.Name
  11699. fed.MedType = order.MedType
  11700. //处方医嘱信息
  11701. var orders []*models.FsiOrderDtos
  11702. //for _, item := range prescriptions {
  11703. // for _, subItem := range item.HisDoctorAdviceInfo {
  11704. // var order models.FsiOrderDtos
  11705. // order.RxID = strconv.FormatInt(item.ID, 10)
  11706. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11707. // order.LongDrordFlag = "0"
  11708. // order.HilistType = "1"
  11709. // order.ChrgType = "1"
  11710. // order.DrordBhvr = "-"
  11711. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11712. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11713. // order.HilistLv = "1"
  11714. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11715. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11716. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11717. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11718. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11719. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11720. // order.OwnpayAmt = ""
  11721. // order.SelfpayAmt = ""
  11722. // order.Spec = ""
  11723. // order.SpecUnt = ""
  11724. // order.DrordBegnDate = s_tm
  11725. // order.DrordStopDate = ""
  11726. // order.DrordDrCodg = "1"
  11727. // order.DrordDeptName = department.Name
  11728. // order.DrordDrCodg = "1"
  11729. // order.DrordDrName = doctor_info.UserName
  11730. // order.DrordDrProfttl = ""
  11731. // order.CurrDrordFlag = "1"
  11732. // orders = append(orders, &order)
  11733. // }
  11734. // for _, subItem := range item.HisPrescriptionProject {
  11735. // if subItem.Type == 2 {
  11736. // var order models.FsiOrderDtos
  11737. // order.RxID = strconv.FormatInt(item.ID, 10)
  11738. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11739. // order.LongDrordFlag = "0"
  11740. // order.HilistType = "1"
  11741. // order.ChrgType = "1"
  11742. // order.DrordBhvr = "-"
  11743. // order.HilistCode = subItem.HisProject.MedicalCode
  11744. // order.HosplistName = subItem.HisProject.ProjectName
  11745. // order.HilistLv = "1"
  11746. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11747. // order.HosplistCode = subItem.HisProject.MedicalCode
  11748. // order.HosplistName = subItem.HisProject.ProjectName
  11749. // order.Cnt = subItem.Count
  11750. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11751. //
  11752. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11753. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11754. // order.OwnpayAmt = ""
  11755. // order.SelfpayAmt = ""
  11756. // order.Spec = ""
  11757. // order.SpecUnt = ""
  11758. // order.DrordBegnDate = s_tm
  11759. // order.DrordStopDate = ""
  11760. // order.DrordDrCodg = "1"
  11761. // order.DrordDeptName = department.Name
  11762. // order.DrordDrCodg = "1"
  11763. // order.DrordDrName = doctor_info.UserName
  11764. // order.DrordDrProfttl = ""
  11765. // order.CurrDrordFlag = "1"
  11766. // orders = append(orders, &order)
  11767. //
  11768. // }
  11769. // if subItem.Type == 3 {
  11770. //
  11771. // var order models.FsiOrderDtos
  11772. // order.RxID = strconv.FormatInt(item.ID, 10)
  11773. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11774. // order.LongDrordFlag = "0"
  11775. // order.HilistType = "1"
  11776. // order.ChrgType = "1"
  11777. // order.DrordBhvr = "-"
  11778. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11779. // order.HosplistName = subItem.GoodInfo.GoodName
  11780. // order.HilistLv = "1"
  11781. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11782. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11783. // order.HosplistName = subItem.GoodInfo.GoodName
  11784. // order.Cnt = subItem.Count
  11785. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11786. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11787. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11788. // order.OwnpayAmt = ""
  11789. // order.SelfpayAmt = ""
  11790. // order.Spec = ""
  11791. // order.SpecUnt = ""
  11792. // order.DrordBegnDate = s_tm
  11793. // order.DrordStopDate = ""
  11794. // order.DrordDrCodg = "1"
  11795. // order.DrordDeptName = department.Name
  11796. // order.DrordDrCodg = "1"
  11797. // order.DrordDrName = doctor_info.UserName
  11798. // order.DrordDrProfttl = ""
  11799. // order.CurrDrordFlag = "1"
  11800. // orders = append(orders, &order)
  11801. //
  11802. // }
  11803. // }
  11804. //}
  11805. for _, item := range prescriptions {
  11806. for _, subItem := range item.HisDoctorAdviceInfo {
  11807. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11808. var order models.FsiOrderDtos
  11809. order.RxID = strconv.FormatInt(item.ID, 10)
  11810. order.Rxno = strconv.FormatInt(item.ID, 10)
  11811. order.LongDrordFlag = "0"
  11812. order.HilistType = "101"
  11813. order.ChrgType = "1"
  11814. order.DrordBhvr = "-"
  11815. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11816. order.HosplistName = subItem.BaseDrugLib.DrugName
  11817. order.HilistLv = "1"
  11818. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11819. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11820. order.HosplistName = subItem.BaseDrugLib.DrugName
  11821. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11822. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11823. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11824. order.OwnpayAmt = ""
  11825. order.SelfpayAmt = ""
  11826. order.Spec = ""
  11827. order.SpecUnt = ""
  11828. order.DrordBegnDate = s_tm
  11829. order.DrordStopDate = ""
  11830. order.DrordDrCodg = doctor_info.DoctorNumber
  11831. order.DrordDeptName = department.Name
  11832. order.DrordDeptCodg = department.Number
  11833. order.DrordDrName = doctor_info.UserName
  11834. order.DrordDrProfttl = "234"
  11835. order.CurrDrordFlag = "1"
  11836. orders = append(orders, &order)
  11837. }
  11838. }
  11839. for _, subItem := range item.HisPrescriptionProject {
  11840. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11841. var order models.FsiOrderDtos
  11842. order.RxID = strconv.FormatInt(item.ID, 10)
  11843. order.Rxno = strconv.FormatInt(item.ID, 10)
  11844. order.LongDrordFlag = "0"
  11845. order.HilistType = "201"
  11846. order.ChrgType = "1"
  11847. order.DrordBhvr = "-"
  11848. order.HilistCode = subItem.HisProject.MedicalCode
  11849. order.HosplistName = subItem.HisProject.ProjectName
  11850. order.HilistLv = "1"
  11851. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11852. order.HosplistCode = subItem.HisProject.MedicalCode
  11853. order.HosplistName = subItem.HisProject.ProjectName
  11854. order.Cnt = subItem.Count
  11855. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11856. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11857. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11858. order.OwnpayAmt = ""
  11859. order.SelfpayAmt = ""
  11860. order.Spec = ""
  11861. order.SpecUnt = ""
  11862. order.DrordBegnDate = s_tm
  11863. order.DrordStopDate = ""
  11864. order.DrordDrCodg = doctor_info.DoctorNumber
  11865. order.DrordDeptName = department.Name
  11866. order.DrordDeptCodg = department.Number
  11867. order.DrordDrName = doctor_info.UserName
  11868. order.DrordDrProfttl = "234"
  11869. order.CurrDrordFlag = "1"
  11870. orders = append(orders, &order)
  11871. }
  11872. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11873. var order models.FsiOrderDtos
  11874. order.RxID = strconv.FormatInt(item.ID, 10)
  11875. order.Rxno = strconv.FormatInt(item.ID, 10)
  11876. order.LongDrordFlag = "0"
  11877. order.HilistType = "301"
  11878. order.ChrgType = "1"
  11879. order.DrordBhvr = "0"
  11880. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11881. order.HosplistName = subItem.GoodInfo.GoodName
  11882. order.HilistLv = "1"
  11883. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11884. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11885. order.HosplistName = subItem.GoodInfo.GoodName
  11886. order.Cnt = subItem.Count
  11887. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11888. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11889. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11890. order.OwnpayAmt = ""
  11891. order.SelfpayAmt = ""
  11892. order.Spec = ""
  11893. order.SpecUnt = ""
  11894. order.DrordBegnDate = s_tm
  11895. order.DrordStopDate = ""
  11896. order.DrordDrCodg = doctor_info.DoctorNumber
  11897. order.DrordDeptName = department.Name
  11898. order.DrordDeptCodg = department.Number
  11899. order.DrordDrName = doctor_info.UserName
  11900. order.DrordDrProfttl = "234"
  11901. order.CurrDrordFlag = "1"
  11902. orders = append(orders, &order)
  11903. }
  11904. }
  11905. }
  11906. //处方医嘱信息
  11907. fed.MatnStas = "0"
  11908. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11909. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11910. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11911. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11912. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11913. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11914. fed.SetlTotlnum = "1"
  11915. fed.Insutype = his.Insutype
  11916. fed.ReimFlag = "0"
  11917. fed.OutSetlFlag = "0"
  11918. var fopd []*models.FsiOperationDtosData
  11919. data := make(map[string]interface{})
  11920. data["fed"] = fed
  11921. data["fdd"] = fdds
  11922. data["fod"] = orders
  11923. data["pd"] = pd
  11924. data["pp"] = pp
  11925. data["fopd"] = fopd
  11926. data["trig_scen"] = trig_scen
  11927. client := &http.Client{}
  11928. bytesData, _ := json.Marshal(data)
  11929. var req *http.Request
  11930. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  11931. if miConfig.MdtrtareaAdmvs == "320830" {
  11932. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3102", bytes.NewReader(bytesData))
  11933. } else if miConfig.MdtrtareaAdmvs == "320921" {
  11934. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11935. } else {
  11936. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11937. }
  11938. resp, _ := client.Do(req)
  11939. defer resp.Body.Close()
  11940. body, ioErr := ioutil.ReadAll(resp.Body)
  11941. if ioErr != nil {
  11942. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11944. return res
  11945. }
  11946. var respJSON map[string]interface{}
  11947. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11948. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11950. return res
  11951. }
  11952. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11953. result, _ := json.Marshal(respJSON)
  11954. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11955. utils.ErrorLog("解析失败:%v", err)
  11956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11957. return res
  11958. }
  11959. return res
  11960. } else {
  11961. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11962. saveLog(output, input, "3102", "事中")
  11963. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11964. utils.ErrorLog("解析失败:%v", err)
  11965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11966. return
  11967. }
  11968. return res
  11969. }
  11970. return res
  11971. }
  11972. 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) {
  11973. var res Resultgd3101
  11974. adminUser := c.GetAdminUserInfo()
  11975. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11976. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11977. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11978. //record_time := c.GetString("record_time")
  11979. //trig_scen := c.GetString("trig_scen")
  11980. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11981. //psn_info, _ := service.GetPatientId(patient_id)
  11982. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11983. timeLayout := "2006-01-02"
  11984. loc, _ := time.LoadLocation("Local")
  11985. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11986. if err != nil {
  11987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11988. return res
  11989. }
  11990. recordDateTime := theTime.Unix()
  11991. var patientPrescription models.HisPrescriptionInfo
  11992. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11993. //if patientPrescription.ID == 0 {
  11994. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11995. //}
  11996. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11997. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11998. //
  11999. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  12000. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12001. var str string
  12002. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  12003. str = timestampToBirthdayString(patient.Birthday)
  12004. } else {
  12005. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  12006. }
  12007. var pp models.PublicParams
  12008. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12009. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12010. pp.FixmedinsName = miConfig.OrgName
  12011. pp.FixmedinsCode = miConfig.Code
  12012. pp.RequestUrl = miConfig.Url
  12013. pp.Cainfo = miConfig.Cainfo
  12014. pp.SecretKey = miConfig.SecretKey
  12015. pp.AccessKey = miConfig.AccessKey
  12016. pp.OpterName = roles.UserName
  12017. var config []*models.HisXtDiagnoseConfig
  12018. for _, item := range diagnosis_ids {
  12019. id, _ := strconv.ParseInt(item, 10, 64)
  12020. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12021. config = append(config, &diagnosisConfig)
  12022. }
  12023. var pd models.PatientDtos
  12024. pd.PatnID = his.PsnNo
  12025. pd.PatnName = his.Name
  12026. pd.Gend = his.Gend
  12027. pd.Brdy = str
  12028. pd.Poolarea = miConfig.MdtrtareaAdmvs
  12029. pd.CurrMdtrtID = his.Number
  12030. var fed models.FsiEncounterDtos
  12031. fed.MdtrtID = his.Number
  12032. fed.MedinsID = miConfig.Code
  12033. fed.MedinsName = miConfig.OrgName
  12034. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12035. fed.MedMdtrtType = "1"
  12036. fed.MedinsType = "1"
  12037. fed.MedinsLv = "11"
  12038. tm := time.Unix(his.RecordDate, 0)
  12039. s_tm := tm.Format("2006-01-02 15:04:05")
  12040. fed.AdmDate = s_tm
  12041. fed.DscgDate = s_tm
  12042. fed.DscgMainDiseCodg = config[0].CountryCode
  12043. fed.DscgMainDiseName = config[0].CountryContentName
  12044. //诊断信息
  12045. var fdds []*models.FsiDiagnoseDtos
  12046. for index, item := range config {
  12047. if index == 0 {
  12048. var fdd models.FsiDiagnoseDtos
  12049. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12050. fdd.InoutDiseType = "1"
  12051. fdd.MaindiseFlag = "1"
  12052. fdd.DiseDate = s_tm
  12053. fdd.DiasSrtNo = "1"
  12054. fdd.DiseName = item.CountryContentName
  12055. fdd.DiseCodg = item.CountryCode
  12056. fdds = append(fdds, &fdd)
  12057. } else {
  12058. var fdd models.FsiDiagnoseDtos
  12059. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12060. fdd.InoutDiseType = "1"
  12061. fdd.MaindiseFlag = "1"
  12062. fdd.DiseDate = s_tm
  12063. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12064. fdd.DiseName = item.CountryContentName
  12065. fdd.DiseCodg = item.CountryCode
  12066. fdds = append(fdds, &fdd)
  12067. }
  12068. }
  12069. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12070. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  12071. fed.AdmDeptName = de.Name
  12072. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  12073. fed.DscgDeptName = de.Name
  12074. fed.MedMdtrtType = "1"
  12075. fed.MedType = "11"
  12076. //if his.Insutype == "390" {
  12077. // fed.MedType = "1402"
  12078. //} else {
  12079. // fed.MedType = "9933"
  12080. //}
  12081. var orders []*models.FsiOrderDtos
  12082. if trig_scen == "2" {
  12083. //处方医嘱信息
  12084. for _, item := range prescriptions {
  12085. for _, subItem := range item.HisDoctorAdviceInfo {
  12086. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12087. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12088. var order models.FsiOrderDtos
  12089. order.RxID = strconv.FormatInt(item.ID, 10)
  12090. order.Rxno = strconv.FormatInt(item.ID, 10)
  12091. order.LongDrordFlag = "0"
  12092. order.HilistType = "101"
  12093. order.ChrgType = "1"
  12094. order.DrordBhvr = "0"
  12095. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12096. order.HosplistName = subItem.BaseDrugLib.DrugName
  12097. order.HilistLv = "1"
  12098. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12099. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12100. order.HosplistName = subItem.BaseDrugLib.DrugName
  12101. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12102. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12103. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12104. order.OwnpayAmt = ""
  12105. order.SelfpayAmt = ""
  12106. order.Spec = spec
  12107. order.SpecUnt = subItem.PrescribingNumberUnit
  12108. order.DrordBegnDate = s_tm
  12109. order.DrordStopDate = ""
  12110. order.DrordDrCodg = doctor_info.DoctorNumber
  12111. order.DrordDeptName = department.Name
  12112. order.DrordDeptCodg = department.Number
  12113. order.DrordDrName = doctor_info.UserName
  12114. order.DrordDrProfttl = "234"
  12115. order.CurrDrordFlag = "1"
  12116. orders = append(orders, &order)
  12117. }
  12118. }
  12119. for _, subItem := range item.HisPrescriptionProject {
  12120. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12121. var order models.FsiOrderDtos
  12122. order.RxID = strconv.FormatInt(item.ID, 10)
  12123. order.Rxno = strconv.FormatInt(item.ID, 10)
  12124. order.LongDrordFlag = "0"
  12125. order.HilistType = "201"
  12126. order.ChrgType = "1"
  12127. order.DrordBhvr = "0"
  12128. order.HilistCode = subItem.HisProject.MedicalCode
  12129. order.HosplistName = subItem.HisProject.ProjectName
  12130. order.HilistLv = "1"
  12131. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12132. order.HosplistCode = subItem.HisProject.MedicalCode
  12133. order.HosplistName = subItem.HisProject.ProjectName
  12134. order.Cnt = subItem.Count
  12135. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12136. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12137. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12138. order.OwnpayAmt = ""
  12139. order.SelfpayAmt = ""
  12140. order.Spec = subItem.Unit
  12141. order.SpecUnt = subItem.Unit
  12142. order.DrordBegnDate = s_tm
  12143. order.DrordStopDate = ""
  12144. order.DrordDrCodg = doctor_info.DoctorNumber
  12145. order.DrordDeptName = department.Name
  12146. order.DrordDeptCodg = department.Number
  12147. order.DrordDrName = doctor_info.UserName
  12148. order.DrordDrProfttl = "234"
  12149. order.CurrDrordFlag = "1"
  12150. orders = append(orders, &order)
  12151. }
  12152. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12153. var order models.FsiOrderDtos
  12154. order.RxID = strconv.FormatInt(item.ID, 10)
  12155. order.Rxno = strconv.FormatInt(item.ID, 10)
  12156. order.LongDrordFlag = "0"
  12157. order.HilistType = "301"
  12158. order.ChrgType = "1"
  12159. order.DrordBhvr = "0"
  12160. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12161. order.HosplistName = subItem.GoodInfo.GoodName
  12162. order.HilistLv = "1"
  12163. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12164. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12165. order.HosplistName = subItem.GoodInfo.GoodName
  12166. order.Cnt = subItem.Count
  12167. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12168. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12169. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12170. order.OwnpayAmt = ""
  12171. order.SelfpayAmt = ""
  12172. order.Spec = subItem.GoodInfo.SpecificationName
  12173. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12174. order.DrordBegnDate = s_tm
  12175. order.DrordStopDate = ""
  12176. order.DrordDrCodg = doctor_info.DoctorNumber
  12177. order.DrordDeptName = department.Name
  12178. order.DrordDeptCodg = department.Number
  12179. order.DrordDrName = doctor_info.UserName
  12180. order.DrordDrProfttl = "234"
  12181. order.CurrDrordFlag = "1"
  12182. orders = append(orders, &order)
  12183. }
  12184. }
  12185. }
  12186. //处方医嘱信息
  12187. }
  12188. fed.MatnStas = "0"
  12189. fed.MedfeeSumamt = "0"
  12190. fed.OwnpayAmt = "0"
  12191. fed.SelfpayAmt = "0"
  12192. fed.AcctPayamt = "0"
  12193. fed.MaAmt = "0"
  12194. fed.HifpPayamt = "0"
  12195. fed.SetlTotlnum = "1"
  12196. fed.Insutype = his.Insutype
  12197. fed.ReimFlag = "0"
  12198. fed.OutSetlFlag = "0"
  12199. var fopd []*models.FsiOperationDtosData
  12200. data := make(map[string]interface{})
  12201. data["fed"] = fed
  12202. data["fdd"] = fdds
  12203. data["fod"] = orders
  12204. data["pd"] = pd
  12205. data["pp"] = pp
  12206. data["fopd"] = fopd
  12207. data["trig_scen"] = trig_scen
  12208. fmt.Println(data)
  12209. fmt.Println(fed)
  12210. fmt.Println(fdds)
  12211. fmt.Println(orders)
  12212. fmt.Println(pd)
  12213. fmt.Println(pp)
  12214. fmt.Println(fopd)
  12215. client := &http.Client{}
  12216. bytesData, _ := json.Marshal(data)
  12217. var req *http.Request
  12218. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12219. if miConfig.MdtrtareaAdmvs == "320830" {
  12220. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  12221. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12222. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12223. } else {
  12224. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12225. }
  12226. resp, _ := client.Do(req)
  12227. defer resp.Body.Close()
  12228. body, ioErr := ioutil.ReadAll(resp.Body)
  12229. if ioErr != nil {
  12230. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12232. return res
  12233. }
  12234. var respJSON map[string]interface{}
  12235. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12236. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12238. return res
  12239. }
  12240. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12241. fmt.Println(respJSON)
  12242. result, _ := json.Marshal(respJSON)
  12243. fmt.Println(result)
  12244. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12245. utils.ErrorLog("解析失败:%v", err)
  12246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12247. return res
  12248. }
  12249. return res
  12250. } else {
  12251. //if miConfig.MdtrtareaAdmvs == "441202" {
  12252. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12253. saveLog(output, input, "3101", "事前")
  12254. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12255. utils.ErrorLog("解析失败:%v", err)
  12256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12257. return
  12258. }
  12259. return res
  12260. //}
  12261. }
  12262. }
  12263. 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) {
  12264. adminUser := c.GetAdminUserInfo()
  12265. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12266. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12267. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12268. //record_time := c.GetString("record_time")
  12269. //trig_scen := c.GetString("trig_scen")
  12270. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  12271. timeLayout := "2006-01-02"
  12272. loc, _ := time.LoadLocation("Local")
  12273. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12274. if err != nil {
  12275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12276. return res
  12277. }
  12278. recordDateTime := theTime.Unix()
  12279. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  12280. var patientPrescription models.HisPrescriptionInfo
  12281. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12282. if patientPrescription.ID == 0 {
  12283. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12284. }
  12285. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12286. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12287. //
  12288. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  12289. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12290. var pp models.PublicParams
  12291. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12292. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12293. pp.FixmedinsName = miConfig.OrgName
  12294. pp.FixmedinsCode = miConfig.Code
  12295. pp.RequestUrl = miConfig.Url
  12296. pp.Cainfo = miConfig.Cainfo
  12297. pp.SecretKey = miConfig.SecretKey
  12298. pp.AccessKey = miConfig.AccessKey
  12299. pp.OpterName = roles.UserName
  12300. var config []*models.HisXtDiagnoseConfig
  12301. for _, item := range diagnosis_ids {
  12302. id, _ := strconv.ParseInt(item, 10, 64)
  12303. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12304. config = append(config, &diagnosisConfig)
  12305. }
  12306. //str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  12307. var str string
  12308. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  12309. str = timestampToBirthdayString(patient.Birthday)
  12310. } else {
  12311. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  12312. }
  12313. var pd models.PatientDtos
  12314. pd.PatnID = his.PsnNo
  12315. pd.PatnName = his.Name
  12316. pd.Gend = his.Gend
  12317. pd.Brdy = str
  12318. pd.Poolarea = his.InsuplcAdmdvs
  12319. pd.CurrMdtrtID = his.Number
  12320. var fed models.FsiEncounterDtos
  12321. fed.MdtrtID = his.Number
  12322. fed.MedinsID = miConfig.Code
  12323. fed.MedinsName = miConfig.OrgName
  12324. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12325. fed.MedMdtrtType = "1"
  12326. fed.MedinsType = "1"
  12327. fed.MedinsLv = "11"
  12328. tm := time.Unix(his.RecordDate, 0)
  12329. s_tm := tm.Format("2006-01-02 15:04:05")
  12330. fed.AdmDate = s_tm
  12331. fed.DscgDate = s_tm
  12332. fed.DscgMainDiseCodg = config[0].CountryCode
  12333. fed.DscgMainDiseName = config[0].CountryContentName
  12334. //诊断信息
  12335. var fdds []*models.FsiDiagnoseDtos
  12336. for index, item := range config {
  12337. if index == 0 {
  12338. var fdd models.FsiDiagnoseDtos
  12339. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12340. fdd.InoutDiseType = "1"
  12341. fdd.MaindiseFlag = "1"
  12342. fdd.DiseDate = s_tm
  12343. fdd.DiasSrtNo = "1"
  12344. fdd.DiseName = item.CountryContentName
  12345. fdd.DiseCodg = item.CountryCode
  12346. fdds = append(fdds, &fdd)
  12347. } else {
  12348. var fdd models.FsiDiagnoseDtos
  12349. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12350. fdd.InoutDiseType = "1"
  12351. fdd.MaindiseFlag = "1"
  12352. fdd.DiseDate = s_tm
  12353. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12354. fdd.DiseName = item.CountryContentName
  12355. fdd.DiseCodg = item.CountryCode
  12356. fdds = append(fdds, &fdd)
  12357. }
  12358. }
  12359. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12360. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  12361. fed.AdmDeptName = department.Name
  12362. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  12363. fed.DscgDeptName = department.Name
  12364. fed.MedMdtrtType = "1"
  12365. fed.MedType = "11"
  12366. //if his.Insutype == "390" {
  12367. // fed.MedType = "1402"
  12368. //} else {
  12369. // fed.MedType = "9933"
  12370. //}
  12371. var orders []*models.FsiOrderDtos
  12372. if trig_scen == "2" {
  12373. //处方医嘱信息
  12374. for _, item := range prescriptions {
  12375. for _, subItem := range item.HisDoctorAdviceInfo {
  12376. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12377. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12378. var order models.FsiOrderDtos
  12379. order.RxID = strconv.FormatInt(item.ID, 10)
  12380. order.Rxno = strconv.FormatInt(item.ID, 10)
  12381. order.LongDrordFlag = "0"
  12382. order.HilistType = "101"
  12383. order.ChrgType = "1"
  12384. order.DrordBhvr = "0"
  12385. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12386. order.HosplistName = subItem.BaseDrugLib.DrugName
  12387. order.HilistLv = "1"
  12388. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12389. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12390. order.HosplistName = subItem.BaseDrugLib.DrugName
  12391. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12392. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12393. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12394. order.OwnpayAmt = ""
  12395. order.SelfpayAmt = ""
  12396. order.Spec = spec
  12397. order.SpecUnt = subItem.PrescribingNumberUnit
  12398. order.DrordBegnDate = s_tm
  12399. order.DrordStopDate = ""
  12400. order.DrordDrCodg = doctor_info.DoctorNumber
  12401. order.DrordDeptName = department.Name
  12402. order.DrordDeptCodg = department.Number
  12403. order.DrordDrName = doctor_info.UserName
  12404. order.DrordDrProfttl = "234"
  12405. order.CurrDrordFlag = "1"
  12406. orders = append(orders, &order)
  12407. }
  12408. }
  12409. for _, subItem := range item.HisPrescriptionProject {
  12410. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12411. var order models.FsiOrderDtos
  12412. order.RxID = strconv.FormatInt(item.ID, 10)
  12413. order.Rxno = strconv.FormatInt(item.ID, 10)
  12414. order.LongDrordFlag = "0"
  12415. order.HilistType = "201"
  12416. order.ChrgType = "1"
  12417. order.DrordBhvr = "0"
  12418. order.HilistCode = subItem.HisProject.MedicalCode
  12419. order.HosplistName = subItem.HisProject.ProjectName
  12420. order.HilistLv = "1"
  12421. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12422. order.HosplistCode = subItem.HisProject.MedicalCode
  12423. order.HosplistName = subItem.HisProject.ProjectName
  12424. order.Cnt = subItem.Count
  12425. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12426. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12427. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12428. order.OwnpayAmt = ""
  12429. order.SelfpayAmt = ""
  12430. order.Spec = subItem.Unit
  12431. order.SpecUnt = subItem.Unit
  12432. order.DrordBegnDate = s_tm
  12433. order.DrordStopDate = ""
  12434. order.DrordDrCodg = doctor_info.DoctorNumber
  12435. order.DrordDeptName = department.Name
  12436. order.DrordDeptCodg = department.Number
  12437. order.DrordDrName = doctor_info.UserName
  12438. order.DrordDrProfttl = "234"
  12439. order.CurrDrordFlag = "1"
  12440. orders = append(orders, &order)
  12441. }
  12442. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12443. var order models.FsiOrderDtos
  12444. order.RxID = strconv.FormatInt(item.ID, 10)
  12445. order.Rxno = strconv.FormatInt(item.ID, 10)
  12446. order.LongDrordFlag = "0"
  12447. order.HilistType = "301"
  12448. order.ChrgType = "1"
  12449. order.DrordBhvr = "0"
  12450. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12451. order.HosplistName = subItem.GoodInfo.GoodName
  12452. order.HilistLv = "1"
  12453. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12454. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12455. order.HosplistName = subItem.GoodInfo.GoodName
  12456. order.Cnt = subItem.Count
  12457. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12458. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12459. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12460. order.OwnpayAmt = ""
  12461. order.SelfpayAmt = ""
  12462. order.Spec = subItem.GoodInfo.SpecificationName
  12463. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12464. order.DrordBegnDate = s_tm
  12465. order.DrordStopDate = ""
  12466. order.DrordDrCodg = doctor_info.DoctorNumber
  12467. order.DrordDeptName = department.Name
  12468. order.DrordDeptCodg = department.Number
  12469. order.DrordDrName = doctor_info.UserName
  12470. order.DrordDrProfttl = "234"
  12471. order.CurrDrordFlag = "1"
  12472. orders = append(orders, &order)
  12473. }
  12474. }
  12475. }
  12476. //处方医嘱信息
  12477. }
  12478. fed.MatnStas = "0"
  12479. fed.MedfeeSumamt = "0"
  12480. fed.OwnpayAmt = "0"
  12481. fed.SelfpayAmt = "0"
  12482. fed.AcctPayamt = "0"
  12483. fed.MaAmt = "0"
  12484. fed.HifpPayamt = "0"
  12485. fed.SetlTotlnum = "1"
  12486. fed.Insutype = his.Insutype
  12487. fed.ReimFlag = "0"
  12488. fed.OutSetlFlag = "0"
  12489. var fopd []*models.FsiOperationDtosData
  12490. data := make(map[string]interface{})
  12491. data["fed"] = fed
  12492. data["fdd"] = fdds
  12493. data["fod"] = orders
  12494. data["pd"] = pd
  12495. data["pp"] = pp
  12496. data["fopd"] = fopd
  12497. data["trig_scen"] = trig_scen
  12498. fmt.Println(data)
  12499. fmt.Println(fed)
  12500. fmt.Println(fdds)
  12501. fmt.Println(orders)
  12502. fmt.Println(pd)
  12503. fmt.Println(pp)
  12504. fmt.Println(fopd)
  12505. client := &http.Client{}
  12506. bytesData, _ := json.Marshal(data)
  12507. var req *http.Request
  12508. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12509. if miConfig.MdtrtareaAdmvs == "320830" {
  12510. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  12511. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12512. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12513. } else {
  12514. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12515. }
  12516. resp, _ := client.Do(req)
  12517. defer resp.Body.Close()
  12518. body, ioErr := ioutil.ReadAll(resp.Body)
  12519. if ioErr != nil {
  12520. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12522. return res
  12523. }
  12524. var respJSON map[string]interface{}
  12525. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12526. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12528. return res
  12529. }
  12530. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12531. fmt.Println(respJSON)
  12532. result, _ := json.Marshal(respJSON)
  12533. fmt.Println(result)
  12534. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12535. utils.ErrorLog("解析失败:%v", err)
  12536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12537. return res
  12538. }
  12539. return res
  12540. } else {
  12541. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12542. saveLog(output, input, "3101", "事前")
  12543. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12544. utils.ErrorLog("解析失败:%v", err)
  12545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12546. return
  12547. }
  12548. return res
  12549. }
  12550. return res
  12551. }
  12552. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  12553. adminUser := c.GetAdminUserInfo()
  12554. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12555. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12556. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12557. record_time := c.GetString("record_time")
  12558. order, _ := service.GetHisOrderByID(order_id)
  12559. timeLayout := "2006-01-02"
  12560. loc, _ := time.LoadLocation("Local")
  12561. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12562. if err != nil {
  12563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12564. return
  12565. }
  12566. recordDateTime := theTime.Unix()
  12567. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  12568. var patientPrescription models.HisPrescriptionInfo
  12569. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12570. if patientPrescription.ID == 0 {
  12571. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12572. }
  12573. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12574. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12575. //
  12576. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  12577. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12578. var pp models.PublicParams
  12579. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12580. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12581. pp.FixmedinsName = miConfig.OrgName
  12582. pp.FixmedinsCode = miConfig.Code
  12583. pp.RequestUrl = miConfig.Url
  12584. pp.Cainfo = miConfig.Cainfo
  12585. pp.SecretKey = miConfig.SecretKey
  12586. pp.AccessKey = miConfig.AccessKey
  12587. pp.OpterName = roles.UserName
  12588. var config []*models.HisXtDiagnoseConfig
  12589. for _, item := range diagnosis_ids {
  12590. id, _ := strconv.ParseInt(item, 10, 64)
  12591. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12592. config = append(config, &diagnosisConfig)
  12593. }
  12594. //str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  12595. var str string
  12596. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  12597. str = timestampToBirthdayString(patient.Birthday)
  12598. } else {
  12599. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  12600. }
  12601. var pd models.PatientDtos
  12602. pd.PatnID = his.PsnNo
  12603. pd.PatnName = his.Name
  12604. pd.Gend = his.Gend
  12605. pd.Brdy = str
  12606. pd.Poolarea = his.InsuplcAdmdvs
  12607. pd.CurrMdtrtID = his.Number
  12608. var fed models.FsiEncounterDtos
  12609. fed.MdtrtID = his.Number
  12610. fed.MedinsID = miConfig.Code
  12611. fed.MedinsName = miConfig.OrgName
  12612. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12613. fed.MedMdtrtType = "1"
  12614. fed.MedinsType = "1"
  12615. fed.MedinsLv = "11"
  12616. tm := time.Unix(his.RecordDate, 0)
  12617. s_tm := tm.Format("2006-01-02 15:04:05")
  12618. fed.AdmDate = s_tm
  12619. fed.DscgDate = s_tm
  12620. fed.DscgMainDiseCodg = config[0].CountryCode
  12621. fed.DscgMainDiseName = config[0].CountryContentName
  12622. //诊断信息
  12623. var fdds []*models.FsiDiagnoseDtos
  12624. for index, item := range config {
  12625. if index == 0 {
  12626. var fdd models.FsiDiagnoseDtos
  12627. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12628. fdd.InoutDiseType = "1"
  12629. fdd.MaindiseFlag = "1"
  12630. fdd.DiseDate = s_tm
  12631. fdd.DiasSrtNo = "1"
  12632. fdd.DiseName = item.CountryContentName
  12633. fdd.DiseCodg = item.CountryCode
  12634. fdds = append(fdds, &fdd)
  12635. } else {
  12636. var fdd models.FsiDiagnoseDtos
  12637. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12638. fdd.InoutDiseType = "1"
  12639. fdd.MaindiseFlag = "1"
  12640. fdd.DiseDate = s_tm
  12641. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12642. fdd.DiseName = item.CountryContentName
  12643. fdd.DiseCodg = item.CountryCode
  12644. fdds = append(fdds, &fdd)
  12645. }
  12646. }
  12647. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12648. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  12649. fed.AdmDeptName = department.Name
  12650. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  12651. fed.DscgDeptName = department.Name
  12652. fed.MedType = order.MedType
  12653. //处方医嘱信息
  12654. var orders []*models.FsiOrderDtos
  12655. //for _, item := range prescriptions {
  12656. // for _, subItem := range item.HisDoctorAdviceInfo {
  12657. // var order models.FsiOrderDtos
  12658. // order.RxID = strconv.FormatInt(item.ID, 10)
  12659. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12660. // order.LongDrordFlag = "0"
  12661. // order.HilistType = "1"
  12662. // order.ChrgType = "1"
  12663. // order.DrordBhvr = "-"
  12664. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12665. // order.HosplistName = subItem.BaseDrugLib.DrugName
  12666. // order.HilistLv = "1"
  12667. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12668. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12669. // order.HosplistName = subItem.BaseDrugLib.DrugName
  12670. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  12671. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12672. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  12673. // order.OwnpayAmt = ""
  12674. // order.SelfpayAmt = ""
  12675. // order.Spec = ""
  12676. // order.SpecUnt = ""
  12677. // order.DrordBegnDate = s_tm
  12678. // order.DrordStopDate = ""
  12679. // order.DrordDrCodg = "1"
  12680. // order.DrordDeptName = department.Name
  12681. // order.DrordDrCodg = "1"
  12682. // order.DrordDrName = doctor_info.UserName
  12683. // order.DrordDrProfttl = ""
  12684. // order.CurrDrordFlag = "1"
  12685. // orders = append(orders, &order)
  12686. // }
  12687. // for _, subItem := range item.HisPrescriptionProject {
  12688. // if subItem.Type == 2 {
  12689. // var order models.FsiOrderDtos
  12690. // order.RxID = strconv.FormatInt(item.ID, 10)
  12691. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12692. // order.LongDrordFlag = "0"
  12693. // order.HilistType = "1"
  12694. // order.ChrgType = "1"
  12695. // order.DrordBhvr = "-"
  12696. // order.HilistCode = subItem.HisProject.MedicalCode
  12697. // order.HosplistName = subItem.HisProject.ProjectName
  12698. // order.HilistLv = "1"
  12699. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12700. // order.HosplistCode = subItem.HisProject.MedicalCode
  12701. // order.HosplistName = subItem.HisProject.ProjectName
  12702. // order.Cnt = subItem.Count
  12703. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12704. //
  12705. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12706. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  12707. // order.OwnpayAmt = ""
  12708. // order.SelfpayAmt = ""
  12709. // order.Spec = ""
  12710. // order.SpecUnt = ""
  12711. // order.DrordBegnDate = s_tm
  12712. // order.DrordStopDate = ""
  12713. // order.DrordDrCodg = "1"
  12714. // order.DrordDeptName = department.Name
  12715. // order.DrordDrCodg = "1"
  12716. // order.DrordDrName = doctor_info.UserName
  12717. // order.DrordDrProfttl = ""
  12718. // order.CurrDrordFlag = "1"
  12719. // orders = append(orders, &order)
  12720. //
  12721. // }
  12722. // if subItem.Type == 3 {
  12723. //
  12724. // var order models.FsiOrderDtos
  12725. // order.RxID = strconv.FormatInt(item.ID, 10)
  12726. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12727. // order.LongDrordFlag = "0"
  12728. // order.HilistType = "1"
  12729. // order.ChrgType = "1"
  12730. // order.DrordBhvr = "-"
  12731. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12732. // order.HosplistName = subItem.GoodInfo.GoodName
  12733. // order.HilistLv = "1"
  12734. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12735. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12736. // order.HosplistName = subItem.GoodInfo.GoodName
  12737. // order.Cnt = subItem.Count
  12738. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12739. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12740. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  12741. // order.OwnpayAmt = ""
  12742. // order.SelfpayAmt = ""
  12743. // order.Spec = ""
  12744. // order.SpecUnt = ""
  12745. // order.DrordBegnDate = s_tm
  12746. // order.DrordStopDate = ""
  12747. // order.DrordDrCodg = "1"
  12748. // order.DrordDeptName = department.Name
  12749. // order.DrordDrCodg = "1"
  12750. // order.DrordDrName = doctor_info.UserName
  12751. // order.DrordDrProfttl = ""
  12752. // order.CurrDrordFlag = "1"
  12753. // orders = append(orders, &order)
  12754. //
  12755. // }
  12756. // }
  12757. //}
  12758. for _, item := range prescriptions {
  12759. for _, subItem := range item.HisDoctorAdviceInfo {
  12760. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12761. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12762. var order models.FsiOrderDtos
  12763. order.RxID = strconv.FormatInt(item.ID, 10)
  12764. order.Rxno = strconv.FormatInt(item.ID, 10)
  12765. order.LongDrordFlag = "0"
  12766. order.HilistType = "101"
  12767. order.ChrgType = "01"
  12768. order.DrordBhvr = "0"
  12769. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12770. order.HosplistName = subItem.BaseDrugLib.DrugName
  12771. order.HilistLv = "1"
  12772. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12773. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12774. order.HosplistName = subItem.BaseDrugLib.DrugName
  12775. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12776. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12777. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12778. order.OwnpayAmt = ""
  12779. order.SelfpayAmt = ""
  12780. order.Spec = spec
  12781. order.SpecUnt = subItem.PrescribingNumberUnit
  12782. order.DrordBegnDate = s_tm
  12783. order.DrordStopDate = ""
  12784. order.DrordDrCodg = doctor_info.DoctorNumber
  12785. order.DrordDeptName = department.Name
  12786. order.DrordDeptCodg = department.Number
  12787. order.DrordDrName = doctor_info.UserName
  12788. order.DrordDrProfttl = "234"
  12789. order.CurrDrordFlag = "1"
  12790. orders = append(orders, &order)
  12791. }
  12792. }
  12793. for _, subItem := range item.HisPrescriptionProject {
  12794. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12795. var order models.FsiOrderDtos
  12796. order.RxID = strconv.FormatInt(item.ID, 10)
  12797. order.Rxno = strconv.FormatInt(item.ID, 10)
  12798. order.LongDrordFlag = "0"
  12799. order.HilistType = "201"
  12800. order.ChrgType = "05"
  12801. order.DrordBhvr = "0"
  12802. order.HilistCode = subItem.HisProject.MedicalCode
  12803. order.HosplistName = subItem.HisProject.ProjectName
  12804. order.HilistLv = "1"
  12805. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12806. order.HosplistCode = subItem.HisProject.MedicalCode
  12807. order.HosplistName = subItem.HisProject.ProjectName
  12808. order.Cnt = subItem.Count
  12809. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12810. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12811. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12812. order.OwnpayAmt = ""
  12813. order.SelfpayAmt = ""
  12814. order.Spec = subItem.Unit
  12815. order.SpecUnt = subItem.Unit
  12816. order.DrordBegnDate = s_tm
  12817. order.DrordStopDate = ""
  12818. order.DrordDrCodg = doctor_info.DoctorNumber
  12819. order.DrordDeptName = department.Name
  12820. order.DrordDeptCodg = department.Number
  12821. order.DrordDrName = doctor_info.UserName
  12822. order.DrordDrProfttl = "234"
  12823. order.CurrDrordFlag = "1"
  12824. orders = append(orders, &order)
  12825. }
  12826. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12827. var order models.FsiOrderDtos
  12828. order.RxID = strconv.FormatInt(item.ID, 10)
  12829. order.Rxno = strconv.FormatInt(item.ID, 10)
  12830. order.LongDrordFlag = "0"
  12831. order.HilistType = "301"
  12832. order.ChrgType = "08"
  12833. order.DrordBhvr = "0"
  12834. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12835. order.HosplistName = subItem.GoodInfo.GoodName
  12836. order.HilistLv = "1"
  12837. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12838. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12839. order.HosplistName = subItem.GoodInfo.GoodName
  12840. order.Cnt = subItem.Count
  12841. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12842. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12843. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12844. order.OwnpayAmt = ""
  12845. order.SelfpayAmt = ""
  12846. order.Spec = subItem.GoodInfo.SpecificationName
  12847. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12848. order.DrordBegnDate = s_tm
  12849. order.DrordStopDate = ""
  12850. order.DrordDrCodg = doctor_info.DoctorNumber
  12851. order.DrordDeptName = department.Name
  12852. order.DrordDeptCodg = department.Number
  12853. order.DrordDrName = doctor_info.UserName
  12854. order.DrordDrProfttl = "234"
  12855. order.CurrDrordFlag = "1"
  12856. orders = append(orders, &order)
  12857. }
  12858. }
  12859. }
  12860. //处方医嘱信息
  12861. fed.MatnStas = "0"
  12862. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  12863. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  12864. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  12865. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  12866. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  12867. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  12868. fed.SetlTotlnum = "1"
  12869. fed.Insutype = his.Insutype
  12870. fed.ReimFlag = "0"
  12871. fed.OutSetlFlag = "0"
  12872. var fopd []*models.FsiOperationDtosData
  12873. data := make(map[string]interface{})
  12874. data["fed"] = fed
  12875. data["fdd"] = fdds
  12876. data["fod"] = orders
  12877. data["pd"] = pd
  12878. data["pp"] = pp
  12879. data["fopd"] = fopd
  12880. data["trig_scen"] = trig_scen
  12881. client := &http.Client{}
  12882. bytesData, _ := json.Marshal(data)
  12883. var req *http.Request
  12884. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12885. if miConfig.MdtrtareaAdmvs == "320830" {
  12886. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3102", bytes.NewReader(bytesData))
  12887. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12888. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12889. } else {
  12890. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12891. }
  12892. resp, _ := client.Do(req)
  12893. defer resp.Body.Close()
  12894. body, ioErr := ioutil.ReadAll(resp.Body)
  12895. if ioErr != nil {
  12896. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12898. return res
  12899. }
  12900. var respJSON map[string]interface{}
  12901. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12902. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12904. return res
  12905. }
  12906. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12907. result, _ := json.Marshal(respJSON)
  12908. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12909. utils.ErrorLog("解析失败:%v", err)
  12910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12911. return res
  12912. }
  12913. return res
  12914. } else {
  12915. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12916. saveLog(output, input, "3102", "事中")
  12917. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12918. utils.ErrorLog("解析失败:%v", err)
  12919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12920. return
  12921. }
  12922. return res
  12923. }
  12924. return res
  12925. }
  12926. func (c *HisApiController) Check() {
  12927. psn_no := c.GetString("psn_no")
  12928. in := c.GetString("in")
  12929. mt := c.GetString("mt")
  12930. baseParams := models.BaseParams{
  12931. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  12932. FixmedinsCode: "H15049901371",
  12933. InsuplcAdmdvs: "150499",
  12934. MdtrtareaAdmvs: "150499",
  12935. OrgName: "赤峰费森血液透析中心",
  12936. Doctor: "1111",
  12937. }
  12938. service.Gdyb2001(baseParams, psn_no, in, mt)
  12939. }
  12940. func (c *HisApiController) GetPsnNcdsInfo() {
  12941. admin_user_id, _ := c.GetInt64("admin_user_id")
  12942. patient_id, _ := c.GetInt64("patient_id")
  12943. //id, _ := c.GetInt64("id")
  12944. adminUser := c.GetAdminUserInfo()
  12945. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12946. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12947. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  12948. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12949. //psn_record, _ := service.GetP(id)
  12950. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12951. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  12952. //
  12953. //if psn_record.ID == 0 {
  12954. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12955. // return
  12956. //}
  12957. var res Result5301
  12958. var res10265 Result5301For10265
  12959. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12960. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12961. var api string
  12962. if miConfig.MdtrtareaAdmvs == "320830" {
  12963. api = miConfig.AppSecret + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12964. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12965. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12966. 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 +
  12967. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12968. } else {
  12969. 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 +
  12970. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12971. }
  12972. resp, requestErr := http.Get(api)
  12973. if requestErr != nil {
  12974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12975. return
  12976. }
  12977. body, ioErr := ioutil.ReadAll(resp.Body)
  12978. if ioErr != nil {
  12979. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12981. return
  12982. }
  12983. var respJSON map[string]interface{}
  12984. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12985. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12987. return
  12988. }
  12989. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12990. result, _ := json.Marshal(respJSON)
  12991. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12992. utils.ErrorLog("解析失败:%v", err)
  12993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12994. return
  12995. }
  12996. res.ErrMsg = res10265.ErrMsg
  12997. res.Output = res10265.Output
  12998. res.InfRefmsgid = res10265.InfRefmsgid
  12999. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13000. res.Infcode = infocode
  13001. } else if miConfig.MdtrtareaAdmvs == "341203" {
  13002. psn_info, _ := service.GetPsnByPatientId(patient_id)
  13003. var api string
  13004. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  13005. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  13006. resp, requestErr := http.Get(api)
  13007. if requestErr != nil {
  13008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13009. return
  13010. }
  13011. body, ioErr := ioutil.ReadAll(resp.Body)
  13012. if ioErr != nil {
  13013. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13015. return
  13016. }
  13017. var respJSON map[string]interface{}
  13018. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13019. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13021. return
  13022. }
  13023. status := respJSON["data"].(map[string]interface{})["status"].(string)
  13024. if status == "0" {
  13025. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  13026. c.ServeSuccessJSON(map[string]interface{}{
  13027. "failed_code": -10,
  13028. "msg": err_msg,
  13029. })
  13030. return
  13031. }
  13032. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13033. result, _ := json.Marshal(respJSON)
  13034. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13035. utils.ErrorLog("解析失败:%v", err)
  13036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13037. return
  13038. }
  13039. } else if miConfig.MdtrtareaAdmvs == "340699" {
  13040. psn_info, _ := service.GetHisPatientByPatientId(patient_id)
  13041. var api string
  13042. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  13043. "&insuplc_admdvs=" + psn_info.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  13044. resp, requestErr := http.Get(api)
  13045. if requestErr != nil {
  13046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13047. return
  13048. }
  13049. body, ioErr := ioutil.ReadAll(resp.Body)
  13050. if ioErr != nil {
  13051. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13053. return
  13054. }
  13055. var respJSON map[string]interface{}
  13056. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13057. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13059. return
  13060. }
  13061. status := respJSON["data"].(map[string]interface{})["status"].(string)
  13062. if status == "0" {
  13063. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  13064. c.ServeSuccessJSON(map[string]interface{}{
  13065. "failed_code": -10,
  13066. "msg": err_msg,
  13067. })
  13068. return
  13069. }
  13070. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13071. result, _ := json.Marshal(respJSON)
  13072. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13073. utils.ErrorLog("解析失败:%v", err)
  13074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13075. return
  13076. }
  13077. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13078. p, _ := service.GetHisPatientById(patient_id)
  13079. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13080. var dat map[string]interface{}
  13081. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13082. fmt.Println(dat)
  13083. } else {
  13084. fmt.Println(err)
  13085. }
  13086. userJSONBytes, _ := json.Marshal(dat)
  13087. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13088. utils.ErrorLog("解析失败:%v", err)
  13089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13090. return
  13091. }
  13092. } else if miConfig.MdtrtareaAdmvs == "361025" {
  13093. p, _ := service.GetHisPatientById(patient_id)
  13094. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13095. var dat map[string]interface{}
  13096. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13097. fmt.Println(dat)
  13098. } else {
  13099. fmt.Println(err)
  13100. }
  13101. userJSONBytes, _ := json.Marshal(dat)
  13102. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13103. utils.ErrorLog("解析失败:%v", err)
  13104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13105. return
  13106. }
  13107. } else if miConfig.MdtrtareaAdmvs == "360100" {
  13108. p, _ := service.GetHisPatientById(patient_id)
  13109. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13110. var dat map[string]interface{}
  13111. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13112. fmt.Println(dat)
  13113. } else {
  13114. fmt.Println(err)
  13115. }
  13116. userJSONBytes, _ := json.Marshal(dat)
  13117. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13118. utils.ErrorLog("解析失败:%v", err)
  13119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13120. return
  13121. }
  13122. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13123. p, _ := service.GetHisPatientById(patient_id)
  13124. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13125. var dat map[string]interface{}
  13126. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13127. fmt.Println(dat)
  13128. } else {
  13129. fmt.Println(err)
  13130. }
  13131. userJSONBytes, _ := json.Marshal(dat)
  13132. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13133. utils.ErrorLog("解析失败:%v", err)
  13134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13135. return
  13136. }
  13137. } else if miConfig.MdtrtareaAdmvs == "420200" {
  13138. p, _ := service.GetHisPatientById(patient_id)
  13139. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  13140. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13141. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13142. resp, requestErr := http.Get(api)
  13143. if requestErr != nil {
  13144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13145. return
  13146. }
  13147. body, ioErr := ioutil.ReadAll(resp.Body)
  13148. if ioErr != nil {
  13149. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13151. return
  13152. }
  13153. var respJSON map[string]interface{}
  13154. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13155. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13157. return
  13158. }
  13159. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13160. result, _ := json.Marshal(respJSON)
  13161. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13162. utils.ErrorLog("解析失败:%v", err)
  13163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13164. return
  13165. }
  13166. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13167. p, _ := service.GetHisPatientById(patient_id)
  13168. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  13169. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13170. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13171. resp, requestErr := http.Get(api)
  13172. if requestErr != nil {
  13173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13174. return
  13175. }
  13176. body, ioErr := ioutil.ReadAll(resp.Body)
  13177. if ioErr != nil {
  13178. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13180. return
  13181. }
  13182. var respJSON map[string]interface{}
  13183. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13184. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13186. return
  13187. }
  13188. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13189. result, _ := json.Marshal(respJSON)
  13190. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13191. utils.ErrorLog("解析失败:%v", err)
  13192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13193. return
  13194. }
  13195. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13196. p, _ := service.GetHisPatientById(patient_id)
  13197. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  13198. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13199. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13200. resp, requestErr := http.Get(api)
  13201. if requestErr != nil {
  13202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13203. return
  13204. }
  13205. body, ioErr := ioutil.ReadAll(resp.Body)
  13206. if ioErr != nil {
  13207. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13209. return
  13210. }
  13211. var respJSON map[string]interface{}
  13212. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13213. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13215. return
  13216. }
  13217. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13218. result, _ := json.Marshal(respJSON)
  13219. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13220. utils.ErrorLog("解析失败:%v", err)
  13221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13222. return
  13223. }
  13224. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13225. p, _ := service.GetHisPatientById(patient_id)
  13226. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  13227. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13228. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13229. resp, requestErr := http.Get(api)
  13230. if requestErr != nil {
  13231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13232. return
  13233. }
  13234. body, ioErr := ioutil.ReadAll(resp.Body)
  13235. if ioErr != nil {
  13236. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13238. return
  13239. }
  13240. var respJSON map[string]interface{}
  13241. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13242. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13244. return
  13245. }
  13246. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13247. result, _ := json.Marshal(respJSON)
  13248. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13249. utils.ErrorLog("解析失败:%v", err)
  13250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13251. return
  13252. }
  13253. } else if miConfig.MdtrtareaAdmvs == "421300" {
  13254. p, _ := service.GetHisPatientById(patient_id)
  13255. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  13256. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13257. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13258. resp, requestErr := http.Get(api)
  13259. if requestErr != nil {
  13260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13261. return
  13262. }
  13263. body, ioErr := ioutil.ReadAll(resp.Body)
  13264. if ioErr != nil {
  13265. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13267. return
  13268. }
  13269. var respJSON map[string]interface{}
  13270. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13271. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13273. return
  13274. }
  13275. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13276. result, _ := json.Marshal(respJSON)
  13277. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13278. utils.ErrorLog("解析失败:%v", err)
  13279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13280. return
  13281. }
  13282. } else if miConfig.MdtrtareaAdmvs == "441799" {
  13283. p, _ := service.GetHisPatientById(patient_id)
  13284. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  13285. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13286. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13287. resp, requestErr := http.Get(api)
  13288. if requestErr != nil {
  13289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13290. return
  13291. }
  13292. body, ioErr := ioutil.ReadAll(resp.Body)
  13293. if ioErr != nil {
  13294. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13296. return
  13297. }
  13298. var respJSON map[string]interface{}
  13299. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13300. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13302. return
  13303. }
  13304. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13305. result, _ := json.Marshal(respJSON)
  13306. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13307. utils.ErrorLog("解析失败:%v", err)
  13308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13309. return
  13310. }
  13311. } else {
  13312. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  13313. var dat map[string]interface{}
  13314. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13315. fmt.Println(dat)
  13316. } else {
  13317. fmt.Println(err)
  13318. }
  13319. userJSONBytes, _ := json.Marshal(dat)
  13320. if miConfig.Code == "H15049901371" {
  13321. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  13322. utils.ErrorLog("解析失败:%v", err)
  13323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13324. return
  13325. }
  13326. res.InfRefmsgid = res10265.InfRefmsgid
  13327. res.Output = res10265.Output
  13328. res.ErrMsg = res10265.ErrMsg
  13329. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13330. res.Infcode = infocode
  13331. } else {
  13332. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13333. utils.ErrorLog("解析失败:%v", err)
  13334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13335. return
  13336. }
  13337. }
  13338. }
  13339. if res.Infcode == 0 {
  13340. c.ServeSuccessJSON(map[string]interface{}{
  13341. "result": res.Output.Result,
  13342. })
  13343. }
  13344. }
  13345. func (c *HisApiController) CheckInsutype() {
  13346. his_patient_id, _ := c.GetInt64("his_patient_id")
  13347. admin_user_id, _ := c.GetInt64("admin_user_id")
  13348. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13349. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  13350. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13351. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  13352. var dat map[string]interface{}
  13353. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13354. fmt.Println(dat)
  13355. } else {
  13356. fmt.Println(err)
  13357. }
  13358. userJSONBytes, _ := json.Marshal(dat)
  13359. var res Result90100
  13360. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13361. utils.ErrorLog("解析失败:%v", err)
  13362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13363. return
  13364. }
  13365. if res.Infcode != 0 {
  13366. c.ServeSuccessJSON(map[string]interface{}{
  13367. "failed_code": -10,
  13368. "msg": res.ErrMsg,
  13369. })
  13370. return
  13371. } else {
  13372. fmt.Println(res)
  13373. }
  13374. }
  13375. func (c *HisApiController) CheckCardPWD() {
  13376. card_pwd := c.GetString("card_pwd")
  13377. his_patient_id, _ := c.GetInt64("his_patient_id")
  13378. admin_user_id, _ := c.GetInt64("admin_user_id")
  13379. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13380. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13381. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  13382. psn, _ := service.GetPsnByPatientId(his.PatientId)
  13383. bas := strings.Split(psn.CardInfo, "|")
  13384. basNumber := bas[2]
  13385. if psn.InsuplcAdmdvs[:4] == "4403" {
  13386. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  13387. var dat map[string]interface{}
  13388. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13389. fmt.Println(dat)
  13390. } else {
  13391. fmt.Println(err)
  13392. }
  13393. userJSONBytes, _ := json.Marshal(dat)
  13394. var res Result90991
  13395. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13396. utils.ErrorLog("解析失败:%v", err)
  13397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13398. return
  13399. }
  13400. if res.Infcode != 0 {
  13401. c.ServeSuccessJSON(map[string]interface{}{
  13402. "failed_code": -10,
  13403. "msg": res.ErrMsg,
  13404. })
  13405. return
  13406. } else {
  13407. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  13408. var msg string
  13409. switch res.Output.Result.CardStat {
  13410. case "00":
  13411. msg = "未激活"
  13412. break
  13413. case "10":
  13414. msg = "激活"
  13415. break
  13416. case "20":
  13417. msg = "窗口挂失"
  13418. break
  13419. case "21":
  13420. msg = "电话挂失"
  13421. break
  13422. case "22":
  13423. msg = "单位网上申报挂失"
  13424. break
  13425. case "23":
  13426. msg = "保健办挂失"
  13427. break
  13428. case "24":
  13429. msg = "个人网上挂失"
  13430. break
  13431. case "25":
  13432. msg = "网上服务大厅挂失"
  13433. break
  13434. case "30":
  13435. msg = "注销"
  13436. break
  13437. case "40":
  13438. msg = "回收"
  13439. break
  13440. case "99":
  13441. msg = "制卡中(无效卡)"
  13442. break
  13443. }
  13444. c.ServeSuccessJSON(map[string]interface{}{
  13445. "failed_code": -10,
  13446. "msg": msg,
  13447. })
  13448. return
  13449. } else {
  13450. c.ServeSuccessJSON(map[string]interface{}{
  13451. "msg": "校验成功",
  13452. })
  13453. return
  13454. }
  13455. }
  13456. } else {
  13457. c.ServeSuccessJSON(map[string]interface{}{
  13458. "msg": "校验成功",
  13459. })
  13460. return
  13461. }
  13462. }
  13463. func (c *HisApiController) CheckCardPWDTwo() {
  13464. //card_pwd := c.GetString("card_pwd")
  13465. //his_patient_id, _ := c.GetInt64("his_patient_id")
  13466. admin_user_id, _ := c.GetInt64("admin_user_id")
  13467. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13468. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13469. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  13470. var dat map[string]interface{}
  13471. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13472. fmt.Println(dat)
  13473. } else {
  13474. fmt.Println(err)
  13475. }
  13476. userJSONBytes, _ := json.Marshal(dat)
  13477. var res Result90991
  13478. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13479. utils.ErrorLog("解析失败:%v", err)
  13480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13481. return
  13482. }
  13483. if res.Infcode != 0 {
  13484. c.ServeSuccessJSON(map[string]interface{}{
  13485. "failed_code": -10,
  13486. "msg": res.ErrMsg,
  13487. })
  13488. return
  13489. } else {
  13490. if res.Output.Result.SscnoCheckStat == "0" {
  13491. var msg string
  13492. switch res.Output.Result.CardStat {
  13493. case "00":
  13494. msg = "未激活"
  13495. break
  13496. case "10":
  13497. msg = "激活"
  13498. break
  13499. case "20":
  13500. msg = "窗口挂失"
  13501. break
  13502. case "21":
  13503. msg = "电话挂失"
  13504. break
  13505. case "22":
  13506. msg = "单位网上申报挂失"
  13507. break
  13508. case "23":
  13509. msg = "保健办挂失"
  13510. break
  13511. case "24":
  13512. msg = "个人网上挂失"
  13513. break
  13514. case "25":
  13515. msg = "网上服务大厅挂失"
  13516. break
  13517. case "30":
  13518. msg = "注销"
  13519. break
  13520. case "40":
  13521. msg = "回收"
  13522. break
  13523. case "99":
  13524. msg = "制卡中(无效卡)"
  13525. break
  13526. }
  13527. c.ServeSuccessJSON(map[string]interface{}{
  13528. "failed_code": -10,
  13529. "msg": msg,
  13530. })
  13531. return
  13532. } else {
  13533. c.ServeSuccessJSON(map[string]interface{}{
  13534. "msg": "校验成功",
  13535. })
  13536. return
  13537. }
  13538. }
  13539. }
  13540. type ELeCertData struct {
  13541. Data struct {
  13542. Extra string `json:"extra"`
  13543. IDNo string `json:"idNo"`
  13544. IDType string `json:"idType"`
  13545. EcToken string `json:"ecToken"`
  13546. InsuOrg string `json:"insuOrg"`
  13547. UserName string `json:"userName"`
  13548. EcIndexNo string `json:"ecIndexNo"`
  13549. Gender string `json:"gender"`
  13550. Birthday string `json:"birthday"`
  13551. Nationality string `json:"nationality"`
  13552. Email string `json:"email"`
  13553. } `json:"OutData"`
  13554. }
  13555. func (c *HisApiController) ReadCard() {
  13556. id_card_type, _ := c.GetInt64("id_card_type")
  13557. admin_user_id, _ := c.GetInt64("admin_user_id")
  13558. certificates, _ := c.GetInt64("certificates")
  13559. //
  13560. insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  13561. id_card_no := c.GetString("id_card_no")
  13562. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13563. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13564. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13565. switch id_card_type {
  13566. case 1:
  13567. if miConfig.MdtrtareaAdmvs == "421300" {
  13568. var res ResultTwo
  13569. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  13570. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13571. "&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)
  13572. resp, requestErr := http.Get(api)
  13573. if requestErr != nil {
  13574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13575. return
  13576. }
  13577. body, ioErr := ioutil.ReadAll(resp.Body)
  13578. if ioErr != nil {
  13579. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13581. return
  13582. }
  13583. var respJSON map[string]interface{}
  13584. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13585. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13587. return
  13588. }
  13589. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13590. result, _ := json.Marshal(respJSON)
  13591. fmt.Println("log")
  13592. fmt.Println(string(result))
  13593. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13594. utils.ErrorLog("解析失败:%v", err)
  13595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13596. return
  13597. }
  13598. if res.Infcode == 0 {
  13599. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13600. if err == gorm.ErrRecordNotFound {
  13601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13602. return
  13603. } else if err != nil {
  13604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13605. return
  13606. } else {
  13607. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13608. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13609. infoStr := string(Iinfos)
  13610. idetinfoStr := string(Idetinfos)
  13611. var rf []*ResultFive
  13612. json.Unmarshal([]byte(infoStr), &rf)
  13613. var insutypes []*ResultFive
  13614. var insutype string
  13615. var is390 int = 0
  13616. var is310 int = 0
  13617. for _, item := range rf {
  13618. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13619. insutypes = append(insutypes, item)
  13620. }
  13621. }
  13622. if len(insutypes) == 1 {
  13623. insutype = insutypes[0].Insutype
  13624. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13625. } else {
  13626. for _, i := range insutypes {
  13627. if i.Insutype == "390" {
  13628. is390 = 1
  13629. }
  13630. if i.Insutype == "310" {
  13631. is310 = 1
  13632. }
  13633. }
  13634. }
  13635. if is390 == 1 {
  13636. insutype = "390"
  13637. }
  13638. if is310 == 1 {
  13639. insutype = "310"
  13640. }
  13641. if len(insutypes) == 0 {
  13642. insutype = "390"
  13643. }
  13644. var insuplc_admdvs string
  13645. for _, item := range rf {
  13646. if item.Insutype == insutype {
  13647. insuplc_admdvs = item.InsuplcAdmdvs
  13648. }
  13649. }
  13650. if strings.Contains(insuplc_admdvs, "4213") {
  13651. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  13652. }
  13653. psn := &models.HisPsn{
  13654. PsnNo: res.Output.Baseinfo.PsnNo,
  13655. PatientId: patient.ID,
  13656. Certno: res.Output.Baseinfo.Certno,
  13657. Gend: res.Output.Baseinfo.Gend,
  13658. Naty: res.Output.Baseinfo.Naty,
  13659. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13660. PsnName: res.Output.Baseinfo.PsnName,
  13661. Idetinfo: idetinfoStr,
  13662. Insuinfo: infoStr,
  13663. InsuplcAdmdvs: insuplc_admdvs,
  13664. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13665. }
  13666. service.CreateHisPsn(psn)
  13667. c.ServeSuccessJSON(map[string]interface{}{
  13668. "patient": patient,
  13669. "number": res.Output.Baseinfo.Certno,
  13670. })
  13671. }
  13672. } else {
  13673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13674. return
  13675. }
  13676. } else if miConfig.MdtrtareaAdmvs == "420200" {
  13677. var res ResultTwo
  13678. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  13679. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13680. "&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)
  13681. resp, requestErr := http.Get(api)
  13682. if requestErr != nil {
  13683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13684. return
  13685. }
  13686. body, ioErr := ioutil.ReadAll(resp.Body)
  13687. if ioErr != nil {
  13688. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13690. return
  13691. }
  13692. var respJSON map[string]interface{}
  13693. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13694. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13696. return
  13697. }
  13698. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13699. result, _ := json.Marshal(respJSON)
  13700. fmt.Println("log")
  13701. fmt.Println(string(result))
  13702. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13703. utils.ErrorLog("解析失败:%v", err)
  13704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13705. return
  13706. }
  13707. if res.Infcode == 0 {
  13708. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13709. if err == gorm.ErrRecordNotFound {
  13710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13711. return
  13712. } else if err != nil {
  13713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13714. return
  13715. } else {
  13716. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13717. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13718. infoStr := string(Iinfos)
  13719. idetinfoStr := string(Idetinfos)
  13720. psn := &models.HisPsn{
  13721. PsnNo: res.Output.Baseinfo.PsnNo,
  13722. PatientId: patient.ID,
  13723. Certno: res.Output.Baseinfo.Certno,
  13724. Gend: res.Output.Baseinfo.Gend,
  13725. Naty: res.Output.Baseinfo.Naty,
  13726. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13727. PsnName: res.Output.Baseinfo.PsnName,
  13728. Idetinfo: idetinfoStr,
  13729. Insuinfo: infoStr,
  13730. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13731. }
  13732. service.CreateHisPsn(psn)
  13733. var rf []*ResultFive
  13734. json.Unmarshal([]byte(infoStr), &rf)
  13735. var insutypes []*ResultFive
  13736. var insutype string
  13737. var is390 int = 0
  13738. var is310 int = 0
  13739. for _, item := range rf {
  13740. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13741. insutypes = append(insutypes, item)
  13742. }
  13743. }
  13744. if len(insutypes) == 1 {
  13745. insutype = insutypes[0].Insutype
  13746. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13747. } else {
  13748. for _, i := range insutypes {
  13749. if i.Insutype == "390" {
  13750. is390 = 1
  13751. }
  13752. if i.Insutype == "310" {
  13753. is310 = 1
  13754. }
  13755. }
  13756. }
  13757. if is390 == 1 {
  13758. insutype = "390"
  13759. }
  13760. if is310 == 1 {
  13761. insutype = "310"
  13762. }
  13763. if len(insutypes) == 0 {
  13764. insutype = "310"
  13765. }
  13766. c.ServeSuccessJSON(map[string]interface{}{
  13767. "patient": patient,
  13768. "number": res.Output.Baseinfo.Certno,
  13769. "insutype": insutype,
  13770. })
  13771. }
  13772. } else {
  13773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13774. return
  13775. }
  13776. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13777. var res ResultTwo
  13778. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  13779. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13780. "&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)
  13781. resp, requestErr := http.Get(api)
  13782. if requestErr != nil {
  13783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13784. return
  13785. }
  13786. body, ioErr := ioutil.ReadAll(resp.Body)
  13787. if ioErr != nil {
  13788. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13790. return
  13791. }
  13792. var respJSON map[string]interface{}
  13793. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13794. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13796. return
  13797. }
  13798. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13799. result, _ := json.Marshal(respJSON)
  13800. fmt.Println("log")
  13801. fmt.Println(string(result))
  13802. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13803. utils.ErrorLog("解析失败:%v", err)
  13804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13805. return
  13806. }
  13807. if res.Infcode == 0 {
  13808. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13809. if err == gorm.ErrRecordNotFound {
  13810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13811. return
  13812. } else if err != nil {
  13813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13814. return
  13815. } else {
  13816. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13817. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13818. infoStr := string(Iinfos)
  13819. idetinfoStr := string(Idetinfos)
  13820. var rf []*ResultFive
  13821. json.Unmarshal([]byte(infoStr), &rf)
  13822. var insutypes []*ResultFive
  13823. var insutype string
  13824. var is390 int = 0
  13825. var is310 int = 0
  13826. for _, item := range rf {
  13827. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13828. insutypes = append(insutypes, item)
  13829. }
  13830. }
  13831. if len(insutypes) == 1 {
  13832. insutype = insutypes[0].Insutype
  13833. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13834. } else {
  13835. for _, i := range insutypes {
  13836. if i.Insutype == "390" {
  13837. is390 = 1
  13838. }
  13839. if i.Insutype == "310" {
  13840. is310 = 1
  13841. }
  13842. }
  13843. }
  13844. if is390 == 1 {
  13845. insutype = "390"
  13846. }
  13847. if is310 == 1 {
  13848. insutype = "310"
  13849. }
  13850. if len(insutypes) == 0 {
  13851. insutype = "390"
  13852. }
  13853. var insuplc_admdvs string
  13854. for _, item := range rf {
  13855. if item.Insutype == insutype {
  13856. insuplc_admdvs = item.InsuplcAdmdvs
  13857. }
  13858. }
  13859. psn := &models.HisPsn{
  13860. PsnNo: res.Output.Baseinfo.PsnNo,
  13861. PatientId: patient.ID,
  13862. Certno: res.Output.Baseinfo.Certno,
  13863. Gend: res.Output.Baseinfo.Gend,
  13864. Naty: res.Output.Baseinfo.Naty,
  13865. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13866. PsnName: res.Output.Baseinfo.PsnName,
  13867. Idetinfo: idetinfoStr,
  13868. Insuinfo: infoStr,
  13869. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13870. InsuplcAdmdvs: insuplc_admdvs,
  13871. }
  13872. service.CreateHisPsn(psn)
  13873. for _, item := range rf {
  13874. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13875. insutypes = append(insutypes, item)
  13876. }
  13877. }
  13878. if len(insutypes) == 1 {
  13879. insutype = insutypes[0].Insutype
  13880. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13881. } else {
  13882. for _, i := range insutypes {
  13883. if i.Insutype == "390" {
  13884. is390 = 1
  13885. }
  13886. if i.Insutype == "310" {
  13887. is310 = 1
  13888. }
  13889. }
  13890. }
  13891. if is390 == 1 {
  13892. insutype = "390"
  13893. }
  13894. if is310 == 1 {
  13895. insutype = "310"
  13896. }
  13897. if len(insutypes) == 0 {
  13898. insutype = "310"
  13899. }
  13900. c.ServeSuccessJSON(map[string]interface{}{
  13901. "patient": patient,
  13902. "number": res.Output.Baseinfo.Certno,
  13903. "insutype": insutype,
  13904. })
  13905. }
  13906. } else {
  13907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13908. return
  13909. }
  13910. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13911. var res ResultTwo
  13912. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  13913. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13914. "&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)
  13915. resp, requestErr := http.Get(api)
  13916. if requestErr != nil {
  13917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13918. return
  13919. }
  13920. body, ioErr := ioutil.ReadAll(resp.Body)
  13921. if ioErr != nil {
  13922. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13924. return
  13925. }
  13926. var respJSON map[string]interface{}
  13927. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13928. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13930. return
  13931. }
  13932. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13933. result, _ := json.Marshal(respJSON)
  13934. fmt.Println("log")
  13935. fmt.Println(string(result))
  13936. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13937. utils.ErrorLog("解析失败:%v", err)
  13938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13939. return
  13940. }
  13941. if res.Infcode == 0 {
  13942. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13943. if err == gorm.ErrRecordNotFound {
  13944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13945. return
  13946. } else if err != nil {
  13947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13948. return
  13949. } else {
  13950. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13951. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13952. infoStr := string(Iinfos)
  13953. idetinfoStr := string(Idetinfos)
  13954. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13955. psn := &models.HisPsn{
  13956. PsnNo: res.Output.Baseinfo.PsnNo,
  13957. PatientId: patient.ID,
  13958. Certno: res.Output.Baseinfo.Certno,
  13959. Brdy: b,
  13960. Age: float64(age),
  13961. Gend: res.Output.Baseinfo.Gend,
  13962. Naty: res.Output.Baseinfo.Naty,
  13963. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13964. PsnName: res.Output.Baseinfo.PsnName,
  13965. Idetinfo: idetinfoStr,
  13966. Insuinfo: infoStr,
  13967. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13968. }
  13969. service.CreateHisPsn(psn)
  13970. var rf []*ResultFive
  13971. json.Unmarshal([]byte(infoStr), &rf)
  13972. var insutypes []*ResultFive
  13973. var insutype string
  13974. var is390 int = 0
  13975. var is310 int = 0
  13976. for _, item := range rf {
  13977. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13978. insutypes = append(insutypes, item)
  13979. }
  13980. }
  13981. if len(insutypes) == 1 {
  13982. insutype = insutypes[0].Insutype
  13983. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13984. } else {
  13985. for _, i := range insutypes {
  13986. if i.Insutype == "390" {
  13987. is390 = 1
  13988. }
  13989. if i.Insutype == "310" {
  13990. is310 = 1
  13991. }
  13992. }
  13993. }
  13994. if is390 == 1 {
  13995. insutype = "390"
  13996. }
  13997. if is310 == 1 {
  13998. insutype = "310"
  13999. }
  14000. if len(insutypes) == 0 {
  14001. insutype = "310"
  14002. }
  14003. c.ServeSuccessJSON(map[string]interface{}{
  14004. "patient": patient,
  14005. "number": res.Output.Baseinfo.Certno,
  14006. "insutype": insutype,
  14007. })
  14008. }
  14009. } else {
  14010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14011. return
  14012. }
  14013. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  14014. var api string
  14015. if miConfig.MdtrtareaAdmvs == "320830" {
  14016. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  14017. "&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
  14018. fmt.Println(api)
  14019. } else if miConfig.MdtrtareaAdmvs == "320921" {
  14020. 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 +
  14021. "&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
  14022. fmt.Println(api)
  14023. } else {
  14024. 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 +
  14025. "&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)
  14026. }
  14027. resp, requestErr := http.Get(api)
  14028. if requestErr != nil {
  14029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14030. return
  14031. }
  14032. body, ioErr := ioutil.ReadAll(resp.Body)
  14033. if ioErr != nil {
  14034. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14036. return
  14037. }
  14038. var respJSON map[string]interface{}
  14039. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14040. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14042. return
  14043. }
  14044. var status string
  14045. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14046. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14047. //console.log()
  14048. fmt.Println("type===")
  14049. fmt.Println(card_type)
  14050. var token string
  14051. var res ResultTwo //1101结果
  14052. var res10265 ResultTwo10265 //1101结果
  14053. var card_info string //卡信息
  14054. var busi_card_info string
  14055. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14056. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14057. if status == "0" { //读卡成功
  14058. if card_type == "1" {
  14059. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14060. result, _ := json.Marshal(respJSON)
  14061. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14062. utils.ErrorLog("解析失败:%v", err)
  14063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14064. return
  14065. }
  14066. res.ErrMsg = res10265.ErrMsg
  14067. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14068. res.Infcode = infocode
  14069. res.Output = res10265.Output
  14070. res.InfRefmsgid = res10265.InfRefmsgid
  14071. } else {
  14072. //var card_info string //卡信息
  14073. //var busi_card_info string
  14074. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14075. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14076. //fmt.Println(card_info)
  14077. //fmt.Println(busi_card_info)
  14078. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14079. result, _ := json.Marshal(respJSON)
  14080. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14081. utils.ErrorLog("解析失败:%v", err)
  14082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14083. return
  14084. }
  14085. res.ErrMsg = res10265.ErrMsg
  14086. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14087. res.Infcode = infocode
  14088. res.Output = res10265.Output
  14089. res.InfRefmsgid = res10265.InfRefmsgid
  14090. }
  14091. if res.Infcode == 0 {
  14092. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14093. if err == gorm.ErrRecordNotFound {
  14094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14095. return
  14096. } else if err != nil {
  14097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14098. return
  14099. } else {
  14100. if card_type == "1" {
  14101. bas := strings.Split(card_info, "|")
  14102. basNumber := bas[2]
  14103. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14104. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14105. infoStr := string(Iinfos)
  14106. idetinfoStr := string(Idetinfos)
  14107. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  14108. psn := &models.HisPsn{
  14109. PsnNo: res.Output.Baseinfo.PsnNo,
  14110. PatientId: patient.ID,
  14111. Certno: res.Output.Baseinfo.Certno,
  14112. Brdy: b,
  14113. Age: float64(age),
  14114. Gend: res.Output.Baseinfo.Gend,
  14115. Naty: res.Output.Baseinfo.Naty,
  14116. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14117. PsnName: res.Output.Baseinfo.PsnName,
  14118. Idetinfo: idetinfoStr,
  14119. Insuinfo: infoStr,
  14120. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14121. CardInfo: card_info,
  14122. VerifyNumber: busi_card_info,
  14123. }
  14124. service.CreateHisPsn(psn)
  14125. var rf []*ResultFive
  14126. json.Unmarshal([]byte(infoStr), &rf)
  14127. var insutypes []*ResultFive
  14128. var insutype string
  14129. var is390 int = 0
  14130. var is310 int = 0
  14131. for _, item := range rf {
  14132. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14133. insutypes = append(insutypes, item)
  14134. }
  14135. }
  14136. if len(insutypes) == 1 {
  14137. insutype = insutypes[0].Insutype
  14138. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14139. } else {
  14140. for _, i := range insutypes {
  14141. if i.Insutype == "390" {
  14142. is390 = 1
  14143. }
  14144. if i.Insutype == "310" {
  14145. is310 = 1
  14146. }
  14147. }
  14148. }
  14149. if is390 == 1 {
  14150. insutype = "390"
  14151. }
  14152. if is310 == 1 {
  14153. insutype = "310"
  14154. }
  14155. if len(insutypes) == 0 {
  14156. insutype = "310"
  14157. }
  14158. c.ServeSuccessJSON(map[string]interface{}{
  14159. "patient": patient,
  14160. "number": basNumber,
  14161. "insutype": insutype,
  14162. })
  14163. } else {
  14164. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14165. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14166. infoStr := string(Iinfos)
  14167. idetinfoStr := string(Idetinfos)
  14168. psn := &models.HisPsn{
  14169. PsnNo: res.Output.Baseinfo.PsnNo,
  14170. PatientId: patient.ID,
  14171. Certno: res.Output.Baseinfo.Certno,
  14172. Gend: res.Output.Baseinfo.Gend,
  14173. Naty: res.Output.Baseinfo.Naty,
  14174. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14175. PsnName: res.Output.Baseinfo.PsnName,
  14176. Idetinfo: idetinfoStr,
  14177. Insuinfo: infoStr,
  14178. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14179. CardInfo: card_info,
  14180. VerifyNumber: token,
  14181. }
  14182. service.CreateHisPsn(psn)
  14183. c.ServeSuccessJSON(map[string]interface{}{
  14184. "patient": patient,
  14185. "number": token,
  14186. })
  14187. }
  14188. }
  14189. } else {
  14190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14191. return
  14192. }
  14193. } else { //读卡失败
  14194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14195. return
  14196. }
  14197. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14198. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  14199. cardnum = DeleteExtraSpaceTwo(cardnum)
  14200. cardCode = DeleteExtraSpaceTwo(cardCode)
  14201. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  14202. name = DeleteExtraSpaceTwo(name)
  14203. errmsg = DeleteExtraSpaceTwo(errmsg)
  14204. cardnum = Remove0000(cardnum)
  14205. cardCode = Remove0000(cardCode)
  14206. id_card_no = Remove0000(id_card_no)
  14207. name = Remove0000(name)
  14208. errmsg = Remove0000(errmsg)
  14209. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  14210. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  14211. //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)
  14212. //fmt.Println(result2)
  14213. //fmt.Println(requestLog2)
  14214. //fmt.Println(errMsgLog2)
  14215. 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)
  14216. saveLog(result, requestLog, "1101", "获取人员信息")
  14217. fmt.Println(errMsgLog)
  14218. if len(errMsgLog) > 0 {
  14219. } else {
  14220. var dat map[string]interface{}
  14221. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14222. fmt.Println(dat)
  14223. } else {
  14224. fmt.Println(err)
  14225. }
  14226. userJSONBytes, _ := json.Marshal(dat)
  14227. var res ResultTwo
  14228. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14229. utils.ErrorLog("解析失败:%v", err)
  14230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14231. return
  14232. }
  14233. res.ErrMsg = errMsgLog
  14234. if res.Infcode == 0 {
  14235. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  14236. if err == gorm.ErrRecordNotFound {
  14237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14238. return
  14239. } else if err != nil {
  14240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14241. return
  14242. } else {
  14243. fmt.Println(res)
  14244. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14245. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14246. infoStr := string(Iinfos)
  14247. idetinfoStr := string(Idetinfos)
  14248. var rf []*ResultFive
  14249. json.Unmarshal([]byte(infoStr), &rf)
  14250. var insutypes []*ResultFive
  14251. var insutype string
  14252. var is390 int = 0
  14253. var is310 int = 0
  14254. for _, item := range rf {
  14255. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14256. insutypes = append(insutypes, item)
  14257. }
  14258. }
  14259. if len(insutypes) == 1 {
  14260. insutype = insutypes[0].Insutype
  14261. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14262. } else {
  14263. for _, i := range insutypes {
  14264. if i.Insutype == "390" {
  14265. is390 = 1
  14266. }
  14267. if i.Insutype == "310" {
  14268. is310 = 1
  14269. }
  14270. }
  14271. }
  14272. if is390 == 1 {
  14273. insutype = "390"
  14274. }
  14275. if is310 == 1 {
  14276. insutype = "310"
  14277. }
  14278. if len(insutypes) == 0 {
  14279. insutype = "390"
  14280. }
  14281. var insuplc_admdvs string
  14282. for _, item := range rf {
  14283. if item.Insutype == insutype {
  14284. insuplc_admdvs = item.InsuplcAdmdvs
  14285. }
  14286. }
  14287. psn := &models.HisPsn{
  14288. PsnNo: res.Output.Baseinfo.PsnNo,
  14289. PatientId: patient.ID,
  14290. Certno: res.Output.Baseinfo.Certno,
  14291. Gend: res.Output.Baseinfo.Gend,
  14292. Naty: res.Output.Baseinfo.Naty,
  14293. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14294. PsnName: res.Output.Baseinfo.PsnName,
  14295. Idetinfo: idetinfoStr,
  14296. Insuinfo: infoStr,
  14297. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14298. CardInfo: basStr,
  14299. VerifyNumber: "",
  14300. InsuplcAdmdvs: insuplc_admdvs,
  14301. }
  14302. service.CreateHisPsn(psn)
  14303. c.ServeSuccessJSON(map[string]interface{}{
  14304. "patient": patient,
  14305. "number": cardnum,
  14306. "insutype": insutype,
  14307. })
  14308. }
  14309. } else {
  14310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14311. return
  14312. }
  14313. }
  14314. } else if miConfig.MdtrtareaAdmvs == "360302" {
  14315. fmt.Println(initFlag)
  14316. fmt.Println("initFlag")
  14317. if initFlag == 0 {
  14318. c.TestGetJiangXiBasBaseInit()
  14319. }
  14320. basStr := c.GetBasBaseInfo()
  14321. if len(basStr) == 0 {
  14322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14323. return
  14324. }
  14325. fmt.Println(basStr)
  14326. bas := strings.Split(basStr, "|")
  14327. basNumber := bas[1]
  14328. fmt.Println(basNumber)
  14329. card := bas[2]
  14330. card_sn := bas[3]
  14331. fmt.Println(card_sn)
  14332. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14333. 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)
  14334. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14335. var dat map[string]interface{}
  14336. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14337. fmt.Println(dat)
  14338. } else {
  14339. fmt.Println(err)
  14340. }
  14341. userJSONBytes, _ := json.Marshal(dat)
  14342. var res ResultTwo
  14343. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14344. utils.ErrorLog("解析失败:%v", err)
  14345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14346. return
  14347. }
  14348. if res.Infcode == 0 {
  14349. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14350. if err == gorm.ErrRecordNotFound {
  14351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14352. return
  14353. } else if err != nil {
  14354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14355. return
  14356. } else {
  14357. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14358. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14359. infoStr := string(Iinfos)
  14360. idetinfoStr := string(Idetinfos)
  14361. var rf []*ResultFive
  14362. json.Unmarshal([]byte(infoStr), &rf)
  14363. var insutypes []*ResultFive
  14364. var insutype string
  14365. var is390 int = 0
  14366. var is310 int = 0
  14367. var insuplc_admdvs string
  14368. for _, item := range rf {
  14369. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14370. insutypes = append(insutypes, item)
  14371. }
  14372. }
  14373. if len(insutypes) == 1 {
  14374. insutype = insutypes[0].Insutype
  14375. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14376. } else {
  14377. for _, i := range insutypes {
  14378. if i.Insutype == "390" {
  14379. is390 = 1
  14380. }
  14381. if i.Insutype == "310" {
  14382. is310 = 1
  14383. }
  14384. }
  14385. }
  14386. if is390 == 1 {
  14387. insutype = "390"
  14388. }
  14389. if is310 == 1 {
  14390. insutype = "310"
  14391. }
  14392. if len(insutypes) == 0 {
  14393. insutype = "310"
  14394. }
  14395. for _, item := range rf {
  14396. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14397. insuplc_admdvs = item.InsuplcAdmdvs
  14398. }
  14399. }
  14400. psn := &models.HisPsn{
  14401. PsnNo: res.Output.Baseinfo.PsnNo,
  14402. PatientId: patient.ID,
  14403. Certno: res.Output.Baseinfo.Certno,
  14404. Gend: res.Output.Baseinfo.Gend,
  14405. Naty: res.Output.Baseinfo.Naty,
  14406. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14407. PsnName: res.Output.Baseinfo.PsnName,
  14408. Idetinfo: idetinfoStr,
  14409. Insuinfo: infoStr,
  14410. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14411. CardInfo: basStr,
  14412. InsuplcAdmdvs: insuplc_admdvs,
  14413. VerifyNumber: "",
  14414. }
  14415. service.CreateHisPsn(psn)
  14416. c.ServeSuccessJSON(map[string]interface{}{
  14417. "patient": patient,
  14418. "number": basNumber,
  14419. "insutype": insutype,
  14420. })
  14421. }
  14422. } else {
  14423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14424. return
  14425. }
  14426. } else if miConfig.MdtrtareaAdmvs == "361025" {
  14427. basStr := c.GetBasBaseInfo22222()
  14428. fmt.Println(basStr)
  14429. if len(basStr) == 0 {
  14430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14431. return
  14432. }
  14433. fmt.Println(basStr)
  14434. bas := strings.Split(basStr, "|")
  14435. basNumber := bas[2] //卡号
  14436. card_sn := bas[3] //
  14437. id_card_No := bas[1] //卡号
  14438. fmt.Println(basNumber)
  14439. fmt.Println(card_sn)
  14440. fmt.Println(id_card_No)
  14441. var patient service.Patients
  14442. if len(id_card_No) == 0 {
  14443. patient, _ = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14444. } else {
  14445. patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14446. }
  14447. 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)
  14448. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14449. var dat map[string]interface{}
  14450. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14451. fmt.Println(dat)
  14452. } else {
  14453. fmt.Println(err)
  14454. }
  14455. userJSONBytes, _ := json.Marshal(dat)
  14456. var res ResultTwo
  14457. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14458. utils.ErrorLog("解析失败:%v", err)
  14459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14460. return
  14461. }
  14462. if res.Infcode == 0 {
  14463. var pateint2 service.Patients
  14464. var err error
  14465. if len(id_card_No) == 0 {
  14466. pateint2, err = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14467. } else {
  14468. pateint2, err = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14469. //patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14470. }
  14471. if err == gorm.ErrRecordNotFound {
  14472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14473. return
  14474. } else if err != nil {
  14475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14476. return
  14477. } else {
  14478. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14479. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14480. infoStr := string(Iinfos)
  14481. idetinfoStr := string(Idetinfos)
  14482. var rf []*ResultFive
  14483. json.Unmarshal([]byte(infoStr), &rf)
  14484. var insutypes []*ResultFive
  14485. var insutype string
  14486. var is390 int = 0
  14487. var is310 int = 0
  14488. var insuplc_admdvs string
  14489. for _, item := range rf {
  14490. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14491. insutypes = append(insutypes, item)
  14492. }
  14493. }
  14494. if len(insutypes) == 1 {
  14495. insutype = insutypes[0].Insutype
  14496. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14497. } else {
  14498. for _, i := range insutypes {
  14499. if i.Insutype == "390" {
  14500. is390 = 1
  14501. }
  14502. if i.Insutype == "310" {
  14503. is310 = 1
  14504. }
  14505. }
  14506. }
  14507. if is390 == 1 {
  14508. insutype = "390"
  14509. }
  14510. if is310 == 1 {
  14511. insutype = "310"
  14512. }
  14513. if len(insutypes) == 0 {
  14514. insutype = "310"
  14515. }
  14516. for _, item := range rf {
  14517. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14518. insuplc_admdvs = item.InsuplcAdmdvs
  14519. }
  14520. }
  14521. psn := &models.HisPsn{
  14522. PsnNo: res.Output.Baseinfo.PsnNo,
  14523. PatientId: pateint2.ID,
  14524. Certno: res.Output.Baseinfo.Certno,
  14525. Gend: res.Output.Baseinfo.Gend,
  14526. Naty: res.Output.Baseinfo.Naty,
  14527. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14528. PsnName: res.Output.Baseinfo.PsnName,
  14529. Idetinfo: idetinfoStr,
  14530. Insuinfo: infoStr,
  14531. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14532. CardInfo: basStr,
  14533. InsuplcAdmdvs: insuplc_admdvs,
  14534. VerifyNumber: "",
  14535. }
  14536. service.CreateHisPsn(psn)
  14537. c.ServeSuccessJSON(map[string]interface{}{
  14538. "patient": patient,
  14539. "number": basNumber,
  14540. "insutype": insutype,
  14541. })
  14542. }
  14543. } else {
  14544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14545. return
  14546. }
  14547. } else if miConfig.MdtrtareaAdmvs == "360100" {
  14548. fmt.Println(initFlag)
  14549. fmt.Println("initFlag")
  14550. if initFlag == 0 {
  14551. c.TestGetJiangXiBasBaseInittwo()
  14552. }
  14553. basStr := c.GetBasBaseInfo()
  14554. if len(basStr) == 0 {
  14555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14556. return
  14557. }
  14558. fmt.Println(basStr)
  14559. bas := strings.Split(basStr, "|")
  14560. basNumber := bas[1]
  14561. fmt.Println(basNumber)
  14562. card_sn := bas[3]
  14563. fmt.Println(card_sn)
  14564. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14565. 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)
  14566. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14567. var dat map[string]interface{}
  14568. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14569. fmt.Println(dat)
  14570. } else {
  14571. fmt.Println(err)
  14572. }
  14573. userJSONBytes, _ := json.Marshal(dat)
  14574. var res ResultTwo
  14575. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14576. utils.ErrorLog("解析失败:%v", err)
  14577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14578. return
  14579. }
  14580. if res.Infcode == 0 {
  14581. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14582. if err == gorm.ErrRecordNotFound {
  14583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14584. return
  14585. } else if err != nil {
  14586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14587. return
  14588. } else {
  14589. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14590. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14591. infoStr := string(Iinfos)
  14592. idetinfoStr := string(Idetinfos)
  14593. var rf []*ResultFive
  14594. json.Unmarshal([]byte(infoStr), &rf)
  14595. var insutypes []*ResultFive
  14596. var insutype string
  14597. var is390 int = 0
  14598. var is310 int = 0
  14599. var insuplc_admdvs string
  14600. for _, item := range rf {
  14601. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14602. insutypes = append(insutypes, item)
  14603. }
  14604. }
  14605. if len(insutypes) == 1 {
  14606. insutype = insutypes[0].Insutype
  14607. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14608. } else {
  14609. for _, i := range insutypes {
  14610. if i.Insutype == "390" {
  14611. is390 = 1
  14612. }
  14613. if i.Insutype == "310" {
  14614. is310 = 1
  14615. }
  14616. }
  14617. }
  14618. if is390 == 1 {
  14619. insutype = "390"
  14620. }
  14621. if is310 == 1 {
  14622. insutype = "310"
  14623. }
  14624. if len(insutypes) == 0 {
  14625. insutype = "310"
  14626. }
  14627. for _, item := range rf {
  14628. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14629. insuplc_admdvs = item.InsuplcAdmdvs
  14630. }
  14631. }
  14632. psn := &models.HisPsn{
  14633. PsnNo: res.Output.Baseinfo.PsnNo,
  14634. PatientId: patient.ID,
  14635. Certno: res.Output.Baseinfo.Certno,
  14636. Gend: res.Output.Baseinfo.Gend,
  14637. Naty: res.Output.Baseinfo.Naty,
  14638. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14639. PsnName: res.Output.Baseinfo.PsnName,
  14640. Idetinfo: idetinfoStr,
  14641. Insuinfo: infoStr,
  14642. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14643. CardInfo: basStr,
  14644. InsuplcAdmdvs: insuplc_admdvs,
  14645. VerifyNumber: "",
  14646. }
  14647. service.CreateHisPsn(psn)
  14648. c.ServeSuccessJSON(map[string]interface{}{
  14649. "patient": patient,
  14650. "number": basNumber,
  14651. "insutype": insutype,
  14652. })
  14653. }
  14654. } else {
  14655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14656. return
  14657. }
  14658. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14659. fmt.Println(initFlag)
  14660. fmt.Println("initFlag")
  14661. if initFlag == 0 {
  14662. c.TestGetHnBasBaseInit()
  14663. }
  14664. basStr := c.GetBasBaseInfo()
  14665. if len(basStr) == 0 {
  14666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14667. return
  14668. }
  14669. fmt.Println(basStr)
  14670. bas := strings.Split(basStr, "|")
  14671. basNumber := bas[1]
  14672. fmt.Println(basNumber)
  14673. card_sn := bas[3]
  14674. card_no := bas[2]
  14675. fmt.Println(card_sn)
  14676. name := bas[4]
  14677. name = ConvertToString(name, "gbk", "utf-8")
  14678. 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)
  14679. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14680. var dat map[string]interface{}
  14681. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14682. fmt.Println(dat)
  14683. } else {
  14684. fmt.Println(err)
  14685. }
  14686. userJSONBytes, _ := json.Marshal(dat)
  14687. var res ResultTwo
  14688. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14689. utils.ErrorLog("解析失败:%v", err)
  14690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14691. return
  14692. }
  14693. if res.Infcode == 0 {
  14694. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14695. if err == gorm.ErrRecordNotFound {
  14696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14697. return
  14698. } else if err != nil {
  14699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14700. return
  14701. } else {
  14702. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14703. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14704. infoStr := string(Iinfos)
  14705. idetinfoStr := string(Idetinfos)
  14706. psn := &models.HisPsn{
  14707. PsnNo: res.Output.Baseinfo.PsnNo,
  14708. PatientId: patient.ID,
  14709. Certno: res.Output.Baseinfo.Certno,
  14710. Gend: res.Output.Baseinfo.Gend,
  14711. Naty: res.Output.Baseinfo.Naty,
  14712. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14713. PsnName: res.Output.Baseinfo.PsnName,
  14714. Idetinfo: idetinfoStr,
  14715. Insuinfo: infoStr,
  14716. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14717. CardInfo: basStr,
  14718. VerifyNumber: "",
  14719. }
  14720. service.CreateHisPsn(psn)
  14721. var rf []*ResultFive
  14722. json.Unmarshal([]byte(infoStr), &rf)
  14723. var insutypes []*ResultFive
  14724. var insutype string
  14725. var is390 int = 0
  14726. var is310 int = 0
  14727. for _, item := range rf {
  14728. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14729. insutypes = append(insutypes, item)
  14730. }
  14731. }
  14732. if len(insutypes) == 1 {
  14733. insutype = insutypes[0].Insutype
  14734. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14735. } else {
  14736. for _, i := range insutypes {
  14737. if i.Insutype == "390" {
  14738. is390 = 1
  14739. }
  14740. if i.Insutype == "310" {
  14741. is310 = 1
  14742. }
  14743. }
  14744. }
  14745. if is390 == 1 {
  14746. insutype = "390"
  14747. }
  14748. if is310 == 1 {
  14749. insutype = "310"
  14750. }
  14751. if len(insutypes) == 0 {
  14752. insutype = "310"
  14753. }
  14754. c.ServeSuccessJSON(map[string]interface{}{
  14755. "patient": patient,
  14756. "number": basNumber,
  14757. "insutype": insutype,
  14758. })
  14759. }
  14760. } else {
  14761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14762. return
  14763. }
  14764. } else if miConfig.MdtrtareaAdmvs == "150499" {
  14765. var api string
  14766. 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 +
  14767. "&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
  14768. fmt.Println(api)
  14769. resp, requestErr := http.Get(api)
  14770. if requestErr != nil {
  14771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14772. return
  14773. }
  14774. body, ioErr := ioutil.ReadAll(resp.Body)
  14775. if ioErr != nil {
  14776. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14778. return
  14779. }
  14780. var respJSON map[string]interface{}
  14781. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14782. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14784. return
  14785. }
  14786. var res ResultTwo //1101结果
  14787. var res10265 ResultTwo10265 //1101结果
  14788. var card_info string //卡信息
  14789. token := respJSON["data"].(map[string]interface{})["token"].(string)
  14790. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14791. result, _ := json.Marshal(respJSON)
  14792. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14793. utils.ErrorLog("解析失败:%v", err)
  14794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14795. return
  14796. }
  14797. res.ErrMsg = res10265.ErrMsg
  14798. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14799. res.Infcode = infocode
  14800. res.Output = res10265.Output
  14801. res.InfRefmsgid = res10265.InfRefmsgid
  14802. if res.Infcode == 0 {
  14803. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14804. if err == gorm.ErrRecordNotFound {
  14805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14806. return
  14807. } else if err != nil {
  14808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14809. return
  14810. } else {
  14811. bas := strings.Split(card_info, "|")
  14812. basNumber := bas[2]
  14813. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14814. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14815. infoStr := string(Iinfos)
  14816. idetinfoStr := string(Idetinfos)
  14817. psn := &models.HisPsn{
  14818. PsnNo: res.Output.Baseinfo.PsnNo,
  14819. PatientId: patient.ID,
  14820. Certno: res.Output.Baseinfo.Certno,
  14821. Gend: res.Output.Baseinfo.Gend,
  14822. Naty: res.Output.Baseinfo.Naty,
  14823. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14824. PsnName: res.Output.Baseinfo.PsnName,
  14825. Idetinfo: idetinfoStr,
  14826. Insuinfo: infoStr,
  14827. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14828. CardInfo: card_info,
  14829. VerifyNumber: token,
  14830. }
  14831. service.CreateHisPsn(psn)
  14832. var rf []*ResultFive
  14833. json.Unmarshal([]byte(infoStr), &rf)
  14834. var insutypes []*ResultFive
  14835. var insutype string
  14836. var is390 int = 0
  14837. var is310 int = 0
  14838. for _, item := range rf {
  14839. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14840. insutypes = append(insutypes, item)
  14841. }
  14842. }
  14843. if len(insutypes) == 1 {
  14844. insutype = insutypes[0].Insutype
  14845. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14846. } else {
  14847. for _, i := range insutypes {
  14848. if i.Insutype == "390" {
  14849. is390 = 1
  14850. }
  14851. if i.Insutype == "310" {
  14852. is310 = 1
  14853. }
  14854. }
  14855. }
  14856. if is390 == 1 {
  14857. insutype = "390"
  14858. }
  14859. if is310 == 1 {
  14860. insutype = "310"
  14861. }
  14862. if len(insutypes) == 0 {
  14863. insutype = "310"
  14864. }
  14865. c.ServeSuccessJSON(map[string]interface{}{
  14866. "patient": patient,
  14867. "number": basNumber,
  14868. "insutype": insutype,
  14869. })
  14870. }
  14871. } else {
  14872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14873. return
  14874. }
  14875. } else if miConfig.MdtrtareaAdmvs == "450721" {
  14876. res := c.GetoleInfo()
  14877. if res.Infcode == 0 {
  14878. var result string
  14879. if res.Output.MdtrtCertType == "01" {
  14880. 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)
  14881. } else if res.Output.MdtrtCertType == "02" {
  14882. 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)
  14883. } else if res.Output.MdtrtCertType == "03" {
  14884. 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)
  14885. }
  14886. var dat map[string]interface{}
  14887. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14888. fmt.Println(dat)
  14889. } else {
  14890. fmt.Println(err)
  14891. }
  14892. userJSONBytes, _ := json.Marshal(dat)
  14893. var res2 ResultTwo
  14894. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14895. utils.ErrorLog("解析失败:%v", err)
  14896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14897. return
  14898. }
  14899. if res2.Infcode == 0 {
  14900. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14901. if err == gorm.ErrRecordNotFound {
  14902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14903. return
  14904. } else if err != nil {
  14905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14906. return
  14907. } else {
  14908. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14909. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14910. infoStr := string(Iinfos)
  14911. idetinfoStr := string(Idetinfos)
  14912. var rf []*ResultFive
  14913. json.Unmarshal([]byte(infoStr), &rf)
  14914. var insutypes []*ResultFive
  14915. var insutype string
  14916. var is390 int = 0
  14917. var is310 int = 0
  14918. //var insuplc_admdvs string
  14919. for _, item := range rf {
  14920. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14921. insutypes = append(insutypes, item)
  14922. }
  14923. }
  14924. if len(insutypes) == 1 {
  14925. insutype = insutypes[0].Insutype
  14926. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14927. } else {
  14928. for _, i := range insutypes {
  14929. if i.Insutype == "390" {
  14930. is390 = 1
  14931. }
  14932. if i.Insutype == "310" {
  14933. is310 = 1
  14934. }
  14935. }
  14936. }
  14937. if is390 == 1 {
  14938. insutype = "390"
  14939. }
  14940. if is310 == 1 {
  14941. insutype = "310"
  14942. }
  14943. if len(insutypes) == 0 {
  14944. insutype = "310"
  14945. }
  14946. psn := &models.HisPsn{
  14947. PsnNo: res2.Output.Baseinfo.PsnNo,
  14948. PatientId: patient.ID,
  14949. Certno: res2.Output.Baseinfo.Certno,
  14950. Gend: res2.Output.Baseinfo.Gend,
  14951. Naty: res2.Output.Baseinfo.Naty,
  14952. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14953. PsnName: res2.Output.Baseinfo.PsnName,
  14954. Idetinfo: idetinfoStr,
  14955. Insuinfo: infoStr,
  14956. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14957. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14958. VerifyNumber: res.Output.EcToken,
  14959. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14960. }
  14961. if res.Output.MdtrtCertType == "01" {
  14962. psn.VerifyNumber = res.Output.EcToken
  14963. //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)
  14964. } else if res.Output.MdtrtCertType == "02" {
  14965. psn.VerifyNumber = res.Output.MdtrtCertNo
  14966. //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)
  14967. } else if res.Output.MdtrtCertType == "03" {
  14968. psn.VerifyNumber = res.Output.MdtrtCertNo
  14969. //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)
  14970. }
  14971. var balc float64
  14972. for _, item := range rf {
  14973. if item.Insutype == insutype {
  14974. balc = item.Balc
  14975. }
  14976. }
  14977. service.CreateHisPsn(psn)
  14978. c.ServeSuccessJSON(map[string]interface{}{
  14979. "patient": patient,
  14980. "number": res.Output.CardNo,
  14981. "insutype": insutype,
  14982. "blac": balc,
  14983. "desc": idetinfoStr,
  14984. })
  14985. }
  14986. } else {
  14987. c.ServeSuccessJSON(map[string]interface{}{
  14988. "failed_code": -10,
  14989. "msg": res2.ErrMsg,
  14990. })
  14991. }
  14992. } else {
  14993. c.ServeSuccessJSON(map[string]interface{}{
  14994. "failed_code": -10,
  14995. "msg": res.ErrMsg,
  14996. })
  14997. }
  14998. } else if miConfig.MdtrtareaAdmvs == "341203" {
  14999. var api string
  15000. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15001. "&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
  15002. fmt.Println(api)
  15003. resp, requestErr := http.Get(api)
  15004. if requestErr != nil {
  15005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15006. return
  15007. }
  15008. body, ioErr := ioutil.ReadAll(resp.Body)
  15009. if ioErr != nil {
  15010. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15012. return
  15013. }
  15014. var respJSON map[string]interface{}
  15015. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15016. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15018. return
  15019. }
  15020. var status string
  15021. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15022. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15023. //console.log()
  15024. fmt.Println("type===")
  15025. fmt.Println(card_type)
  15026. var token string
  15027. var res ResultTwo //1101结果
  15028. //var res10265 ResultTwoesultTwo10265 //1101结果
  15029. var card_info string //卡信息
  15030. var busi_card_info string
  15031. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15032. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15033. if status == "0" { //读卡成功
  15034. if card_type == "1" {
  15035. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15036. result, _ := json.Marshal(respJSON)
  15037. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15038. utils.ErrorLog("解析失败:%v", err)
  15039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15040. return
  15041. }
  15042. } else {
  15043. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15044. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15045. result, _ := json.Marshal(respJSON)
  15046. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15047. utils.ErrorLog("解析失败:%v", err)
  15048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15049. return
  15050. }
  15051. }
  15052. if res.Infcode == 0 {
  15053. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15054. if err == gorm.ErrRecordNotFound {
  15055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15056. return
  15057. } else if err != nil {
  15058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15059. return
  15060. } else {
  15061. if card_type == "1" {
  15062. bas := strings.Split(card_info, "|")
  15063. basNumber := bas[2]
  15064. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15065. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15066. infoStr := string(Iinfos)
  15067. idetinfoStr := string(Idetinfos)
  15068. psn := &models.HisPsn{
  15069. PsnNo: res.Output.Baseinfo.PsnNo,
  15070. PatientId: patient.ID,
  15071. Certno: res.Output.Baseinfo.Certno,
  15072. Gend: res.Output.Baseinfo.Gend,
  15073. Naty: res.Output.Baseinfo.Naty,
  15074. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15075. PsnName: res.Output.Baseinfo.PsnName,
  15076. Idetinfo: idetinfoStr,
  15077. Insuinfo: infoStr,
  15078. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15079. CardInfo: card_info,
  15080. VerifyNumber: busi_card_info,
  15081. }
  15082. service.CreateHisPsn(psn)
  15083. var rf []*ResultFive
  15084. json.Unmarshal([]byte(infoStr), &rf)
  15085. var insutypes []*ResultFive
  15086. var insutype string
  15087. var is390 int = 0
  15088. var is310 int = 0
  15089. for _, item := range rf {
  15090. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15091. insutypes = append(insutypes, item)
  15092. }
  15093. }
  15094. if len(insutypes) == 1 {
  15095. insutype = insutypes[0].Insutype
  15096. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15097. } else {
  15098. for _, i := range insutypes {
  15099. if i.Insutype == "390" {
  15100. is390 = 1
  15101. }
  15102. if i.Insutype == "310" {
  15103. is310 = 1
  15104. }
  15105. }
  15106. }
  15107. if is390 == 1 {
  15108. insutype = "390"
  15109. }
  15110. if is310 == 1 {
  15111. insutype = "310"
  15112. }
  15113. if len(insutypes) == 0 {
  15114. insutype = "310"
  15115. }
  15116. c.ServeSuccessJSON(map[string]interface{}{
  15117. "patient": patient,
  15118. "number": basNumber,
  15119. "insutype": insutype,
  15120. })
  15121. } else {
  15122. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15123. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15124. infoStr := string(Iinfos)
  15125. idetinfoStr := string(Idetinfos)
  15126. psn := &models.HisPsn{
  15127. PsnNo: res.Output.Baseinfo.PsnNo,
  15128. PatientId: patient.ID,
  15129. Certno: res.Output.Baseinfo.Certno,
  15130. Gend: res.Output.Baseinfo.Gend,
  15131. Naty: res.Output.Baseinfo.Naty,
  15132. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15133. PsnName: res.Output.Baseinfo.PsnName,
  15134. Idetinfo: idetinfoStr,
  15135. Insuinfo: infoStr,
  15136. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15137. CardInfo: card_info,
  15138. VerifyNumber: token,
  15139. }
  15140. service.CreateHisPsn(psn)
  15141. c.ServeSuccessJSON(map[string]interface{}{
  15142. "patient": patient,
  15143. "number": token,
  15144. })
  15145. }
  15146. }
  15147. } else {
  15148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15149. return
  15150. }
  15151. } else { //读卡失败
  15152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15153. return
  15154. }
  15155. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15156. var api string
  15157. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15158. "&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
  15159. fmt.Println(api)
  15160. resp, requestErr := http.Get(api)
  15161. if requestErr != nil {
  15162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15163. return
  15164. }
  15165. body, ioErr := ioutil.ReadAll(resp.Body)
  15166. if ioErr != nil {
  15167. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15169. return
  15170. }
  15171. var respJSON map[string]interface{}
  15172. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15173. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15175. return
  15176. }
  15177. var status string
  15178. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15179. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15180. //console.log()
  15181. fmt.Println("type===")
  15182. fmt.Println(card_type)
  15183. var token string
  15184. var res ResultTwo //1101结果
  15185. //var res10265 ResultTwoesultTwo10265 //1101结果
  15186. var card_info string //卡信息
  15187. //var busi_card_info string
  15188. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15189. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15190. if status == "0" { //读卡成功
  15191. if card_type == "1" {
  15192. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15193. result, _ := json.Marshal(respJSON)
  15194. fmt.Println(result)
  15195. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15196. utils.ErrorLog("解析失败:%v", err)
  15197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15198. return
  15199. }
  15200. fmt.Println(res)
  15201. } else {
  15202. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15203. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15204. result, _ := json.Marshal(respJSON)
  15205. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15206. utils.ErrorLog("解析失败:%v", err)
  15207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15208. return
  15209. }
  15210. }
  15211. if res.Infcode == 0 {
  15212. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15213. if err == gorm.ErrRecordNotFound {
  15214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15215. return
  15216. } else if err != nil {
  15217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15218. return
  15219. } else {
  15220. if card_type == "1" {
  15221. bas := strings.Split(card_info, "|")
  15222. basNumber := bas[2]
  15223. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15224. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15225. infoStr := string(Iinfos)
  15226. idetinfoStr := string(Idetinfos)
  15227. psn := &models.HisPsn{
  15228. PsnNo: res.Output.Baseinfo.PsnNo,
  15229. PatientId: patient.ID,
  15230. Certno: res.Output.Baseinfo.Certno,
  15231. Gend: res.Output.Baseinfo.Gend,
  15232. Naty: res.Output.Baseinfo.Naty,
  15233. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15234. PsnName: res.Output.Baseinfo.PsnName,
  15235. Idetinfo: idetinfoStr,
  15236. Insuinfo: infoStr,
  15237. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15238. CardInfo: card_info,
  15239. //VerifyNumber: busi_card_info,
  15240. }
  15241. service.CreateHisPsn(psn)
  15242. var rf []*ResultFive
  15243. json.Unmarshal([]byte(infoStr), &rf)
  15244. var insutypes []*ResultFive
  15245. var insutype string
  15246. var is390 int = 0
  15247. var is310 int = 0
  15248. for _, item := range rf {
  15249. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15250. insutypes = append(insutypes, item)
  15251. }
  15252. }
  15253. if len(insutypes) == 1 {
  15254. insutype = insutypes[0].Insutype
  15255. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15256. } else {
  15257. for _, i := range insutypes {
  15258. if i.Insutype == "390" {
  15259. is390 = 1
  15260. }
  15261. if i.Insutype == "310" {
  15262. is310 = 1
  15263. }
  15264. }
  15265. }
  15266. if is390 == 1 {
  15267. insutype = "390"
  15268. }
  15269. if is310 == 1 {
  15270. insutype = "310"
  15271. }
  15272. if len(insutypes) == 0 {
  15273. insutype = "310"
  15274. }
  15275. c.ServeSuccessJSON(map[string]interface{}{
  15276. "patient": patient,
  15277. "number": basNumber,
  15278. "insutype": insutype,
  15279. })
  15280. } else {
  15281. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15282. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15283. infoStr := string(Iinfos)
  15284. idetinfoStr := string(Idetinfos)
  15285. psn := &models.HisPsn{
  15286. PsnNo: res.Output.Baseinfo.PsnNo,
  15287. PatientId: patient.ID,
  15288. Certno: res.Output.Baseinfo.Certno,
  15289. Gend: res.Output.Baseinfo.Gend,
  15290. Naty: res.Output.Baseinfo.Naty,
  15291. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15292. PsnName: res.Output.Baseinfo.PsnName,
  15293. Idetinfo: idetinfoStr,
  15294. Insuinfo: infoStr,
  15295. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15296. CardInfo: card_info,
  15297. VerifyNumber: token,
  15298. }
  15299. service.CreateHisPsn(psn)
  15300. c.ServeSuccessJSON(map[string]interface{}{
  15301. "patient": patient,
  15302. "number": token,
  15303. })
  15304. }
  15305. }
  15306. } else {
  15307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15308. return
  15309. }
  15310. } else { //读卡失败
  15311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15312. return
  15313. }
  15314. } else {
  15315. if initFlag == 0 {
  15316. c.TestGetBasBaseInit()
  15317. }
  15318. basStr := c.GetBasBaseInfo()
  15319. if len(basStr) == 0 {
  15320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15321. return
  15322. }
  15323. fmt.Println(basStr)
  15324. bas := strings.Split(basStr, "|")
  15325. basNumber := bas[1]
  15326. fmt.Println(basNumber)
  15327. card_sn := bas[3]
  15328. fmt.Println(card_sn)
  15329. cardNumber := bas[2]
  15330. fmt.Println(cardNumber)
  15331. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  15332. var result string
  15333. if bas[0][:2] == "44" {
  15334. 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)
  15335. } else {
  15336. 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)
  15337. }
  15338. var dat map[string]interface{}
  15339. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15340. fmt.Println(dat)
  15341. } else {
  15342. fmt.Println(err)
  15343. }
  15344. userJSONBytes, _ := json.Marshal(dat)
  15345. var res ResultTwo
  15346. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15347. utils.ErrorLog("解析失败:%v", err)
  15348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15349. return
  15350. }
  15351. if res.Infcode == 0 {
  15352. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  15353. if err == gorm.ErrRecordNotFound {
  15354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15355. return
  15356. } else if err != nil {
  15357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15358. return
  15359. } else {
  15360. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15361. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15362. infoStr := string(Iinfos)
  15363. idetinfoStr := string(Idetinfos)
  15364. var rf []*ResultFive
  15365. json.Unmarshal([]byte(infoStr), &rf)
  15366. var insutypes []*ResultFive
  15367. var insutype string
  15368. var is390 int = 0
  15369. var is310 int = 0
  15370. var insuplc_admdvs string
  15371. for _, item := range rf {
  15372. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15373. insutypes = append(insutypes, item)
  15374. }
  15375. }
  15376. if len(insutypes) == 1 {
  15377. insutype = insutypes[0].Insutype
  15378. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15379. } else {
  15380. for _, i := range insutypes {
  15381. if i.Insutype == "390" {
  15382. is390 = 1
  15383. }
  15384. if i.Insutype == "310" {
  15385. is310 = 1
  15386. }
  15387. }
  15388. }
  15389. if is390 == 1 {
  15390. insutype = "390"
  15391. }
  15392. if is310 == 1 {
  15393. insutype = "310"
  15394. }
  15395. if len(insutypes) == 0 {
  15396. insutype = "310"
  15397. }
  15398. for _, item := range rf {
  15399. if item.Insutype == insutype {
  15400. insuplc_admdvs = item.InsuplcAdmdvs
  15401. }
  15402. }
  15403. psn := &models.HisPsn{
  15404. PsnNo: res.Output.Baseinfo.PsnNo,
  15405. PatientId: patient.ID,
  15406. Certno: res.Output.Baseinfo.Certno,
  15407. Gend: res.Output.Baseinfo.Gend,
  15408. Naty: res.Output.Baseinfo.Naty,
  15409. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15410. PsnName: res.Output.Baseinfo.PsnName,
  15411. Idetinfo: idetinfoStr,
  15412. Insuinfo: infoStr,
  15413. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15414. CardInfo: basStr,
  15415. VerifyNumber: "",
  15416. InsuplcAdmdvs: insuplc_admdvs,
  15417. }
  15418. service.CreateHisPsn(psn)
  15419. c.ServeSuccessJSON(map[string]interface{}{
  15420. "patient": patient,
  15421. "insutype": insutype,
  15422. "number": basNumber,
  15423. })
  15424. }
  15425. } else {
  15426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15427. return
  15428. }
  15429. break
  15430. }
  15431. case 2:
  15432. if miConfig.MdtrtareaAdmvs == "430800" {
  15433. if initFlag == 0 {
  15434. c.TestGetHnBasBaseInit()
  15435. }
  15436. SFZStr := c.GetSFZBaseInfo()
  15437. if len(SFZStr) == 0 {
  15438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15439. return
  15440. }
  15441. fmt.Println(SFZStr)
  15442. id_card_str := strings.Split(SFZStr, "^")
  15443. card_no := id_card_str[0]
  15444. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  15445. //name := id_card_str[1]
  15446. //name = ConvertToString(name, "gbk", "utf-8")
  15447. 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)
  15448. var dat map[string]interface{}
  15449. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15450. fmt.Println(dat)
  15451. } else {
  15452. fmt.Println(err)
  15453. }
  15454. userJSONBytes, _ := json.Marshal(dat)
  15455. var res ResultTwo
  15456. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15457. utils.ErrorLog("解析失败:%v", err)
  15458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15459. return
  15460. }
  15461. if res.Infcode == 0 {
  15462. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  15463. if err == gorm.ErrRecordNotFound {
  15464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15465. return
  15466. } else if err != nil {
  15467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15468. return
  15469. } else {
  15470. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15471. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15472. infoStr := string(Iinfos)
  15473. idetinfoStr := string(Idetinfos)
  15474. var rf []*ResultFive
  15475. json.Unmarshal([]byte(infoStr), &rf)
  15476. var insutypes []*ResultFive
  15477. var insutype string
  15478. var is390 int = 0
  15479. var is310 int = 0
  15480. for _, item := range rf {
  15481. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15482. insutypes = append(insutypes, item)
  15483. }
  15484. }
  15485. if len(insutypes) == 1 {
  15486. insutype = insutypes[0].Insutype
  15487. } else {
  15488. for _, i := range insutypes {
  15489. if i.Insutype == "390" {
  15490. is390 = 1
  15491. }
  15492. if i.Insutype == "310" {
  15493. is310 = 1
  15494. }
  15495. }
  15496. }
  15497. if is390 == 1 {
  15498. insutype = "390"
  15499. }
  15500. if is310 == 1 {
  15501. insutype = "310"
  15502. }
  15503. if len(insutypes) == 0 {
  15504. insutype = "310"
  15505. }
  15506. var InsuplcAdmdvs string
  15507. for _, item := range rf {
  15508. if item.Insutype == insutype {
  15509. InsuplcAdmdvs = item.InsuplcAdmdvs
  15510. }
  15511. }
  15512. psn := &models.HisPsn{
  15513. PsnNo: res.Output.Baseinfo.PsnNo,
  15514. PatientId: patient.ID,
  15515. Certno: res.Output.Baseinfo.Certno,
  15516. Gend: res.Output.Baseinfo.Gend,
  15517. Naty: res.Output.Baseinfo.Naty,
  15518. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15519. PsnName: res.Output.Baseinfo.PsnName,
  15520. Idetinfo: idetinfoStr,
  15521. Insuinfo: infoStr,
  15522. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15523. CardInfo: SFZStr,
  15524. VerifyNumber: "",
  15525. InsuplcAdmdvs: InsuplcAdmdvs,
  15526. }
  15527. service.CreateHisPsn(psn)
  15528. c.ServeSuccessJSON(map[string]interface{}{
  15529. "patient": patient,
  15530. "number": card_no,
  15531. "insutype": insutype,
  15532. })
  15533. }
  15534. } else {
  15535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15536. return
  15537. }
  15538. } else if miConfig.MdtrtareaAdmvs == "420200" {
  15539. var res ResultTwo
  15540. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  15541. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15542. "&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)
  15543. resp, requestErr := http.Get(api)
  15544. if requestErr != nil {
  15545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15546. return
  15547. }
  15548. body, ioErr := ioutil.ReadAll(resp.Body)
  15549. if ioErr != nil {
  15550. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15552. return
  15553. }
  15554. var respJSON map[string]interface{}
  15555. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15556. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15558. return
  15559. }
  15560. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15561. result, _ := json.Marshal(respJSON)
  15562. fmt.Println("log")
  15563. fmt.Println(string(result))
  15564. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15565. utils.ErrorLog("解析失败:%v", err)
  15566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15567. return
  15568. }
  15569. if res.Infcode == 0 {
  15570. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15571. if err == gorm.ErrRecordNotFound {
  15572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15573. return
  15574. } else if err != nil {
  15575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15576. return
  15577. } else {
  15578. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15579. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15580. infoStr := string(Iinfos)
  15581. idetinfoStr := string(Idetinfos)
  15582. psn := &models.HisPsn{
  15583. PsnNo: res.Output.Baseinfo.PsnNo,
  15584. PatientId: patient.ID,
  15585. Certno: res.Output.Baseinfo.Certno,
  15586. Gend: res.Output.Baseinfo.Gend,
  15587. Naty: res.Output.Baseinfo.Naty,
  15588. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15589. PsnName: res.Output.Baseinfo.PsnName,
  15590. Idetinfo: idetinfoStr,
  15591. Insuinfo: infoStr,
  15592. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15593. }
  15594. service.CreateHisPsn(psn)
  15595. c.ServeSuccessJSON(map[string]interface{}{
  15596. "patient": patient,
  15597. "number": res.Output.Baseinfo.Certno,
  15598. })
  15599. }
  15600. } else {
  15601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15602. return
  15603. }
  15604. } else if miConfig.MdtrtareaAdmvs == "421182" {
  15605. var res ResultTwo
  15606. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  15607. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15608. "&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)
  15609. resp, requestErr := http.Get(api)
  15610. if requestErr != nil {
  15611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15612. return
  15613. }
  15614. body, ioErr := ioutil.ReadAll(resp.Body)
  15615. if ioErr != nil {
  15616. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15618. return
  15619. }
  15620. var respJSON map[string]interface{}
  15621. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15622. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15624. return
  15625. }
  15626. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15627. result, _ := json.Marshal(respJSON)
  15628. fmt.Println("log")
  15629. fmt.Println(string(result))
  15630. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15631. utils.ErrorLog("解析失败:%v", err)
  15632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15633. return
  15634. }
  15635. if res.Infcode == 0 {
  15636. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15637. if err == gorm.ErrRecordNotFound {
  15638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15639. return
  15640. } else if err != nil {
  15641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15642. return
  15643. } else {
  15644. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15645. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15646. infoStr := string(Iinfos)
  15647. idetinfoStr := string(Idetinfos)
  15648. psn := &models.HisPsn{
  15649. PsnNo: res.Output.Baseinfo.PsnNo,
  15650. PatientId: patient.ID,
  15651. Certno: res.Output.Baseinfo.Certno,
  15652. Gend: res.Output.Baseinfo.Gend,
  15653. Naty: res.Output.Baseinfo.Naty,
  15654. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15655. PsnName: res.Output.Baseinfo.PsnName,
  15656. Idetinfo: idetinfoStr,
  15657. Insuinfo: infoStr,
  15658. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15659. }
  15660. service.CreateHisPsn(psn)
  15661. c.ServeSuccessJSON(map[string]interface{}{
  15662. "patient": patient,
  15663. "number": res.Output.Baseinfo.Certno,
  15664. })
  15665. }
  15666. } else {
  15667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15668. return
  15669. }
  15670. } else if miConfig.MdtrtareaAdmvs == "420902" {
  15671. var res ResultTwo
  15672. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  15673. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15674. "&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)
  15675. resp, requestErr := http.Get(api)
  15676. if requestErr != nil {
  15677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15678. return
  15679. }
  15680. body, ioErr := ioutil.ReadAll(resp.Body)
  15681. if ioErr != nil {
  15682. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15684. return
  15685. }
  15686. var respJSON map[string]interface{}
  15687. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15688. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15690. return
  15691. }
  15692. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15693. result, _ := json.Marshal(respJSON)
  15694. fmt.Println("log")
  15695. fmt.Println(string(result))
  15696. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15697. utils.ErrorLog("解析失败:%v", err)
  15698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15699. return
  15700. }
  15701. if res.Infcode == 0 {
  15702. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15703. if err == gorm.ErrRecordNotFound {
  15704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15705. return
  15706. } else if err != nil {
  15707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15708. return
  15709. } else {
  15710. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15711. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15712. infoStr := string(Iinfos)
  15713. idetinfoStr := string(Idetinfos)
  15714. var rf []*ResultFive
  15715. json.Unmarshal([]byte(infoStr), &rf)
  15716. var insutypes []*ResultFive
  15717. var insutype string
  15718. var is390 int = 0
  15719. var is310 int = 0
  15720. for _, item := range rf {
  15721. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  15722. insutypes = append(insutypes, item)
  15723. }
  15724. }
  15725. if len(insutypes) == 1 {
  15726. insutype = insutypes[0].Insutype
  15727. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15728. } else {
  15729. for _, i := range insutypes {
  15730. if i.Insutype == "390" {
  15731. is390 = 1
  15732. }
  15733. if i.Insutype == "310" {
  15734. is310 = 1
  15735. }
  15736. }
  15737. }
  15738. if is390 == 1 {
  15739. insutype = "390"
  15740. }
  15741. if is310 == 1 {
  15742. insutype = "310"
  15743. }
  15744. if len(insutypes) == 0 {
  15745. insutype = "390"
  15746. }
  15747. var insuplc_admdvs string
  15748. for _, item := range rf {
  15749. if item.Insutype == insutype {
  15750. insuplc_admdvs = item.InsuplcAdmdvs
  15751. }
  15752. }
  15753. psn := &models.HisPsn{
  15754. PsnNo: res.Output.Baseinfo.PsnNo,
  15755. PatientId: patient.ID,
  15756. Certno: res.Output.Baseinfo.Certno,
  15757. Gend: res.Output.Baseinfo.Gend,
  15758. Naty: res.Output.Baseinfo.Naty,
  15759. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15760. PsnName: res.Output.Baseinfo.PsnName,
  15761. Idetinfo: idetinfoStr,
  15762. Insuinfo: infoStr,
  15763. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15764. InsuplcAdmdvs: insuplc_admdvs,
  15765. }
  15766. service.CreateHisPsn(psn)
  15767. c.ServeSuccessJSON(map[string]interface{}{
  15768. "patient": patient,
  15769. "number": res.Output.Baseinfo.Certno,
  15770. })
  15771. }
  15772. } else {
  15773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15774. return
  15775. }
  15776. } else if miConfig.MdtrtareaAdmvs == "450721" {
  15777. res := c.GetoleInfo()
  15778. if res.Infcode == 0 {
  15779. var result string
  15780. if res.Output.MdtrtCertType == "01" {
  15781. 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)
  15782. } else if res.Output.MdtrtCertType == "02" {
  15783. 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)
  15784. } else if res.Output.MdtrtCertType == "03" {
  15785. 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)
  15786. }
  15787. var dat map[string]interface{}
  15788. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15789. fmt.Println(dat)
  15790. } else {
  15791. fmt.Println(err)
  15792. }
  15793. userJSONBytes, _ := json.Marshal(dat)
  15794. var res2 ResultTwo
  15795. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15796. utils.ErrorLog("解析失败:%v", err)
  15797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15798. return
  15799. }
  15800. if res2.Infcode == 0 {
  15801. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  15802. if err == gorm.ErrRecordNotFound {
  15803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15804. return
  15805. } else if err != nil {
  15806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15807. return
  15808. } else {
  15809. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  15810. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  15811. infoStr := string(Iinfos)
  15812. idetinfoStr := string(Idetinfos)
  15813. var rf []*ResultFive
  15814. json.Unmarshal([]byte(infoStr), &rf)
  15815. var insutypes []*ResultFive
  15816. var insutype string
  15817. var is390 int = 0
  15818. var is310 int = 0
  15819. //var insuplc_admdvs string
  15820. for _, item := range rf {
  15821. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15822. insutypes = append(insutypes, item)
  15823. }
  15824. }
  15825. if len(insutypes) == 1 {
  15826. insutype = insutypes[0].Insutype
  15827. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15828. } else {
  15829. for _, i := range insutypes {
  15830. if i.Insutype == "390" {
  15831. is390 = 1
  15832. }
  15833. if i.Insutype == "310" {
  15834. is310 = 1
  15835. }
  15836. }
  15837. }
  15838. if is390 == 1 {
  15839. insutype = "390"
  15840. }
  15841. if is310 == 1 {
  15842. insutype = "310"
  15843. }
  15844. if len(insutypes) == 0 {
  15845. insutype = "310"
  15846. }
  15847. psn := &models.HisPsn{
  15848. PsnNo: res2.Output.Baseinfo.PsnNo,
  15849. PatientId: patient.ID,
  15850. //Brdy: res2.Output.Baseinfo.Brdy,
  15851. Certno: res2.Output.Baseinfo.Certno,
  15852. Gend: res2.Output.Baseinfo.Gend,
  15853. Naty: res2.Output.Baseinfo.Naty,
  15854. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  15855. PsnName: res2.Output.Baseinfo.PsnName,
  15856. Idetinfo: idetinfoStr,
  15857. Insuinfo: infoStr,
  15858. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15859. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  15860. VerifyNumber: res.Output.EcToken,
  15861. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  15862. }
  15863. service.CreateHisPsn(psn)
  15864. var balc float64
  15865. for _, item := range rf {
  15866. if item.Insutype == insutype {
  15867. balc = item.Balc
  15868. }
  15869. }
  15870. c.ServeSuccessJSON(map[string]interface{}{
  15871. "patient": patient,
  15872. "number": res.Output.CardNo,
  15873. "insutype": insutype,
  15874. "blac": balc,
  15875. "desc": idetinfoStr,
  15876. })
  15877. }
  15878. } else {
  15879. c.ServeSuccessJSON(map[string]interface{}{
  15880. "failed_code": -10,
  15881. "msg": res2.ErrMsg,
  15882. })
  15883. }
  15884. } else {
  15885. c.ServeSuccessJSON(map[string]interface{}{
  15886. "failed_code": -10,
  15887. "msg": res.ErrMsg,
  15888. })
  15889. }
  15890. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15891. var insuplc_admdvs string
  15892. if len(patient.InsuplcAdmdvs) > 0 {
  15893. insuplc_admdvs = patient.InsuplcAdmdvs
  15894. } else {
  15895. if len(insuplc_admdvs_str) > 0 {
  15896. insuplc_admdvs = insuplc_admdvs_str
  15897. } else {
  15898. insuplc_admdvs = miConfig.InsuplcAdmdvs
  15899. }
  15900. }
  15901. //请求内网数据
  15902. api := miConfig.SecretKey + "ahyb/1101?url=" + miConfig.Url + "&cert_no=" + patient.IdCardNo +
  15903. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15904. "&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=" + ""
  15905. resp, requestErr := http.Get(api)
  15906. if requestErr != nil {
  15907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15908. return
  15909. }
  15910. body, ioErr := ioutil.ReadAll(resp.Body)
  15911. if ioErr != nil {
  15912. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15914. return
  15915. }
  15916. var respJSON map[string]interface{}
  15917. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15918. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15920. return
  15921. }
  15922. status := respJSON["data"].(map[string]interface{})["status"].(string)
  15923. if status == "0" {
  15924. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  15925. c.ServeSuccessJSON(map[string]interface{}{
  15926. "failed_code": -10,
  15927. "msg": err_msg,
  15928. })
  15929. return
  15930. }
  15931. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15932. var res ResultTwo
  15933. result, _ := json.Marshal(respJSON)
  15934. fmt.Println("log")
  15935. fmt.Println(string(result))
  15936. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15937. utils.ErrorLog("解析失败:%v", err)
  15938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15939. return
  15940. }
  15941. if res.Infcode == 0 {
  15942. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15943. if err == gorm.ErrRecordNotFound {
  15944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15945. return
  15946. } else if err != nil {
  15947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15948. return
  15949. } else {
  15950. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15951. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15952. infoStr := string(Iinfos)
  15953. idetinfoStr := string(Idetinfos)
  15954. psn := &models.HisPsn{
  15955. PsnNo: res.Output.Baseinfo.PsnNo,
  15956. PatientId: patient.ID,
  15957. Certno: res.Output.Baseinfo.Certno,
  15958. Gend: res.Output.Baseinfo.Gend,
  15959. Naty: res.Output.Baseinfo.Naty,
  15960. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15961. PsnName: res.Output.Baseinfo.PsnName,
  15962. Idetinfo: idetinfoStr,
  15963. Insuinfo: infoStr,
  15964. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15965. }
  15966. service.CreateHisPsn(psn)
  15967. var rf []*ResultFive
  15968. json.Unmarshal([]byte(infoStr), &rf)
  15969. var insutypes []*ResultFive
  15970. var is390 int = 0
  15971. var is310 int = 0
  15972. var insutype string
  15973. for _, item := range rf {
  15974. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15975. insutypes = append(insutypes, item)
  15976. }
  15977. }
  15978. if len(insutypes) == 1 {
  15979. insutype = insutypes[0].Insutype
  15980. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15981. } else {
  15982. for _, i := range insutypes {
  15983. if i.Insutype == "390" {
  15984. is390 = 1
  15985. }
  15986. if i.Insutype == "310" {
  15987. is310 = 1
  15988. }
  15989. }
  15990. }
  15991. if is390 == 1 {
  15992. insutype = "390"
  15993. }
  15994. if is310 == 1 {
  15995. insutype = "310"
  15996. }
  15997. if len(insutypes) == 0 {
  15998. insutype = "390"
  15999. }
  16000. c.ServeSuccessJSON(map[string]interface{}{
  16001. "patient": patient,
  16002. "insutype": insutype,
  16003. "number": res.Output.Baseinfo.Certno,
  16004. "info": res,
  16005. })
  16006. }
  16007. } else {
  16008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16009. return
  16010. }
  16011. } else {
  16012. SFZStr := c.GetSFZBaseInfo()
  16013. id_card_str := strings.Split(SFZStr, "^")
  16014. id_card_number := id_card_str[0]
  16015. card_sn := ""
  16016. 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)
  16017. var dat map[string]interface{}
  16018. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16019. fmt.Println(dat)
  16020. } else {
  16021. fmt.Println(err)
  16022. }
  16023. userJSONBytes, _ := json.Marshal(dat)
  16024. var res ResultTwo
  16025. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16026. utils.ErrorLog("解析失败:%v", err)
  16027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16028. return
  16029. }
  16030. if res.Infcode == 0 {
  16031. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  16032. if err == gorm.ErrRecordNotFound {
  16033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16034. return
  16035. } else if err != nil {
  16036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16037. return
  16038. } else {
  16039. c.ServeSuccessJSON(map[string]interface{}{
  16040. "patient": patient,
  16041. "number": id_card_number,
  16042. })
  16043. }
  16044. } else {
  16045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16046. return
  16047. }
  16048. }
  16049. break
  16050. case 3:
  16051. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  16052. var api string
  16053. if miConfig.MdtrtareaAdmvs == "320830" {
  16054. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16055. "&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
  16056. fmt.Println(api)
  16057. } else if miConfig.MdtrtareaAdmvs == "320921" {
  16058. 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 +
  16059. "&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
  16060. fmt.Println(api)
  16061. } else {
  16062. 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 +
  16063. "&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)
  16064. }
  16065. resp, requestErr := http.Get(api)
  16066. if requestErr != nil {
  16067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16068. return
  16069. }
  16070. body, ioErr := ioutil.ReadAll(resp.Body)
  16071. if ioErr != nil {
  16072. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16074. return
  16075. }
  16076. var respJSON map[string]interface{}
  16077. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16078. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16080. return
  16081. }
  16082. var status string
  16083. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16084. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16085. var token string
  16086. var res ResultTwo //1101结果
  16087. var res10265 ResultTwo10265 //1101结果
  16088. var card_info string //卡信息
  16089. var busi_card_info string
  16090. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16091. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16092. if status == "0" { //读卡成功
  16093. if card_type == "1" {
  16094. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16095. result, _ := json.Marshal(respJSON)
  16096. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16097. utils.ErrorLog("解析失败:%v", err)
  16098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16099. return
  16100. }
  16101. res.ErrMsg = res10265.ErrMsg
  16102. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16103. res.Infcode = infocode
  16104. res.Output = res10265.Output
  16105. res.InfRefmsgid = res10265.InfRefmsgid
  16106. } else {
  16107. //var card_info string //卡信息
  16108. //var busi_card_info string
  16109. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16110. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16111. //fmt.Println(card_info)
  16112. //fmt.Println(busi_card_info)
  16113. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16114. result, _ := json.Marshal(respJSON)
  16115. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16116. utils.ErrorLog("解析失败:%v", err)
  16117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16118. return
  16119. }
  16120. res.ErrMsg = res10265.ErrMsg
  16121. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16122. res.Infcode = infocode
  16123. res.Output = res10265.Output
  16124. res.InfRefmsgid = res10265.InfRefmsgid
  16125. }
  16126. if res.Infcode == 0 {
  16127. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16128. if err == gorm.ErrRecordNotFound {
  16129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16130. return
  16131. } else if err != nil {
  16132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16133. return
  16134. } else {
  16135. if card_type == "1" {
  16136. bas := strings.Split(card_info, "|")
  16137. basNumber := bas[2]
  16138. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16139. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16140. infoStr := string(Iinfos)
  16141. idetinfoStr := string(Idetinfos)
  16142. psn := &models.HisPsn{
  16143. PsnNo: res.Output.Baseinfo.PsnNo,
  16144. PatientId: patient.ID,
  16145. Certno: res.Output.Baseinfo.Certno,
  16146. //Brdy: res.Output.Baseinfo.Brdy,
  16147. Gend: res.Output.Baseinfo.Gend,
  16148. Naty: res.Output.Baseinfo.Naty,
  16149. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16150. PsnName: res.Output.Baseinfo.PsnName,
  16151. Idetinfo: idetinfoStr,
  16152. Insuinfo: infoStr,
  16153. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16154. CardInfo: card_info,
  16155. VerifyNumber: busi_card_info,
  16156. }
  16157. service.CreateHisPsn(psn)
  16158. c.ServeSuccessJSON(map[string]interface{}{
  16159. "patient": patient,
  16160. "number": basNumber,
  16161. })
  16162. } else {
  16163. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16164. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16165. infoStr := string(Iinfos)
  16166. idetinfoStr := string(Idetinfos)
  16167. psn := &models.HisPsn{
  16168. PsnNo: res.Output.Baseinfo.PsnNo,
  16169. PatientId: patient.ID,
  16170. Certno: res.Output.Baseinfo.Certno,
  16171. Gend: res.Output.Baseinfo.Gend,
  16172. Naty: res.Output.Baseinfo.Naty,
  16173. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16174. PsnName: res.Output.Baseinfo.PsnName,
  16175. Idetinfo: idetinfoStr,
  16176. Insuinfo: infoStr,
  16177. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16178. CardInfo: card_info,
  16179. VerifyNumber: token,
  16180. }
  16181. service.CreateHisPsn(psn)
  16182. var rf []*ResultFive
  16183. json.Unmarshal([]byte(infoStr), &rf)
  16184. var insutypes []*ResultFive
  16185. var insutype string
  16186. var is390 int = 0
  16187. var is310 int = 0
  16188. for _, item := range rf {
  16189. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16190. insutypes = append(insutypes, item)
  16191. }
  16192. }
  16193. if len(insutypes) == 1 {
  16194. insutype = insutypes[0].Insutype
  16195. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16196. } else {
  16197. for _, i := range insutypes {
  16198. if i.Insutype == "390" {
  16199. is390 = 1
  16200. }
  16201. if i.Insutype == "310" {
  16202. is310 = 1
  16203. }
  16204. }
  16205. }
  16206. if is390 == 1 {
  16207. insutype = "390"
  16208. }
  16209. if is310 == 1 {
  16210. insutype = "310"
  16211. }
  16212. if len(insutypes) == 0 {
  16213. insutype = "310"
  16214. }
  16215. c.ServeSuccessJSON(map[string]interface{}{
  16216. "patient": patient,
  16217. "number": token,
  16218. "insutype": insutype,
  16219. })
  16220. }
  16221. }
  16222. } else {
  16223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16224. return
  16225. }
  16226. } else { //读卡失败
  16227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16228. return
  16229. }
  16230. }
  16231. break
  16232. case 4:
  16233. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  16234. var api string
  16235. if miConfig.MdtrtareaAdmvs == "320830" {
  16236. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16237. "&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
  16238. fmt.Println(api)
  16239. } else if miConfig.MdtrtareaAdmvs == "320921" {
  16240. 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 +
  16241. "&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
  16242. fmt.Println(api)
  16243. } else {
  16244. 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 +
  16245. "&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)
  16246. }
  16247. resp, requestErr := http.Get(api)
  16248. if requestErr != nil {
  16249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16250. return
  16251. }
  16252. body, ioErr := ioutil.ReadAll(resp.Body)
  16253. if ioErr != nil {
  16254. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16256. return
  16257. }
  16258. var respJSON map[string]interface{}
  16259. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16260. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16262. return
  16263. }
  16264. var status string
  16265. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16266. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16267. var token string
  16268. var res ResultTwo //1101结果
  16269. var res10265 ResultTwo10265 //1101结果
  16270. if status == "0" { //读卡成功
  16271. var card_info string //卡信息
  16272. var busi_card_info string
  16273. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16274. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16275. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16276. fmt.Println(card_info)
  16277. fmt.Println(busi_card_info)
  16278. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16279. result, _ := json.Marshal(respJSON)
  16280. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16281. utils.ErrorLog("解析失败:%v", err)
  16282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16283. return
  16284. }
  16285. res.ErrMsg = res10265.ErrMsg
  16286. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16287. res.Infcode = infocode
  16288. res.Output = res10265.Output
  16289. res.InfRefmsgid = res10265.InfRefmsgid
  16290. if res.Infcode == 0 {
  16291. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16292. if err == gorm.ErrRecordNotFound {
  16293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16294. return
  16295. } else if err != nil {
  16296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16297. return
  16298. } else {
  16299. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16300. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16301. infoStr := string(Iinfos)
  16302. idetinfoStr := string(Idetinfos)
  16303. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  16304. psn := &models.HisPsn{
  16305. PsnNo: res.Output.Baseinfo.PsnNo,
  16306. PatientId: patient.ID,
  16307. Certno: res.Output.Baseinfo.Certno,
  16308. Brdy: b,
  16309. Age: float64(age),
  16310. //Brdy: res.Output.Baseinfo.Brdy,
  16311. Gend: res.Output.Baseinfo.Gend,
  16312. Naty: res.Output.Baseinfo.Naty,
  16313. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16314. PsnName: res.Output.Baseinfo.PsnName,
  16315. Idetinfo: idetinfoStr,
  16316. Insuinfo: infoStr,
  16317. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16318. CardInfo: card_info,
  16319. VerifyNumber: token,
  16320. }
  16321. var rf []*ResultFive
  16322. json.Unmarshal([]byte(infoStr), &rf)
  16323. var insutypes []*ResultFive
  16324. var insutype string
  16325. var is390 int = 0
  16326. var is310 int = 0
  16327. for _, item := range rf {
  16328. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16329. insutypes = append(insutypes, item)
  16330. }
  16331. }
  16332. if len(insutypes) == 1 {
  16333. insutype = insutypes[0].Insutype
  16334. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16335. } else {
  16336. for _, i := range insutypes {
  16337. if i.Insutype == "390" {
  16338. is390 = 1
  16339. }
  16340. if i.Insutype == "310" {
  16341. is310 = 1
  16342. }
  16343. }
  16344. }
  16345. if is390 == 1 {
  16346. insutype = "390"
  16347. }
  16348. if is310 == 1 {
  16349. insutype = "310"
  16350. }
  16351. if len(insutypes) == 0 {
  16352. insutype = "310"
  16353. }
  16354. service.CreateHisPsn(psn)
  16355. c.ServeSuccessJSON(map[string]interface{}{
  16356. "patient": patient,
  16357. "number": token,
  16358. "insutype": insutype,
  16359. })
  16360. }
  16361. } else {
  16362. c.ServeSuccessJSON(map[string]interface{}{
  16363. "failed_code": -10,
  16364. "msg": res.ErrMsg,
  16365. })
  16366. }
  16367. } else { //读卡失败
  16368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16369. return
  16370. }
  16371. } else if miConfig.MdtrtareaAdmvs == "341203" {
  16372. var api string
  16373. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16374. "&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
  16375. resp, requestErr := http.Get(api)
  16376. if requestErr != nil {
  16377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16378. return
  16379. }
  16380. body, ioErr := ioutil.ReadAll(resp.Body)
  16381. if ioErr != nil {
  16382. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16384. return
  16385. }
  16386. var respJSON map[string]interface{}
  16387. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16388. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16390. return
  16391. }
  16392. var status string
  16393. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16394. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16395. var token string
  16396. var res ResultTwo //1101结果
  16397. if status == "1" { //读卡成功
  16398. var card_info string //卡信息
  16399. var busi_card_info string
  16400. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16401. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16402. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16403. fmt.Println(card_info)
  16404. fmt.Println(busi_card_info)
  16405. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16406. result, _ := json.Marshal(respJSON)
  16407. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16408. utils.ErrorLog("解析失败:%v", err)
  16409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16410. return
  16411. }
  16412. if res.Infcode == 0 {
  16413. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16414. if err == gorm.ErrRecordNotFound {
  16415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16416. return
  16417. } else if err != nil {
  16418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16419. return
  16420. } else {
  16421. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16422. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16423. infoStr := string(Iinfos)
  16424. idetinfoStr := string(Idetinfos)
  16425. psn := &models.HisPsn{
  16426. PsnNo: res.Output.Baseinfo.PsnNo,
  16427. PatientId: patient.ID,
  16428. Certno: res.Output.Baseinfo.Certno,
  16429. Gend: res.Output.Baseinfo.Gend,
  16430. Naty: res.Output.Baseinfo.Naty,
  16431. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16432. PsnName: res.Output.Baseinfo.PsnName,
  16433. Idetinfo: idetinfoStr,
  16434. Insuinfo: infoStr,
  16435. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16436. CardInfo: card_info,
  16437. VerifyNumber: token,
  16438. }
  16439. var rf []*ResultFive
  16440. json.Unmarshal([]byte(infoStr), &rf)
  16441. var insutypes []*ResultFive
  16442. var insutype string
  16443. var is390 int = 0
  16444. var is310 int = 0
  16445. for _, item := range rf {
  16446. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16447. insutypes = append(insutypes, item)
  16448. }
  16449. }
  16450. if len(insutypes) == 1 {
  16451. insutype = insutypes[0].Insutype
  16452. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16453. } else {
  16454. for _, i := range insutypes {
  16455. if i.Insutype == "390" {
  16456. is390 = 1
  16457. }
  16458. if i.Insutype == "310" {
  16459. is310 = 1
  16460. }
  16461. }
  16462. }
  16463. if is390 == 1 {
  16464. insutype = "390"
  16465. }
  16466. if is310 == 1 {
  16467. insutype = "310"
  16468. }
  16469. if len(insutypes) == 0 {
  16470. insutype = "310"
  16471. }
  16472. service.CreateHisPsn(psn)
  16473. c.ServeSuccessJSON(map[string]interface{}{
  16474. "patient": patient,
  16475. "number": token,
  16476. "insutype": insutype,
  16477. })
  16478. }
  16479. } else {
  16480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16481. return
  16482. }
  16483. } else { //读卡失败
  16484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16485. return
  16486. }
  16487. } else if miConfig.MdtrtareaAdmvs == "340699" {
  16488. var api string
  16489. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16490. "&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
  16491. resp, requestErr := http.Get(api)
  16492. if requestErr != nil {
  16493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16494. return
  16495. }
  16496. body, ioErr := ioutil.ReadAll(resp.Body)
  16497. if ioErr != nil {
  16498. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16500. return
  16501. }
  16502. var respJSON map[string]interface{}
  16503. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16504. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16506. return
  16507. }
  16508. var status string
  16509. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16510. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16511. var token string
  16512. var res ResultTwo //1101结果
  16513. if status == "1" { //读卡成功
  16514. var card_info string //卡信息
  16515. var busi_card_info string
  16516. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16517. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16518. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16519. fmt.Println(card_info)
  16520. fmt.Println(busi_card_info)
  16521. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16522. result, _ := json.Marshal(respJSON)
  16523. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16524. utils.ErrorLog("解析失败:%v", err)
  16525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16526. return
  16527. }
  16528. if res.Infcode == 0 {
  16529. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16530. if err == gorm.ErrRecordNotFound {
  16531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16532. return
  16533. } else if err != nil {
  16534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16535. return
  16536. } else {
  16537. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16538. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16539. infoStr := string(Iinfos)
  16540. idetinfoStr := string(Idetinfos)
  16541. psn := &models.HisPsn{
  16542. PsnNo: res.Output.Baseinfo.PsnNo,
  16543. PatientId: patient.ID,
  16544. Certno: res.Output.Baseinfo.Certno,
  16545. Gend: res.Output.Baseinfo.Gend,
  16546. Naty: res.Output.Baseinfo.Naty,
  16547. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16548. PsnName: res.Output.Baseinfo.PsnName,
  16549. Idetinfo: idetinfoStr,
  16550. Insuinfo: infoStr,
  16551. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16552. CardInfo: card_info,
  16553. VerifyNumber: token,
  16554. }
  16555. var rf []*ResultFive
  16556. json.Unmarshal([]byte(infoStr), &rf)
  16557. var insutypes []*ResultFive
  16558. var insutype string
  16559. var is390 int = 0
  16560. var is310 int = 0
  16561. for _, item := range rf {
  16562. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16563. insutypes = append(insutypes, item)
  16564. }
  16565. }
  16566. if len(insutypes) == 1 {
  16567. insutype = insutypes[0].Insutype
  16568. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16569. } else {
  16570. for _, i := range insutypes {
  16571. if i.Insutype == "390" {
  16572. is390 = 1
  16573. }
  16574. if i.Insutype == "310" {
  16575. is310 = 1
  16576. }
  16577. }
  16578. }
  16579. if is390 == 1 {
  16580. insutype = "390"
  16581. }
  16582. if is310 == 1 {
  16583. insutype = "310"
  16584. }
  16585. if len(insutypes) == 0 {
  16586. insutype = "390"
  16587. }
  16588. service.CreateHisPsn(psn)
  16589. c.ServeSuccessJSON(map[string]interface{}{
  16590. "patient": patient,
  16591. "number": token,
  16592. "insutype": insutype,
  16593. })
  16594. }
  16595. } else {
  16596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16597. return
  16598. }
  16599. } else { //读卡失败
  16600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16601. return
  16602. }
  16603. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16604. //idNo := c.GetString("idNo")
  16605. //userName := c.GetString("userName")
  16606. //ecToken := c.GetString("ecToken")
  16607. //insuOrg := c.GetString("insuOrg")
  16608. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  16609. utils.ErrorLog("解析失败:%v", json_result)
  16610. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16611. type ELeData struct {
  16612. Data struct {
  16613. IdNo string `json:"idNo"`
  16614. IdType string `json:"idType"`
  16615. UserName string `json:"userName"`
  16616. EcToken string `json:"ecToken"`
  16617. InsuOrg string `json:"insuOrg"`
  16618. Gender string `json:"gender"`
  16619. Birthday string `json:"birthday"`
  16620. Nationality string `json:"nationality"`
  16621. Email string `json:"email"`
  16622. Extra string `json:"extra"`
  16623. } `json:"data"`
  16624. Code int `json:"code"`
  16625. Message string `json:"message"`
  16626. }
  16627. var ele ELeData
  16628. err := json.Unmarshal([]byte(json_result), &ele)
  16629. if err != nil {
  16630. utils.ErrorLog("解析失败:%v", err)
  16631. }
  16632. token := ele.Data.EcToken
  16633. token = Remove0000(token)
  16634. 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)
  16635. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16636. var res ResultTwo
  16637. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16638. utils.ErrorLog("解析失败:%v", err)
  16639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16640. return
  16641. }
  16642. if res.Infcode == 0 {
  16643. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16644. if err == gorm.ErrRecordNotFound {
  16645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16646. return
  16647. } else if err != nil {
  16648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16649. return
  16650. } else {
  16651. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16652. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16653. infoStr := string(Iinfos)
  16654. idetinfoStr := string(Idetinfos)
  16655. psn := &models.HisPsn{
  16656. PsnNo: res.Output.Baseinfo.PsnNo,
  16657. PatientId: patient.ID,
  16658. Certno: res.Output.Baseinfo.Certno,
  16659. Gend: res.Output.Baseinfo.Gend,
  16660. Naty: res.Output.Baseinfo.Naty,
  16661. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16662. PsnName: res.Output.Baseinfo.PsnName,
  16663. Idetinfo: idetinfoStr,
  16664. Insuinfo: infoStr,
  16665. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16666. CardInfo: "",
  16667. Stage: "1",
  16668. VerifyNumber: token,
  16669. InsuplcAdmdvs: ele.Data.InsuOrg,
  16670. }
  16671. service.CreateHisPsn(psn)
  16672. var rf []*ResultFive
  16673. json.Unmarshal([]byte(infoStr), &rf)
  16674. var insutypes []*ResultFive
  16675. var insutype string
  16676. var is390 int = 0
  16677. var is310 int = 0
  16678. for _, item := range rf {
  16679. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16680. insutypes = append(insutypes, item)
  16681. }
  16682. }
  16683. if len(insutypes) == 1 {
  16684. insutype = insutypes[0].Insutype
  16685. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16686. } else {
  16687. for _, i := range insutypes {
  16688. if i.Insutype == "390" {
  16689. is390 = 1
  16690. }
  16691. if i.Insutype == "310" {
  16692. is310 = 1
  16693. }
  16694. }
  16695. }
  16696. if is390 == 1 {
  16697. insutype = "390"
  16698. }
  16699. if is310 == 1 {
  16700. insutype = "310"
  16701. }
  16702. if len(insutypes) == 0 {
  16703. insutype = "310"
  16704. }
  16705. c.ServeSuccessJSON(map[string]interface{}{
  16706. "patient": patient,
  16707. "number": token,
  16708. "insutype": insutype,
  16709. })
  16710. }
  16711. } else {
  16712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16713. return
  16714. }
  16715. } else if miConfig.MdtrtareaAdmvs == "360302" {
  16716. //if initFlag == 0 {
  16717. //c.TestGetJiangXiBasBaseInit()
  16718. //}
  16719. //if initEleFlag == 0 {
  16720. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16721. //}
  16722. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16723. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16724. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16725. type ELeData struct {
  16726. Data struct {
  16727. IdNo string `json:"idNo"`
  16728. IdType string `json:"idType"`
  16729. UserName string `json:"userName"`
  16730. EcToken string `json:"ecToken"`
  16731. InsuOrg string `json:"insuOrg"`
  16732. Gender string `json:"gender"`
  16733. Birthday string `json:"birthday"`
  16734. Nationality string `json:"nationality"`
  16735. Email string `json:"email"`
  16736. Extra string `json:"extra"`
  16737. } `json:"data"`
  16738. Code int `json:"code"`
  16739. Message string `json:"message"`
  16740. }
  16741. var ele ELeData
  16742. err := json.Unmarshal([]byte(result), &ele)
  16743. if err != nil {
  16744. utils.ErrorLog("解析失败:%v", err)
  16745. }
  16746. token := ele.Data.EcToken
  16747. token = Remove0000(token)
  16748. 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)
  16749. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16750. var res ResultTwo
  16751. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16752. utils.ErrorLog("解析失败:%v", err)
  16753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16754. return
  16755. }
  16756. if res.Infcode == 0 {
  16757. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16758. if err == gorm.ErrRecordNotFound {
  16759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16760. return
  16761. } else if err != nil {
  16762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16763. return
  16764. } else {
  16765. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16766. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16767. infoStr := string(Iinfos)
  16768. idetinfoStr := string(Idetinfos)
  16769. psn := &models.HisPsn{
  16770. PsnNo: res.Output.Baseinfo.PsnNo,
  16771. PatientId: patient.ID,
  16772. Certno: res.Output.Baseinfo.Certno,
  16773. Gend: res.Output.Baseinfo.Gend,
  16774. Naty: res.Output.Baseinfo.Naty,
  16775. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16776. PsnName: res.Output.Baseinfo.PsnName,
  16777. Idetinfo: idetinfoStr,
  16778. Insuinfo: infoStr,
  16779. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16780. CardInfo: "",
  16781. VerifyNumber: token,
  16782. InsuplcAdmdvs: ele.Data.InsuOrg,
  16783. }
  16784. service.CreateHisPsn(psn)
  16785. var rf []*ResultFive
  16786. json.Unmarshal([]byte(infoStr), &rf)
  16787. var insutypes []*ResultFive
  16788. var insutype string
  16789. var is390 int = 0
  16790. var is310 int = 0
  16791. for _, item := range rf {
  16792. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16793. insutypes = append(insutypes, item)
  16794. }
  16795. }
  16796. if len(insutypes) == 1 {
  16797. insutype = insutypes[0].Insutype
  16798. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16799. } else {
  16800. for _, i := range insutypes {
  16801. if i.Insutype == "390" {
  16802. is390 = 1
  16803. }
  16804. if i.Insutype == "310" {
  16805. is310 = 1
  16806. }
  16807. }
  16808. }
  16809. if is390 == 1 {
  16810. insutype = "390"
  16811. }
  16812. if is310 == 1 {
  16813. insutype = "310"
  16814. }
  16815. if len(insutypes) == 0 {
  16816. insutype = "310"
  16817. }
  16818. c.ServeSuccessJSON(map[string]interface{}{
  16819. "patient": patient,
  16820. "number": token,
  16821. "insutype": insutype,
  16822. })
  16823. }
  16824. } else {
  16825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16826. return
  16827. }
  16828. } else if miConfig.MdtrtareaAdmvs == "361025" {
  16829. //if initFlag == 0 {
  16830. //c.TestGetJiangXiBasBaseInit()
  16831. //}
  16832. //if initEleFlag == 0 {
  16833. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16834. //}
  16835. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16836. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16837. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16838. type ELeData struct {
  16839. Data struct {
  16840. IdNo string `json:"idNo"`
  16841. IdType string `json:"idType"`
  16842. UserName string `json:"userName"`
  16843. EcToken string `json:"ecToken"`
  16844. InsuOrg string `json:"insuOrg"`
  16845. Gender string `json:"gender"`
  16846. Birthday string `json:"birthday"`
  16847. Nationality string `json:"nationality"`
  16848. Email string `json:"email"`
  16849. Extra string `json:"extra"`
  16850. } `json:"data"`
  16851. Code int `json:"code"`
  16852. Message string `json:"message"`
  16853. }
  16854. var ele ELeData
  16855. err := json.Unmarshal([]byte(result), &ele)
  16856. if err != nil {
  16857. utils.ErrorLog("解析失败:%v", err)
  16858. }
  16859. token := ele.Data.EcToken
  16860. token = Remove0000(token)
  16861. 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)
  16862. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16863. var res ResultTwo
  16864. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16865. utils.ErrorLog("解析失败:%v", err)
  16866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16867. return
  16868. }
  16869. if res.Infcode == 0 {
  16870. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16871. if err == gorm.ErrRecordNotFound {
  16872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16873. return
  16874. } else if err != nil {
  16875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16876. return
  16877. } else {
  16878. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16879. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16880. infoStr := string(Iinfos)
  16881. idetinfoStr := string(Idetinfos)
  16882. psn := &models.HisPsn{
  16883. PsnNo: res.Output.Baseinfo.PsnNo,
  16884. PatientId: patient.ID,
  16885. Certno: res.Output.Baseinfo.Certno,
  16886. Gend: res.Output.Baseinfo.Gend,
  16887. Naty: res.Output.Baseinfo.Naty,
  16888. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16889. PsnName: res.Output.Baseinfo.PsnName,
  16890. Idetinfo: idetinfoStr,
  16891. Insuinfo: infoStr,
  16892. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16893. CardInfo: "",
  16894. VerifyNumber: token,
  16895. InsuplcAdmdvs: ele.Data.InsuOrg,
  16896. }
  16897. service.CreateHisPsn(psn)
  16898. var rf []*ResultFive
  16899. json.Unmarshal([]byte(infoStr), &rf)
  16900. var insutypes []*ResultFive
  16901. var insutype string
  16902. var is390 int = 0
  16903. var is310 int = 0
  16904. for _, item := range rf {
  16905. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16906. insutypes = append(insutypes, item)
  16907. }
  16908. }
  16909. if len(insutypes) == 1 {
  16910. insutype = insutypes[0].Insutype
  16911. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16912. } else {
  16913. for _, i := range insutypes {
  16914. if i.Insutype == "390" {
  16915. is390 = 1
  16916. }
  16917. if i.Insutype == "310" {
  16918. is310 = 1
  16919. }
  16920. }
  16921. }
  16922. if is390 == 1 {
  16923. insutype = "390"
  16924. }
  16925. if is310 == 1 {
  16926. insutype = "310"
  16927. }
  16928. if len(insutypes) == 0 {
  16929. insutype = "310"
  16930. }
  16931. c.ServeSuccessJSON(map[string]interface{}{
  16932. "patient": patient,
  16933. "number": token,
  16934. "insutype": insutype,
  16935. })
  16936. }
  16937. } else {
  16938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16939. return
  16940. }
  16941. } else if miConfig.MdtrtareaAdmvs == "360100" {
  16942. //if initFlag == 0 {
  16943. //c.TestGetJiangXiBasBaseInit()
  16944. //}
  16945. //if initEleFlag == 0 {
  16946. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16947. //}
  16948. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16949. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16950. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16951. type ELeData struct {
  16952. Data struct {
  16953. IdNo string `json:"idNo"`
  16954. IdType string `json:"idType"`
  16955. UserName string `json:"userName"`
  16956. EcToken string `json:"ecToken"`
  16957. InsuOrg string `json:"insuOrg"`
  16958. Gender string `json:"gender"`
  16959. Birthday string `json:"birthday"`
  16960. Nationality string `json:"nationality"`
  16961. Email string `json:"email"`
  16962. Extra string `json:"extra"`
  16963. } `json:"data"`
  16964. Code int `json:"code"`
  16965. Message string `json:"message"`
  16966. }
  16967. var ele ELeData
  16968. err := json.Unmarshal([]byte(result), &ele)
  16969. if err != nil {
  16970. utils.ErrorLog("解析失败:%v", err)
  16971. }
  16972. token := ele.Data.EcToken
  16973. token = Remove0000(token)
  16974. 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)
  16975. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16976. var res ResultTwo
  16977. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16978. utils.ErrorLog("解析失败:%v", err)
  16979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16980. return
  16981. }
  16982. if res.Infcode == 0 {
  16983. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16984. if err == gorm.ErrRecordNotFound {
  16985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16986. return
  16987. } else if err != nil {
  16988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16989. return
  16990. } else {
  16991. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16992. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16993. infoStr := string(Iinfos)
  16994. idetinfoStr := string(Idetinfos)
  16995. psn := &models.HisPsn{
  16996. PsnNo: res.Output.Baseinfo.PsnNo,
  16997. PatientId: patient.ID,
  16998. Certno: res.Output.Baseinfo.Certno,
  16999. Gend: res.Output.Baseinfo.Gend,
  17000. Naty: res.Output.Baseinfo.Naty,
  17001. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17002. PsnName: res.Output.Baseinfo.PsnName,
  17003. Idetinfo: idetinfoStr,
  17004. Insuinfo: infoStr,
  17005. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17006. CardInfo: "",
  17007. VerifyNumber: token,
  17008. InsuplcAdmdvs: ele.Data.InsuOrg,
  17009. }
  17010. service.CreateHisPsn(psn)
  17011. var rf []*ResultFive
  17012. json.Unmarshal([]byte(infoStr), &rf)
  17013. var insutypes []*ResultFive
  17014. var insutype string
  17015. var is390 int = 0
  17016. var is310 int = 0
  17017. for _, item := range rf {
  17018. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17019. insutypes = append(insutypes, item)
  17020. }
  17021. }
  17022. if len(insutypes) == 1 {
  17023. insutype = insutypes[0].Insutype
  17024. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17025. } else {
  17026. for _, i := range insutypes {
  17027. if i.Insutype == "390" {
  17028. is390 = 1
  17029. }
  17030. if i.Insutype == "310" {
  17031. is310 = 1
  17032. }
  17033. }
  17034. }
  17035. if is390 == 1 {
  17036. insutype = "390"
  17037. }
  17038. if is310 == 1 {
  17039. insutype = "310"
  17040. }
  17041. if len(insutypes) == 0 {
  17042. insutype = "310"
  17043. }
  17044. c.ServeSuccessJSON(map[string]interface{}{
  17045. "patient": patient,
  17046. "number": token,
  17047. "insutype": insutype,
  17048. })
  17049. }
  17050. } else {
  17051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17052. return
  17053. }
  17054. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17055. //if initFlag == 0 {
  17056. c.TestGetJiangXiBasBaseInit()
  17057. //}
  17058. //if initEleFlag == 0 {
  17059. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  17060. //}
  17061. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  17062. type ELeData struct {
  17063. Data struct {
  17064. IdNo string `json:"idNo"`
  17065. IdType string `json:"idType"`
  17066. UserName string `json:"userName"`
  17067. EcToken string `json:"ecToken"`
  17068. InsuOrg string `json:"insuOrg"`
  17069. Gender string `json:"gender"`
  17070. Birthday string `json:"birthday"`
  17071. Nationality string `json:"nationality"`
  17072. Email string `json:"email"`
  17073. Extra string `json:"extra"`
  17074. } `json:"data"`
  17075. Code int `json:"code"`
  17076. Message string `json:"message"`
  17077. }
  17078. var ele ELeData
  17079. err := json.Unmarshal([]byte(json_result), &ele)
  17080. if err != nil {
  17081. utils.ErrorLog("解析失败:%v", err)
  17082. }
  17083. token := ele.Data.EcToken
  17084. token = Remove0000(token)
  17085. 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)
  17086. saveLog(result2, requestLog2, "1101", "获取人员信息")
  17087. var res ResultTwo
  17088. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17089. utils.ErrorLog("解析失败:%v", err)
  17090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17091. return
  17092. }
  17093. if res.Infcode == 0 {
  17094. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17095. if err == gorm.ErrRecordNotFound {
  17096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17097. return
  17098. } else if err != nil {
  17099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17100. return
  17101. } else {
  17102. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17103. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17104. infoStr := string(Iinfos)
  17105. idetinfoStr := string(Idetinfos)
  17106. psn := &models.HisPsn{
  17107. PsnNo: res.Output.Baseinfo.PsnNo,
  17108. PatientId: patient.ID,
  17109. Certno: res.Output.Baseinfo.Certno,
  17110. Gend: res.Output.Baseinfo.Gend,
  17111. Naty: res.Output.Baseinfo.Naty,
  17112. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17113. PsnName: res.Output.Baseinfo.PsnName,
  17114. Idetinfo: idetinfoStr,
  17115. Insuinfo: infoStr,
  17116. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17117. CardInfo: "",
  17118. VerifyNumber: token,
  17119. }
  17120. service.CreateHisPsn(psn)
  17121. var rf []*ResultFive
  17122. json.Unmarshal([]byte(infoStr), &rf)
  17123. var insutypes []*ResultFive
  17124. var insutype string
  17125. var is390 int = 0
  17126. var is310 int = 0
  17127. for _, item := range rf {
  17128. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17129. insutypes = append(insutypes, item)
  17130. }
  17131. }
  17132. if len(insutypes) == 1 {
  17133. insutype = insutypes[0].Insutype
  17134. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17135. } else {
  17136. for _, i := range insutypes {
  17137. if i.Insutype == "390" {
  17138. is390 = 1
  17139. }
  17140. if i.Insutype == "310" {
  17141. is310 = 1
  17142. }
  17143. }
  17144. }
  17145. if is390 == 1 {
  17146. insutype = "390"
  17147. }
  17148. if is310 == 1 {
  17149. insutype = "310"
  17150. }
  17151. if len(insutypes) == 0 {
  17152. insutype = "310"
  17153. }
  17154. c.ServeSuccessJSON(map[string]interface{}{
  17155. "patient": patient,
  17156. "number": token,
  17157. "insutype": insutype,
  17158. })
  17159. }
  17160. } else {
  17161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17162. return
  17163. }
  17164. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17165. type ELeData struct {
  17166. Code string `json:"code"`
  17167. Data struct {
  17168. Aac002 string `json:"aac002"`
  17169. Aaz500 string `json:"aaz500"`
  17170. ActCardNo string `json:"actCardNo"`
  17171. Bab520 string `json:"bab520"`
  17172. Bkz543 string `json:"bkz543"`
  17173. BusinessType string `json:"businessType"`
  17174. CertfCodg string `json:"certfCodg"`
  17175. EcIndexNo string `json:"ecIndexNo"`
  17176. EcToken string `json:"ecToken"`
  17177. ID0000 string `json:"id0000"`
  17178. IDNo string `json:"idNo"`
  17179. IDType string `json:"idType"`
  17180. Idcode string `json:"idcode"`
  17181. IdentityToken string `json:"identity_token"`
  17182. InsuOrg string `json:"insuOrg"`
  17183. OfficeID string `json:"officeId"`
  17184. OfficeName string `json:"officeName"`
  17185. OperatorID string `json:"operatorId"`
  17186. OperatorName string `json:"operatorName"`
  17187. OrgID string `json:"orgId"`
  17188. UserName string `json:"userName"`
  17189. } `json:"data"`
  17190. Infno interface{} `json:"infno"`
  17191. Message string `json:"message"`
  17192. OrgID string `json:"orgId"`
  17193. TransType string `json:"transType"`
  17194. }
  17195. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  17196. outPutInfo = Remove0000(outPutInfo)
  17197. if len(outPutInfo) > 0 {
  17198. var ele ELeData
  17199. err := json.Unmarshal([]byte(outPutInfo), &ele)
  17200. if err != nil {
  17201. utils.ErrorLog("解析失败:%v", err)
  17202. }
  17203. token := ele.Data.EcToken
  17204. fmt.Println(inputInfo)
  17205. fmt.Println(outPutInfo)
  17206. 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)
  17207. saveLog(result, requestLog, "1101", "获取人员信息")
  17208. var dat map[string]interface{}
  17209. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17210. fmt.Println(dat)
  17211. } else {
  17212. fmt.Println(err)
  17213. }
  17214. userJSONBytes, _ := json.Marshal(dat)
  17215. var res ResultTwo
  17216. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17217. utils.ErrorLog("解析失败:%v", err)
  17218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17219. return
  17220. }
  17221. res.ErrMsg = errMsgLog
  17222. if res.Infcode == 0 {
  17223. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  17224. if err == gorm.ErrRecordNotFound {
  17225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17226. return
  17227. } else if err != nil {
  17228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17229. return
  17230. } else {
  17231. fmt.Println(res)
  17232. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17233. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17234. infoStr := string(Iinfos)
  17235. idetinfoStr := string(Idetinfos)
  17236. psn := &models.HisPsn{
  17237. PsnNo: res.Output.Baseinfo.PsnNo,
  17238. PatientId: patient.ID,
  17239. Certno: res.Output.Baseinfo.Certno,
  17240. Gend: res.Output.Baseinfo.Gend,
  17241. Naty: res.Output.Baseinfo.Naty,
  17242. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17243. PsnName: res.Output.Baseinfo.PsnName,
  17244. Idetinfo: idetinfoStr,
  17245. Insuinfo: infoStr,
  17246. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17247. CardInfo: outPutInfo,
  17248. VerifyNumber: token,
  17249. InsuplcAdmdvs: ele.Data.InsuOrg,
  17250. }
  17251. service.CreateHisPsn(psn)
  17252. var rf []*ResultFive
  17253. json.Unmarshal([]byte(infoStr), &rf)
  17254. var insutypes []*ResultFive
  17255. var insutype string
  17256. var is390 int = 0
  17257. var is310 int = 0
  17258. for _, item := range rf {
  17259. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  17260. insutypes = append(insutypes, item)
  17261. }
  17262. }
  17263. if len(insutypes) == 1 {
  17264. insutype = insutypes[0].Insutype
  17265. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17266. } else {
  17267. for _, i := range insutypes {
  17268. if i.Insutype == "390" {
  17269. is390 = 1
  17270. }
  17271. if i.Insutype == "310" {
  17272. is310 = 1
  17273. }
  17274. }
  17275. }
  17276. if is390 == 1 {
  17277. insutype = "390"
  17278. }
  17279. if is310 == 1 {
  17280. insutype = "310"
  17281. }
  17282. if len(insutypes) == 0 {
  17283. insutype = "310"
  17284. }
  17285. c.ServeSuccessJSON(map[string]interface{}{
  17286. "patient": patient,
  17287. "number": token,
  17288. "insutype": insutype,
  17289. })
  17290. }
  17291. } else {
  17292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17293. return
  17294. }
  17295. }
  17296. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17297. var api string
  17298. 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 +
  17299. "&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
  17300. resp, requestErr := http.Get(api)
  17301. if requestErr != nil {
  17302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17303. return
  17304. }
  17305. body, ioErr := ioutil.ReadAll(resp.Body)
  17306. if ioErr != nil {
  17307. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17309. return
  17310. }
  17311. var respJSON map[string]interface{}
  17312. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17313. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17315. return
  17316. }
  17317. var status string
  17318. status = respJSON["data"].(map[string]interface{})["status"].(string)
  17319. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  17320. var token string
  17321. var res ResultTwo //1101结果
  17322. var res10265 ResultTwo10265 //1101结果
  17323. if status == "0" { //读卡成功
  17324. var card_info string //卡信息
  17325. var busi_card_info string
  17326. token = respJSON["data"].(map[string]interface{})["token"].(string)
  17327. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  17328. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  17329. fmt.Println(card_info)
  17330. fmt.Println(busi_card_info)
  17331. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  17332. result, _ := json.Marshal(respJSON)
  17333. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17334. utils.ErrorLog("解析失败:%v", err)
  17335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17336. return
  17337. }
  17338. res.ErrMsg = res10265.ErrMsg
  17339. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  17340. res.Infcode = infocode
  17341. res.Output = res10265.Output
  17342. res.InfRefmsgid = res10265.InfRefmsgid
  17343. if res.Infcode == 0 {
  17344. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17345. if err == gorm.ErrRecordNotFound {
  17346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17347. return
  17348. } else if err != nil {
  17349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17350. return
  17351. } else {
  17352. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17353. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17354. infoStr := string(Iinfos)
  17355. idetinfoStr := string(Idetinfos)
  17356. psn := &models.HisPsn{
  17357. PsnNo: res.Output.Baseinfo.PsnNo,
  17358. PatientId: patient.ID,
  17359. Certno: res.Output.Baseinfo.Certno,
  17360. Gend: res.Output.Baseinfo.Gend,
  17361. Naty: res.Output.Baseinfo.Naty,
  17362. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17363. PsnName: res.Output.Baseinfo.PsnName,
  17364. Idetinfo: idetinfoStr,
  17365. Insuinfo: infoStr,
  17366. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17367. CardInfo: card_info,
  17368. VerifyNumber: token,
  17369. }
  17370. var rf []*ResultFive
  17371. json.Unmarshal([]byte(infoStr), &rf)
  17372. var insutypes []*ResultFive
  17373. var insutype string
  17374. var is390 int = 0
  17375. var is310 int = 0
  17376. for _, item := range rf {
  17377. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17378. insutypes = append(insutypes, item)
  17379. }
  17380. }
  17381. if len(insutypes) == 1 {
  17382. insutype = insutypes[0].Insutype
  17383. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17384. } else {
  17385. for _, i := range insutypes {
  17386. if i.Insutype == "390" {
  17387. is390 = 1
  17388. }
  17389. if i.Insutype == "310" {
  17390. is310 = 1
  17391. }
  17392. }
  17393. }
  17394. if is390 == 1 {
  17395. insutype = "390"
  17396. }
  17397. if is310 == 1 {
  17398. insutype = "310"
  17399. }
  17400. if len(insutypes) == 0 {
  17401. insutype = "310"
  17402. }
  17403. service.CreateHisPsn(psn)
  17404. c.ServeSuccessJSON(map[string]interface{}{
  17405. "patient": patient,
  17406. "number": token,
  17407. "insutype": insutype,
  17408. })
  17409. }
  17410. } else {
  17411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17412. return
  17413. }
  17414. } else { //读卡失败
  17415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17416. return
  17417. }
  17418. } else if miConfig.MdtrtareaAdmvs == "450721" {
  17419. res := c.GetoleInfo()
  17420. if res.Infcode == 0 {
  17421. var result string
  17422. if res.Output.MdtrtCertType == "01" {
  17423. 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)
  17424. } else if res.Output.MdtrtCertType == "02" {
  17425. 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)
  17426. } else if res.Output.MdtrtCertType == "03" {
  17427. 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)
  17428. }
  17429. var dat map[string]interface{}
  17430. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17431. fmt.Println(dat)
  17432. } else {
  17433. fmt.Println(err)
  17434. }
  17435. userJSONBytes, _ := json.Marshal(dat)
  17436. var res2 ResultTwo
  17437. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17438. utils.ErrorLog("解析失败:%v", err)
  17439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17440. return
  17441. }
  17442. if res2.Infcode == 0 {
  17443. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  17444. if err == gorm.ErrRecordNotFound {
  17445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17446. return
  17447. } else if err != nil {
  17448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17449. return
  17450. } else {
  17451. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  17452. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  17453. infoStr := string(Iinfos)
  17454. idetinfoStr := string(Idetinfos)
  17455. var rf []*ResultFive
  17456. json.Unmarshal([]byte(infoStr), &rf)
  17457. var insutypes []*ResultFive
  17458. var insutype string
  17459. var is390 int = 0
  17460. var is310 int = 0
  17461. //var insuplc_admdvs string
  17462. for _, item := range rf {
  17463. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17464. insutypes = append(insutypes, item)
  17465. }
  17466. }
  17467. if len(insutypes) == 1 {
  17468. insutype = insutypes[0].Insutype
  17469. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17470. } else {
  17471. for _, i := range insutypes {
  17472. if i.Insutype == "390" {
  17473. is390 = 1
  17474. }
  17475. if i.Insutype == "310" {
  17476. is310 = 1
  17477. }
  17478. }
  17479. }
  17480. if is390 == 1 {
  17481. insutype = "390"
  17482. }
  17483. if is310 == 1 {
  17484. insutype = "310"
  17485. }
  17486. if len(insutypes) == 0 {
  17487. insutype = "310"
  17488. }
  17489. psn := &models.HisPsn{
  17490. PsnNo: res2.Output.Baseinfo.PsnNo,
  17491. PatientId: patient.ID,
  17492. Certno: res2.Output.Baseinfo.Certno,
  17493. Gend: res2.Output.Baseinfo.Gend,
  17494. Naty: res2.Output.Baseinfo.Naty,
  17495. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  17496. PsnName: res2.Output.Baseinfo.PsnName,
  17497. Idetinfo: idetinfoStr,
  17498. Insuinfo: infoStr,
  17499. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17500. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  17501. VerifyNumber: res.Output.EcToken,
  17502. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  17503. }
  17504. if res.Output.MdtrtCertType == "01" {
  17505. psn.VerifyNumber = res.Output.EcToken
  17506. //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)
  17507. } else if res.Output.MdtrtCertType == "02" {
  17508. psn.VerifyNumber = res.Output.CardNo
  17509. //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)
  17510. } else if res.Output.MdtrtCertType == "03" {
  17511. psn.VerifyNumber = res.Output.MdtrtCertNo
  17512. //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)
  17513. }
  17514. service.CreateHisPsn(psn)
  17515. var balc float64
  17516. for _, item := range rf {
  17517. if item.Insutype == insutype {
  17518. balc = item.Balc
  17519. }
  17520. }
  17521. c.ServeSuccessJSON(map[string]interface{}{
  17522. "patient": patient,
  17523. "number": res.Output.CardNo,
  17524. "insutype": insutype,
  17525. "blac": balc,
  17526. "desc": idetinfoStr,
  17527. })
  17528. }
  17529. } else {
  17530. c.ServeSuccessJSON(map[string]interface{}{
  17531. "failed_code": -10,
  17532. "msg": res2.ErrMsg,
  17533. })
  17534. }
  17535. } else {
  17536. c.ServeSuccessJSON(map[string]interface{}{
  17537. "failed_code": -10,
  17538. "msg": res.ErrMsg,
  17539. })
  17540. }
  17541. } else if miConfig.MdtrtareaAdmvs == "420902" {
  17542. var res ResultTwo
  17543. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  17544. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  17545. "&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)
  17546. resp, requestErr := http.Get(api)
  17547. if requestErr != nil {
  17548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17549. return
  17550. }
  17551. body, ioErr := ioutil.ReadAll(resp.Body)
  17552. if ioErr != nil {
  17553. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17555. return
  17556. }
  17557. var respJSON map[string]interface{}
  17558. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17559. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17561. return
  17562. }
  17563. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17564. result, _ := json.Marshal(respJSON)
  17565. fmt.Println("log")
  17566. fmt.Println(string(result))
  17567. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17568. utils.ErrorLog("解析失败:%v", err)
  17569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17570. return
  17571. }
  17572. if res.Infcode == 0 {
  17573. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17574. if err == gorm.ErrRecordNotFound {
  17575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17576. return
  17577. } else if err != nil {
  17578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17579. return
  17580. } else {
  17581. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17582. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17583. infoStr := string(Iinfos)
  17584. idetinfoStr := string(Idetinfos)
  17585. var rf []*ResultFive
  17586. json.Unmarshal([]byte(infoStr), &rf)
  17587. var insutypes []*ResultFive
  17588. var insutype string
  17589. var is390 int = 0
  17590. var is310 int = 0
  17591. for _, item := range rf {
  17592. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  17593. insutypes = append(insutypes, item)
  17594. }
  17595. }
  17596. if len(insutypes) == 1 {
  17597. insutype = insutypes[0].Insutype
  17598. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17599. } else {
  17600. for _, i := range insutypes {
  17601. if i.Insutype == "390" {
  17602. is390 = 1
  17603. }
  17604. if i.Insutype == "310" {
  17605. is310 = 1
  17606. }
  17607. }
  17608. }
  17609. if is390 == 1 {
  17610. insutype = "390"
  17611. }
  17612. if is310 == 1 {
  17613. insutype = "310"
  17614. }
  17615. if len(insutypes) == 0 {
  17616. insutype = "390"
  17617. }
  17618. var insuplc_admdvs string
  17619. for _, item := range rf {
  17620. if item.Insutype == insutype {
  17621. insuplc_admdvs = item.InsuplcAdmdvs
  17622. }
  17623. }
  17624. psn := &models.HisPsn{
  17625. PsnNo: res.Output.Baseinfo.PsnNo,
  17626. PatientId: patient.ID,
  17627. Certno: res.Output.Baseinfo.Certno,
  17628. Gend: res.Output.Baseinfo.Gend,
  17629. Naty: res.Output.Baseinfo.Naty,
  17630. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17631. PsnName: res.Output.Baseinfo.PsnName,
  17632. Idetinfo: idetinfoStr,
  17633. Insuinfo: infoStr,
  17634. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17635. InsuplcAdmdvs: insuplc_admdvs,
  17636. }
  17637. service.CreateHisPsn(psn)
  17638. c.ServeSuccessJSON(map[string]interface{}{
  17639. "patient": patient,
  17640. "number": res.Output.Baseinfo.Certno,
  17641. })
  17642. }
  17643. } else {
  17644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17645. return
  17646. }
  17647. } else {
  17648. type ELeData struct {
  17649. Code string `json:"code"`
  17650. Data struct {
  17651. Aac002 string `json:"aac002"`
  17652. Aaz500 string `json:"aaz500"`
  17653. ActCardNo string `json:"actCardNo"`
  17654. Bab520 string `json:"bab520"`
  17655. Bkz543 string `json:"bkz543"`
  17656. BusinessType string `json:"businessType"`
  17657. CertfCodg string `json:"certfCodg"`
  17658. EcIndexNo string `json:"ecIndexNo"`
  17659. EcToken string `json:"ecToken"`
  17660. ID0000 string `json:"id0000"`
  17661. IDNo string `json:"idNo"`
  17662. IDType string `json:"idType"`
  17663. Idcode string `json:"idcode"`
  17664. IdentityToken string `json:"identity_token"`
  17665. InsuOrg string `json:"insuOrg"`
  17666. OfficeID string `json:"officeId"`
  17667. OfficeName string `json:"officeName"`
  17668. OperatorID string `json:"operatorId"`
  17669. OperatorName string `json:"operatorName"`
  17670. OrgID string `json:"orgId"`
  17671. UserName string `json:"userName"`
  17672. } `json:"data"`
  17673. Infno interface{} `json:"infno"`
  17674. Message string `json:"message"`
  17675. OrgID string `json:"orgId"`
  17676. TransType string `json:"transType"`
  17677. }
  17678. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  17679. fmt.Println(result)
  17680. outPutInfo := Remove0000(result)
  17681. fmt.Println(outPutInfo)
  17682. if len(outPutInfo) > 0 {
  17683. var ele ELeData
  17684. err := json.Unmarshal([]byte(outPutInfo), &ele)
  17685. if err != nil {
  17686. utils.ErrorLog("解析失败:%v", err)
  17687. }
  17688. token := ele.Data.EcToken
  17689. fmt.Println(outPutInfo)
  17690. 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)
  17691. saveLog(result, requestLog, "1101", "获取人员信息")
  17692. var dat map[string]interface{}
  17693. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17694. fmt.Println(dat)
  17695. } else {
  17696. fmt.Println(err)
  17697. }
  17698. userJSONBytes, _ := json.Marshal(dat)
  17699. var res ResultTwo
  17700. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17701. utils.ErrorLog("解析失败:%v", err)
  17702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17703. return
  17704. }
  17705. if res.Infcode == 0 {
  17706. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  17707. if err == gorm.ErrRecordNotFound {
  17708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17709. return
  17710. } else if err != nil {
  17711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17712. return
  17713. } else {
  17714. fmt.Println(res)
  17715. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17716. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17717. infoStr := string(Iinfos)
  17718. idetinfoStr := string(Idetinfos)
  17719. psn := &models.HisPsn{
  17720. PsnNo: res.Output.Baseinfo.PsnNo,
  17721. PatientId: patient.ID,
  17722. Certno: res.Output.Baseinfo.Certno,
  17723. Gend: res.Output.Baseinfo.Gend,
  17724. Naty: res.Output.Baseinfo.Naty,
  17725. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17726. PsnName: res.Output.Baseinfo.PsnName,
  17727. Idetinfo: idetinfoStr,
  17728. Insuinfo: infoStr,
  17729. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17730. CardInfo: outPutInfo,
  17731. VerifyNumber: token,
  17732. InsuplcAdmdvs: ele.Data.InsuOrg,
  17733. }
  17734. service.CreateHisPsn(psn)
  17735. var rf []*ResultFive
  17736. json.Unmarshal([]byte(infoStr), &rf)
  17737. var insutypes []*ResultFive
  17738. var insutype string
  17739. var is390 int = 0
  17740. var is310 int = 0
  17741. for _, item := range rf {
  17742. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17743. insutypes = append(insutypes, item)
  17744. }
  17745. }
  17746. if len(insutypes) == 1 {
  17747. insutype = insutypes[0].Insutype
  17748. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17749. } else {
  17750. for _, i := range insutypes {
  17751. if i.Insutype == "390" {
  17752. is390 = 1
  17753. }
  17754. if i.Insutype == "310" {
  17755. is310 = 1
  17756. }
  17757. }
  17758. }
  17759. if is390 == 1 {
  17760. insutype = "390"
  17761. }
  17762. if is310 == 1 {
  17763. insutype = "310"
  17764. }
  17765. if len(insutypes) == 0 {
  17766. insutype = "310"
  17767. }
  17768. c.ServeSuccessJSON(map[string]interface{}{
  17769. "patient": patient,
  17770. "number": token,
  17771. "insutype": insutype,
  17772. })
  17773. }
  17774. } else {
  17775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17776. return
  17777. }
  17778. }
  17779. //fmt.Println(result)
  17780. //
  17781. //if initFlag == 0 {
  17782. // c.TestGetBasBaseInit()
  17783. //}
  17784. //token := c.GetEleBaseInfo()
  17785. //
  17786. //token = Remove0000(token)
  17787. //
  17788. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  17789. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  17790. ////
  17791. //var res ResultTwo
  17792. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17793. // utils.ErrorLog("解析失败:%v", err)
  17794. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17795. // return
  17796. //}
  17797. //
  17798. //if res.Infcode == 0 {
  17799. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17800. // if err == gorm.ErrRecordNotFound {
  17801. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17802. // return
  17803. // } else if err != nil {
  17804. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17805. // return
  17806. //
  17807. // } else {
  17808. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17809. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17810. // infoStr := string(Iinfos)
  17811. // idetinfoStr := string(Idetinfos)
  17812. //
  17813. //
  17814. //
  17815. //
  17816. // var rf []*ResultFive
  17817. // json.Unmarshal([]byte(infoStr), &rf)
  17818. //
  17819. // var insutypes []*ResultFive
  17820. // var insutype string
  17821. // var is390 int = 0
  17822. // var is310 int = 0
  17823. // var insuplc_admdvs string
  17824. //
  17825. // for _, item := range rf {
  17826. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17827. // insutypes = append(insutypes, item)
  17828. // }
  17829. // }
  17830. //
  17831. // if len(insutypes) == 1 {
  17832. // insutype = insutypes[0].Insutype
  17833. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17834. // } else {
  17835. // for _, i := range insutypes {
  17836. // if i.Insutype == "390" {
  17837. // is390 = 1
  17838. // }
  17839. //
  17840. // if i.Insutype == "310" {
  17841. // is310 = 1
  17842. // }
  17843. // }
  17844. // }
  17845. // if is390 == 1 {
  17846. // insutype = "390"
  17847. // }
  17848. //
  17849. // if is310 == 1 {
  17850. // insutype = "310"
  17851. // }
  17852. // if len(insutypes) == 0 {
  17853. // insutype = "310"
  17854. // }
  17855. // for _, item := range rf {
  17856. // if item.Insutype == insutype {
  17857. // insuplc_admdvs = item.InsuplcAdmdvs
  17858. // }
  17859. // }
  17860. // psn := &models.HisPsn{
  17861. // PsnNo: res.Output.Baseinfo.PsnNo,
  17862. // Age: res.Output.Baseinfo.Age,
  17863. // PatientId: patient.ID,
  17864. // Certno: res.Output.Baseinfo.Certno,
  17865. // Brdy: res.Output.Baseinfo.Brdy,
  17866. // Gend: res.Output.Baseinfo.Gend,
  17867. // Naty: res.Output.Baseinfo.Naty,
  17868. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  17869. // PsnName: res.Output.Baseinfo.PsnName,
  17870. // Idetinfo: idetinfoStr,
  17871. // Insuinfo: infoStr,
  17872. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17873. // CardInfo: "",
  17874. // VerifyNumber: token,
  17875. // InsuplcAdmdvs: insuplc_admdvs,
  17876. // }
  17877. // service.CreateHisPsn(psn)
  17878. //
  17879. // c.ServeSuccessJSON(map[string]interface{}{
  17880. // "patient": patient,
  17881. // "number": token,
  17882. // })
  17883. // }
  17884. //} else {
  17885. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17886. // return
  17887. //}
  17888. }
  17889. break
  17890. case 5:
  17891. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  17892. var api string
  17893. if miConfig.MdtrtareaAdmvs == "320830" {
  17894. api = miConfig.AppSecret + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  17895. "&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
  17896. fmt.Println(api)
  17897. } else if miConfig.MdtrtareaAdmvs == "320921" {
  17898. 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 +
  17899. "&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
  17900. fmt.Println(api)
  17901. } else {
  17902. 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 +
  17903. "&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)
  17904. }
  17905. resp, requestErr := http.Get(api)
  17906. if requestErr != nil {
  17907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17908. return
  17909. }
  17910. body, ioErr := ioutil.ReadAll(resp.Body)
  17911. if ioErr != nil {
  17912. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17914. return
  17915. }
  17916. var respJSON map[string]interface{}
  17917. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17918. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17920. return
  17921. }
  17922. var status string
  17923. status = respJSON["data"].(map[string]interface{})["status"].(string)
  17924. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  17925. var token string
  17926. var res ResultTwo //1101结果
  17927. var res10265 ResultTwo10265 //1101结果
  17928. if status == "0" { //读卡成功
  17929. var card_info string //卡信息
  17930. //var busi_card_info string
  17931. var auth_info string
  17932. token = respJSON["data"].(map[string]interface{})["token"].(string)
  17933. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  17934. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  17935. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  17936. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  17937. result, _ := json.Marshal(respJSON)
  17938. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17939. utils.ErrorLog("解析失败:%v", err)
  17940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17941. return
  17942. }
  17943. res.ErrMsg = res10265.ErrMsg
  17944. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  17945. res.Infcode = infocode
  17946. res.Output = res10265.Output
  17947. res.InfRefmsgid = res10265.InfRefmsgid
  17948. if res.Infcode == 0 {
  17949. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17950. if err == gorm.ErrRecordNotFound {
  17951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17952. return
  17953. } else if err != nil {
  17954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17955. return
  17956. } else {
  17957. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17958. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17959. infoStr := string(Iinfos)
  17960. idetinfoStr := string(Idetinfos)
  17961. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  17962. psn := &models.HisPsn{
  17963. PsnNo: res.Output.Baseinfo.PsnNo,
  17964. PatientId: patient.ID,
  17965. Certno: res.Output.Baseinfo.Certno,
  17966. Gend: res.Output.Baseinfo.Gend,
  17967. Brdy: b,
  17968. Age: float64(age),
  17969. Naty: res.Output.Baseinfo.Naty,
  17970. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17971. PsnName: res.Output.Baseinfo.PsnName,
  17972. Idetinfo: idetinfoStr,
  17973. Insuinfo: infoStr,
  17974. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17975. CardInfo: card_info,
  17976. VerifyNumber: token,
  17977. AuthInfo: auth_info,
  17978. }
  17979. var rf []*ResultFive
  17980. json.Unmarshal([]byte(infoStr), &rf)
  17981. var insutypes []*ResultFive
  17982. var insutype string
  17983. var is390 int = 0
  17984. var is310 int = 0
  17985. for _, item := range rf {
  17986. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17987. insutypes = append(insutypes, item)
  17988. }
  17989. }
  17990. if len(insutypes) == 1 {
  17991. insutype = insutypes[0].Insutype
  17992. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17993. } else {
  17994. for _, i := range insutypes {
  17995. if i.Insutype == "390" {
  17996. is390 = 1
  17997. }
  17998. if i.Insutype == "310" {
  17999. is310 = 1
  18000. }
  18001. }
  18002. }
  18003. if is390 == 1 {
  18004. insutype = "390"
  18005. }
  18006. if is310 == 1 {
  18007. insutype = "310"
  18008. }
  18009. if len(insutypes) == 0 {
  18010. insutype = "310"
  18011. }
  18012. service.CreateHisPsn(psn)
  18013. c.ServeSuccessJSON(map[string]interface{}{
  18014. "patient": patient,
  18015. "number": token,
  18016. "insutype": insutype,
  18017. })
  18018. }
  18019. } else {
  18020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18021. return
  18022. }
  18023. } else { //读卡失败
  18024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18025. return
  18026. }
  18027. }
  18028. break
  18029. }
  18030. }
  18031. var initFlag int64 = 0
  18032. var initEleFlag int64 = 0
  18033. func (c *HisApiController) TestGetBasBaseInit() {
  18034. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18035. Iinit := DllDef.MustFindProc("Init")
  18036. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18037. url := ""
  18038. if miConfig.InsuplcAdmdvs[:4] == "4403" {
  18039. url = "http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"
  18040. } else if miConfig.InsuplcAdmdvs[:4] == "4401" {
  18041. url = ""
  18042. } else {
  18043. url = "http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"
  18044. }
  18045. fmt.Println("SSCard的报错原因:", url)
  18046. fmt.Println("SSCard的报错原因:", miConfig.InsuplcAdmdvs)
  18047. ret, _, err := Iinit.Call(StrPtr(url), StrPtr(miConfig.InsuplcAdmdvs))
  18048. if ret != 0 {
  18049. fmt.Println("SSCard的报错原因:", err)
  18050. fmt.Println("SSCard的运算结果为:", ret)
  18051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18052. return
  18053. }
  18054. result := int(ret)
  18055. fmt.Println("SSCard的运算结果为1:", result)
  18056. initFlag = 1
  18057. return
  18058. }
  18059. func (c *HisApiController) HandleJiangXiReadCard() {
  18060. fmt.Println("~~~~~~")
  18061. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18062. admin_user_id, _ := c.GetInt64("admin_user_id")
  18063. id_card_type, _ := c.GetInt64("id_card_type")
  18064. //certificates, _ := c.GetInt64("certificates")
  18065. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18066. if initFlag == 0 {
  18067. c.TestGetJiangXiBasBaseInit()
  18068. }
  18069. basStr := c.GetBasBaseInfo()
  18070. if len(basStr) == 0 {
  18071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18072. return
  18073. }
  18074. fmt.Println(basStr)
  18075. bas := strings.Split(basStr, "|")
  18076. basNumber := bas[1]
  18077. fmt.Println(basNumber)
  18078. card_sn := bas[3]
  18079. fmt.Println(card_sn)
  18080. 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, "")
  18081. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  18082. var dat map[string]interface{}
  18083. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18084. fmt.Println(dat)
  18085. } else {
  18086. fmt.Println(err)
  18087. }
  18088. userJSONBytes, _ := json.Marshal(dat)
  18089. var res ResultTwo
  18090. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18091. utils.ErrorLog("解析失败:%v", err)
  18092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18093. return
  18094. }
  18095. if res.Infcode == 0 {
  18096. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  18097. if err == gorm.ErrRecordNotFound {
  18098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  18099. return
  18100. } else if err != nil {
  18101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  18102. return
  18103. } else {
  18104. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  18105. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  18106. infoStr := string(Iinfos)
  18107. idetinfoStr := string(Idetinfos)
  18108. psn := &models.HisPsn{
  18109. PsnNo: res.Output.Baseinfo.PsnNo,
  18110. PatientId: patient.ID,
  18111. Certno: res.Output.Baseinfo.Certno,
  18112. Gend: res.Output.Baseinfo.Gend,
  18113. Naty: res.Output.Baseinfo.Naty,
  18114. PsnCertType: res.Output.Baseinfo.PsnCertType,
  18115. PsnName: res.Output.Baseinfo.PsnName,
  18116. Idetinfo: idetinfoStr,
  18117. Insuinfo: infoStr,
  18118. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18119. CardInfo: basStr,
  18120. VerifyNumber: "",
  18121. }
  18122. service.CreateHisPsn(psn)
  18123. c.ServeSuccessJSON(map[string]interface{}{
  18124. "patient": patient,
  18125. "number": basNumber,
  18126. })
  18127. }
  18128. } else {
  18129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18130. return
  18131. }
  18132. }
  18133. func (c *HisApiController) TestGetHnBasBaseInit() {
  18134. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18135. Iinit := DllDef.MustFindProc("Init")
  18136. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18137. //http://10.77.211.236/CSB/hsa-fsi-1303
  18138. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  18139. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  18140. // 调用 Init 函数
  18141. 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"))))
  18142. //if ret != 0 {
  18143. fmt.Println("SSCard的报错原因:", err)
  18144. fmt.Println("SSCard的运算结果为:", ret)
  18145. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18146. // return
  18147. //}
  18148. result := int(ret)
  18149. fmt.Println("SSCard的运算结果为1:", result)
  18150. initFlag = 1
  18151. return
  18152. }
  18153. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  18154. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18155. Iinit := DllDef.MustFindProc("Init")
  18156. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18157. //http://10.77.211.236/CSB/hsa-fsi-1303
  18158. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360302"))
  18159. if ret != 0 {
  18160. fmt.Println("SSCard的报错原因:", err)
  18161. fmt.Println("SSCard的运算结果为:", ret)
  18162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18163. return
  18164. }
  18165. result := int(ret)
  18166. fmt.Println("SSCard的运算结果为1:", result)
  18167. initFlag = 1
  18168. return
  18169. }
  18170. func (c *HisApiController) TestGetJiangXiBasBaseInittwo() {
  18171. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18172. Iinit := DllDef.MustFindProc("Init")
  18173. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18174. //http://10.77.211.236/CSB/hsa-fsi-1303
  18175. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360100"))
  18176. if ret != 0 {
  18177. fmt.Println("SSCard的报错原因:", err)
  18178. fmt.Println("SSCard的运算结果为:", ret)
  18179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18180. return
  18181. }
  18182. result := int(ret)
  18183. fmt.Println("SSCard的运算结果为1:", result)
  18184. initFlag = 1
  18185. return
  18186. }
  18187. func (c *HisApiController) GetSFZBaseInfo() string {
  18188. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18189. readCard := DllDef.MustFindProc("ReadSFZ")
  18190. if readCard == nil {
  18191. fmt.Println("readcard is nil")
  18192. readCard = DllDef.MustFindProc("ReadSFZ")
  18193. }
  18194. str := make([]byte, 8096)
  18195. str1 := make([]byte, 8096)
  18196. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  18197. fmt.Println(r)
  18198. return Remove0000(string(str))
  18199. }
  18200. func (c *HisApiController) GetEleBaseInfo() string {
  18201. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18202. readCard := DllDef.MustFindProc("GetQRBase")
  18203. fmt.Println(readCard)
  18204. if readCard == nil {
  18205. fmt.Println("readcard is nil")
  18206. readCard = DllDef.MustFindProc("GetQRBase")
  18207. }
  18208. str := make([]byte, 1024)
  18209. str1 := make([]byte, 1024)
  18210. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  18211. fmt.Println(ret2)
  18212. fmt.Println(string(str1))
  18213. fmt.Println(string(str))
  18214. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18215. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18216. if ret2 != 0 {
  18217. return ""
  18218. }
  18219. return string(str)
  18220. }
  18221. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  18222. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18223. readCard := DllDef.MustFindProc("NationEcTrans")
  18224. fmt.Println(readCard)
  18225. fmt.Println("!!!!!")
  18226. pBusiCardInfo := make([]byte, 2048)
  18227. input := make(map[string]interface{})
  18228. inputData := make(map[string]interface{})
  18229. inputData["orgId"] = code
  18230. inputData["businessType"] = "01101"
  18231. inputData["operatorId"] = "1"
  18232. inputData["operatorName"] = "admin"
  18233. inputData["officeId"] = "001"
  18234. inputData["officeName"] = "血透室"
  18235. inputData["deviceType"] = ""
  18236. input["data"] = inputData
  18237. input["orgId"] = code
  18238. input["transType"] = "ec.query"
  18239. bytesData, _ := json.Marshal(input)
  18240. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  18241. fmt.Println(ret2)
  18242. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18243. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18244. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  18245. }
  18246. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  18247. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18248. readCard := DllDef.MustFindProc("NationEcTrans")
  18249. fmt.Println(readCard)
  18250. fmt.Println("!!!!!")
  18251. pBusiCardInfo := make([]byte, 2048)
  18252. input := make(map[string]interface{})
  18253. inputData := make(map[string]interface{})
  18254. inputData["orgId"] = code
  18255. inputData["businessType"] = "01101"
  18256. inputData["operatorId"] = "9"
  18257. inputData["operatorName"] = "admin"
  18258. inputData["officeId"] = "001"
  18259. inputData["officeName"] = "血透室"
  18260. inputData["deviceType"] = ""
  18261. input["data"] = inputData
  18262. input["orgId"] = code
  18263. input["transType"] = "ec.query"
  18264. bytesData, _ := json.Marshal(input)
  18265. 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])))
  18266. fmt.Println(ret2)
  18267. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18268. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18269. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  18270. }
  18271. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  18272. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18273. readCard := DllDef.MustFindProc("NationEcTrans")
  18274. fmt.Println(readCard)
  18275. fmt.Println("!!!!!")
  18276. pBusiCardInfo := make([]byte, 2048)
  18277. input := make(map[string]interface{})
  18278. inputData := make(map[string]interface{})
  18279. inputData["orgId"] = code
  18280. inputData["businessType"] = "01301"
  18281. inputData["operatorId"] = "9"
  18282. inputData["operatorName"] = "admin"
  18283. inputData["officeId"] = "001"
  18284. inputData["officeName"] = "血透室"
  18285. inputData["deviceType"] = ""
  18286. input["data"] = inputData
  18287. input["orgId"] = code
  18288. input["transType"] = "ec.query"
  18289. bytesData, _ := json.Marshal(input)
  18290. 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])))
  18291. fmt.Println(ret2)
  18292. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18293. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18294. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  18295. }
  18296. func GetJxEleBaseInfo(org_id int64) string {
  18297. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18298. readCard := DllDef.MustFindProc("NationEcTrans")
  18299. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18300. if readCard == nil {
  18301. fmt.Println("readcard is nil")
  18302. readCard = DllDef.MustFindProc("NationEcTrans")
  18303. }
  18304. str1 := make([]byte, 1024)
  18305. data := make(map[string]interface{})
  18306. inputData := make(map[string]interface{})
  18307. inputData["orgId"] = miConfig.Code
  18308. inputData["businessType"] = "01101"
  18309. inputData["operatorId"] = "test001"
  18310. inputData["operatorName"] = "cn"
  18311. inputData["officeId"] = "32760"
  18312. inputData["officeName"] = "waike"
  18313. inputData["deviceType"] = ""
  18314. data["data"] = inputData
  18315. data["transType"] = "ec.query"
  18316. data["extra "] = ""
  18317. data["orgId"] = miConfig.Code
  18318. bytesData, _ := json.Marshal(data)
  18319. //bytesData, _ := json.Marshal(data)
  18320. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18321. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18322. fmt.Println(ret2)
  18323. fmt.Println(string(str1))
  18324. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18325. if ret2 != 0 {
  18326. return ""
  18327. }
  18328. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18329. }
  18330. //func GetJxEleBaseInfoTWO(org_id int64) string {
  18331. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  18332. // readCard := DllDef.MustFindProc("NationEcTrans")
  18333. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18334. //
  18335. // if readCard == nil {
  18336. // fmt.Println("readcard is nil")
  18337. // readCard = DllDef.MustFindProc("NationEcTrans")
  18338. // }
  18339. // str1 := make([]byte, 1024)
  18340. //
  18341. // data := make(map[string]interface{})
  18342. //
  18343. // inputData := make(map[string]interface{})
  18344. // inputData["orgId"] = miConfig.Code
  18345. // inputData["businessType"] = "01101"
  18346. // inputData["operatorId"] = "test001"
  18347. // inputData["operatorName"] = "cn"
  18348. // inputData["officeId"] = "32760"
  18349. // inputData["officeName"] = "waike"
  18350. // inputData["deviceType"] = ""
  18351. //
  18352. // data["data"] = inputData
  18353. // data["transType"] = "ec.query"
  18354. // data["extra "] = ""
  18355. // data["orgId"] = miConfig.Code
  18356. // bytesData, _ := json.Marshal(data)
  18357. // //bytesData, _ := json.Marshal(data)
  18358. //
  18359. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18360. //
  18361. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18362. // fmt.Println(ret2)
  18363. // fmt.Println(string(str1))
  18364. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18365. //
  18366. // if ret2 != 0 {
  18367. // return ""
  18368. // }
  18369. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18370. //}
  18371. func GetJxEleBaseInitInfo(org_id int64) string {
  18372. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18373. readCard := DllDef.MustFindProc("NationEcTrans")
  18374. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18375. if readCard == nil {
  18376. fmt.Println("readcard is nil")
  18377. readCard = DllDef.MustFindProc("NationEcTrans")
  18378. }
  18379. str1 := make([]byte, 2048)
  18380. data := make(map[string]interface{})
  18381. inputData := make(map[string]interface{})
  18382. inputData["orgId"] = miConfig.Code
  18383. inputData["businessType"] = "01101"
  18384. inputData["operatorId"] = "1"
  18385. inputData["operatorName"] = "huangchuang"
  18386. inputData["officeId"] = "101"
  18387. inputData["officeName"] = "xuetou"
  18388. inputData["deviceType"] = ""
  18389. data["data"] = inputData
  18390. data["transType"] = "ec.query"
  18391. data["orgId"] = miConfig.Code
  18392. bytesData, _ := json.Marshal(data)
  18393. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18394. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18395. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  18396. fmt.Println(ret2)
  18397. fmt.Println(string(str1))
  18398. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18399. if ret2 != 0 {
  18400. return ""
  18401. }
  18402. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  18403. initEleFlag = 1
  18404. }
  18405. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18406. }
  18407. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  18408. // // 构建命令
  18409. // cmd := exec.Command("python", "b.py")
  18410. //
  18411. // // 执行命令并等待完成
  18412. // output, err := cmd.CombinedOutput()
  18413. // if err != nil {
  18414. // fmt.Println("Error executing Python script:", err)
  18415. // return
  18416. // }
  18417. //
  18418. // // 打印Python脚本的输出
  18419. // fmt.Println(string(output))
  18420. //}
  18421. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  18422. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  18423. readCard := DllDef.MustFindProc("gxyb_call")
  18424. if readCard == nil {
  18425. fmt.Println("readcard is nil")
  18426. readCard = DllDef.MustFindProc("gxyb_call")
  18427. }
  18428. str := make([]byte, 1024)
  18429. str1 := make([]byte, 1024)
  18430. //data := make(map[string]interface{})
  18431. currentTime := time.Now()
  18432. // 格式化时间为 "YYYYMMDDHH24MISS"
  18433. formattedTime := currentTime.Format("20060102150405")
  18434. inputData := make(map[string]interface{})
  18435. inputData2 := make(map[string]interface{})
  18436. inputData["transNo"] = "1401"
  18437. inputData["transType"] = "passwordCheck"
  18438. inputData["timestamp"] = formattedTime
  18439. inputData2["fixmedinsCode"] = code
  18440. inputData2["psnNo"] = ""
  18441. inputData["data"] = inputData2
  18442. jsonBytes, err := json.Marshal(inputData)
  18443. if err != nil {
  18444. fmt.Println("Error encoding map to JSON:", err)
  18445. }
  18446. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18447. fmt.Println(string(str1))
  18448. fmt.Println(string(str))
  18449. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18450. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18451. if ret2 != 0 {
  18452. return ""
  18453. }
  18454. return string(str)
  18455. }
  18456. func (c *HisApiController) GetoleInfo() Response {
  18457. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  18458. defer ole.CoUninitialize()
  18459. // Replace with the ProgID or CLSID of your COM object
  18460. progID := "YinHai.XJ.Actual.Interface.New"
  18461. // Create COM object
  18462. unknown, err := oleutil.CreateObject(progID)
  18463. if err != nil {
  18464. fmt.Println("Unable to create COM object:", err)
  18465. }
  18466. defer unknown.Release()
  18467. // Query for the IDispatch interface
  18468. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  18469. if err != nil {
  18470. fmt.Println("Unable to get IDispatch interface:", err)
  18471. }
  18472. defer dispatch.Release()
  18473. // Prepare parameters
  18474. transNo := "1401"
  18475. transType := "passwordCheck"
  18476. timestamp := time.Now().Unix()
  18477. fixmedinsCode := "H45072101171"
  18478. psnNo := ""
  18479. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  18480. result2 := ""
  18481. // Call COM object's method using the IDispatch interface
  18482. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  18483. fmt.Println(resulr)
  18484. fmt.Println(result2)
  18485. if err != nil {
  18486. fmt.Println("调用COM对象方法失败:", err)
  18487. }
  18488. var response Response
  18489. err2 := json.Unmarshal([]byte(result2), &response)
  18490. if err2 != nil {
  18491. fmt.Println("解析JSON失败:", err)
  18492. }
  18493. return response
  18494. }
  18495. func (c *HisApiController) GetBasBaseInfo() string {
  18496. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18497. readCard := DllDef.MustFindProc("ReadCardBas")
  18498. if readCard == nil {
  18499. fmt.Println("readcard is nil")
  18500. readCard = DllDef.MustFindProc("ReadCardBas")
  18501. }
  18502. str := make([]byte, 1024)
  18503. str1 := make([]byte, 1024)
  18504. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  18505. fmt.Println(string(str1))
  18506. fmt.Println(string(str))
  18507. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18508. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18509. if ret2 != 0 {
  18510. return ""
  18511. }
  18512. return string(str)
  18513. }
  18514. type Program struct {
  18515. FunctionID string `xml:"function_id"`
  18516. CardInfo string `xml:"cardinfo"`
  18517. User string `xml:"user"`
  18518. }
  18519. func (c *HisApiController) GetBasBaseInfo1111() string {
  18520. DllDef := syscall.MustLoadDLL("HealthyCarder.dll")
  18521. readCard := DllDef.MustFindProc("ReadSICardInfo")
  18522. readCard2 := DllDef.MustFindProc("ReadCardInfo")
  18523. if readCard == nil {
  18524. fmt.Println("readcard is nil")
  18525. readCard = DllDef.MustFindProc("ReadSICardInfo")
  18526. }
  18527. if readCard2 == nil {
  18528. fmt.Println("readcard is nil")
  18529. readCard2 = DllDef.MustFindProc("ReadCardInfo")
  18530. }
  18531. str := make([]byte, 1024)
  18532. str1 := make([]byte, 1024)
  18533. readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18534. str3 := make([]byte, 1024)
  18535. str4 := make([]byte, 1024)
  18536. readCard.Call((uintptr)(unsafe.Pointer(&str[3])), (uintptr)(unsafe.Pointer(&str1[4])))
  18537. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18538. //if err != nil {
  18539. // fmt.Println("Error opening file:", err)
  18540. //}
  18541. //defer file.Close()
  18542. //
  18543. //var lastProgram Program
  18544. //scanner := bufio.NewScanner(file)
  18545. //inProgram := false
  18546. //
  18547. //for scanner.Scan() {
  18548. // line := scanner.Text()
  18549. // if strings.Contains(line, "<program>") {
  18550. // inProgram = true
  18551. // programXML := "<program>"
  18552. // for scanner.Scan() {
  18553. // line = scanner.Text()
  18554. // programXML += line
  18555. // if strings.Contains(line, "</program>") {
  18556. // programXML += "</program>"
  18557. // break
  18558. // }
  18559. // }
  18560. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18561. // // 解析成功,更新最后的 Program
  18562. // }
  18563. // inProgram = false
  18564. // }
  18565. //}
  18566. //
  18567. // fmt.Println("Error reading file:", inProgram)
  18568. //
  18569. //if err := scanner.Err(); err != nil {
  18570. // fmt.Println("Error reading file:", err)
  18571. //}
  18572. // 输出最后一次的 Program
  18573. //fmt.Printf("最后一次的 <program>:\n")
  18574. //fmt.Printf("<program>\n")
  18575. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18576. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18577. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18578. //fmt.Printf("</program>\n")
  18579. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18580. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18581. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  18582. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  18583. return ConvertToString(string(str), "gbk", "utf-8")
  18584. }
  18585. func (c *HisApiController) GetBasBaseInfo22222() string {
  18586. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  18587. readCard := DllDef.MustFindProc("iReadCardUnclassifiedBas")
  18588. if readCard == nil {
  18589. fmt.Println("readcard is nil")
  18590. readCard = DllDef.MustFindProc("iReadCardUnclassifiedBas")
  18591. }
  18592. str := make([]byte, 1024)
  18593. str1 := make([]byte, 1024)
  18594. readCard.Call(uintptr(1), (uintptr)(unsafe.Pointer(&str1[0])))
  18595. //ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  18596. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18597. //if err != nil {
  18598. // fmt.Println("Error opening file:", err)
  18599. //}
  18600. //defer file.Close()
  18601. //
  18602. //var lastProgram Program
  18603. //scanner := bufio.NewScanner(file)
  18604. //inProgram := false
  18605. //
  18606. //for scanner.Scan() {
  18607. // line := scanner.Text()
  18608. // if strings.Contains(line, "<program>") {
  18609. // inProgram = true
  18610. // programXML := "<program>"
  18611. // for scanner.Scan() {
  18612. // line = scanner.Text()
  18613. // programXML += line
  18614. // if strings.Contains(line, "</program>") {
  18615. // programXML += "</program>"
  18616. // break
  18617. // }
  18618. // }
  18619. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18620. // // 解析成功,更新最后的 Program
  18621. // }
  18622. // inProgram = false
  18623. // }
  18624. //}
  18625. //
  18626. // fmt.Println("Error reading file:", inProgram)
  18627. //
  18628. //if err := scanner.Err(); err != nil {
  18629. // fmt.Println("Error reading file:", err)
  18630. //}
  18631. // 输出最后一次的 Program
  18632. //fmt.Printf("最后一次的 <program>:\n")
  18633. //fmt.Printf("<program>\n")
  18634. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18635. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18636. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18637. //fmt.Printf("</program>\n")
  18638. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18639. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18640. return ConvertToString(string(str1), "gbk", "utf-8")
  18641. }
  18642. func (c *HisApiController) GetahBasBaseInfo() string {
  18643. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  18644. readCard := DllDef.MustFindProc("iReadCardBas")
  18645. if readCard == nil {
  18646. fmt.Println("readcard is nil")
  18647. readCard = DllDef.MustFindProc("iReadCardBas")
  18648. }
  18649. //str := make([]byte, 1024)
  18650. str1 := make([]byte, 1024)
  18651. ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  18652. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18653. //if err != nil {
  18654. // fmt.Println("Error opening file:", err)
  18655. //}
  18656. //defer file.Close()
  18657. //
  18658. //var lastProgram Program
  18659. //scanner := bufio.NewScanner(file)
  18660. //inProgram := false
  18661. //
  18662. //for scanner.Scan() {
  18663. // line := scanner.Text()
  18664. // if strings.Contains(line, "<program>") {
  18665. // inProgram = true
  18666. // programXML := "<program>"
  18667. // for scanner.Scan() {
  18668. // line = scanner.Text()
  18669. // programXML += line
  18670. // if strings.Contains(line, "</program>") {
  18671. // programXML += "</program>"
  18672. // break
  18673. // }
  18674. // }
  18675. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18676. // // 解析成功,更新最后的 Program
  18677. // }
  18678. // inProgram = false
  18679. // }
  18680. //}
  18681. //
  18682. // fmt.Println("Error reading file:", inProgram)
  18683. //
  18684. //if err := scanner.Err(); err != nil {
  18685. // fmt.Println("Error reading file:", err)
  18686. //}
  18687. // 输出最后一次的 Program
  18688. //fmt.Printf("最后一次的 <program>:\n")
  18689. //fmt.Printf("<program>\n")
  18690. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18691. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18692. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18693. //fmt.Printf("</program>\n")
  18694. fmt.Println(string(str1))
  18695. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18696. if ret2 != 0 {
  18697. return ""
  18698. }
  18699. return string(str1)
  18700. }
  18701. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  18702. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  18703. readCard := DllDef.MustFindProc("read_cardinfo")
  18704. if readCard == nil {
  18705. fmt.Println("readcard is nil")
  18706. readCard = DllDef.MustFindProc("read_cardinfo")
  18707. }
  18708. str := make([]byte, 1024) //卡号
  18709. str1 := make([]byte, 1024) //卡识别码
  18710. str2 := make([]byte, 1024) //身份证号
  18711. str3 := make([]byte, 1024) //姓名
  18712. str4 := make([]byte, 1024) //错误信息
  18713. 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])))
  18714. fmt.Println(string(str1))
  18715. fmt.Println(string(str))
  18716. fmt.Println(string(str2))
  18717. fmt.Println(string(str3))
  18718. fmt.Println(string(str4))
  18719. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18720. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18721. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  18722. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  18723. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  18724. if ret2 != 0 {
  18725. return "", "", "", "", ""
  18726. }
  18727. return string(str), string(str1), string(str2), string(str3), string(str4)
  18728. }
  18729. type CustomFundPay struct {
  18730. FundPayType string `json:"fund_pay_type"`
  18731. FundPayamt float64 `json:"fund_payamt"`
  18732. InscpScpAmt float64 `json:"inscp_scp_amt"`
  18733. }
  18734. //func (c *HisApiController) GetBatchSettleList() {
  18735. // start_time_str := c.GetString("start_time")
  18736. // //end_time_str := c.GetString("end_time")
  18737. // admin_user_id, _ := c.GetInt64("admin_user_id")
  18738. //
  18739. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  18740. //
  18741. // for _, item := range orders {
  18742. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  18743. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18744. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18745. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18746. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18747. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18748. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18749. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18750. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18751. //
  18752. // if order.ID == 0 {
  18753. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  18754. // return
  18755. // }
  18756. //
  18757. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18758. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18759. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18760. // //fmt.Println(count)
  18761. // //var zero string
  18762. // //number := count + 1
  18763. // //if number >= 1000 {
  18764. // // zero = "0000" + strconv.FormatInt(number, 10)
  18765. // //} else if number >= 10000 {
  18766. // // zero = "000" + strconv.FormatInt(number, 10)
  18767. // //} else if number >= 100000 {
  18768. // // zero = "00" + strconv.FormatInt(number, 10)
  18769. // //} else if number >= 1000000 {
  18770. // // zero = "0" + strconv.FormatInt(number, 10)
  18771. // //} else {
  18772. // // zero = strconv.FormatInt(number, 10)
  18773. // //}
  18774. // //fmt.Println(zero)
  18775. //
  18776. // struct4101 := service.Struct4101{
  18777. // PsnNo: order.PsnNo,
  18778. // MdtrtId: order.MdtrtId,
  18779. // SetlId: order.SetlId,
  18780. // PsnName: order.PsnName,
  18781. // Gend: order.Gend,
  18782. // Brdy: his.Brdy,
  18783. // Age: his.Age,
  18784. // Naty: order.Naty,
  18785. // PatnCertType: "01",
  18786. // Certno: order.Certno,
  18787. // Prfs: "90",
  18788. // ConerName: roles[0].UserName,
  18789. // PatnRlts: "99",
  18790. // ConerAddr: miConfig.OrgName,
  18791. // ConerTel: admin.Mobile,
  18792. // HiType: order.Insutype,
  18793. // Insuplc: miConfig.InsuplcAdmdvs,
  18794. // MaindiagFlag: "1",
  18795. // BillCode: order.SetlId,
  18796. // BillNo: order.SetlId,
  18797. // BizSn: order.Number,
  18798. // PsnSelfPay: order.PsnPartAmt,
  18799. // PsnOwnPay: order.PsnPartAmt,
  18800. // AcctPay: order.AcctPay,
  18801. // PsnCashpay: order.PsnCashPay,
  18802. // HiPaymtd: "1",
  18803. // Hsorg: miConfig.InsuplcAdmdvs,
  18804. // HsorgOpter: miConfig.InsuplcAdmdvs,
  18805. // MedinsFillPsn: curRoles.UserName,
  18806. // MedinsFillDept: miConfig.OrgName,
  18807. // IptMedType: "2",
  18808. // }
  18809. // struct4101.SetlBegnDate = order.SetlTime
  18810. // struct4101.SetlEndDate = order.SetlTime
  18811. // time_arr := strings.Split(order.SetlTime, " ")
  18812. // struct4101.AdmTime = time_arr[0]
  18813. // struct4101.AdmEndTime = time_arr[0]
  18814. //
  18815. // var rf []CustomFundPay
  18816. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  18817. //
  18818. // var tempFunPays []service.CustomStruct
  18819. // for _, item := range rf {
  18820. // var tempFunPay service.CustomStruct
  18821. // tempFunPay.FundPayamt = item.FundPayamt
  18822. // tempFunPay.FundPayType = item.FundPayType
  18823. // tempFunPays = append(tempFunPays, tempFunPay)
  18824. // }
  18825. // struct4101.CustomStruct = tempFunPays
  18826. //
  18827. // var tempDiaginfos []service.DiaginfoStructTwo
  18828. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18829. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18830. //
  18831. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18832. // var config []*models.HisXtDiagnoseConfig
  18833. // for _, item := range diagnosis_ids {
  18834. // id, _ := strconv.ParseInt(item, 10, 64)
  18835. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  18836. // config = append(config, &diagnosisConfig)
  18837. // }
  18838. //
  18839. // for index, item := range config {
  18840. // if index == 0 {
  18841. // var tempDiaginfo service.DiaginfoStructTwo
  18842. // tempDiaginfo.DiagCode = item.CountryCode
  18843. // tempDiaginfo.DiagName = item.CountryContentName
  18844. // tempDiaginfo.DiagType = "1"
  18845. // tempDiaginfo.MaindiagFlag = "1"
  18846. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18847. // } else {
  18848. // var tempDiaginfo service.DiaginfoStructTwo
  18849. // tempDiaginfo.DiagCode = item.CountryCode
  18850. // tempDiaginfo.DiagName = item.CountryContentName
  18851. // tempDiaginfo.DiagType = "1"
  18852. // tempDiaginfo.MaindiagFlag = "0"
  18853. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18854. // }
  18855. // }
  18856. // struct4101.Diseinfo = tempDiaginfos
  18857. //
  18858. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  18859. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18860. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18861. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18862. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18863. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18864. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18865. //
  18866. // var iteminfo service.IteminfoStruct
  18867. //
  18868. // var bedCostTotal float64 = 0 //床位总费
  18869. // var bedCostSelfTotal float64 = 0 //床位自费
  18870. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18871. //
  18872. // var operationCostTotal float64 = 0 //手术费
  18873. // var operationCostSelfTotal float64 = 0 //手术费
  18874. // var operationCostPartSelfTotal float64 = 0 //手术费
  18875. //
  18876. // var otherCostTotal float64 = 0 //其他费用
  18877. // var otherCostSelfTotal float64 = 0 //其他费用
  18878. // var otherCostPartSelfTotal float64 = 0 //其他费用
  18879. //
  18880. // var materialCostTotal float64 = 0 //材料费
  18881. // var materialCostSelfTotal float64 = 0 //材料费
  18882. // var materialCostPartSelfTotal float64 = 0 //材料费
  18883. //
  18884. // var westernMedicineCostTotal float64 = 0 //西药费
  18885. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  18886. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18887. //
  18888. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18889. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18890. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18891. //
  18892. // var checkCostTotal float64 = 0 //检查费
  18893. // var checkCostSelfTotal float64 = 0 //检查费
  18894. // var checkCostPartSelfTotal float64 = 0 //检查费
  18895. //
  18896. // var laboratoryCostTotal float64 = 0 //化验费
  18897. // var laboratoryCostSelfTotal float64 = 0 //化验费
  18898. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18899. //
  18900. // var treatCostTotal float64 = 0 //治疗费用
  18901. // var treatCostSelfTotal float64 = 0 //治疗费用
  18902. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  18903. //
  18904. // decimal.DivisionPrecision = 2
  18905. //
  18906. // var bed_fulamt_ownpay_amt float64 = 0
  18907. // var operation_fulamt_ownpay_amt float64 = 0
  18908. // var other_fulamt_ownpay_amt float64 = 0
  18909. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  18910. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18911. // var check_fulamt_ownpay_amt float64 = 0
  18912. // var material_fulamt_ownpay_amt float64 = 0
  18913. // var laboratory_fulamt_ownpay_amt float64 = 0
  18914. // var treat_fulamt_ownpay_amt float64 = 0
  18915. //
  18916. // var bed_claa_sunmfee float64 = 0
  18917. // var bed_clab_amt float64 = 0
  18918. // var bed_other_amt float64 = 0
  18919. //
  18920. // var operation_claa_sunmfee float64 = 0
  18921. // var operation_clab_amt float64 = 0
  18922. // var operation_other_amt float64 = 0
  18923. //
  18924. // var other_claa_sunmfee float64 = 0
  18925. // var other_clab_amt float64 = 0
  18926. // var other_other_amt float64 = 0
  18927. //
  18928. // var westernMedicine_claa_sunmfee float64 = 0
  18929. // var westernMedicine_clab_amt float64 = 0
  18930. // var westernMedicine_other_amt float64 = 0
  18931. //
  18932. // var chineseTraditional_claa_sunmfee float64 = 0
  18933. // var chineseTraditional_clab_amt float64 = 0
  18934. // var chineseTraditional_other_amt float64 = 0
  18935. //
  18936. // var check_claa_sunmfee float64 = 0
  18937. // var check_clab_amt float64 = 0
  18938. // var check_other_amt float64 = 0
  18939. //
  18940. // var material_claa_sunmfee float64 = 0
  18941. // var material_clab_amt float64 = 0
  18942. // var material_other_amt float64 = 0
  18943. //
  18944. // var laboratory_claa_sunmfee float64 = 0
  18945. // var laboratory_clab_amt float64 = 0
  18946. // var laboratory_other_amt float64 = 0
  18947. //
  18948. // var treat_claa_sunmfee float64 = 0
  18949. // var treat_clab_amt float64 = 0
  18950. // var treat_other_amt float64 = 0
  18951. //
  18952. // for _, item := range order.HisOrderInfo {
  18953. // if item.MedChrgitmType == "01" { //床位费
  18954. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18955. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18956. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18957. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18958. // if item.ChrgitmLv == "1" {
  18959. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18960. // }
  18961. // if item.ChrgitmLv == "2" {
  18962. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18963. //
  18964. // }
  18965. // if item.ChrgitmLv == "3" {
  18966. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18967. // }
  18968. //
  18969. // }
  18970. //
  18971. // if item.MedChrgitmType == "03" { //检查费
  18972. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18973. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18974. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18975. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18976. // if item.ChrgitmLv == "1" {
  18977. //
  18978. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18979. //
  18980. // }
  18981. // if item.ChrgitmLv == "2" {
  18982. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18983. //
  18984. // }
  18985. // if item.ChrgitmLv == "3" {
  18986. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18987. // }
  18988. // }
  18989. //
  18990. // if item.MedChrgitmType == "04" { //化验费
  18991. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18992. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18993. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18994. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18995. // if item.ChrgitmLv == "1" {
  18996. //
  18997. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18998. //
  18999. // }
  19000. // if item.ChrgitmLv == "2" {
  19001. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19002. //
  19003. // }
  19004. // if item.ChrgitmLv == "3" {
  19005. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19006. // }
  19007. // }
  19008. //
  19009. // if item.MedChrgitmType == "05" { //治疗费
  19010. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19011. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19012. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19013. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19014. // if item.ChrgitmLv == "1" {
  19015. //
  19016. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19017. //
  19018. // }
  19019. // if item.ChrgitmLv == "2" {
  19020. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19021. //
  19022. // }
  19023. // if item.ChrgitmLv == "3" {
  19024. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19025. // }
  19026. // }
  19027. //
  19028. // if item.MedChrgitmType == "06" { //手术费
  19029. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19030. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19031. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19032. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19033. //
  19034. // if item.ChrgitmLv == "1" {
  19035. //
  19036. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19037. //
  19038. // }
  19039. // if item.ChrgitmLv == "2" {
  19040. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19041. //
  19042. // }
  19043. // if item.ChrgitmLv == "3" {
  19044. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19045. // }
  19046. // }
  19047. //
  19048. // if item.MedChrgitmType == "08" { //材料费
  19049. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19050. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19051. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19052. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19053. // if item.ChrgitmLv == "1" {
  19054. //
  19055. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19056. //
  19057. // }
  19058. // if item.ChrgitmLv == "2" {
  19059. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19060. //
  19061. // }
  19062. // if item.ChrgitmLv == "3" {
  19063. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19064. // }
  19065. // }
  19066. //
  19067. // if item.MedChrgitmType == "09" { //西药费
  19068. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19069. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19070. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19071. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19072. // if item.ChrgitmLv == "1" {
  19073. //
  19074. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19075. //
  19076. // }
  19077. // if item.ChrgitmLv == "2" {
  19078. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19079. //
  19080. // }
  19081. // if item.ChrgitmLv == "3" {
  19082. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19083. // }
  19084. // }
  19085. //
  19086. // if item.MedChrgitmType == "11" { //中成费
  19087. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19088. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19089. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19090. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19091. // if item.ChrgitmLv == "1" {
  19092. //
  19093. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19094. //
  19095. // }
  19096. // if item.ChrgitmLv == "2" {
  19097. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19098. //
  19099. // }
  19100. // if item.ChrgitmLv == "3" {
  19101. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19102. // }
  19103. // }
  19104. //
  19105. // if item.MedChrgitmType == "14" { //其他费
  19106. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19107. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19108. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19109. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19110. // if item.ChrgitmLv == "1" {
  19111. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19112. //
  19113. // }
  19114. // if item.ChrgitmLv == "2" {
  19115. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19116. //
  19117. // }
  19118. // if item.ChrgitmLv == "3" {
  19119. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19120. // }
  19121. // }
  19122. //
  19123. // }
  19124. //
  19125. // var iteminfoStructs []service.IteminfoStruct
  19126. //
  19127. // if bedCostTotal != 0 {
  19128. // iteminfo.MedChrgitm = "01"
  19129. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19130. // iteminfo.Amt = bedCostTotal
  19131. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  19132. // iteminfo.ClabAmt = bed_clab_amt
  19133. // iteminfo.OthAmt = bed_other_amt
  19134. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19135. // }
  19136. //
  19137. // if checkCostTotal != 0 {
  19138. // iteminfo.MedChrgitm = "03"
  19139. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19140. // iteminfo.Amt = checkCostTotal
  19141. // iteminfo.ClaaSumfee = check_claa_sunmfee
  19142. // iteminfo.ClabAmt = check_clab_amt
  19143. // iteminfo.OthAmt = check_other_amt
  19144. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19145. //
  19146. // }
  19147. //
  19148. // if laboratoryCostTotal != 0 {
  19149. // iteminfo.MedChrgitm = "04"
  19150. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19151. // iteminfo.Amt = laboratoryCostTotal
  19152. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19153. // iteminfo.ClabAmt = laboratory_clab_amt
  19154. // iteminfo.OthAmt = laboratory_other_amt
  19155. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19156. //
  19157. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19158. //
  19159. // }
  19160. //
  19161. // if treatCostTotal != 0 {
  19162. // iteminfo.MedChrgitm = "05"
  19163. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19164. // iteminfo.Amt = treatCostTotal
  19165. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  19166. // iteminfo.ClabAmt = treat_clab_amt
  19167. // iteminfo.OthAmt = treat_other_amt
  19168. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19169. // //(struct4101.IteminfoStruct, iteminfo)
  19170. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19171. // }
  19172. //
  19173. // if operationCostTotal != 0 {
  19174. // iteminfo.MedChrgitm = "06"
  19175. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19176. // iteminfo.Amt = operationCostTotal
  19177. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  19178. // iteminfo.ClabAmt = operation_clab_amt
  19179. // iteminfo.OthAmt = operation_other_amt
  19180. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19181. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19182. // }
  19183. //
  19184. // if materialCostTotal != 0 {
  19185. // iteminfo.MedChrgitm = "08"
  19186. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19187. // iteminfo.Amt = materialCostTotal
  19188. // iteminfo.ClaaSumfee = material_claa_sunmfee
  19189. // iteminfo.ClabAmt = material_clab_amt
  19190. // iteminfo.OthAmt = material_other_amt
  19191. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19192. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19193. // }
  19194. //
  19195. // if westernMedicineCostTotal != 0 {
  19196. // iteminfo.MedChrgitm = "09"
  19197. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19198. // iteminfo.Amt = westernMedicineCostTotal
  19199. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19200. // iteminfo.ClabAmt = westernMedicine_clab_amt
  19201. // iteminfo.OthAmt = westernMedicine_other_amt
  19202. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19203. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19204. //
  19205. // }
  19206. // if chineseTraditionalMedicineCostTotal != 0 {
  19207. // iteminfo.MedChrgitm = "11"
  19208. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19209. // iteminfo.Amt = westernMedicineCostTotal
  19210. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19211. // iteminfo.ClabAmt = westernMedicine_clab_amt
  19212. // iteminfo.OthAmt = westernMedicine_other_amt
  19213. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19214. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19215. //
  19216. // }
  19217. // if otherCostTotal != 0 {
  19218. // iteminfo.MedChrgitm = "14"
  19219. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19220. // iteminfo.Amt = otherCostTotal
  19221. // iteminfo.ClaaSumfee = other_claa_sunmfee
  19222. // iteminfo.ClabAmt = other_clab_amt
  19223. // iteminfo.OthAmt = other_other_amt
  19224. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19225. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19226. //
  19227. // }
  19228. // struct4101.IteminfoStruct = iteminfoStructs
  19229. // struct4101.Ntly = "中国"
  19230. // struct4101.AdmCaty = "A03.06"
  19231. //
  19232. // struct4101.DoctorName = doctor.UserName
  19233. // struct4101.DoctorCode = doctor.DoctorNumber
  19234. //
  19235. // var res ResultSeventeen
  19236. //
  19237. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19238. // struct4101.BillCode = order.Number
  19239. // struct4101.BillNo = order.SetlId
  19240. // var resOther ResultSeventeenOther
  19241. // var pp models.PublicParams
  19242. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19243. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19244. // pp.FixmedinsName = miConfig.OrgName
  19245. // pp.FixmedinsCode = miConfig.Code
  19246. // pp.RequestUrl = miConfig.Url
  19247. // pp.Cainfo = miConfig.Cainfo
  19248. // pp.SecretKey = miConfig.SecretKey
  19249. // pp.AccessKey = miConfig.AccessKey
  19250. // pp.OpterName = curRoles.UserName
  19251. //
  19252. // client := &http.Client{}
  19253. // var req *http.Request
  19254. // data := make(map[string]interface{})
  19255. // data["struct4101"] = struct4101
  19256. // data["pp"] = pp
  19257. // bytesData, _ := json.Marshal(data)
  19258. // if miConfig.MdtrtareaAdmvs == "320921" {
  19259. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19260. // } else {
  19261. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19262. // }
  19263. // resp, _ := client.Do(req)
  19264. // defer resp.Body.Close()
  19265. // body, ioErr := ioutil.ReadAll(resp.Body)
  19266. // if ioErr != nil {
  19267. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19268. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19269. // return
  19270. // }
  19271. // var respJSON map[string]interface{}
  19272. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19273. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19274. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19275. // return
  19276. // }
  19277. //
  19278. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19279. // userJSONBytes, _ := json.Marshal(respJSON)
  19280. // fmt.Println("log")
  19281. // fmt.Println(string(userJSONBytes))
  19282. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19283. // utils.ErrorLog("解析失败:%v", err)
  19284. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19285. // return
  19286. // }
  19287. // res.InfRefmsgid = resOther.InfRefmsgid
  19288. // res.Output = resOther.Output
  19289. // res.ErrMsg = resOther.ErrMsg
  19290. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19291. // res.Infcode = infocode
  19292. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  19293. //
  19294. // var pp models.PublicParams
  19295. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19296. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19297. // pp.FixmedinsName = miConfig.OrgName
  19298. // pp.FixmedinsCode = miConfig.Code
  19299. // pp.RequestUrl = miConfig.Url
  19300. // pp.Cainfo = miConfig.Cainfo
  19301. // pp.SecretKey = miConfig.SecretKey
  19302. // pp.AccessKey = miConfig.AccessKey
  19303. // pp.OpterName = curRoles.UserName
  19304. // result, _ := service.Jxyb4101(struct4101, pp)
  19305. // var dat map[string]interface{}
  19306. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19307. // fmt.Println(dat)
  19308. // } else {
  19309. // fmt.Println(err)
  19310. // }
  19311. // userJSONBytes, _ := json.Marshal(dat)
  19312. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19313. // utils.ErrorLog("解析失败:%v", err)
  19314. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19315. // return
  19316. // }
  19317. //
  19318. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  19319. // var pp models.PublicParams
  19320. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19321. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19322. // pp.FixmedinsName = miConfig.OrgName
  19323. // pp.FixmedinsCode = miConfig.Code
  19324. // pp.RequestUrl = miConfig.Url
  19325. // pp.Cainfo = miConfig.Cainfo
  19326. // pp.SecretKey = miConfig.SecretKey
  19327. // pp.AccessKey = miConfig.AccessKey
  19328. // pp.OpterName = curRoles.UserName
  19329. // result, _ := service.Hnyb4101(struct4101, pp)
  19330. // var dat map[string]interface{}
  19331. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19332. // fmt.Println(dat)
  19333. // } else {
  19334. // fmt.Println(err)
  19335. // }
  19336. // userJSONBytes, _ := json.Marshal(dat)
  19337. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19338. // utils.ErrorLog("解析失败:%v", err)
  19339. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19340. // return
  19341. // }
  19342. //
  19343. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  19344. // var resOther ResultSeventeenOther
  19345. //
  19346. // var pp models.PublicParams
  19347. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19348. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19349. // pp.FixmedinsName = miConfig.OrgName
  19350. // pp.FixmedinsCode = miConfig.Code
  19351. // pp.RequestUrl = miConfig.Url
  19352. // pp.Cainfo = miConfig.Cainfo
  19353. // pp.SecretKey = miConfig.SecretKey
  19354. // pp.AccessKey = miConfig.AccessKey
  19355. // pp.OpterName = curRoles.UserName
  19356. // client := &http.Client{}
  19357. // var req *http.Request
  19358. // data := make(map[string]interface{})
  19359. // data["struct4101"] = struct4101
  19360. // data["pp"] = pp
  19361. // bytesData, _ := json.Marshal(data)
  19362. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19363. // resp, _ := client.Do(req)
  19364. // defer resp.Body.Close()
  19365. // body, ioErr := ioutil.ReadAll(resp.Body)
  19366. // if ioErr != nil {
  19367. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19368. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19369. // return
  19370. // }
  19371. // var respJSON map[string]interface{}
  19372. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19373. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19374. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19375. // return
  19376. // }
  19377. //
  19378. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19379. // userJSONBytes, _ := json.Marshal(respJSON)
  19380. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19381. // utils.ErrorLog("解析失败:%v", err)
  19382. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19383. // return
  19384. // }
  19385. // res.InfRefmsgid = resOther.InfRefmsgid
  19386. // res.Output = resOther.Output
  19387. // res.ErrMsg = resOther.ErrMsg
  19388. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19389. // res.Infcode = infocode
  19390. //
  19391. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  19392. // var pp models.PublicParams
  19393. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19394. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19395. // pp.FixmedinsName = miConfig.OrgName
  19396. // pp.FixmedinsCode = miConfig.Code
  19397. // pp.RequestUrl = miConfig.Url
  19398. // pp.Cainfo = miConfig.Cainfo
  19399. // pp.SecretKey = miConfig.SecretKey
  19400. // pp.AccessKey = miConfig.AccessKey
  19401. // pp.OpterName = curRoles.UserName
  19402. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19403. // fmt.Println(requestLog)
  19404. // fmt.Println(errMsgLog)
  19405. //
  19406. // saveLog(result, requestLog, "4101a", "上传清单")
  19407. //
  19408. // var dat map[string]interface{}
  19409. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19410. // fmt.Println(dat)
  19411. // } else {
  19412. // fmt.Println(err)
  19413. // }
  19414. // userJSONBytes, _ := json.Marshal(dat)
  19415. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19416. // utils.ErrorLog("解析失败:%v", err)
  19417. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19418. // return
  19419. // }
  19420. //
  19421. // } else {
  19422. //
  19423. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  19424. // var dat map[string]interface{}
  19425. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19426. // fmt.Println(dat)
  19427. // } else {
  19428. // fmt.Println(err)
  19429. // }
  19430. // userJSONBytes, _ := json.Marshal(dat)
  19431. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19432. // utils.ErrorLog("解析失败:%v", err)
  19433. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19434. // return
  19435. // }
  19436. // }
  19437. //
  19438. // if res.Infcode != 0 {
  19439. // adminUser := c.GetAdminUserInfo()
  19440. // errlog := &models.HisOrderError{
  19441. // UserOrgId: adminUser.CurrentOrgId,
  19442. // Ctime: time.Now().Unix(),
  19443. // Mtime: time.Now().Unix(),
  19444. // ErrMsg: res.ErrMsg,
  19445. // Status: 1,
  19446. // PatientId: order.ID,
  19447. // Stage: 10265,
  19448. // }
  19449. // service.CreateErrMsgLog(errlog)
  19450. // continue
  19451. // } else {
  19452. // //order.FaPiaoNumber = zero
  19453. // //order.FaPiaoCode = last_order.FaPiaoCode
  19454. // //service.UpdateOrder(order)
  19455. // hisFundSettleListResult := &models.HisFundSettleListResult{
  19456. // Number: res.Output.SetlListId,
  19457. // Status: 1,
  19458. // Ctime: time.Now().Unix(),
  19459. // Mtime: time.Now().Unix(),
  19460. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19461. // IsUpload: 1,
  19462. // OrderId: order.ID,
  19463. // }
  19464. // service.CreateUploadRecord(hisFundSettleListResult)
  19465. // c.ServeSuccessJSON(map[string]interface{}{
  19466. // "msg": "上传成功",
  19467. // "result": hisFundSettleListResult,
  19468. // })
  19469. // continue
  19470. // }
  19471. // }
  19472. //}
  19473. func (c *HisApiController) GetbatchSettleList() {
  19474. //order_id, _ := c.GetInt64("order_id")
  19475. admin_user_id, _ := c.GetInt64("admin_user_id")
  19476. orders, _ := service.GetAllHisOrderTwo10485()
  19477. for _, item := range orders {
  19478. order, _ := service.GetHisOrderByIDTwo(item.ID)
  19479. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19480. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  19481. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19482. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19483. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19484. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19485. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  19486. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  19487. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19488. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19489. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19490. //fmt.Println(count)
  19491. //var zero string
  19492. //number := count + 1
  19493. //if number >= 1000 {
  19494. // zero = "0000" + strconv.FormatInt(number, 10)
  19495. //} else if number >= 10000 {
  19496. // zero = "000" + strconv.FormatInt(number, 10)
  19497. //} else if number >= 100000 {
  19498. // zero = "00" + strconv.FormatInt(number, 10)
  19499. //} else if number >= 1000000 {
  19500. // zero = "0" + strconv.FormatInt(number, 10)
  19501. //} else {
  19502. // zero = strconv.FormatInt(number, 10)
  19503. //}
  19504. //fmt.Println(zero)
  19505. struct4101 := service.Struct4101{
  19506. PsnNo: order.PsnNo,
  19507. MdtrtId: order.MdtrtId,
  19508. SetlId: order.SetlId,
  19509. PsnName: order.PsnName,
  19510. Gend: order.Gend,
  19511. Brdy: his.Brdy,
  19512. Age: his.Age,
  19513. Naty: order.Naty,
  19514. PatnCertType: "01",
  19515. Certno: order.Certno,
  19516. Prfs: "90",
  19517. ConerName: roles[0].UserName,
  19518. PatnRlts: "99",
  19519. ConerAddr: miConfig.OrgName,
  19520. ConerTel: admin.Mobile,
  19521. HiType: order.Insutype,
  19522. Insuplc: miConfig.InsuplcAdmdvs,
  19523. MaindiagFlag: "1",
  19524. BillCode: order.SetlId,
  19525. BillNo: order.SetlId,
  19526. BizSn: order.Number,
  19527. PsnSelfPay: order.PsnPartAmt,
  19528. PsnOwnPay: order.PsnPartAmt,
  19529. AcctPay: order.AcctPay,
  19530. PsnCashpay: order.PsnCashPay,
  19531. HiPaymtd: "1",
  19532. Hsorg: miConfig.InsuplcAdmdvs,
  19533. HsorgOpter: miConfig.InsuplcAdmdvs,
  19534. MedinsFillPsn: curRoles.UserName,
  19535. MedinsFillDept: miConfig.OrgName,
  19536. IptMedType: "2",
  19537. }
  19538. struct4101.SetlBegnDate = order.SetlTime
  19539. struct4101.SetlEndDate = order.SetlTime
  19540. time_arr := strings.Split(order.SetlTime, " ")
  19541. struct4101.AdmTime = time_arr[0]
  19542. struct4101.AdmEndTime = time_arr[0]
  19543. //var rf []CustomFundPay
  19544. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19545. //
  19546. //var tempFunPays []service.CustomStruct
  19547. //for _, item := range rf {
  19548. // var tempFunPay service.CustomStruct
  19549. // tempFunPay.FundPayamt = item.FundPayamt
  19550. // tempFunPay.FundPayType = item.FundPayType
  19551. // tempFunPays = append(tempFunPays, tempFunPay)
  19552. //}
  19553. //struct4101.CustomStruct = tempFunPays
  19554. var tempDiaginfos []service.DiaginfoStructTwo
  19555. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19556. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19557. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  19558. var config []*models.HisXtDiagnoseConfig
  19559. for _, item := range diagnosis_ids {
  19560. id, _ := strconv.ParseInt(item, 10, 64)
  19561. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19562. config = append(config, &diagnosisConfig)
  19563. }
  19564. for index, item := range config {
  19565. if index == 0 {
  19566. var tempDiaginfo service.DiaginfoStructTwo
  19567. tempDiaginfo.DiagCode = item.CountryCode
  19568. tempDiaginfo.DiagName = item.CountryContentName
  19569. tempDiaginfo.DiagType = "1"
  19570. tempDiaginfo.MaindiagFlag = "1"
  19571. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19572. } else {
  19573. var tempDiaginfo service.DiaginfoStructTwo
  19574. tempDiaginfo.DiagCode = item.CountryCode
  19575. tempDiaginfo.DiagName = item.CountryContentName
  19576. tempDiaginfo.DiagType = "1"
  19577. tempDiaginfo.MaindiagFlag = "0"
  19578. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19579. }
  19580. }
  19581. struct4101.Diseinfo = tempDiaginfos
  19582. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19583. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19584. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19585. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  19586. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  19587. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19588. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19589. var iteminfo service.IteminfoStruct
  19590. var bedCostTotal float64 = 0 //床位总费
  19591. var bedCostSelfTotal float64 = 0 //床位自费
  19592. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19593. var operationCostTotal float64 = 0 //手术费
  19594. var operationCostSelfTotal float64 = 0 //手术费
  19595. var operationCostPartSelfTotal float64 = 0 //手术费
  19596. var otherCostTotal float64 = 0 //其他费用
  19597. var otherCostSelfTotal float64 = 0 //其他费用
  19598. var otherCostPartSelfTotal float64 = 0 //其他费用
  19599. var materialCostTotal float64 = 0 //材料费
  19600. var materialCostSelfTotal float64 = 0 //材料费
  19601. var materialCostPartSelfTotal float64 = 0 //材料费
  19602. var westernMedicineCostTotal float64 = 0 //西药费
  19603. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19604. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19605. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19606. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19607. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19608. var checkCostTotal float64 = 0 //检查费
  19609. var checkCostSelfTotal float64 = 0 //检查费
  19610. var checkCostPartSelfTotal float64 = 0 //检查费
  19611. var laboratoryCostTotal float64 = 0 //化验费
  19612. var laboratoryCostSelfTotal float64 = 0 //化验费
  19613. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19614. var treatCostTotal float64 = 0 //治疗费用
  19615. var treatCostSelfTotal float64 = 0 //治疗费用
  19616. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19617. decimal.DivisionPrecision = 2
  19618. var bed_fulamt_ownpay_amt float64 = 0
  19619. var operation_fulamt_ownpay_amt float64 = 0
  19620. var other_fulamt_ownpay_amt float64 = 0
  19621. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19622. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19623. var check_fulamt_ownpay_amt float64 = 0
  19624. var material_fulamt_ownpay_amt float64 = 0
  19625. var laboratory_fulamt_ownpay_amt float64 = 0
  19626. var treat_fulamt_ownpay_amt float64 = 0
  19627. var bed_claa_sunmfee float64 = 0
  19628. var bed_clab_amt float64 = 0
  19629. var bed_other_amt float64 = 0
  19630. var operation_claa_sunmfee float64 = 0
  19631. var operation_clab_amt float64 = 0
  19632. var operation_other_amt float64 = 0
  19633. var other_claa_sunmfee float64 = 0
  19634. var other_clab_amt float64 = 0
  19635. var other_other_amt float64 = 0
  19636. var westernMedicine_claa_sunmfee float64 = 0
  19637. var westernMedicine_clab_amt float64 = 0
  19638. var westernMedicine_other_amt float64 = 0
  19639. var chineseTraditional_claa_sunmfee float64 = 0
  19640. var chineseTraditional_clab_amt float64 = 0
  19641. var chineseTraditional_other_amt float64 = 0
  19642. var check_claa_sunmfee float64 = 0
  19643. var check_clab_amt float64 = 0
  19644. var check_other_amt float64 = 0
  19645. var material_claa_sunmfee float64 = 0
  19646. var material_clab_amt float64 = 0
  19647. var material_other_amt float64 = 0
  19648. var laboratory_claa_sunmfee float64 = 0
  19649. var laboratory_clab_amt float64 = 0
  19650. var laboratory_other_amt float64 = 0
  19651. var treat_claa_sunmfee float64 = 0
  19652. var treat_clab_amt float64 = 0
  19653. var treat_other_amt float64 = 0
  19654. for _, item := range order.HisOrderInfo {
  19655. if item.MedChrgitmType == "01" { //床位费
  19656. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19657. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19658. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19659. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19660. if item.ChrgitmLv == "1" {
  19661. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19662. }
  19663. if item.ChrgitmLv == "2" {
  19664. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19665. }
  19666. if item.ChrgitmLv == "3" {
  19667. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19668. }
  19669. }
  19670. if item.MedChrgitmType == "03" { //检查费
  19671. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19672. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19673. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19674. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19675. if item.ChrgitmLv == "1" {
  19676. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19677. }
  19678. if item.ChrgitmLv == "2" {
  19679. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19680. }
  19681. if item.ChrgitmLv == "3" {
  19682. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19683. }
  19684. }
  19685. if item.MedChrgitmType == "04" { //化验费
  19686. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19687. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19688. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19689. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19690. if item.ChrgitmLv == "1" {
  19691. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19692. }
  19693. if item.ChrgitmLv == "2" {
  19694. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19695. }
  19696. if item.ChrgitmLv == "3" {
  19697. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19698. }
  19699. }
  19700. if item.MedChrgitmType == "05" { //治疗费
  19701. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19702. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19703. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19704. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19705. if item.ChrgitmLv == "1" {
  19706. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19707. }
  19708. if item.ChrgitmLv == "2" {
  19709. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19710. }
  19711. if item.ChrgitmLv == "3" {
  19712. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19713. }
  19714. }
  19715. if item.MedChrgitmType == "06" { //手术费
  19716. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19717. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19718. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19719. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19720. if item.ChrgitmLv == "1" {
  19721. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19722. }
  19723. if item.ChrgitmLv == "2" {
  19724. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19725. }
  19726. if item.ChrgitmLv == "3" {
  19727. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19728. }
  19729. }
  19730. if item.MedChrgitmType == "08" { //材料费
  19731. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19732. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19733. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19734. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19735. if item.ChrgitmLv == "1" {
  19736. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19737. }
  19738. if item.ChrgitmLv == "2" {
  19739. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19740. }
  19741. if item.ChrgitmLv == "3" {
  19742. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19743. }
  19744. }
  19745. if item.MedChrgitmType == "09" { //西药费
  19746. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19747. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19748. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19749. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19750. if item.ChrgitmLv == "1" {
  19751. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19752. }
  19753. if item.ChrgitmLv == "2" {
  19754. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19755. }
  19756. if item.ChrgitmLv == "3" {
  19757. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19758. }
  19759. }
  19760. if item.MedChrgitmType == "11" { //中成费
  19761. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19762. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19763. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19764. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19765. if item.ChrgitmLv == "1" {
  19766. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19767. }
  19768. if item.ChrgitmLv == "2" {
  19769. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19770. }
  19771. if item.ChrgitmLv == "3" {
  19772. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19773. }
  19774. }
  19775. if item.MedChrgitmType == "14" { //其他费
  19776. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19777. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19778. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19779. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19780. if item.ChrgitmLv == "1" {
  19781. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19782. }
  19783. if item.ChrgitmLv == "2" {
  19784. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19785. }
  19786. if item.ChrgitmLv == "3" {
  19787. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19788. }
  19789. }
  19790. }
  19791. var iteminfoStructs []service.IteminfoStruct
  19792. if bedCostTotal != 0 {
  19793. iteminfo.MedChrgitm = "01"
  19794. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19795. iteminfo.Amt = bedCostTotal
  19796. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19797. iteminfo.ClabAmt = bed_clab_amt
  19798. iteminfo.OthAmt = bed_other_amt
  19799. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19800. }
  19801. if checkCostTotal != 0 {
  19802. iteminfo.MedChrgitm = "03"
  19803. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19804. iteminfo.Amt = checkCostTotal
  19805. iteminfo.ClaaSumfee = check_claa_sunmfee
  19806. iteminfo.ClabAmt = check_clab_amt
  19807. iteminfo.OthAmt = check_other_amt
  19808. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19809. }
  19810. if laboratoryCostTotal != 0 {
  19811. iteminfo.MedChrgitm = "04"
  19812. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19813. iteminfo.Amt = laboratoryCostTotal
  19814. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19815. iteminfo.ClabAmt = laboratory_clab_amt
  19816. iteminfo.OthAmt = laboratory_other_amt
  19817. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19818. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19819. }
  19820. if treatCostTotal != 0 {
  19821. iteminfo.MedChrgitm = "05"
  19822. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19823. iteminfo.Amt = treatCostTotal
  19824. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19825. iteminfo.ClabAmt = treat_clab_amt
  19826. iteminfo.OthAmt = treat_other_amt
  19827. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19828. //(struct4101.IteminfoStruct, iteminfo)
  19829. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19830. }
  19831. if operationCostTotal != 0 {
  19832. iteminfo.MedChrgitm = "06"
  19833. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19834. iteminfo.Amt = operationCostTotal
  19835. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19836. iteminfo.ClabAmt = operation_clab_amt
  19837. iteminfo.OthAmt = operation_other_amt
  19838. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19839. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19840. }
  19841. if materialCostTotal != 0 {
  19842. iteminfo.MedChrgitm = "08"
  19843. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19844. iteminfo.Amt = materialCostTotal
  19845. iteminfo.ClaaSumfee = material_claa_sunmfee
  19846. iteminfo.ClabAmt = material_clab_amt
  19847. iteminfo.OthAmt = material_other_amt
  19848. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19849. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19850. }
  19851. if westernMedicineCostTotal != 0 {
  19852. iteminfo.MedChrgitm = "09"
  19853. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19854. iteminfo.Amt = westernMedicineCostTotal
  19855. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19856. iteminfo.ClabAmt = westernMedicine_clab_amt
  19857. iteminfo.OthAmt = westernMedicine_other_amt
  19858. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19859. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19860. }
  19861. if chineseTraditionalMedicineCostTotal != 0 {
  19862. iteminfo.MedChrgitm = "11"
  19863. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19864. iteminfo.Amt = westernMedicineCostTotal
  19865. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19866. iteminfo.ClabAmt = westernMedicine_clab_amt
  19867. iteminfo.OthAmt = westernMedicine_other_amt
  19868. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19869. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19870. }
  19871. if otherCostTotal != 0 {
  19872. iteminfo.MedChrgitm = "14"
  19873. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19874. iteminfo.Amt = otherCostTotal
  19875. iteminfo.ClaaSumfee = other_claa_sunmfee
  19876. iteminfo.ClabAmt = other_clab_amt
  19877. iteminfo.OthAmt = other_other_amt
  19878. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19879. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19880. }
  19881. struct4101.IteminfoStruct = iteminfoStructs
  19882. struct4101.Ntly = "中国"
  19883. struct4101.AdmCaty = "A03.06"
  19884. struct4101.DoctorName = doctor.UserName
  19885. struct4101.DoctorCode = doctor.DoctorNumber
  19886. var res ResultSeventeen
  19887. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  19888. struct4101.BillCode = order.Number
  19889. struct4101.BillNo = order.SetlId
  19890. var resOther ResultSeventeenOther
  19891. var pp models.PublicParams
  19892. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19893. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19894. pp.FixmedinsName = miConfig.OrgName
  19895. pp.FixmedinsCode = miConfig.Code
  19896. pp.RequestUrl = miConfig.Url
  19897. pp.Cainfo = miConfig.Cainfo
  19898. pp.SecretKey = miConfig.SecretKey
  19899. pp.AccessKey = miConfig.AccessKey
  19900. pp.OpterName = curRoles.UserName
  19901. client := &http.Client{}
  19902. var req *http.Request
  19903. data := make(map[string]interface{})
  19904. data["struct4101"] = struct4101
  19905. data["pp"] = pp
  19906. bytesData, _ := json.Marshal(data)
  19907. if miConfig.MdtrtareaAdmvs == "320830" {
  19908. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/4101", bytes.NewReader(bytesData))
  19909. } else if miConfig.MdtrtareaAdmvs == "320921" {
  19910. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19911. } else {
  19912. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19913. }
  19914. resp, _ := client.Do(req)
  19915. defer resp.Body.Close()
  19916. body, ioErr := ioutil.ReadAll(resp.Body)
  19917. if ioErr != nil {
  19918. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19920. return
  19921. }
  19922. var respJSON map[string]interface{}
  19923. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19924. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19926. return
  19927. }
  19928. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19929. userJSONBytes, _ := json.Marshal(respJSON)
  19930. fmt.Println("log")
  19931. fmt.Println(string(userJSONBytes))
  19932. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19933. utils.ErrorLog("解析失败:%v", err)
  19934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19935. return
  19936. }
  19937. res.InfRefmsgid = resOther.InfRefmsgid
  19938. res.Output = resOther.Output
  19939. res.ErrMsg = resOther.ErrMsg
  19940. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19941. res.Infcode = infocode
  19942. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19943. var pp models.PublicParams
  19944. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19945. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19946. pp.FixmedinsName = miConfig.OrgName
  19947. pp.FixmedinsCode = miConfig.Code
  19948. pp.RequestUrl = miConfig.Url
  19949. pp.Cainfo = miConfig.Cainfo
  19950. pp.SecretKey = miConfig.SecretKey
  19951. pp.AccessKey = miConfig.AccessKey
  19952. pp.OpterName = curRoles.UserName
  19953. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  19954. result, _ := service.Jxyb4101(struct4101, pp)
  19955. var dat map[string]interface{}
  19956. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19957. fmt.Println(dat)
  19958. } else {
  19959. fmt.Println(err)
  19960. }
  19961. userJSONBytes, _ := json.Marshal(dat)
  19962. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19963. utils.ErrorLog("解析失败:%v", err)
  19964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19965. return
  19966. }
  19967. } else if miConfig.MdtrtareaAdmvs == "361025" {
  19968. var pp models.PublicParams
  19969. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19970. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19971. pp.FixmedinsName = miConfig.OrgName
  19972. pp.FixmedinsCode = miConfig.Code
  19973. pp.RequestUrl = miConfig.Url
  19974. pp.Cainfo = miConfig.Cainfo
  19975. pp.SecretKey = miConfig.SecretKey
  19976. pp.AccessKey = miConfig.AccessKey
  19977. pp.OpterName = curRoles.UserName
  19978. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  19979. result, _ := service.Jxyb4101(struct4101, pp)
  19980. var dat map[string]interface{}
  19981. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19982. fmt.Println(dat)
  19983. } else {
  19984. fmt.Println(err)
  19985. }
  19986. userJSONBytes, _ := json.Marshal(dat)
  19987. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19988. utils.ErrorLog("解析失败:%v", err)
  19989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19990. return
  19991. }
  19992. } else if miConfig.MdtrtareaAdmvs == "360100" {
  19993. var pp models.PublicParams
  19994. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19995. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19996. pp.FixmedinsName = miConfig.OrgName
  19997. pp.FixmedinsCode = miConfig.Code
  19998. pp.RequestUrl = miConfig.Url
  19999. pp.Cainfo = miConfig.Cainfo
  20000. pp.SecretKey = miConfig.SecretKey
  20001. pp.AccessKey = miConfig.AccessKey
  20002. pp.OpterName = curRoles.UserName
  20003. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  20004. result, _ := service.Jxyb4101(struct4101, pp)
  20005. var dat map[string]interface{}
  20006. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20007. fmt.Println(dat)
  20008. } else {
  20009. fmt.Println(err)
  20010. }
  20011. userJSONBytes, _ := json.Marshal(dat)
  20012. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20013. utils.ErrorLog("解析失败:%v", err)
  20014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20015. return
  20016. }
  20017. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20018. var pp models.PublicParams
  20019. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20020. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20021. pp.FixmedinsName = miConfig.OrgName
  20022. pp.FixmedinsCode = miConfig.Code
  20023. pp.RequestUrl = miConfig.Url
  20024. pp.Cainfo = miConfig.Cainfo
  20025. pp.SecretKey = miConfig.SecretKey
  20026. pp.AccessKey = miConfig.AccessKey
  20027. pp.OpterName = curRoles.UserName
  20028. result, _ := service.Hnyb4101(struct4101, pp)
  20029. var dat map[string]interface{}
  20030. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20031. fmt.Println(dat)
  20032. } else {
  20033. fmt.Println(err)
  20034. }
  20035. userJSONBytes, _ := json.Marshal(dat)
  20036. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20037. utils.ErrorLog("解析失败:%v", err)
  20038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20039. return
  20040. }
  20041. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20042. var resOther ResultSeventeenOther
  20043. var pp models.PublicParams
  20044. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20045. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20046. pp.FixmedinsName = miConfig.OrgName
  20047. pp.FixmedinsCode = miConfig.Code
  20048. pp.RequestUrl = miConfig.Url
  20049. pp.Cainfo = miConfig.Cainfo
  20050. pp.SecretKey = miConfig.SecretKey
  20051. pp.AccessKey = miConfig.AccessKey
  20052. pp.OpterName = curRoles.UserName
  20053. client := &http.Client{}
  20054. var req *http.Request
  20055. data := make(map[string]interface{})
  20056. data["struct4101"] = struct4101
  20057. data["pp"] = pp
  20058. bytesData, _ := json.Marshal(data)
  20059. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20060. resp, _ := client.Do(req)
  20061. defer resp.Body.Close()
  20062. body, ioErr := ioutil.ReadAll(resp.Body)
  20063. if ioErr != nil {
  20064. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20066. return
  20067. }
  20068. var respJSON map[string]interface{}
  20069. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20070. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20072. return
  20073. }
  20074. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20075. userJSONBytes, _ := json.Marshal(respJSON)
  20076. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20077. utils.ErrorLog("解析失败:%v", err)
  20078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20079. return
  20080. }
  20081. res.InfRefmsgid = resOther.InfRefmsgid
  20082. res.Output = resOther.Output
  20083. res.ErrMsg = resOther.ErrMsg
  20084. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20085. res.Infcode = infocode
  20086. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20087. var pp models.PublicParams
  20088. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20089. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20090. pp.FixmedinsName = miConfig.OrgName
  20091. pp.FixmedinsCode = miConfig.Code
  20092. pp.RequestUrl = miConfig.Url
  20093. pp.Cainfo = miConfig.Cainfo
  20094. pp.SecretKey = miConfig.SecretKey
  20095. pp.AccessKey = miConfig.AccessKey
  20096. pp.OpterName = curRoles.UserName
  20097. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  20098. fmt.Println(requestLog)
  20099. fmt.Println(errMsgLog)
  20100. saveLog(result, requestLog, "4101a", "上传清单")
  20101. var dat map[string]interface{}
  20102. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20103. fmt.Println(dat)
  20104. } else {
  20105. fmt.Println(err)
  20106. }
  20107. userJSONBytes, _ := json.Marshal(dat)
  20108. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20109. utils.ErrorLog("解析失败:%v", err)
  20110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20111. return
  20112. }
  20113. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20114. var pp models.PublicParams
  20115. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20116. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20117. pp.FixmedinsName = miConfig.OrgName
  20118. pp.FixmedinsCode = miConfig.Code
  20119. pp.RequestUrl = miConfig.Url
  20120. pp.Cainfo = miConfig.Cainfo
  20121. pp.SecretKey = miConfig.SecretKey
  20122. pp.AccessKey = miConfig.AccessKey
  20123. pp.OpterName = curRoles.UserName
  20124. client := &http.Client{}
  20125. var req *http.Request
  20126. data := make(map[string]interface{})
  20127. data["struct4101"] = struct4101
  20128. data["pp"] = pp
  20129. bytesData, _ := json.Marshal(data)
  20130. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  20131. resp, _ := client.Do(req)
  20132. defer resp.Body.Close()
  20133. body, ioErr := ioutil.ReadAll(resp.Body)
  20134. if ioErr != nil {
  20135. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20137. return
  20138. }
  20139. var respJSON map[string]interface{}
  20140. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20141. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20143. return
  20144. }
  20145. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20146. userJSONBytes, _ := json.Marshal(respJSON)
  20147. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20148. utils.ErrorLog("解析失败:%v", err)
  20149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20150. return
  20151. }
  20152. } else {
  20153. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20154. var dat map[string]interface{}
  20155. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20156. fmt.Println(dat)
  20157. } else {
  20158. fmt.Println(err)
  20159. }
  20160. userJSONBytes, _ := json.Marshal(dat)
  20161. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20162. utils.ErrorLog("解析失败:%v", err)
  20163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20164. return
  20165. }
  20166. }
  20167. if res.Infcode != 0 {
  20168. errlog := &models.HisOrderError{
  20169. UserOrgId: order.UserOrgId,
  20170. Ctime: time.Now().Unix(),
  20171. Mtime: time.Now().Unix(),
  20172. ErrMsg: res.ErrMsg + "解析失败",
  20173. Status: 1,
  20174. PatientId: order.ID,
  20175. Stage: 10485,
  20176. }
  20177. service.CreateErrMsgLog(errlog)
  20178. continue
  20179. //c.ServeSuccessJSON(map[string]interface{}{
  20180. // "failed_code": -10,
  20181. // "msg": res.ErrMsg,
  20182. //})
  20183. } else {
  20184. //order.FaPiaoNumber = zero
  20185. //order.FaPiaoCode = last_order.FaPiaoCode
  20186. //service.UpdateOrder(order)
  20187. hisFundSettleListResult := &models.HisFundSettleListResult{
  20188. Number: res.Output.SetlListId,
  20189. Status: 1,
  20190. Ctime: time.Now().Unix(),
  20191. Mtime: time.Now().Unix(),
  20192. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20193. IsUpload: 1,
  20194. OrderId: order.ID,
  20195. }
  20196. service.CreateUploadRecord(hisFundSettleListResult)
  20197. continue
  20198. }
  20199. }
  20200. }
  20201. func (c *HisApiController) GetSettleList() {
  20202. order_id, _ := c.GetInt64("order_id")
  20203. admin_user_id, _ := c.GetInt64("admin_user_id")
  20204. order, _ := service.GetHisOrderByIDTwo(order_id)
  20205. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20206. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  20207. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20208. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  20209. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20210. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20211. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  20212. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  20213. if order.ID == 0 {
  20214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20215. return
  20216. }
  20217. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  20218. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  20219. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  20220. //fmt.Println(count)
  20221. //var zero string
  20222. //number := count + 1
  20223. //if number >= 1000 {
  20224. // zero = "0000" + strconv.FormatInt(number, 10)
  20225. //} else if number >= 10000 {
  20226. // zero = "000" + strconv.FormatInt(number, 10)
  20227. //} else if number >= 100000 {
  20228. // zero = "00" + strconv.FormatInt(number, 10)
  20229. //} else if number >= 1000000 {
  20230. // zero = "0" + strconv.FormatInt(number, 10)
  20231. //} else {
  20232. // zero = strconv.FormatInt(number, 10)
  20233. //}
  20234. //fmt.Println(zero)
  20235. struct4101 := service.Struct4101{
  20236. PsnNo: order.PsnNo,
  20237. MdtrtId: order.MdtrtId,
  20238. SetlId: order.SetlId,
  20239. PsnName: order.PsnName,
  20240. Gend: order.Gend,
  20241. Brdy: his.Brdy,
  20242. Age: his.Age,
  20243. Naty: order.Naty,
  20244. PatnCertType: "01",
  20245. Certno: order.Certno,
  20246. Prfs: "90",
  20247. ConerName: roles[0].UserName,
  20248. PatnRlts: "99",
  20249. ConerAddr: miConfig.OrgName,
  20250. ConerTel: admin.Mobile,
  20251. HiType: order.Insutype,
  20252. Insuplc: miConfig.InsuplcAdmdvs,
  20253. MaindiagFlag: "1",
  20254. BillCode: order.SetlId,
  20255. BillNo: order.SetlId,
  20256. BizSn: order.Number,
  20257. PsnSelfPay: order.PsnPartAmt,
  20258. PsnOwnPay: order.PsnPartAmt,
  20259. AcctPay: order.AcctPay,
  20260. PsnCashpay: order.PsnCashPay,
  20261. HiPaymtd: "1",
  20262. Hsorg: miConfig.InsuplcAdmdvs,
  20263. HsorgOpter: miConfig.InsuplcAdmdvs,
  20264. MedinsFillPsn: curRoles.UserName,
  20265. MedinsFillDept: miConfig.OrgName,
  20266. IptMedType: "2",
  20267. }
  20268. struct4101.SetlBegnDate = order.SetlTime
  20269. struct4101.SetlEndDate = order.SetlTime
  20270. time_arr := strings.Split(order.SetlTime, " ")
  20271. struct4101.AdmTime = time_arr[0]
  20272. struct4101.AdmEndTime = time_arr[0]
  20273. //
  20274. //var rf []CustomFundPay
  20275. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  20276. //
  20277. //var tempFunPays []service.CustomStruct
  20278. //for _, item := range rf {
  20279. // var tempFunPay service.CustomStruct
  20280. // tempFunPay.FundPayamt = item.FundPayamt
  20281. // tempFunPay.FundPayType = item.FundPayType
  20282. // tempFunPays = append(tempFunPays, tempFunPay)
  20283. //}
  20284. //struct4101.CustomStruct = tempFunPays
  20285. var tempDiaginfos []service.DiaginfoStructTwo
  20286. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20287. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20288. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  20289. var config []*models.HisXtDiagnoseConfig
  20290. for _, item := range diagnosis_ids {
  20291. id, _ := strconv.ParseInt(item, 10, 64)
  20292. diagnosisConfig, _ := service.FindDiagnoseById(id)
  20293. config = append(config, &diagnosisConfig)
  20294. }
  20295. if miConfig.Code == "H15049901371" {
  20296. //for _, item := range config {
  20297. // if item.ID == 138 {
  20298. diagnosisConfig, _ := service.FindDiagnoseById(138)
  20299. var tempDiaginfo service.DiaginfoStructTwo
  20300. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  20301. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  20302. tempDiaginfo.DiagType = "1"
  20303. tempDiaginfo.MaindiagFlag = "1"
  20304. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20305. //}
  20306. //}
  20307. for _, item := range config {
  20308. if item.ID != 138 {
  20309. var tempDiaginfo service.DiaginfoStructTwo
  20310. tempDiaginfo.DiagCode = item.CountryCode
  20311. tempDiaginfo.DiagName = item.CountryContentName
  20312. tempDiaginfo.DiagType = "1"
  20313. tempDiaginfo.MaindiagFlag = "0"
  20314. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20315. }
  20316. }
  20317. } else {
  20318. for index, item := range config {
  20319. if index == 0 {
  20320. var tempDiaginfo service.DiaginfoStructTwo
  20321. tempDiaginfo.DiagCode = item.CountryCode
  20322. tempDiaginfo.DiagName = item.CountryContentName
  20323. tempDiaginfo.DiagType = "1"
  20324. tempDiaginfo.MaindiagFlag = "1"
  20325. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20326. } else {
  20327. var tempDiaginfo service.DiaginfoStructTwo
  20328. tempDiaginfo.DiagCode = item.CountryCode
  20329. tempDiaginfo.DiagName = item.CountryContentName
  20330. tempDiaginfo.DiagType = "1"
  20331. tempDiaginfo.MaindiagFlag = "0"
  20332. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20333. }
  20334. }
  20335. }
  20336. struct4101.Diseinfo = tempDiaginfos
  20337. sickConfigTwo, _ := service.FindSickById(his.SickType)
  20338. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20339. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20340. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  20341. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  20342. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20343. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20344. var iteminfo service.IteminfoStruct
  20345. var bedCostTotal float64 = 0 //床位总费
  20346. var bedCostSelfTotal float64 = 0 //床位自费
  20347. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20348. var operationCostTotal float64 = 0 //手术费
  20349. var operationCostSelfTotal float64 = 0 //手术费
  20350. var operationCostPartSelfTotal float64 = 0 //手术费
  20351. var otherCostTotal float64 = 0 //其他费用
  20352. var otherCostSelfTotal float64 = 0 //其他费用
  20353. var otherCostPartSelfTotal float64 = 0 //其他费用
  20354. var materialCostTotal float64 = 0 //材料费
  20355. var materialCostSelfTotal float64 = 0 //材料费
  20356. var materialCostPartSelfTotal float64 = 0 //材料费
  20357. var westernMedicineCostTotal float64 = 0 //西药费
  20358. var westernMedicineCostSelfTotal float64 = 0 //西药费
  20359. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20360. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20361. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20362. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20363. var checkCostTotal float64 = 0 //检查费
  20364. var checkCostSelfTotal float64 = 0 //检查费
  20365. var checkCostPartSelfTotal float64 = 0 //检查费
  20366. var laboratoryCostTotal float64 = 0 //化验费
  20367. var laboratoryCostSelfTotal float64 = 0 //化验费
  20368. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20369. var treatCostTotal float64 = 0 //治疗费用
  20370. var treatCostSelfTotal float64 = 0 //治疗费用
  20371. var treatCostPartSelfTotal float64 = 0 //治疗费用
  20372. decimal.DivisionPrecision = 2
  20373. var bed_fulamt_ownpay_amt float64 = 0
  20374. var operation_fulamt_ownpay_amt float64 = 0
  20375. var other_fulamt_ownpay_amt float64 = 0
  20376. var westernMedicine_fulamt_ownpay_amt float64 = 0
  20377. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20378. var check_fulamt_ownpay_amt float64 = 0
  20379. var material_fulamt_ownpay_amt float64 = 0
  20380. var laboratory_fulamt_ownpay_amt float64 = 0
  20381. var treat_fulamt_ownpay_amt float64 = 0
  20382. var bed_claa_sunmfee float64 = 0
  20383. var bed_clab_amt float64 = 0
  20384. var bed_other_amt float64 = 0
  20385. var operation_claa_sunmfee float64 = 0
  20386. var operation_clab_amt float64 = 0
  20387. var operation_other_amt float64 = 0
  20388. var other_claa_sunmfee float64 = 0
  20389. var other_clab_amt float64 = 0
  20390. var other_other_amt float64 = 0
  20391. var westernMedicine_claa_sunmfee float64 = 0
  20392. var westernMedicine_clab_amt float64 = 0
  20393. var westernMedicine_other_amt float64 = 0
  20394. var chineseTraditional_claa_sunmfee float64 = 0
  20395. var chineseTraditional_clab_amt float64 = 0
  20396. var chineseTraditional_other_amt float64 = 0
  20397. var check_claa_sunmfee float64 = 0
  20398. var check_clab_amt float64 = 0
  20399. var check_other_amt float64 = 0
  20400. var material_claa_sunmfee float64 = 0
  20401. var material_clab_amt float64 = 0
  20402. var material_other_amt float64 = 0
  20403. var laboratory_claa_sunmfee float64 = 0
  20404. var laboratory_clab_amt float64 = 0
  20405. var laboratory_other_amt float64 = 0
  20406. var treat_claa_sunmfee float64 = 0
  20407. var treat_clab_amt float64 = 0
  20408. var treat_other_amt float64 = 0
  20409. for _, item := range order.HisOrderInfo {
  20410. if item.MedChrgitmType == "01" { //床位费
  20411. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20412. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20413. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20414. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20415. if item.ChrgitmLv == "1" {
  20416. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20417. }
  20418. if item.ChrgitmLv == "2" {
  20419. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20420. }
  20421. if item.ChrgitmLv == "3" {
  20422. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20423. }
  20424. }
  20425. if item.MedChrgitmType == "03" { //检查费
  20426. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20427. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20428. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20429. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20430. if item.ChrgitmLv == "1" {
  20431. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20432. }
  20433. if item.ChrgitmLv == "2" {
  20434. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20435. }
  20436. if item.ChrgitmLv == "3" {
  20437. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20438. }
  20439. }
  20440. if item.MedChrgitmType == "04" { //化验费
  20441. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20442. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20443. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20444. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20445. if item.ChrgitmLv == "1" {
  20446. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20447. }
  20448. if item.ChrgitmLv == "2" {
  20449. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20450. }
  20451. if item.ChrgitmLv == "3" {
  20452. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20453. }
  20454. }
  20455. if item.MedChrgitmType == "05" { //治疗费
  20456. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20457. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20458. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20459. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20460. if item.ChrgitmLv == "1" {
  20461. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20462. }
  20463. if item.ChrgitmLv == "2" {
  20464. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20465. }
  20466. if item.ChrgitmLv == "3" {
  20467. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20468. }
  20469. }
  20470. if item.MedChrgitmType == "06" { //手术费
  20471. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20472. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20473. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20474. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20475. if item.ChrgitmLv == "1" {
  20476. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20477. }
  20478. if item.ChrgitmLv == "2" {
  20479. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20480. }
  20481. if item.ChrgitmLv == "3" {
  20482. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20483. }
  20484. }
  20485. if item.MedChrgitmType == "08" { //材料费
  20486. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20487. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20488. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20489. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20490. if item.ChrgitmLv == "1" {
  20491. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20492. }
  20493. if item.ChrgitmLv == "2" {
  20494. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20495. }
  20496. if item.ChrgitmLv == "3" {
  20497. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20498. }
  20499. }
  20500. if item.MedChrgitmType == "09" { //西药费
  20501. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20502. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20503. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20504. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20505. if item.ChrgitmLv == "1" {
  20506. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20507. }
  20508. if item.ChrgitmLv == "2" {
  20509. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20510. }
  20511. if item.ChrgitmLv == "3" {
  20512. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20513. }
  20514. }
  20515. if item.MedChrgitmType == "11" { //中成费
  20516. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20517. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20518. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20519. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20520. if item.ChrgitmLv == "1" {
  20521. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20522. }
  20523. if item.ChrgitmLv == "2" {
  20524. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20525. }
  20526. if item.ChrgitmLv == "3" {
  20527. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20528. }
  20529. }
  20530. if item.MedChrgitmType == "14" { //其他费
  20531. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20532. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20533. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20534. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20535. if item.ChrgitmLv == "1" {
  20536. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20537. }
  20538. if item.ChrgitmLv == "2" {
  20539. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20540. }
  20541. if item.ChrgitmLv == "3" {
  20542. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20543. }
  20544. }
  20545. }
  20546. var iteminfoStructs []service.IteminfoStruct
  20547. if bedCostTotal != 0 {
  20548. iteminfo.MedChrgitm = "01"
  20549. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20550. iteminfo.Amt = bedCostTotal
  20551. iteminfo.ClaaSumfee = bed_claa_sunmfee
  20552. iteminfo.ClabAmt = bed_clab_amt
  20553. iteminfo.OthAmt = bed_other_amt
  20554. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20555. }
  20556. if checkCostTotal != 0 {
  20557. iteminfo.MedChrgitm = "03"
  20558. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20559. iteminfo.Amt = checkCostTotal
  20560. iteminfo.ClaaSumfee = check_claa_sunmfee
  20561. iteminfo.ClabAmt = check_clab_amt
  20562. iteminfo.OthAmt = check_other_amt
  20563. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20564. }
  20565. if laboratoryCostTotal != 0 {
  20566. iteminfo.MedChrgitm = "04"
  20567. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20568. iteminfo.Amt = laboratoryCostTotal
  20569. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20570. iteminfo.ClabAmt = laboratory_clab_amt
  20571. iteminfo.OthAmt = laboratory_other_amt
  20572. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20573. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20574. }
  20575. if treatCostTotal != 0 {
  20576. iteminfo.MedChrgitm = "05"
  20577. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20578. iteminfo.Amt = treatCostTotal
  20579. iteminfo.ClaaSumfee = treat_claa_sunmfee
  20580. iteminfo.ClabAmt = treat_clab_amt
  20581. iteminfo.OthAmt = treat_other_amt
  20582. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20583. //(struct4101.IteminfoStruct, iteminfo)
  20584. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20585. }
  20586. if operationCostTotal != 0 {
  20587. iteminfo.MedChrgitm = "06"
  20588. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20589. iteminfo.Amt = operationCostTotal
  20590. iteminfo.ClaaSumfee = operation_claa_sunmfee
  20591. iteminfo.ClabAmt = operation_clab_amt
  20592. iteminfo.OthAmt = operation_other_amt
  20593. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20594. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20595. }
  20596. if materialCostTotal != 0 {
  20597. iteminfo.MedChrgitm = "08"
  20598. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20599. iteminfo.Amt = materialCostTotal
  20600. iteminfo.ClaaSumfee = material_claa_sunmfee
  20601. iteminfo.ClabAmt = material_clab_amt
  20602. iteminfo.OthAmt = material_other_amt
  20603. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20604. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20605. }
  20606. if westernMedicineCostTotal != 0 {
  20607. iteminfo.MedChrgitm = "09"
  20608. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20609. iteminfo.Amt = westernMedicineCostTotal
  20610. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20611. iteminfo.ClabAmt = westernMedicine_clab_amt
  20612. iteminfo.OthAmt = westernMedicine_other_amt
  20613. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20614. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20615. }
  20616. if chineseTraditionalMedicineCostTotal != 0 {
  20617. iteminfo.MedChrgitm = "11"
  20618. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20619. iteminfo.Amt = westernMedicineCostTotal
  20620. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20621. iteminfo.ClabAmt = westernMedicine_clab_amt
  20622. iteminfo.OthAmt = westernMedicine_other_amt
  20623. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20624. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20625. }
  20626. if otherCostTotal != 0 {
  20627. iteminfo.MedChrgitm = "14"
  20628. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20629. iteminfo.Amt = otherCostTotal
  20630. iteminfo.ClaaSumfee = other_claa_sunmfee
  20631. iteminfo.ClabAmt = other_clab_amt
  20632. iteminfo.OthAmt = other_other_amt
  20633. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20634. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20635. }
  20636. struct4101.IteminfoStruct = iteminfoStructs
  20637. struct4101.Ntly = "中国"
  20638. struct4101.AdmCaty = "A03.06"
  20639. struct4101.DoctorName = doctor.UserName
  20640. struct4101.DoctorCode = doctor.DoctorNumber
  20641. var res ResultSeventeen
  20642. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  20643. struct4101.BillCode = order.Number
  20644. struct4101.BillNo = order.SetlId
  20645. var resOther ResultSeventeenOther
  20646. var pp models.PublicParams
  20647. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20648. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20649. pp.FixmedinsName = miConfig.OrgName
  20650. pp.FixmedinsCode = miConfig.Code
  20651. pp.RequestUrl = miConfig.Url
  20652. pp.Cainfo = miConfig.Cainfo
  20653. pp.SecretKey = miConfig.SecretKey
  20654. pp.AccessKey = miConfig.AccessKey
  20655. pp.OpterName = curRoles.UserName
  20656. client := &http.Client{}
  20657. var req *http.Request
  20658. data := make(map[string]interface{})
  20659. data["struct4101"] = struct4101
  20660. data["pp"] = pp
  20661. bytesData, _ := json.Marshal(data)
  20662. if miConfig.MdtrtareaAdmvs == "320830" {
  20663. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/4101", bytes.NewReader(bytesData))
  20664. } else if miConfig.MdtrtareaAdmvs == "320921" {
  20665. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  20666. } else {
  20667. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  20668. }
  20669. resp, _ := client.Do(req)
  20670. defer resp.Body.Close()
  20671. body, ioErr := ioutil.ReadAll(resp.Body)
  20672. if ioErr != nil {
  20673. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20675. return
  20676. }
  20677. var respJSON map[string]interface{}
  20678. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20679. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20681. return
  20682. }
  20683. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  20684. userJSONBytes, _ := json.Marshal(respJSON)
  20685. fmt.Println("log")
  20686. fmt.Println(string(userJSONBytes))
  20687. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20688. utils.ErrorLog("解析失败:%v", err)
  20689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20690. return
  20691. }
  20692. res.InfRefmsgid = resOther.InfRefmsgid
  20693. res.Output = resOther.Output
  20694. res.ErrMsg = resOther.ErrMsg
  20695. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20696. res.Infcode = infocode
  20697. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20698. var pp models.PublicParams
  20699. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20700. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20701. pp.FixmedinsName = miConfig.OrgName
  20702. pp.FixmedinsCode = miConfig.Code
  20703. pp.RequestUrl = miConfig.Url
  20704. pp.Cainfo = miConfig.Cainfo
  20705. pp.SecretKey = miConfig.SecretKey
  20706. pp.AccessKey = miConfig.AccessKey
  20707. pp.OpterName = curRoles.UserName
  20708. result, _ := service.Jxyb4101(struct4101, pp)
  20709. var dat map[string]interface{}
  20710. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20711. fmt.Println(dat)
  20712. } else {
  20713. fmt.Println(err)
  20714. }
  20715. userJSONBytes, _ := json.Marshal(dat)
  20716. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20717. utils.ErrorLog("解析失败:%v", err)
  20718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20719. return
  20720. }
  20721. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20722. var pp models.PublicParams
  20723. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20724. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20725. pp.FixmedinsName = miConfig.OrgName
  20726. pp.FixmedinsCode = miConfig.Code
  20727. pp.RequestUrl = miConfig.Url
  20728. pp.Cainfo = miConfig.Cainfo
  20729. pp.SecretKey = miConfig.SecretKey
  20730. pp.AccessKey = miConfig.AccessKey
  20731. pp.OpterName = curRoles.UserName
  20732. result, _ := service.Jxyb4101(struct4101, pp)
  20733. var dat map[string]interface{}
  20734. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20735. fmt.Println(dat)
  20736. } else {
  20737. fmt.Println(err)
  20738. }
  20739. userJSONBytes, _ := json.Marshal(dat)
  20740. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20741. utils.ErrorLog("解析失败:%v", err)
  20742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20743. return
  20744. }
  20745. } else if miConfig.MdtrtareaAdmvs == "360100" {
  20746. var pp models.PublicParams
  20747. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20748. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20749. pp.FixmedinsName = miConfig.OrgName
  20750. pp.FixmedinsCode = miConfig.Code
  20751. pp.RequestUrl = miConfig.Url
  20752. pp.Cainfo = miConfig.Cainfo
  20753. pp.SecretKey = miConfig.SecretKey
  20754. pp.AccessKey = miConfig.AccessKey
  20755. pp.OpterName = curRoles.UserName
  20756. result, _ := service.Jxyb4101(struct4101, pp)
  20757. var dat map[string]interface{}
  20758. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20759. fmt.Println(dat)
  20760. } else {
  20761. fmt.Println(err)
  20762. }
  20763. userJSONBytes, _ := json.Marshal(dat)
  20764. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20765. utils.ErrorLog("解析失败:%v", err)
  20766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20767. return
  20768. }
  20769. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20770. var pp models.PublicParams
  20771. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20772. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20773. pp.FixmedinsName = miConfig.OrgName
  20774. pp.FixmedinsCode = miConfig.Code
  20775. pp.RequestUrl = miConfig.Url
  20776. pp.Cainfo = miConfig.Cainfo
  20777. pp.SecretKey = miConfig.SecretKey
  20778. pp.AccessKey = miConfig.AccessKey
  20779. pp.OpterName = curRoles.UserName
  20780. result, _ := service.Hnyb4101(struct4101, pp)
  20781. var dat map[string]interface{}
  20782. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20783. fmt.Println(dat)
  20784. } else {
  20785. fmt.Println(err)
  20786. }
  20787. userJSONBytes, _ := json.Marshal(dat)
  20788. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20789. utils.ErrorLog("解析失败:%v", err)
  20790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20791. return
  20792. }
  20793. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20794. var resOther ResultSeventeenOther
  20795. var pp models.PublicParams
  20796. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20797. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20798. pp.FixmedinsName = miConfig.OrgName
  20799. pp.FixmedinsCode = miConfig.Code
  20800. pp.RequestUrl = miConfig.Url
  20801. pp.Cainfo = miConfig.Cainfo
  20802. pp.SecretKey = miConfig.SecretKey
  20803. pp.AccessKey = miConfig.AccessKey
  20804. pp.OpterName = curRoles.UserName
  20805. client := &http.Client{}
  20806. var req *http.Request
  20807. data := make(map[string]interface{})
  20808. data["struct4101"] = struct4101
  20809. data["pp"] = pp
  20810. bytesData, _ := json.Marshal(data)
  20811. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20812. resp, _ := client.Do(req)
  20813. defer resp.Body.Close()
  20814. body, ioErr := ioutil.ReadAll(resp.Body)
  20815. if ioErr != nil {
  20816. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20818. return
  20819. }
  20820. var respJSON map[string]interface{}
  20821. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20822. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20824. return
  20825. }
  20826. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20827. userJSONBytes, _ := json.Marshal(respJSON)
  20828. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20829. utils.ErrorLog("解析失败:%v", err)
  20830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20831. return
  20832. }
  20833. res.InfRefmsgid = resOther.InfRefmsgid
  20834. res.Output = resOther.Output
  20835. res.ErrMsg = resOther.ErrMsg
  20836. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20837. res.Infcode = infocode
  20838. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20839. var pp models.PublicParams
  20840. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20841. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20842. pp.FixmedinsName = miConfig.OrgName
  20843. pp.FixmedinsCode = miConfig.Code
  20844. pp.RequestUrl = miConfig.Url
  20845. pp.Cainfo = miConfig.Cainfo
  20846. pp.SecretKey = miConfig.SecretKey
  20847. pp.AccessKey = miConfig.AccessKey
  20848. pp.OpterName = curRoles.UserName
  20849. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  20850. fmt.Println(requestLog)
  20851. fmt.Println(errMsgLog)
  20852. saveLog(result, requestLog, "4101a", "上传清单")
  20853. var dat map[string]interface{}
  20854. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20855. fmt.Println(dat)
  20856. } else {
  20857. fmt.Println(err)
  20858. }
  20859. userJSONBytes, _ := json.Marshal(dat)
  20860. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20861. utils.ErrorLog("解析失败:%v", err)
  20862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20863. return
  20864. }
  20865. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20866. var pp models.PublicParams
  20867. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20868. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20869. pp.FixmedinsName = miConfig.OrgName
  20870. pp.FixmedinsCode = miConfig.Code
  20871. pp.RequestUrl = miConfig.Url
  20872. pp.Cainfo = miConfig.Cainfo
  20873. pp.SecretKey = miConfig.SecretKey
  20874. pp.AccessKey = miConfig.AccessKey
  20875. pp.OpterName = curRoles.UserName
  20876. client := &http.Client{}
  20877. var req *http.Request
  20878. data := make(map[string]interface{})
  20879. data["struct4101"] = struct4101
  20880. data["pp"] = pp
  20881. bytesData, _ := json.Marshal(data)
  20882. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  20883. resp, _ := client.Do(req)
  20884. defer resp.Body.Close()
  20885. body, ioErr := ioutil.ReadAll(resp.Body)
  20886. if ioErr != nil {
  20887. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20889. return
  20890. }
  20891. var respJSON map[string]interface{}
  20892. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20893. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20895. return
  20896. }
  20897. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20898. userJSONBytes, _ := json.Marshal(respJSON)
  20899. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20900. utils.ErrorLog("解析失败:%v", err)
  20901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20902. return
  20903. }
  20904. } else {
  20905. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20906. var dat map[string]interface{}
  20907. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20908. fmt.Println(dat)
  20909. } else {
  20910. fmt.Println(err)
  20911. }
  20912. userJSONBytes, _ := json.Marshal(dat)
  20913. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20914. utils.ErrorLog("解析失败:%v", err)
  20915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20916. return
  20917. }
  20918. }
  20919. if res.Infcode != 0 {
  20920. c.ServeSuccessJSON(map[string]interface{}{
  20921. "failed_code": -10,
  20922. "msg": res.ErrMsg,
  20923. })
  20924. return
  20925. } else {
  20926. //order.FaPiaoNumber = zero
  20927. //order.FaPiaoCode = last_order.FaPiaoCode
  20928. //service.UpdateOrder(order)
  20929. hisFundSettleListResult := &models.HisFundSettleListResult{
  20930. Number: res.Output.SetlListId,
  20931. Status: 1,
  20932. Ctime: time.Now().Unix(),
  20933. Mtime: time.Now().Unix(),
  20934. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20935. IsUpload: 1,
  20936. OrderId: order_id,
  20937. }
  20938. service.CreateUploadRecord(hisFundSettleListResult)
  20939. c.ServeSuccessJSON(map[string]interface{}{
  20940. "msg": "上传成功",
  20941. "result": hisFundSettleListResult,
  20942. })
  20943. return
  20944. }
  20945. }
  20946. func (c *HisApiController) GetSettleListHospital() {
  20947. order_id, _ := c.GetInt64("order_id")
  20948. admin_user_id, _ := c.GetInt64("admin_user_id")
  20949. order, _ := service.GetHisOrderByIDTwo(order_id)
  20950. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20951. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  20952. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20953. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  20954. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20955. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20956. if order.ID == 0 {
  20957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20958. return
  20959. }
  20960. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  20961. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  20962. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  20963. fmt.Println(count)
  20964. var zero string
  20965. number := count + 1
  20966. if number >= 1000 {
  20967. zero = "0000" + strconv.FormatInt(number, 10)
  20968. } else if number >= 10000 {
  20969. zero = "000" + strconv.FormatInt(number, 10)
  20970. } else if number >= 100000 {
  20971. zero = "00" + strconv.FormatInt(number, 10)
  20972. } else if number >= 1000000 {
  20973. zero = "0" + strconv.FormatInt(number, 10)
  20974. } else {
  20975. zero = strconv.FormatInt(number, 10)
  20976. }
  20977. fmt.Println(zero)
  20978. struct4101 := service.Struct4101{
  20979. PsnNo: order.PsnNo,
  20980. MdtrtId: order.MdtrtId,
  20981. SetlId: order.SetlId,
  20982. PsnName: order.PsnName,
  20983. Gend: order.Gend,
  20984. Brdy: his.Brdy,
  20985. Age: int64(order.Age),
  20986. Naty: order.Naty,
  20987. PatnCertType: "01",
  20988. Certno: order.Certno,
  20989. Prfs: "90",
  20990. ConerName: roles[0].UserName,
  20991. PatnRlts: "99",
  20992. ConerAddr: miConfig.OrgName,
  20993. ConerTel: admin.Mobile,
  20994. HiType: order.Insutype,
  20995. Insuplc: miConfig.InsuplcAdmdvs,
  20996. MaindiagFlag: "1",
  20997. BillCode: order.SetlId,
  20998. BillNo: order.SetlId,
  20999. BizSn: order.Number,
  21000. PsnSelfPay: order.PsnPartAmt,
  21001. PsnOwnPay: order.PsnPartAmt,
  21002. AcctPay: order.AcctPay,
  21003. PsnCashpay: order.PsnCashPay,
  21004. HiPaymtd: "1",
  21005. Hsorg: miConfig.InsuplcAdmdvs,
  21006. HsorgOpter: miConfig.InsuplcAdmdvs,
  21007. MedinsFillPsn: curRoles.UserName,
  21008. MedinsFillDept: depart.Name,
  21009. IptMedType: "2",
  21010. AdmTime: his.InHosptialTime,
  21011. AdmEndTime: his.OutHosptialTime,
  21012. }
  21013. struct4101.SetlBegnDate = order.SetlTime
  21014. struct4101.SetlEndDate = order.SetlTime
  21015. //var rf []CustomFundPay
  21016. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  21017. //
  21018. //var tempFunPays []service.CustomStruct
  21019. //for _, item := range rf {
  21020. // var tempFunPay service.CustomStruct
  21021. // tempFunPay.FundPayamt = item.FundPayamt
  21022. // tempFunPay.FundPayType = item.FundPayType
  21023. // tempFunPays = append(tempFunPays, tempFunPay)
  21024. //}
  21025. //struct4101.CustomStruct = tempFunPays
  21026. var tempDiaginfos []service.DiaginfoStructTwo
  21027. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  21028. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  21029. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  21030. //for _, item := range infos {
  21031. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  21032. //}
  21033. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  21034. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  21035. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  21036. fmt.Println(diagnosis_ids_arr)
  21037. if order.UserOrgId == 10210 {
  21038. var diagnosis_ids_arr_two []int64
  21039. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  21040. var config []*models.HisXtDiagnoseConfig
  21041. for _, id := range diagnosis_ids_arr_two {
  21042. //id, _ := strconv.ParseInt(item, 10, 64)
  21043. diagnosisConfig, _ := service.FindDiagnoseById(id)
  21044. if diagnosisConfig.ID > 0 {
  21045. config = append(config, &diagnosisConfig)
  21046. }
  21047. }
  21048. for index, item := range config {
  21049. if item.ID > 0 {
  21050. if index == 0 {
  21051. var tempDiaginfo service.DiaginfoStructTwo
  21052. tempDiaginfo.DiagCode = item.CountryCode
  21053. tempDiaginfo.DiagName = item.CountryContentName
  21054. tempDiaginfo.DiagType = "1"
  21055. tempDiaginfo.MaindiagFlag = "1"
  21056. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21057. } else {
  21058. var tempDiaginfo service.DiaginfoStructTwo
  21059. tempDiaginfo.DiagCode = item.CountryCode
  21060. tempDiaginfo.DiagName = item.CountryContentName
  21061. tempDiaginfo.DiagType = "1"
  21062. tempDiaginfo.MaindiagFlag = "0"
  21063. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21064. }
  21065. }
  21066. }
  21067. struct4101.Diseinfo = tempDiaginfos
  21068. } else {
  21069. var config []*models.HisXtDiagnoseConfig
  21070. for _, item := range diagnosis_ids_arr {
  21071. id, _ := strconv.ParseInt(item, 10, 64)
  21072. diagnosisConfig, _ := service.FindDiagnoseById(id)
  21073. if diagnosisConfig.ID > 0 {
  21074. config = append(config, &diagnosisConfig)
  21075. }
  21076. }
  21077. for index, item := range config {
  21078. if item.ID > 0 {
  21079. if index == 0 {
  21080. var tempDiaginfo service.DiaginfoStructTwo
  21081. tempDiaginfo.DiagCode = item.CountryCode
  21082. tempDiaginfo.DiagName = item.CountryContentName
  21083. tempDiaginfo.DiagType = "1"
  21084. tempDiaginfo.MaindiagFlag = "1"
  21085. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21086. } else {
  21087. var tempDiaginfo service.DiaginfoStructTwo
  21088. tempDiaginfo.DiagCode = item.CountryCode
  21089. tempDiaginfo.DiagName = item.CountryContentName
  21090. tempDiaginfo.DiagType = "1"
  21091. tempDiaginfo.MaindiagFlag = "0"
  21092. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21093. }
  21094. }
  21095. }
  21096. struct4101.Diseinfo = tempDiaginfos
  21097. }
  21098. sickConfigTwo, _ := service.FindSickById(his.SickType)
  21099. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  21100. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  21101. tempOpspdiseinfo2.OprnOprtCode = ""
  21102. tempOpspdiseinfo2.OprnOprtName = ""
  21103. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  21104. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  21105. var iteminfo service.IteminfoStruct
  21106. var bedCostTotal float64 = 0 //床位总费
  21107. var bedCostSelfTotal float64 = 0 //床位自费
  21108. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  21109. var operationCostTotal float64 = 0 //手术费
  21110. var operationCostSelfTotal float64 = 0 //手术费
  21111. var operationCostPartSelfTotal float64 = 0 //手术费
  21112. var otherCostTotal float64 = 0 //其他费用
  21113. var otherCostSelfTotal float64 = 0 //其他费用
  21114. var otherCostPartSelfTotal float64 = 0 //其他费用
  21115. var materialCostTotal float64 = 0 //材料费
  21116. var materialCostSelfTotal float64 = 0 //材料费
  21117. var materialCostPartSelfTotal float64 = 0 //材料费
  21118. var westernMedicineCostTotal float64 = 0 //西药费
  21119. var westernMedicineCostSelfTotal float64 = 0 //西药费
  21120. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  21121. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  21122. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  21123. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  21124. var checkCostTotal float64 = 0 //检查费
  21125. var checkCostSelfTotal float64 = 0 //检查费
  21126. var checkCostPartSelfTotal float64 = 0 //检查费
  21127. var laboratoryCostTotal float64 = 0 //化验费
  21128. var laboratoryCostSelfTotal float64 = 0 //化验费
  21129. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  21130. var treatCostTotal float64 = 0 //治疗费用
  21131. var treatCostSelfTotal float64 = 0 //治疗费用
  21132. var treatCostPartSelfTotal float64 = 0 //治疗费用
  21133. decimal.DivisionPrecision = 2
  21134. var bed_fulamt_ownpay_amt float64 = 0
  21135. var operation_fulamt_ownpay_amt float64 = 0
  21136. var other_fulamt_ownpay_amt float64 = 0
  21137. var westernMedicine_fulamt_ownpay_amt float64 = 0
  21138. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  21139. var check_fulamt_ownpay_amt float64 = 0
  21140. var material_fulamt_ownpay_amt float64 = 0
  21141. var laboratory_fulamt_ownpay_amt float64 = 0
  21142. var treat_fulamt_ownpay_amt float64 = 0
  21143. var bed_claa_sunmfee float64 = 0
  21144. var bed_clab_amt float64 = 0
  21145. var bed_other_amt float64 = 0
  21146. var operation_claa_sunmfee float64 = 0
  21147. var operation_clab_amt float64 = 0
  21148. var operation_other_amt float64 = 0
  21149. var other_claa_sunmfee float64 = 0
  21150. var other_clab_amt float64 = 0
  21151. var other_other_amt float64 = 0
  21152. var westernMedicine_claa_sunmfee float64 = 0
  21153. var westernMedicine_clab_amt float64 = 0
  21154. var westernMedicine_other_amt float64 = 0
  21155. var chineseTraditional_claa_sunmfee float64 = 0
  21156. var chineseTraditional_clab_amt float64 = 0
  21157. var chineseTraditional_other_amt float64 = 0
  21158. var check_claa_sunmfee float64 = 0
  21159. var check_clab_amt float64 = 0
  21160. var check_other_amt float64 = 0
  21161. var material_claa_sunmfee float64 = 0
  21162. var material_clab_amt float64 = 0
  21163. var material_other_amt float64 = 0
  21164. var laboratory_claa_sunmfee float64 = 0
  21165. var laboratory_clab_amt float64 = 0
  21166. var laboratory_other_amt float64 = 0
  21167. var treat_claa_sunmfee float64 = 0
  21168. var treat_clab_amt float64 = 0
  21169. var treat_other_amt float64 = 0
  21170. for _, item := range order.HisOrderInfo {
  21171. if item.MedChrgitmType == "01" { //床位费
  21172. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21173. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21174. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21175. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21176. if item.ChrgitmLv == "1" {
  21177. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21178. }
  21179. if item.ChrgitmLv == "2" {
  21180. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21181. }
  21182. if item.ChrgitmLv == "3" {
  21183. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21184. }
  21185. }
  21186. if item.MedChrgitmType == "03" { //检查费
  21187. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21188. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21189. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21190. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21191. if item.ChrgitmLv == "1" {
  21192. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21193. }
  21194. if item.ChrgitmLv == "2" {
  21195. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21196. }
  21197. if item.ChrgitmLv == "3" {
  21198. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21199. }
  21200. }
  21201. if item.MedChrgitmType == "04" { //化验费
  21202. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21203. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21204. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21205. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21206. if item.ChrgitmLv == "1" {
  21207. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21208. }
  21209. if item.ChrgitmLv == "2" {
  21210. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21211. }
  21212. if item.ChrgitmLv == "3" {
  21213. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21214. }
  21215. }
  21216. if item.MedChrgitmType == "05" { //治疗费
  21217. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21218. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21219. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21220. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21221. if item.ChrgitmLv == "1" {
  21222. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21223. }
  21224. if item.ChrgitmLv == "2" {
  21225. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21226. }
  21227. if item.ChrgitmLv == "3" {
  21228. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21229. }
  21230. }
  21231. if item.MedChrgitmType == "06" { //手术费
  21232. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21233. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21234. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21235. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21236. if item.ChrgitmLv == "1" {
  21237. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21238. }
  21239. if item.ChrgitmLv == "2" {
  21240. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21241. }
  21242. if item.ChrgitmLv == "3" {
  21243. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21244. }
  21245. }
  21246. if item.MedChrgitmType == "08" { //材料费
  21247. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21248. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21249. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21250. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21251. if item.ChrgitmLv == "1" {
  21252. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21253. }
  21254. if item.ChrgitmLv == "2" {
  21255. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21256. }
  21257. if item.ChrgitmLv == "3" {
  21258. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21259. }
  21260. }
  21261. if item.MedChrgitmType == "09" { //西药费
  21262. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21263. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21264. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21265. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21266. if item.ChrgitmLv == "1" {
  21267. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21268. }
  21269. if item.ChrgitmLv == "2" {
  21270. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21271. }
  21272. if item.ChrgitmLv == "3" {
  21273. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21274. }
  21275. }
  21276. if item.MedChrgitmType == "11" { //中成费
  21277. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21278. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21279. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21280. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21281. if item.ChrgitmLv == "1" {
  21282. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21283. }
  21284. if item.ChrgitmLv == "2" {
  21285. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21286. }
  21287. if item.ChrgitmLv == "3" {
  21288. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21289. }
  21290. }
  21291. if item.MedChrgitmType == "14" { //其他费
  21292. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21293. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21294. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21295. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21296. if item.ChrgitmLv == "1" {
  21297. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21298. }
  21299. if item.ChrgitmLv == "2" {
  21300. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21301. }
  21302. if item.ChrgitmLv == "3" {
  21303. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21304. }
  21305. }
  21306. }
  21307. var iteminfoStructs []service.IteminfoStruct
  21308. if bedCostTotal != 0 {
  21309. iteminfo.MedChrgitm = "01"
  21310. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21311. iteminfo.Amt = bedCostTotal
  21312. iteminfo.ClaaSumfee = bed_claa_sunmfee
  21313. iteminfo.ClabAmt = bed_clab_amt
  21314. iteminfo.OthAmt = bed_other_amt
  21315. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21316. }
  21317. if checkCostTotal != 0 {
  21318. iteminfo.MedChrgitm = "03"
  21319. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  21320. iteminfo.Amt = checkCostTotal
  21321. iteminfo.ClaaSumfee = check_claa_sunmfee
  21322. iteminfo.ClabAmt = check_clab_amt
  21323. iteminfo.OthAmt = check_other_amt
  21324. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21325. }
  21326. if laboratoryCostTotal != 0 {
  21327. iteminfo.MedChrgitm = "04"
  21328. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  21329. iteminfo.Amt = laboratoryCostTotal
  21330. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  21331. iteminfo.ClabAmt = laboratory_clab_amt
  21332. iteminfo.OthAmt = laboratory_other_amt
  21333. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21334. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21335. }
  21336. if treatCostTotal != 0 {
  21337. iteminfo.MedChrgitm = "05"
  21338. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  21339. iteminfo.Amt = treatCostTotal
  21340. iteminfo.ClaaSumfee = treat_claa_sunmfee
  21341. iteminfo.ClabAmt = treat_clab_amt
  21342. iteminfo.OthAmt = treat_other_amt
  21343. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21344. //(struct4101.IteminfoStruct, iteminfo)
  21345. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21346. }
  21347. if operationCostTotal != 0 {
  21348. iteminfo.MedChrgitm = "06"
  21349. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21350. iteminfo.Amt = operationCostTotal
  21351. iteminfo.ClaaSumfee = operation_claa_sunmfee
  21352. iteminfo.ClabAmt = operation_clab_amt
  21353. iteminfo.OthAmt = operation_other_amt
  21354. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21355. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21356. }
  21357. if materialCostTotal != 0 {
  21358. iteminfo.MedChrgitm = "08"
  21359. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  21360. iteminfo.Amt = materialCostTotal
  21361. iteminfo.ClaaSumfee = material_claa_sunmfee
  21362. iteminfo.ClabAmt = material_clab_amt
  21363. iteminfo.OthAmt = material_other_amt
  21364. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21365. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21366. }
  21367. if westernMedicineCostTotal != 0 {
  21368. iteminfo.MedChrgitm = "09"
  21369. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21370. iteminfo.Amt = westernMedicineCostTotal
  21371. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21372. iteminfo.ClabAmt = westernMedicine_clab_amt
  21373. iteminfo.OthAmt = westernMedicine_other_amt
  21374. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21375. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21376. }
  21377. if chineseTraditionalMedicineCostTotal != 0 {
  21378. iteminfo.MedChrgitm = "11"
  21379. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21380. iteminfo.Amt = westernMedicineCostTotal
  21381. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21382. iteminfo.ClabAmt = westernMedicine_clab_amt
  21383. iteminfo.OthAmt = westernMedicine_other_amt
  21384. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21385. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21386. }
  21387. if otherCostTotal != 0 {
  21388. iteminfo.MedChrgitm = "14"
  21389. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  21390. iteminfo.Amt = otherCostTotal
  21391. iteminfo.ClaaSumfee = other_claa_sunmfee
  21392. iteminfo.ClabAmt = other_clab_amt
  21393. iteminfo.OthAmt = other_other_amt
  21394. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21395. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21396. }
  21397. struct4101.IteminfoStruct = iteminfoStructs
  21398. struct4101.Ntly = "中国"
  21399. struct4101.AdmCaty = "A03.06"
  21400. var resOther ResultSeventeenOther
  21401. var res ResultSeventeen
  21402. if miConfig.MdtrtareaAdmvs == "150499" {
  21403. var pp models.PublicParams
  21404. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  21405. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21406. pp.FixmedinsName = miConfig.OrgName
  21407. pp.FixmedinsCode = miConfig.Code
  21408. pp.RequestUrl = miConfig.Url
  21409. pp.Cainfo = miConfig.Cainfo
  21410. pp.SecretKey = miConfig.SecretKey
  21411. pp.AccessKey = miConfig.AccessKey
  21412. pp.OpterName = curRoles.UserName
  21413. client := &http.Client{}
  21414. var req *http.Request
  21415. data := make(map[string]interface{})
  21416. data["struct4101"] = struct4101
  21417. data["pp"] = pp
  21418. bytesData, _ := json.Marshal(data)
  21419. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  21420. resp, _ := client.Do(req)
  21421. defer resp.Body.Close()
  21422. body, ioErr := ioutil.ReadAll(resp.Body)
  21423. if ioErr != nil {
  21424. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21426. return
  21427. }
  21428. var respJSON map[string]interface{}
  21429. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21430. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21432. return
  21433. }
  21434. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21435. userJSONBytes, _ := json.Marshal(respJSON)
  21436. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  21437. utils.ErrorLog("解析失败:%v", err)
  21438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21439. return
  21440. }
  21441. res.InfRefmsgid = resOther.InfRefmsgid
  21442. res.Output = resOther.Output
  21443. res.ErrMsg = resOther.ErrMsg
  21444. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  21445. res.Infcode = infocode
  21446. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21447. var pp models.PublicParams
  21448. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21449. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21450. pp.FixmedinsName = miConfig.OrgName
  21451. pp.FixmedinsCode = miConfig.Code
  21452. pp.RequestUrl = miConfig.Url
  21453. pp.Cainfo = miConfig.Cainfo
  21454. pp.SecretKey = miConfig.SecretKey
  21455. pp.AccessKey = miConfig.AccessKey
  21456. pp.OpterName = curRoles.UserName
  21457. result, _ := service.Jxyb4101(struct4101, pp)
  21458. var dat map[string]interface{}
  21459. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21460. fmt.Println(dat)
  21461. } else {
  21462. fmt.Println(err)
  21463. }
  21464. userJSONBytes, _ := json.Marshal(dat)
  21465. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21466. utils.ErrorLog("解析失败:%v", err)
  21467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21468. return
  21469. }
  21470. } else if miConfig.MdtrtareaAdmvs == "361025" {
  21471. var pp models.PublicParams
  21472. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21473. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21474. pp.FixmedinsName = miConfig.OrgName
  21475. pp.FixmedinsCode = miConfig.Code
  21476. pp.RequestUrl = miConfig.Url
  21477. pp.Cainfo = miConfig.Cainfo
  21478. pp.SecretKey = miConfig.SecretKey
  21479. pp.AccessKey = miConfig.AccessKey
  21480. pp.OpterName = curRoles.UserName
  21481. result, _ := service.Jxyb4101(struct4101, pp)
  21482. var dat map[string]interface{}
  21483. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21484. fmt.Println(dat)
  21485. } else {
  21486. fmt.Println(err)
  21487. }
  21488. userJSONBytes, _ := json.Marshal(dat)
  21489. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21490. utils.ErrorLog("解析失败:%v", err)
  21491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21492. return
  21493. }
  21494. } else if miConfig.MdtrtareaAdmvs == "360100" {
  21495. var pp models.PublicParams
  21496. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21497. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21498. pp.FixmedinsName = miConfig.OrgName
  21499. pp.FixmedinsCode = miConfig.Code
  21500. pp.RequestUrl = miConfig.Url
  21501. pp.Cainfo = miConfig.Cainfo
  21502. pp.SecretKey = miConfig.SecretKey
  21503. pp.AccessKey = miConfig.AccessKey
  21504. pp.OpterName = curRoles.UserName
  21505. result, _ := service.Jxyb4101(struct4101, pp)
  21506. var dat map[string]interface{}
  21507. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21508. fmt.Println(dat)
  21509. } else {
  21510. fmt.Println(err)
  21511. }
  21512. userJSONBytes, _ := json.Marshal(dat)
  21513. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21514. utils.ErrorLog("解析失败:%v", err)
  21515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21516. return
  21517. }
  21518. } else {
  21519. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  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. }
  21533. if res.Infcode != 0 {
  21534. c.ServeSuccessJSON(map[string]interface{}{
  21535. "failed_code": -10,
  21536. "msg": res.ErrMsg,
  21537. })
  21538. return
  21539. } else {
  21540. if miConfig.MdtrtareaAdmvs != "150499" {
  21541. order.FaPiaoNumber = zero
  21542. order.FaPiaoCode = last_order.FaPiaoCode
  21543. service.UpdateOrder(order)
  21544. }
  21545. hisFundSettleListResult := &models.HisFundSettleListResult{
  21546. Number: res.Output.SetlListId,
  21547. Status: 1,
  21548. Ctime: time.Now().Unix(),
  21549. Mtime: time.Now().Unix(),
  21550. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21551. IsUpload: 1,
  21552. OrderId: order_id,
  21553. }
  21554. service.CreateUploadRecord(hisFundSettleListResult)
  21555. c.ServeSuccessJSON(map[string]interface{}{
  21556. "msg": "上传成功",
  21557. "result": hisFundSettleListResult,
  21558. })
  21559. return
  21560. }
  21561. }
  21562. //func (c *HisApiController) GetBatchSettleList() {
  21563. // orders, _ := service.GetAllHisOrder(10106)
  21564. // for _, item := range orders {
  21565. // order_id := item.ID
  21566. // order, _ := service.GetHisOrderByIDTwo(order_id)
  21567. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  21568. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  21569. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  21570. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  21571. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  21572. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  21573. //
  21574. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  21575. //
  21576. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  21577. //
  21578. // if order.ID == 0 {
  21579. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  21580. // return
  21581. // }
  21582. // if his.BalanceAccountsType == 2 {
  21583. // continue
  21584. // }
  21585. // struct4101 := service.Struct4101{
  21586. // PsnNo: order.PsnNo,
  21587. // MdtrtId: order.MdtrtId,
  21588. // SetlId: order.SetlId,
  21589. // PsnName: order.PsnName,
  21590. // Gend: order.Gend,
  21591. // Brdy: his.Brdy,
  21592. // Age: his.Age,
  21593. // Naty: order.Naty,
  21594. // PatnCertType: "01",
  21595. // Certno: order.Certno,
  21596. // Prfs: "90",
  21597. // ConerName: roles[0].UserName,
  21598. // PatnRlts: "99",
  21599. // ConerAddr: miConfig.OrgName,
  21600. // ConerTel: admin.Mobile,
  21601. // HiType: order.Insutype,
  21602. // Insuplc: his.InsuplcAdmdvs,
  21603. // MaindiagFlag: "1",
  21604. // BillCode: order.SetlId,
  21605. // BillNo: order.SetlId,
  21606. // BizSn: order.Number,
  21607. // PsnSelfPay: order.PsnPartAmt,
  21608. // PsnOwnPay: order.PsnPartAmt,
  21609. // AcctPay: order.AcctPay,
  21610. // PsnCashpay: order.PsnCashPay,
  21611. // HiPaymtd: "1",
  21612. // Hsorg: his.InsuplcAdmdvs,
  21613. // HsorgOpter: his.InsuplcAdmdvs,
  21614. // MedinsFillPsn: curRoles.UserName,
  21615. // MedinsFillDept: depart.Name,
  21616. // IptMedType: "2",
  21617. // }
  21618. // struct4101.SetlBegnDate = order.SetlTime
  21619. // struct4101.SetlEndDate = order.SetlTime
  21620. // //if order.SettleType == 1 {
  21621. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  21622. // // dateStr := t.Format("2006-01-02")
  21623. // // struct4101.SetlBegnDate = dateStr
  21624. // // struct4101.SetlEndDate = dateStr
  21625. // //} else {
  21626. // // t := time.Unix(int64(order.SettleStartTime), 0)
  21627. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  21628. // // dateStartStr := t.Format("2006-01-02")
  21629. // // dateEndStr := t2.Format("2006-01-02")
  21630. // // struct4101.SetlBegnDate = dateStartStr
  21631. // // struct4101.SetlEndDate = dateEndStr
  21632. // //}
  21633. //
  21634. // var rf []CustomFundPay
  21635. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  21636. //
  21637. // var tempFunPays []service.CustomStruct
  21638. // var tempFunPay610100 service.CustomStruct
  21639. //
  21640. // for _, item := range rf {
  21641. // if item.FundPayType == "610100" {
  21642. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  21643. // tempFunPay610100.FundPayType = item.FundPayType
  21644. // } else {
  21645. // var tempFunPay service.CustomStruct
  21646. // tempFunPay.FundPayamt = item.FundPayamt
  21647. // tempFunPay.FundPayType = item.FundPayType
  21648. // tempFunPays = append(tempFunPays, tempFunPay)
  21649. // }
  21650. // }
  21651. // tempFunPays = append(tempFunPays, tempFunPay610100)
  21652. // struct4101.CustomStruct = tempFunPays
  21653. //
  21654. // var tempDiaginfos []service.DiaginfoStructTwo
  21655. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  21656. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  21657. //
  21658. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  21659. // var config []*models.HisXtDiagnoseConfig
  21660. // for _, item := range diagnosis_ids {
  21661. // id, _ := strconv.ParseInt(item, 10, 64)
  21662. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  21663. // config = append(config, &diagnosisConfig)
  21664. // }
  21665. //
  21666. // for index, item := range config {
  21667. // if index == 0 {
  21668. // var tempDiaginfo service.DiaginfoStructTwo
  21669. // tempDiaginfo.DiagCode = item.CountryCode
  21670. // tempDiaginfo.DiagName = item.CountryContentName
  21671. // tempDiaginfo.DiagType = "1"
  21672. // tempDiaginfo.MaindiagFlag = "1"
  21673. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21674. // } else {
  21675. //
  21676. // var tempDiaginfo service.DiaginfoStructTwo
  21677. // tempDiaginfo.DiagCode = item.CountryCode
  21678. // tempDiaginfo.DiagName = item.CountryContentName
  21679. // tempDiaginfo.DiagType = "2"
  21680. // tempDiaginfo.MaindiagFlag = "0"
  21681. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21682. // }
  21683. // }
  21684. // struct4101.Diseinfo = tempDiaginfos
  21685. //
  21686. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  21687. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  21688. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  21689. // tempOpspdiseinfo2.OprnOprtCode = ""
  21690. // tempOpspdiseinfo2.OprnOprtName = ""
  21691. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  21692. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  21693. //
  21694. // var iteminfo service.IteminfoStruct
  21695. //
  21696. // var bedCostTotal float64 = 0 //床位总费
  21697. // var bedCostSelfTotal float64 = 0 //床位自费
  21698. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  21699. //
  21700. // var examineCostTotal float64 = 0 //诊查总费
  21701. // var examineCostSelfTotal float64 = 0 //诊查自费
  21702. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  21703. //
  21704. // var nursingCostTotal float64 = 0 //护理总费
  21705. // var nursingCostSelfTotal float64 = 0 //护理自费
  21706. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  21707. //
  21708. // var chineseMedicineCostTotal float64 = 0 //中成药
  21709. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  21710. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  21711. //
  21712. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  21713. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  21714. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  21715. //
  21716. // var registerCostTotal float64 = 0 //一般诊疗费
  21717. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  21718. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  21719. //
  21720. // var operationCostTotal float64 = 0 //手术费
  21721. // var operationCostSelfTotal float64 = 0 //手术费
  21722. // var operationCostPartSelfTotal float64 = 0 //手术费
  21723. //
  21724. // var otherCostTotal float64 = 0 //其他费用
  21725. // var otherCostSelfTotal float64 = 0 //其他费用
  21726. // var otherCostPartSelfTotal float64 = 0 //其他费用
  21727. //
  21728. // var materialCostTotal float64 = 0 //材料费
  21729. // var materialCostSelfTotal float64 = 0 //材料费
  21730. // var materialCostPartSelfTotal float64 = 0 //材料费
  21731. //
  21732. // var westernMedicineCostTotal float64 = 0 //西药费
  21733. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  21734. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  21735. //
  21736. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  21737. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  21738. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  21739. //
  21740. // var checkCostTotal float64 = 0 //检查费
  21741. // var checkCostSelfTotal float64 = 0 //检查费
  21742. // var checkCostPartSelfTotal float64 = 0 //检查费
  21743. //
  21744. // var laboratoryCostTotal float64 = 0 //化验费
  21745. // var laboratoryCostSelfTotal float64 = 0 //化验费
  21746. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  21747. //
  21748. // var treatCostTotal float64 = 0 //治疗费用
  21749. // var treatCostSelfTotal float64 = 0 //治疗费用
  21750. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  21751. //
  21752. // decimal.DivisionPrecision = 2
  21753. //
  21754. // var bed_fulamt_ownpay_amt float64 = 0
  21755. //
  21756. // var examine_fulamt_ownpay_amt float64 = 0
  21757. //
  21758. // var nursing_fulamt_ownpay_amt float64 = 0
  21759. //
  21760. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  21761. //
  21762. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  21763. //
  21764. // var register_fulamt_ownpay_amt float64 = 0
  21765. //
  21766. // var operation_fulamt_ownpay_amt float64 = 0
  21767. // var other_fulamt_ownpay_amt float64 = 0
  21768. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  21769. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  21770. // var check_fulamt_ownpay_amt float64 = 0
  21771. // var material_fulamt_ownpay_amt float64 = 0
  21772. // var laboratory_fulamt_ownpay_amt float64 = 0
  21773. // var treat_fulamt_ownpay_amt float64 = 0
  21774. //
  21775. // var bed_claa_sunmfee float64 = 0
  21776. // var bed_clab_amt float64 = 0
  21777. // var bed_other_amt float64 = 0
  21778. //
  21779. // var examine_claa_sunmfee float64 = 0
  21780. // var examine_clab_amt float64 = 0
  21781. // var examine_other_amt float64 = 0
  21782. //
  21783. // var nursing_claa_sunmfee float64 = 0
  21784. // var nursing_clab_amt float64 = 0
  21785. // var nursing_other_amt float64 = 0
  21786. //
  21787. // var chinese_medicine_claa_sunmfee float64 = 0
  21788. // var chinese_medicine_clab_amt float64 = 0
  21789. // var chinese_medicine_other_amt float64 = 0
  21790. //
  21791. // var commonly_treatment_claa_sunmfee float64 = 0
  21792. // var commonly_treatment_clab_amt float64 = 0
  21793. // var commonly_treatment_other_amt float64 = 0
  21794. //
  21795. // var operation_claa_sunmfee float64 = 0
  21796. // var operation_clab_amt float64 = 0
  21797. // var operation_other_amt float64 = 0
  21798. //
  21799. // var other_claa_sunmfee float64 = 0
  21800. // var other_clab_amt float64 = 0
  21801. // var other_other_amt float64 = 0
  21802. //
  21803. // var westernMedicine_claa_sunmfee float64 = 0
  21804. // var westernMedicine_clab_amt float64 = 0
  21805. // var westernMedicine_other_amt float64 = 0
  21806. //
  21807. // var chineseTraditional_claa_sunmfee float64 = 0
  21808. // var chineseTraditional_clab_amt float64 = 0
  21809. // var chineseTraditional_other_amt float64 = 0
  21810. //
  21811. // var check_claa_sunmfee float64 = 0
  21812. // var check_clab_amt float64 = 0
  21813. // var check_other_amt float64 = 0
  21814. //
  21815. // var material_claa_sunmfee float64 = 0
  21816. // var material_clab_amt float64 = 0
  21817. // var material_other_amt float64 = 0
  21818. //
  21819. // var laboratory_claa_sunmfee float64 = 0
  21820. // var laboratory_clab_amt float64 = 0
  21821. // var laboratory_other_amt float64 = 0
  21822. //
  21823. // var treat_claa_sunmfee float64 = 0
  21824. // var treat_clab_amt float64 = 0
  21825. // var treat_other_amt float64 = 0
  21826. //
  21827. // var register_claa_sunmfee float64 = 0
  21828. // var register_clab_amt float64 = 0
  21829. // var register_other_amt float64 = 0
  21830. //
  21831. // for _, item := range order.HisOrderInfo {
  21832. // if item.MedChrgitmType == "01" { //床位费
  21833. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21834. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21835. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21836. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21837. // if item.ChrgitmLv == "1" {
  21838. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21839. // }
  21840. // if item.ChrgitmLv == "2" {
  21841. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21842. //
  21843. // }
  21844. // if item.ChrgitmLv == "3" {
  21845. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21846. // }
  21847. //
  21848. // }
  21849. //
  21850. // if item.MedChrgitmType == "02" { //诊查
  21851. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21852. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21853. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21854. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21855. // if item.ChrgitmLv == "1" {
  21856. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21857. // }
  21858. // if item.ChrgitmLv == "2" {
  21859. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21860. //
  21861. // }
  21862. // if item.ChrgitmLv == "3" {
  21863. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21864. // }
  21865. //
  21866. // }
  21867. //
  21868. // if item.MedChrgitmType == "03" { //检查费
  21869. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21870. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21871. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21872. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21873. // if item.ChrgitmLv == "1" {
  21874. //
  21875. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21876. //
  21877. // }
  21878. // if item.ChrgitmLv == "2" {
  21879. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21880. //
  21881. // }
  21882. // if item.ChrgitmLv == "3" {
  21883. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21884. // }
  21885. // }
  21886. //
  21887. // if item.MedChrgitmType == "04" { //化验费
  21888. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21889. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21890. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21891. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21892. // if item.ChrgitmLv == "1" {
  21893. //
  21894. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21895. //
  21896. // }
  21897. // if item.ChrgitmLv == "2" {
  21898. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21899. //
  21900. // }
  21901. // if item.ChrgitmLv == "3" {
  21902. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21903. // }
  21904. // }
  21905. //
  21906. // if item.MedChrgitmType == "05" { //治疗费
  21907. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21908. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21909. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21910. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21911. // if item.ChrgitmLv == "1" {
  21912. //
  21913. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21914. //
  21915. // }
  21916. // if item.ChrgitmLv == "2" {
  21917. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21918. //
  21919. // }
  21920. // if item.ChrgitmLv == "3" {
  21921. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21922. // }
  21923. // }
  21924. //
  21925. // if item.MedChrgitmType == "06" { //手术费
  21926. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21927. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21928. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21929. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21930. //
  21931. // if item.ChrgitmLv == "1" {
  21932. //
  21933. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21934. //
  21935. // }
  21936. // if item.ChrgitmLv == "2" {
  21937. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21938. //
  21939. // }
  21940. // if item.ChrgitmLv == "3" {
  21941. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21942. // }
  21943. // }
  21944. //
  21945. // if item.MedChrgitmType == "07" { //手术费
  21946. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21947. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21948. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21949. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21950. //
  21951. // if item.ChrgitmLv == "1" {
  21952. //
  21953. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21954. //
  21955. // }
  21956. // if item.ChrgitmLv == "2" {
  21957. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21958. //
  21959. // }
  21960. // if item.ChrgitmLv == "3" {
  21961. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21962. // }
  21963. // }
  21964. //
  21965. // if item.MedChrgitmType == "08" { //材料费
  21966. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21967. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21968. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21969. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21970. // if item.ChrgitmLv == "1" {
  21971. //
  21972. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21973. //
  21974. // }
  21975. // if item.ChrgitmLv == "2" {
  21976. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21977. //
  21978. // }
  21979. // if item.ChrgitmLv == "3" {
  21980. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21981. // }
  21982. // }
  21983. // if item.MedChrgitmType == "09" { //西药费
  21984. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21985. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21986. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21987. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21988. // if item.ChrgitmLv == "1" {
  21989. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21990. // }
  21991. // if item.ChrgitmLv == "2" {
  21992. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21993. // }
  21994. // if item.ChrgitmLv == "3" {
  21995. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21996. // }
  21997. // }
  21998. // if item.MedChrgitmType == "10" { //中药饮片
  21999. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22000. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22001. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22002. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22003. // if item.ChrgitmLv == "1" {
  22004. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22005. // }
  22006. // if item.ChrgitmLv == "2" {
  22007. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22008. // }
  22009. // if item.ChrgitmLv == "3" {
  22010. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22011. // }
  22012. // }
  22013. //
  22014. // if item.MedChrgitmType == "11" { //中成费
  22015. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22016. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22017. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22018. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22019. // if item.ChrgitmLv == "1" {
  22020. //
  22021. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22022. //
  22023. // }
  22024. // if item.ChrgitmLv == "2" {
  22025. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22026. //
  22027. // }
  22028. // if item.ChrgitmLv == "3" {
  22029. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22030. // }
  22031. // }
  22032. //
  22033. // if item.MedChrgitmType == "12" { //中成费
  22034. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22035. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22036. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22037. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22038. // if item.ChrgitmLv == "1" {
  22039. //
  22040. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22041. //
  22042. // }
  22043. // if item.ChrgitmLv == "2" {
  22044. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22045. //
  22046. // }
  22047. // if item.ChrgitmLv == "3" {
  22048. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22049. // }
  22050. // }
  22051. //
  22052. // if item.MedChrgitmType == "13" { //中成费
  22053. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22054. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22055. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22056. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22057. // if item.ChrgitmLv == "1" {
  22058. //
  22059. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22060. //
  22061. // }
  22062. // if item.ChrgitmLv == "2" {
  22063. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22064. //
  22065. // }
  22066. // if item.ChrgitmLv == "3" {
  22067. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22068. // }
  22069. // }
  22070. //
  22071. // if item.MedChrgitmType == "14" { //其他费
  22072. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22073. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22074. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22075. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22076. // if item.ChrgitmLv == "1" {
  22077. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22078. //
  22079. // }
  22080. // if item.ChrgitmLv == "2" {
  22081. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22082. //
  22083. // }
  22084. // if item.ChrgitmLv == "3" {
  22085. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22086. // }
  22087. // }
  22088. //
  22089. // }
  22090. //
  22091. // var iteminfoStructs []service.IteminfoStruct
  22092. //
  22093. // if bedCostTotal != 0 {
  22094. // iteminfo.MedChrgitm = "01"
  22095. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  22096. // iteminfo.Amt = bedCostTotal
  22097. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  22098. // iteminfo.ClabAmt = bed_clab_amt
  22099. // iteminfo.OthAmt = bed_other_amt
  22100. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22101. // }
  22102. //
  22103. // if examineCostTotal != 0 {
  22104. // iteminfo.MedChrgitm = "02"
  22105. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  22106. // iteminfo.Amt = examineCostTotal
  22107. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  22108. // iteminfo.ClabAmt = examine_clab_amt
  22109. // iteminfo.OthAmt = examine_other_amt
  22110. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22111. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22112. // }
  22113. //
  22114. // if checkCostTotal != 0 {
  22115. // iteminfo.MedChrgitm = "03"
  22116. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  22117. // iteminfo.Amt = checkCostTotal
  22118. // iteminfo.ClaaSumfee = check_claa_sunmfee
  22119. // iteminfo.ClabAmt = check_clab_amt
  22120. // iteminfo.OthAmt = check_other_amt
  22121. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22122. //
  22123. // }
  22124. //
  22125. // if laboratoryCostTotal != 0 {
  22126. // iteminfo.MedChrgitm = "04"
  22127. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  22128. // iteminfo.Amt = laboratoryCostTotal
  22129. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  22130. // iteminfo.ClabAmt = laboratory_clab_amt
  22131. // iteminfo.OthAmt = laboratory_other_amt
  22132. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22133. //
  22134. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22135. //
  22136. // }
  22137. //
  22138. // if treatCostTotal != 0 {
  22139. // iteminfo.MedChrgitm = "05"
  22140. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  22141. // iteminfo.Amt = treatCostTotal
  22142. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  22143. // iteminfo.ClabAmt = treat_clab_amt
  22144. // iteminfo.OthAmt = treat_other_amt
  22145. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22146. // //(struct4101.IteminfoStruct, iteminfo)
  22147. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22148. // }
  22149. //
  22150. // if operationCostTotal != 0 {
  22151. // iteminfo.MedChrgitm = "06"
  22152. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  22153. // iteminfo.Amt = operationCostTotal
  22154. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  22155. // iteminfo.ClabAmt = operation_clab_amt
  22156. // iteminfo.OthAmt = operation_other_amt
  22157. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22158. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22159. // }
  22160. //
  22161. // if nursingCostTotal != 0 {
  22162. // iteminfo.MedChrgitm = "07"
  22163. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  22164. // iteminfo.Amt = nursingCostTotal
  22165. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  22166. // iteminfo.ClabAmt = nursing_clab_amt
  22167. // iteminfo.OthAmt = nursing_other_amt
  22168. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22169. // }
  22170. //
  22171. // if materialCostTotal != 0 {
  22172. // iteminfo.MedChrgitm = "08"
  22173. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  22174. // iteminfo.Amt = materialCostTotal
  22175. // iteminfo.ClaaSumfee = material_claa_sunmfee
  22176. // iteminfo.ClabAmt = material_clab_amt
  22177. // iteminfo.OthAmt = material_other_amt
  22178. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22179. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22180. // }
  22181. //
  22182. // if westernMedicineCostTotal != 0 {
  22183. // iteminfo.MedChrgitm = "09"
  22184. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  22185. // iteminfo.Amt = westernMedicineCostTotal
  22186. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  22187. // iteminfo.ClabAmt = westernMedicine_clab_amt
  22188. // iteminfo.OthAmt = westernMedicine_other_amt
  22189. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22190. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22191. //
  22192. // }
  22193. //
  22194. // if chineseMedicineCostTotal != 0 {
  22195. // iteminfo.MedChrgitm = "10"
  22196. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  22197. // iteminfo.Amt = chineseMedicineCostTotal
  22198. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  22199. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  22200. // iteminfo.OthAmt = chinese_medicine_other_amt
  22201. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22202. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22203. //
  22204. // }
  22205. //
  22206. // if chineseTraditionalMedicineCostTotal != 0 {
  22207. // iteminfo.MedChrgitm = "11"
  22208. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  22209. // iteminfo.Amt = westernMedicineCostTotal
  22210. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  22211. // iteminfo.ClabAmt = westernMedicine_clab_amt
  22212. // iteminfo.OthAmt = westernMedicine_other_amt
  22213. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22214. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22215. //
  22216. // }
  22217. //
  22218. // if commonlyTreatmentCostTotal != 0 {
  22219. // iteminfo.MedChrgitm = "12"
  22220. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  22221. // iteminfo.Amt = commonlyTreatmentCostTotal
  22222. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  22223. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  22224. // iteminfo.OthAmt = commonly_treatment_other_amt
  22225. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22226. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22227. //
  22228. // }
  22229. //
  22230. // if registerCostTotal != 0 {
  22231. // iteminfo.MedChrgitm = "13"
  22232. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  22233. // iteminfo.Amt = registerCostTotal
  22234. // iteminfo.ClaaSumfee = register_claa_sunmfee
  22235. // iteminfo.ClabAmt = register_clab_amt
  22236. // iteminfo.OthAmt = register_other_amt
  22237. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22238. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22239. //
  22240. // }
  22241. //
  22242. // if otherCostTotal != 0 {
  22243. // iteminfo.MedChrgitm = "14"
  22244. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  22245. // iteminfo.Amt = otherCostTotal
  22246. // iteminfo.ClaaSumfee = other_claa_sunmfee
  22247. // iteminfo.ClabAmt = other_clab_amt
  22248. // iteminfo.OthAmt = other_other_amt
  22249. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22250. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22251. //
  22252. // }
  22253. // struct4101.IteminfoStruct = iteminfoStructs
  22254. // time_arr := strings.Split(order.SetlTime, " ")
  22255. // struct4101.AdmTime = time_arr[0]
  22256. // struct4101.AdmEndTime = time_arr[0]
  22257. //
  22258. // struct4101.DoctorName = doctor.UserName
  22259. // struct4101.DoctorCode = doctor.DoctorNumber
  22260. //
  22261. // struct4101.Ntly = "中国"
  22262. // struct4101.AdmCaty = "A03.06"
  22263. // var res ResultSeventeen
  22264. // if miConfig.MdtrtareaAdmvs == "421300" {
  22265. // data := make(map[string]interface{})
  22266. // data["struct4101"] = struct4101
  22267. // data["secret_key"] = miConfig.SecretKey
  22268. // data["org_name"] = miConfig.OrgName
  22269. // data["opera"] = curRoles.UserName
  22270. // data["code"] = miConfig.Code
  22271. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  22272. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22273. //
  22274. // client := &http.Client{}
  22275. // bytesData, _ := json.Marshal(data)
  22276. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  22277. // resp, _ := client.Do(req)
  22278. // defer resp.Body.Close()
  22279. // body, ioErr := ioutil.ReadAll(resp.Body)
  22280. // if ioErr != nil {
  22281. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22282. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22283. // return
  22284. // }
  22285. // var respJSON map[string]interface{}
  22286. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22287. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22288. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22289. // return
  22290. // }
  22291. //
  22292. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22293. // userJSONBytes, _ := json.Marshal(respJSON)
  22294. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22295. // utils.ErrorLog("解析失败:%v", err)
  22296. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22297. // adminUser := c.GetAdminUserInfo()
  22298. // errlog := &models.HisOrderError{
  22299. // UserOrgId: adminUser.CurrentOrgId,
  22300. // Ctime: time.Now().Unix(),
  22301. // Mtime: time.Now().Unix(),
  22302. // ErrMsg: res.ErrMsg + "解析失败",
  22303. // Status: 1,
  22304. // PatientId: order_id,
  22305. // Stage: 10088,
  22306. // }
  22307. // service.CreateErrMsgLog(errlog)
  22308. // continue
  22309. // }
  22310. //
  22311. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  22312. // data := make(map[string]interface{})
  22313. // data["struct4101"] = struct4101
  22314. // data["secret_key"] = miConfig.SecretKey
  22315. // data["org_name"] = miConfig.OrgName
  22316. // data["opera"] = curRoles.UserName
  22317. // data["code"] = miConfig.Code
  22318. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  22319. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22320. //
  22321. // client := &http.Client{}
  22322. // bytesData, _ := json.Marshal(data)
  22323. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  22324. // resp, _ := client.Do(req)
  22325. // defer resp.Body.Close()
  22326. // body, ioErr := ioutil.ReadAll(resp.Body)
  22327. // if ioErr != nil {
  22328. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22329. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22330. // return
  22331. // }
  22332. // var respJSON map[string]interface{}
  22333. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22334. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22335. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22336. // return
  22337. // }
  22338. //
  22339. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22340. // userJSONBytes, _ := json.Marshal(respJSON)
  22341. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22342. // utils.ErrorLog("解析失败:%v", err)
  22343. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22344. // adminUser := c.GetAdminUserInfo()
  22345. // errlog := &models.HisOrderError{
  22346. // UserOrgId: adminUser.CurrentOrgId,
  22347. // Ctime: time.Now().Unix(),
  22348. // Mtime: time.Now().Unix(),
  22349. // ErrMsg: res.ErrMsg + "解析失败",
  22350. // Status: 1,
  22351. // PatientId: order_id,
  22352. // Stage: 10088,
  22353. // }
  22354. // service.CreateErrMsgLog(errlog)
  22355. // continue
  22356. // }
  22357. //
  22358. // } else {
  22359. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  22360. // fmt.Println(result)
  22361. //
  22362. // var dat map[string]interface{}
  22363. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22364. // fmt.Println(dat)
  22365. // } else {
  22366. // fmt.Println(err)
  22367. // }
  22368. // userJSONBytes, _ := json.Marshal(dat)
  22369. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22370. // utils.ErrorLog("解析失败:%v", err)
  22371. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22372. // adminUser := c.GetAdminUserInfo()
  22373. // errlog := &models.HisOrderError{
  22374. // UserOrgId: adminUser.CurrentOrgId,
  22375. // Ctime: time.Now().Unix(),
  22376. // Mtime: time.Now().Unix(),
  22377. // ErrMsg: res.ErrMsg + "解析失败",
  22378. // Status: 1,
  22379. // PatientId: order_id,
  22380. // Stage: 10106,
  22381. // }
  22382. // service.CreateErrMsgLog(errlog)
  22383. // continue
  22384. // }
  22385. // }
  22386. //
  22387. // if res.Infcode != 0 {
  22388. // adminUser := c.GetAdminUserInfo()
  22389. // errlog := &models.HisOrderError{
  22390. // UserOrgId: adminUser.CurrentOrgId,
  22391. // Ctime: time.Now().Unix(),
  22392. // Mtime: time.Now().Unix(),
  22393. // ErrMsg: res.ErrMsg,
  22394. // Status: 1,
  22395. // PatientId: order_id,
  22396. // Stage: 10106,
  22397. // }
  22398. // service.CreateErrMsgLog(errlog)
  22399. // continue
  22400. // } else {
  22401. // hisFundSettleListResult := &models.HisFundSettleListResult{
  22402. // Number: res.Output.SetlListId,
  22403. // Status: 1,
  22404. // Ctime: time.Now().Unix(),
  22405. // Mtime: time.Now().Unix(),
  22406. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  22407. // IsUpload: 1,
  22408. // OrderId: order_id,
  22409. // }
  22410. // service.CreateUploadRecord(hisFundSettleListResult)
  22411. // continue
  22412. // }
  22413. // }
  22414. //}
  22415. func (c *HisApiController) GetOrgInfo() {
  22416. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  22417. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  22418. }
  22419. func (c *HisApiController) GetHisPatientInfo() {
  22420. medical_insurance_card := c.GetString("medical_insurance_card")
  22421. id_card_type, _ := c.GetInt64("id_card_type")
  22422. id_card := c.GetString("id_card")
  22423. adminInfo := c.GetAdminUserInfo()
  22424. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  22425. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  22426. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  22427. IdCardNo := ""
  22428. if id_card_type == 1 {
  22429. IdCardNo = medical_insurance_card
  22430. } else if id_card_type == 2 {
  22431. IdCardNo = id_card
  22432. }
  22433. if config.IsOpen == 1 {
  22434. 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
  22435. resp, requestErr := http.Get(api)
  22436. if requestErr != nil {
  22437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22438. return
  22439. }
  22440. defer resp.Body.Close()
  22441. body, ioErr := ioutil.ReadAll(resp.Body)
  22442. if ioErr != nil {
  22443. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22445. return
  22446. }
  22447. var respJSON map[string]interface{}
  22448. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22449. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22451. return
  22452. }
  22453. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22454. userJSONBytes, _ := json.Marshal(userJSON)
  22455. var res ResultTwo
  22456. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22457. utils.ErrorLog("解析失败:%v", err)
  22458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22459. return
  22460. }
  22461. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  22462. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  22463. infoStr := string(Iinfos)
  22464. idetinfoStr := string(Idetinfos)
  22465. if res.Infcode == 0 {
  22466. his := models.VMHisPatient{
  22467. Status: 1,
  22468. Ctime: time.Now().Unix(),
  22469. Mtime: time.Now().Unix(),
  22470. PsnNo: res.Output.Baseinfo.PsnNo,
  22471. PsnCertType: res.Output.Baseinfo.PsnCertType,
  22472. Certno: res.Output.Baseinfo.Certno,
  22473. PsnName: res.Output.Baseinfo.PsnName,
  22474. Gend: res.Output.Baseinfo.Gend,
  22475. Naty: res.Output.Baseinfo.Naty,
  22476. Iinfo: infoStr,
  22477. Idetinfo: idetinfoStr,
  22478. UserOrgId: adminInfo.CurrentOrgId,
  22479. IsReturn: 1,
  22480. IdCardType: id_card_type,
  22481. }
  22482. c.ServeSuccessJSON(map[string]interface{}{
  22483. "info": his,
  22484. })
  22485. } else {
  22486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  22487. return
  22488. }
  22489. }
  22490. }
  22491. //func GetBasBaseInfo() (jsonStr string, err error) {
  22492. //
  22493. // handle := syscall.NewLazyDLL("SSCard.dll")
  22494. // add := handle.NewProc("ReadCardBas")
  22495. // str := make([]byte, 1024)
  22496. // str1 := make([]byte, 1024)
  22497. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  22498. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  22499. //
  22500. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  22501. //
  22502. // fmt.Println("> Add(4,5)的结果为:", ret)
  22503. // handle.Release()
  22504. //
  22505. // return "", nil
  22506. //
  22507. //}
  22508. //func GetQRBaseInfo() (jsonStr string, err error) {
  22509. // handle := syscall.LoadDLL("SSCard.dll")
  22510. // ReadCardBas := handle.FindProc("GetQRBase")
  22511. //
  22512. // str := make([]byte, 256)
  22513. // str1 := make([]byte, 256)
  22514. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  22515. //
  22516. // fmt.Println(string(str))
  22517. // fmt.Println(r)
  22518. // return string(str), nil
  22519. //}
  22520. //func CardInit() int {
  22521. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  22522. // add := DllTestDef.MustFindProc("Init")
  22523. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  22524. // if err != nil {
  22525. // fmt.Println("SSCard的运算结果为:", ret)
  22526. // }
  22527. // result := int(ret)
  22528. // return result
  22529. //}
  22530. //func CardInit() int {
  22531. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  22532. // if err != nil {
  22533. // fmt.Println("SSCard的运算结果为:", ret)
  22534. // }
  22535. // fmt.Println(err)
  22536. // result := int(ret)
  22537. // return result
  22538. //}
  22539. func IntPtr(n int) uintptr {
  22540. return uintptr(n)
  22541. }
  22542. func StrPtr(s string) uintptr {
  22543. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  22544. }
  22545. type Result2001 struct {
  22546. Cainfo interface{} `json:"cainfo"`
  22547. ErrMsg string `json:"err_msg"`
  22548. InfRefmsgid string `json:"inf_refmsgid"`
  22549. Infcode int64 `json:"infcode"`
  22550. Output struct {
  22551. Trtinfo struct {
  22552. PsnNo string `json:"psn_no"`
  22553. TrtChkType string `json:"trt_chk_type"`
  22554. FundPayType string `json:"fund_pay_type"`
  22555. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  22556. Begndate string `json:"begndate"`
  22557. Enddate string `json:"enddate"`
  22558. TrtChkRslt string `json:"trt_chk_rslt"`
  22559. } `json:"trtinfo"`
  22560. } `json:"output"`
  22561. RefmsgTime string `json:"refmsg_time"`
  22562. RespondTime string `json:"respond_time"`
  22563. Signtype interface{} `json:"signtype"`
  22564. WarnMsg interface{} `json:"warn_msg"`
  22565. }
  22566. type Result2001Org10265 struct {
  22567. Cainfo interface{} `json:"cainfo"`
  22568. ErrMsg string `json:"err_msg"`
  22569. InfRefmsgid string `json:"inf_refmsgid"`
  22570. Infcode string `json:"infcode"`
  22571. Output struct {
  22572. Trtinfo struct {
  22573. PsnNo string `json:"psn_no"`
  22574. TrtChkType string `json:"trt_chk_type"`
  22575. FundPayType string `json:"fund_pay_type"`
  22576. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  22577. Begndate string `json:"begndate"`
  22578. Enddate string `json:"enddate"`
  22579. TrtChkRslt string `json:"trt_chk_rslt"`
  22580. } `json:"trtinfo"`
  22581. } `json:"output"`
  22582. RefmsgTime string `json:"refmsg_time"`
  22583. RespondTime string `json:"respond_time"`
  22584. Signtype interface{} `json:"signtype"`
  22585. WarnMsg interface{} `json:"warn_msg"`
  22586. }
  22587. type ResultTwo struct {
  22588. ErrMsg string `json:"err_msg"`
  22589. InfRefmsgid string `json:"inf_refmsgid"`
  22590. Infcode int64 `json:"infcode"`
  22591. Output struct {
  22592. Baseinfo struct {
  22593. //Brdy string `json:"brdy"`
  22594. Certno string `json:"certno"`
  22595. Gend string `json:"gend"`
  22596. Naty string `json:"naty"`
  22597. PsnCertType string `json:"psn_cert_type"`
  22598. PsnName string `json:"psn_name"`
  22599. PsnNo string `json:"psn_no"`
  22600. } `json:"baseinfo"`
  22601. Idetinfo []interface{} `json:"idetinfo"`
  22602. Iinfo []struct {
  22603. Balc float64 `json:"balc"`
  22604. CvlservFlag string `json:"cvlserv_flag"`
  22605. EmpName string `json:"emp_name"`
  22606. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22607. Insutype string `json:"insutype"`
  22608. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22609. //PausInsuDate string `json:"paus_insu_date"`
  22610. //PsnInsuDate string `json:"psn_insu_date"`
  22611. PsnInsuStas string `json:"psn_insu_stas"`
  22612. PsnType string `json:"psn_type"`
  22613. } `json:"insuinfo"`
  22614. } `json:"output"`
  22615. RefmsgTime string `json:"refmsg_time"`
  22616. RespondTime string `json:"respond_time"`
  22617. Signtype interface{} `json:"signtype"`
  22618. WarnInfo interface{} `json:"warn_info"`
  22619. }
  22620. type ResultTwo10265 struct {
  22621. ErrMsg string `json:"err_msg"`
  22622. InfRefmsgid string `json:"inf_refmsgid"`
  22623. Infcode string `json:"infcode"`
  22624. Output struct {
  22625. Baseinfo struct {
  22626. //Brdy string `json:"brdy"`
  22627. Certno string `json:"certno"`
  22628. Gend string `json:"gend"`
  22629. Naty string `json:"naty"`
  22630. PsnCertType string `json:"psn_cert_type"`
  22631. PsnName string `json:"psn_name"`
  22632. PsnNo string `json:"psn_no"`
  22633. } `json:"baseinfo"`
  22634. Idetinfo []interface{} `json:"idetinfo"`
  22635. Iinfo []struct {
  22636. Balc float64 `json:"balc"`
  22637. CvlservFlag string `json:"cvlserv_flag"`
  22638. EmpName string `json:"emp_name"`
  22639. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22640. Insutype string `json:"insutype"`
  22641. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22642. PsnInsuStas string `json:"psn_insu_stas"`
  22643. PsnType string `json:"psn_type"`
  22644. } `json:"insuinfo"`
  22645. } `json:"output"`
  22646. RefmsgTime string `json:"refmsg_time"`
  22647. RespondTime string `json:"respond_time"`
  22648. Signtype interface{} `json:"signtype"`
  22649. WarnInfo interface{} `json:"warn_info"`
  22650. }
  22651. type ResultThree struct {
  22652. Cainfo interface{} `json:"cainfo"`
  22653. ErrMsg string `json:"err_msg"`
  22654. InfRefmsgid string `json:"inf_refmsgid"`
  22655. Infcode int64 `json:"infcode"`
  22656. Output struct {
  22657. Data struct {
  22658. IptOtpNo string `json:"ipt_otp_no"`
  22659. MdtrtID string `json:"mdtrt_id"`
  22660. PsnNo string `json:"psn_no"`
  22661. } `json:"data"`
  22662. } `json:"output"`
  22663. RefmsgTime string `json:"refmsg_time"`
  22664. RespondTime string `json:"respond_time"`
  22665. Signtype interface{} `json:"signtype"`
  22666. WarnMsg interface{} `json:"warn_msg"`
  22667. }
  22668. type ResultThree10265 struct {
  22669. Cainfo interface{} `json:"cainfo"`
  22670. ErrMsg string `json:"err_msg"`
  22671. InfRefmsgid string `json:"inf_refmsgid"`
  22672. Infcode string `json:"infcode"`
  22673. Output struct {
  22674. Data struct {
  22675. IptOtpNo string `json:"ipt_otp_no"`
  22676. MdtrtID string `json:"mdtrt_id"`
  22677. PsnNo string `json:"psn_no"`
  22678. } `json:"data"`
  22679. } `json:"output"`
  22680. RefmsgTime string `json:"refmsg_time"`
  22681. RespondTime string `json:"respond_time"`
  22682. Signtype interface{} `json:"signtype"`
  22683. WarnMsg interface{} `json:"warn_msg"`
  22684. }
  22685. type ResultFour struct {
  22686. Cainfo string `json:"cainfo"`
  22687. ErrMsg string `json:"err_msg"`
  22688. InfRefmsgid string `json:"inf_refmsgid"`
  22689. Infcode int64 `json:"infcode"`
  22690. Output struct {
  22691. Result []struct {
  22692. BasMednFlag string `json:"bas_medn_flag"`
  22693. ChldMedcFlag string `json:"chld_medc_flag"`
  22694. ChrgitmLv string `json:"chrgitm_lv"`
  22695. Cnt float64 `json:"cnt"`
  22696. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  22697. DrtReimFlag string `json:"drt_reim_flag"`
  22698. FeedetlSn string `json:"feedetl_sn"`
  22699. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22700. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  22701. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22702. ListSpItemFlag string `json:"list_sp_item_flag"`
  22703. LmtUsedFlag string `json:"lmt_used_flag"`
  22704. MedChrgitmType string `json:"med_chrgitm_type"`
  22705. Memo string `json:"memo"`
  22706. OverlmtAmt float64 `json:"overlmt_amt"`
  22707. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22708. Pric float64 `json:"pric"`
  22709. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  22710. SelfpayProp float64 `json:"selfpay_prop"`
  22711. } `json:"result"`
  22712. } `json:"output"`
  22713. RefmsgTime string `json:"refmsg_time"`
  22714. RespondTime string `json:"respond_time"`
  22715. Signtype string `json:"signtype"`
  22716. WarnMsg string `json:"warn_msg"`
  22717. }
  22718. type ResultFour10265 struct {
  22719. Cainfo string `json:"cainfo"`
  22720. ErrMsg string `json:"err_msg"`
  22721. InfRefmsgid string `json:"inf_refmsgid"`
  22722. Infcode string `json:"infcode"`
  22723. Output struct {
  22724. Result []struct {
  22725. BasMednFlag string `json:"bas_medn_flag"`
  22726. ChldMedcFlag string `json:"chld_medc_flag"`
  22727. ChrgitmLv string `json:"chrgitm_lv"`
  22728. Cnt float64 `json:"cnt"`
  22729. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  22730. DrtReimFlag string `json:"drt_reim_flag"`
  22731. FeedetlSn string `json:"feedetl_sn"`
  22732. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22733. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  22734. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22735. ListSpItemFlag string `json:"list_sp_item_flag"`
  22736. LmtUsedFlag string `json:"lmt_used_flag"`
  22737. MedChrgitmType string `json:"med_chrgitm_type"`
  22738. Memo string `json:"memo"`
  22739. OverlmtAmt float64 `json:"overlmt_amt"`
  22740. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22741. Pric float64 `json:"pric"`
  22742. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  22743. SelfpayProp float64 `json:"selfpay_prop"`
  22744. } `json:"result"`
  22745. } `json:"output"`
  22746. RefmsgTime string `json:"refmsg_time"`
  22747. RespondTime string `json:"respond_time"`
  22748. Signtype string `json:"signtype"`
  22749. WarnMsg string `json:"warn_msg"`
  22750. }
  22751. type ResultMemo struct {
  22752. InsuAdmdvs string `json:"insuAdmdvs"`
  22753. }
  22754. // [{"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}]
  22755. type ResultIDInfo struct {
  22756. Begntime string `json:"begntime"`
  22757. Endtime string `json:"endtime"`
  22758. Memo string `json:"memo"`
  22759. }
  22760. type ResultFive struct {
  22761. Balc float64 `json:"balc"`
  22762. CvlservFlag string `json:"cvlserv_flag"`
  22763. EmpName string `json:"emp_name"`
  22764. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22765. Insutype string `json:"insutype"`
  22766. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22767. PausInsuDate string `json:"paus_insu_date"`
  22768. PsnInsuDate string `json:"psn_insu_date"`
  22769. PsnInsuStas string `json:"psn_insu_stas"`
  22770. PsnType string `json:"psn_type"`
  22771. }
  22772. type ResultSix struct {
  22773. Cainfo interface{} `json:"cainfo"`
  22774. ErrMsg string `json:"err_msg"`
  22775. InfRefmsgid string `json:"inf_refmsgid"`
  22776. Infcode int64 `json:"infcode"`
  22777. Output struct {
  22778. } `json:"output"`
  22779. RefmsgTime string `json:"refmsg_time"`
  22780. RespondTime string `json:"respond_time"`
  22781. Signtype interface{} `json:"signtype"`
  22782. WarnMsg interface{} `json:"warn_msg"`
  22783. }
  22784. type ResultSix3103 struct {
  22785. Cainfo interface{} `json:"cainfo"`
  22786. ErrMsg string `json:"err_msg"`
  22787. InfRefmsgid string `json:"inf_refmsgid"`
  22788. Infcode int64 `json:"infcode"`
  22789. RefmsgTime string `json:"refmsg_time"`
  22790. RespondTime string `json:"respond_time"`
  22791. Signtype interface{} `json:"signtype"`
  22792. WarnMsg interface{} `json:"warn_msg"`
  22793. }
  22794. type FJ3507Result struct {
  22795. Cainfo interface{} `json:"cainfo"`
  22796. ErrMsg string `json:"err_msg"`
  22797. InfRefmsgid string `json:"inf_refmsgid"`
  22798. Infcode int64 `json:"infcode"`
  22799. Output struct {
  22800. retRslt string `json:"retRslt"`
  22801. msgRslt string `json:"msgRslt"`
  22802. } `json:"output"`
  22803. RefmsgTime string `json:"refmsg_time"`
  22804. RespondTime string `json:"respond_time"`
  22805. Signtype interface{} `json:"signtype"`
  22806. WarnMsg interface{} `json:"warn_msg"`
  22807. }
  22808. type FJ3507ResultFor10188 struct {
  22809. Cainfo interface{} `json:"cainfo"`
  22810. ErrMsg string `json:"err_msg"`
  22811. InfRefmsgid string `json:"inf_refmsgid"`
  22812. Infcode string `json:"infcode"`
  22813. RefmsgTime string `json:"refmsg_time"`
  22814. RespondTime string `json:"respond_time"`
  22815. Signtype interface{} `json:"signtype"`
  22816. WarnMsg interface{} `json:"warn_msg"`
  22817. }
  22818. type Result2406 struct {
  22819. Cainfo interface{} `json:"cainfo"`
  22820. ErrMsg string `json:"err_msg"`
  22821. InfRefmsgid string `json:"inf_refmsgid"`
  22822. Infcode int64 `json:"infcode"`
  22823. Output struct {
  22824. Result struct {
  22825. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  22826. } `json:"result"`
  22827. } `json:"output"`
  22828. RefmsgTime string `json:"refmsg_time"`
  22829. RespondTime string `json:"respond_time"`
  22830. Signtype interface{} `json:"signtype"`
  22831. WarnMsg interface{} `json:"warn_msg"`
  22832. }
  22833. type GZResultSix struct {
  22834. Cainfo interface{} `json:"cainfo"`
  22835. ErrMsg string `json:"err_msg"`
  22836. InfRefmsgid string `json:"inf_refmsgid"`
  22837. Infcode int64 `json:"infcode"`
  22838. Output string `json:"output"`
  22839. RefmsgTime string `json:"refmsg_time"`
  22840. RespondTime string `json:"respond_time"`
  22841. Signtype interface{} `json:"signtype"`
  22842. WarnMsg interface{} `json:"warn_msg"`
  22843. }
  22844. type ResultSix10265 struct {
  22845. Cainfo interface{} `json:"cainfo"`
  22846. ErrMsg string `json:"err_msg"`
  22847. InfRefmsgid string `json:"inf_refmsgid"`
  22848. Infcode string `json:"infcode"`
  22849. Output struct {
  22850. } `json:"output"`
  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 ResultSeven struct {
  22857. Cainfo string `json:"cainfo"`
  22858. ErrMsg string `json:"err_msg"`
  22859. InfRefmsgid string `json:"inf_refmsgid"`
  22860. Infcode int64 `json:"infcode"`
  22861. Output struct {
  22862. Setlinfo struct {
  22863. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22864. AcctPay float64 `json:"acct_pay"`
  22865. ActPayDedc float64 `json:"act_pay_dedc"`
  22866. Age float64 `json:"age"`
  22867. Balc float64 `json:"balc"`
  22868. Certno string `json:"certno"`
  22869. ClrOptins string `json:"clr_optins"`
  22870. ClrType string `json:"clr_type"`
  22871. ClrWay string `json:"clr_way"`
  22872. CvlservFlag string `json:"cvlserv_flag"`
  22873. CvlservPay float64 `json:"cvlserv_pay"`
  22874. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22875. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22876. Gend string `json:"gend"`
  22877. HifesPay float64 `json:"hifes_pay"`
  22878. HifmiPay float64 `json:"hifmi_pay"`
  22879. HifpPay float64 `json:"hifp_pay"`
  22880. HospPartAmt float64 `json:"hosp_part_amt"`
  22881. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22882. Insutype string `json:"insutype"`
  22883. MafPay float64 `json:"maf_pay"`
  22884. MdtrtCertType string `json:"mdtrt_cert_type"`
  22885. HifobPay float64 `json:"hifob_pay"`
  22886. MdtrtID string `json:"mdtrt_id"`
  22887. MedType string `json:"med_type"`
  22888. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22889. MedinsSetlID string `json:"medins_setl_id"`
  22890. Naty string `json:"naty"`
  22891. OthPay float64 `json:"oth_pay"`
  22892. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22893. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22894. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22895. PsnCashPay float64 `json:"psn_cash_pay"`
  22896. PsnCertType string `json:"psn_cert_type"`
  22897. PsnName string `json:"psn_name"`
  22898. PsnNo string `json:"psn_no"`
  22899. PsnPartAmt float64 `json:"psn_part_amt"`
  22900. PsnType string `json:"psn_type"`
  22901. SetlID string `json:"setl_id"`
  22902. SetlTime string `json:"setl_time"`
  22903. } `json:"setlinfo"`
  22904. Setldetail interface{} `json:"setldetail"`
  22905. } `json:"output"`
  22906. RefmsgTime string `json:"refmsg_time"`
  22907. RespondTime string `json:"respond_time"`
  22908. Signtype interface{} `json:"signtype"`
  22909. WarnMsg interface{} `json:"warn_msg"`
  22910. }
  22911. type ResultSevenAH struct {
  22912. Cainfo string `json:"cainfo"`
  22913. ErrMsg string `json:"err_msg"`
  22914. InfRefmsgid string `json:"inf_refmsgid"`
  22915. Infcode int64 `json:"infcode"`
  22916. Output struct {
  22917. Setlinfo struct {
  22918. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22919. AcctPay float64 `json:"acct_pay"`
  22920. ActPayDedc float64 `json:"act_pay_dedc"`
  22921. Age float64 `json:"age"`
  22922. Balc float64 `json:"balc"`
  22923. Certno string `json:"certno"`
  22924. ClrOptins string `json:"clr_optins"`
  22925. ClrType string `json:"clr_type"`
  22926. ClrWay string `json:"clr_way"`
  22927. CvlservFlag string `json:"cvlserv_flag"`
  22928. CvlservPay float64 `json:"cvlserv_pay"`
  22929. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22930. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22931. Gend string `json:"gend"`
  22932. HifesPay float64 `json:"hifes_pay"`
  22933. HifmiPay float64 `json:"hifmi_pay"`
  22934. HifpPay float64 `json:"hifp_pay"`
  22935. HospPartAmt float64 `json:"hosp_part_amt"`
  22936. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22937. Insutype string `json:"insutype"`
  22938. MafPay float64 `json:"maf_pay"`
  22939. MdtrtCertType string `json:"mdtrt_cert_type"`
  22940. HifobPay float64 `json:"hifob_pay"`
  22941. MdtrtID string `json:"mdtrt_id"`
  22942. MedType string `json:"med_type"`
  22943. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22944. MedinsSetlID string `json:"medins_setl_id"`
  22945. Naty string `json:"naty"`
  22946. OthPay float64 `json:"oth_pay"`
  22947. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22948. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22949. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22950. PsnCashPay float64 `json:"psn_cash_pay"`
  22951. PsnCertType string `json:"psn_cert_type"`
  22952. PsnName string `json:"psn_name"`
  22953. PsnNo string `json:"psn_no"`
  22954. PsnPartAmt float64 `json:"psn_part_amt"`
  22955. PsnType string `json:"psn_type"`
  22956. SetlID string `json:"setl_id"`
  22957. SetlTime int64 `json:"setl_time"`
  22958. } `json:"setlinfo"`
  22959. Setldetail interface{} `json:"setldetail"`
  22960. } `json:"output"`
  22961. RefmsgTime string `json:"refmsg_time"`
  22962. RespondTime string `json:"respond_time"`
  22963. Signtype interface{} `json:"signtype"`
  22964. WarnMsg interface{} `json:"warn_msg"`
  22965. }
  22966. type ResultSeven10265 struct {
  22967. Cainfo string `json:"cainfo"`
  22968. ErrMsg string `json:"err_msg"`
  22969. InfRefmsgid string `json:"inf_refmsgid"`
  22970. Infcode string `json:"infcode"`
  22971. Output struct {
  22972. Setlinfo struct {
  22973. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22974. AcctPay float64 `json:"acct_pay"`
  22975. ActPayDedc float64 `json:"act_pay_dedc"`
  22976. Age float64 `json:"age"`
  22977. Balc float64 `json:"balc"`
  22978. Certno string `json:"certno"`
  22979. ClrOptins string `json:"clr_optins"`
  22980. ClrType string `json:"clr_type"`
  22981. ClrWay string `json:"clr_way"`
  22982. CvlservFlag string `json:"cvlserv_flag"`
  22983. CvlservPay float64 `json:"cvlserv_pay"`
  22984. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22985. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22986. Gend string `json:"gend"`
  22987. HifesPay float64 `json:"hifes_pay"`
  22988. HifmiPay float64 `json:"hifmi_pay"`
  22989. HifpPay float64 `json:"hifp_pay"`
  22990. HospPartAmt float64 `json:"hosp_part_amt"`
  22991. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22992. Insutype string `json:"insutype"`
  22993. MafPay float64 `json:"maf_pay"`
  22994. MdtrtCertType string `json:"mdtrt_cert_type"`
  22995. HifobPay float64 `json:"hifob_pay"`
  22996. MdtrtID string `json:"mdtrt_id"`
  22997. MedType string `json:"med_type"`
  22998. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22999. MedinsSetlID string `json:"medins_setl_id"`
  23000. Naty string `json:"naty"`
  23001. OthPay float64 `json:"oth_pay"`
  23002. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23003. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23004. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23005. PsnCashPay float64 `json:"psn_cash_pay"`
  23006. PsnCertType string `json:"psn_cert_type"`
  23007. PsnName string `json:"psn_name"`
  23008. PsnNo string `json:"psn_no"`
  23009. PsnPartAmt float64 `json:"psn_part_amt"`
  23010. PsnType string `json:"psn_type"`
  23011. SetlID string `json:"setl_id"`
  23012. SetlTime string `json:"setl_time"`
  23013. } `json:"setlinfo"`
  23014. Setldetail interface{} `json:"setldetail"`
  23015. } `json:"output"`
  23016. RefmsgTime string `json:"refmsg_time"`
  23017. RespondTime string `json:"respond_time"`
  23018. Signtype interface{} `json:"signtype"`
  23019. WarnMsg interface{} `json:"warn_msg"`
  23020. }
  23021. type ResultSeven10265Two struct {
  23022. Cainfo string `json:"cainfo"`
  23023. ErrMsg string `json:"err_msg"`
  23024. InfRefmsgid string `json:"inf_refmsgid"`
  23025. Infcode string `json:"infcode"`
  23026. Output struct {
  23027. Setlinfo struct {
  23028. AcctMulaidPay string `json:"acct_mulaid_pay"`
  23029. AcctPay float64 `json:"acct_pay"`
  23030. ActPayDedc float64 `json:"act_pay_dedc"`
  23031. Age float64 `json:"age"`
  23032. Balc float64 `json:"balc"`
  23033. Certno string `json:"certno"`
  23034. ClrOptins string `json:"clr_optins"`
  23035. ClrType string `json:"clr_type"`
  23036. ClrWay string `json:"clr_way"`
  23037. CvlservFlag string `json:"cvlserv_flag"`
  23038. CvlservPay float64 `json:"cvlserv_pay"`
  23039. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23040. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23041. Gend string `json:"gend"`
  23042. HifesPay float64 `json:"hifes_pay"`
  23043. HifmiPay float64 `json:"hifmi_pay"`
  23044. HifpPay float64 `json:"hifp_pay"`
  23045. HospPartAmt string `json:"hosp_part_amt"`
  23046. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23047. Insutype string `json:"insutype"`
  23048. MafPay float64 `json:"maf_pay"`
  23049. MdtrtCertType string `json:"mdtrt_cert_type"`
  23050. HifobPay float64 `json:"hifob_pay"`
  23051. MdtrtID string `json:"mdtrt_id"`
  23052. MedType string `json:"med_type"`
  23053. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23054. MedinsSetlID string `json:"medins_setl_id"`
  23055. Naty string `json:"naty"`
  23056. OthPay float64 `json:"oth_pay"`
  23057. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23058. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  23059. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23060. PsnCashPay float64 `json:"psn_cash_pay"`
  23061. PsnCertType string `json:"psn_cert_type"`
  23062. PsnName string `json:"psn_name"`
  23063. PsnNo string `json:"psn_no"`
  23064. PsnPartAmt float64 `json:"psn_part_amt"`
  23065. PsnType string `json:"psn_type"`
  23066. SetlID string `json:"setl_id"`
  23067. SetlTime string `json:"setl_time"`
  23068. } `json:"setlinfo"`
  23069. Setldetail interface{} `json:"setldetail"`
  23070. } `json:"output"`
  23071. RefmsgTime string `json:"refmsg_time"`
  23072. RespondTime string `json:"respond_time"`
  23073. Signtype interface{} `json:"signtype"`
  23074. WarnMsg interface{} `json:"warn_msg"`
  23075. }
  23076. type ResultSeven10633Two struct {
  23077. Cainfo string `json:"cainfo"`
  23078. ErrMsg string `json:"err_msg"`
  23079. InfRefmsgid string `json:"inf_refmsgid"`
  23080. Infcode string `json:"infcode"`
  23081. Output struct {
  23082. Setlinfo struct {
  23083. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23084. AcctPay float64 `json:"acct_pay"`
  23085. ActPayDedc float64 `json:"act_pay_dedc"`
  23086. Age float64 `json:"age"`
  23087. Balc float64 `json:"balc"`
  23088. Certno string `json:"certno"`
  23089. ClrOptins string `json:"clr_optins"`
  23090. ClrType string `json:"clr_type"`
  23091. ClrWay string `json:"clr_way"`
  23092. CvlservFlag string `json:"cvlserv_flag"`
  23093. CvlservPay float64 `json:"cvlserv_pay"`
  23094. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23095. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23096. Gend string `json:"gend"`
  23097. HifesPay float64 `json:"hifes_pay"`
  23098. HifmiPay float64 `json:"hifmi_pay"`
  23099. HifpPay float64 `json:"hifp_pay"`
  23100. HospPartAmt float64 `json:"hosp_part_amt"`
  23101. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23102. Insutype string `json:"insutype"`
  23103. MafPay float64 `json:"maf_pay"`
  23104. MdtrtCertType string `json:"mdtrt_cert_type"`
  23105. HifobPay float64 `json:"hifob_pay"`
  23106. MdtrtID string `json:"mdtrt_id"`
  23107. MedType string `json:"med_type"`
  23108. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23109. MedinsSetlID string `json:"medins_setl_id"`
  23110. Naty string `json:"naty"`
  23111. OthPay float64 `json:"oth_pay"`
  23112. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23113. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23114. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23115. PsnCashPay float64 `json:"psn_cash_pay"`
  23116. PsnCertType string `json:"psn_cert_type"`
  23117. PsnName string `json:"psn_name"`
  23118. PsnNo string `json:"psn_no"`
  23119. PsnPartAmt float64 `json:"psn_part_amt"`
  23120. PsnType string `json:"psn_type"`
  23121. SetlID string `json:"setl_id"`
  23122. SetlTime string `json:"setl_time"`
  23123. } `json:"setlinfo"`
  23124. Setldetail interface{} `json:"setldetail"`
  23125. } `json:"output"`
  23126. RefmsgTime string `json:"refmsg_time"`
  23127. RespondTime string `json:"respond_time"`
  23128. Signtype interface{} `json:"signtype"`
  23129. WarnMsg interface{} `json:"warn_msg"`
  23130. }
  23131. type ResultSeven10633Three struct {
  23132. Cainfo string `json:"cainfo"`
  23133. ErrMsg string `json:"err_msg"`
  23134. InfRefmsgid string `json:"inf_refmsgid"`
  23135. Infcode string `json:"infcode"`
  23136. Output struct {
  23137. Setlinfo struct {
  23138. AcctMulaidPay string `json:"acct_mulaid_pay"`
  23139. AcctPay float64 `json:"acct_pay"`
  23140. ActPayDedc float64 `json:"act_pay_dedc"`
  23141. Age float64 `json:"age"`
  23142. Balc float64 `json:"balc"`
  23143. Certno string `json:"certno"`
  23144. ClrOptins string `json:"clr_optins"`
  23145. ClrType string `json:"clr_type"`
  23146. ClrWay string `json:"clr_way"`
  23147. CvlservFlag string `json:"cvlserv_flag"`
  23148. CvlservPay float64 `json:"cvlserv_pay"`
  23149. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23150. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23151. Gend string `json:"gend"`
  23152. HifesPay float64 `json:"hifes_pay"`
  23153. HifmiPay float64 `json:"hifmi_pay"`
  23154. HifpPay float64 `json:"hifp_pay"`
  23155. HospPartAmt string `json:"hosp_part_amt"`
  23156. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23157. Insutype string `json:"insutype"`
  23158. MafPay float64 `json:"maf_pay"`
  23159. MdtrtCertType string `json:"mdtrt_cert_type"`
  23160. HifobPay float64 `json:"hifob_pay"`
  23161. MdtrtID string `json:"mdtrt_id"`
  23162. MedType string `json:"med_type"`
  23163. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23164. MedinsSetlID string `json:"medins_setl_id"`
  23165. Naty string `json:"naty"`
  23166. OthPay float64 `json:"oth_pay"`
  23167. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23168. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  23169. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23170. PsnCashPay float64 `json:"psn_cash_pay"`
  23171. PsnCertType string `json:"psn_cert_type"`
  23172. PsnName string `json:"psn_name"`
  23173. PsnNo string `json:"psn_no"`
  23174. PsnPartAmt float64 `json:"psn_part_amt"`
  23175. PsnType string `json:"psn_type"`
  23176. SetlID string `json:"setl_id"`
  23177. SetlTime string `json:"setl_time"`
  23178. } `json:"setlinfo"`
  23179. Setldetail interface{} `json:"setldetail"`
  23180. } `json:"output"`
  23181. RefmsgTime string `json:"refmsg_time"`
  23182. RespondTime string `json:"respond_time"`
  23183. Signtype interface{} `json:"signtype"`
  23184. WarnMsg interface{} `json:"warn_msg"`
  23185. }
  23186. type GZResultSeven10265Two struct {
  23187. Cainfo string `json:"cainfo"`
  23188. ErrMsg string `json:"err_msg"`
  23189. InfRefmsgid string `json:"inf_refmsgid"`
  23190. Infcode int64 `json:"infcode"`
  23191. Output struct {
  23192. Setlinfo struct {
  23193. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23194. AcctPay float64 `json:"acct_pay"`
  23195. ActPayDedc float64 `json:"act_pay_dedc"`
  23196. Age float64 `json:"age"`
  23197. Balc float64 `json:"balc"`
  23198. Certno string `json:"certno"`
  23199. ClrOptins string `json:"clr_optins"`
  23200. ClrType string `json:"clr_type"`
  23201. ClrWay string `json:"clr_way"`
  23202. CvlservFlag string `json:"cvlserv_flag"`
  23203. CvlservPay float64 `json:"cvlserv_pay"`
  23204. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23205. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23206. Gend string `json:"gend"`
  23207. HifesPay float64 `json:"hifes_pay"`
  23208. HifmiPay float64 `json:"hifmi_pay"`
  23209. HifpPay float64 `json:"hifp_pay"`
  23210. HospPartAmt float64 `json:"hosp_part_amt"`
  23211. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23212. Insutype string `json:"insutype"`
  23213. MafPay float64 `json:"maf_pay"`
  23214. MdtrtCertType string `json:"mdtrt_cert_type"`
  23215. HifobPay float64 `json:"hifob_pay"`
  23216. MdtrtID string `json:"mdtrt_id"`
  23217. MedType string `json:"med_type"`
  23218. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23219. MedinsSetlID string `json:"medins_setl_id"`
  23220. Naty string `json:"naty"`
  23221. OthPay float64 `json:"oth_pay"`
  23222. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23223. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  23224. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23225. PsnCashPay float64 `json:"psn_cash_pay"`
  23226. PsnCertType string `json:"psn_cert_type"`
  23227. PsnName string `json:"psn_name"`
  23228. PsnNo string `json:"psn_no"`
  23229. PsnPartAmt float64 `json:"psn_part_amt"`
  23230. PsnType string `json:"psn_type"`
  23231. SetlID string `json:"setl_id"`
  23232. SetlTime string `json:"setl_time"`
  23233. } `json:"setlinfo"`
  23234. Setldetail interface{} `json:"setldetail"`
  23235. } `json:"output"`
  23236. RefmsgTime string `json:"refmsg_time"`
  23237. RespondTime string `json:"respond_time"`
  23238. Signtype interface{} `json:"signtype"`
  23239. WarnMsg interface{} `json:"warn_msg"`
  23240. }
  23241. type ResultEight struct {
  23242. Cainfo string `json:"cainfo"`
  23243. ErrMsg string `json:"err_msg"`
  23244. InfRefmsgid string `json:"inf_refmsgid"`
  23245. Infcode int64 `json:"infcode"`
  23246. Output struct {
  23247. Stmtinfo struct {
  23248. SetlOptins string `json:"setl_optins"`
  23249. StmtRslt string `json:"stmt_rslt"`
  23250. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  23251. } `json:"stmtinfo"`
  23252. } `json:"output"`
  23253. RefmsgTime string `json:"refmsg_time"`
  23254. RespondTime string `json:"respond_time"`
  23255. Signtype interface{} `json:"signtype"`
  23256. WarnMsg interface{} `json:"warn_msg"`
  23257. }
  23258. type ResultEightFor10188 struct {
  23259. Cainfo string `json:"cainfo"`
  23260. ErrMsg string `json:"err_msg"`
  23261. InfRefmsgid string `json:"inf_refmsgid"`
  23262. Infcode string `json:"infcode"`
  23263. Output struct {
  23264. Stmtinfo struct {
  23265. SetlOptins string `json:"setl_optins"`
  23266. StmtRslt string `json:"stmt_rslt"`
  23267. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  23268. } `json:"stmtinfo"`
  23269. } `json:"output"`
  23270. RefmsgTime string `json:"refmsg_time"`
  23271. RespondTime string `json:"respond_time"`
  23272. Signtype interface{} `json:"signtype"`
  23273. WarnMsg interface{} `json:"warn_msg"`
  23274. }
  23275. type ResultNine struct {
  23276. Cainfo string `json:"cainfo"`
  23277. ErrMsg string `json:"err_msg"`
  23278. InfRefmsgid string `json:"inf_refmsgid"`
  23279. Infcode int64 `json:"infcode"`
  23280. Output struct {
  23281. FileQuryNo string `json:"file_qury_no"`
  23282. } `json:"output"`
  23283. RefmsgTime string `json:"refmsg_time"`
  23284. RespondTime string `json:"respond_time"`
  23285. Signtype interface{} `json:"signtype"`
  23286. WarnMsg interface{} `json:"warn_msg"`
  23287. }
  23288. type ResultTen struct {
  23289. Cainfo string `json:"cainfo"`
  23290. ErrMsg string `json:"err_msg"`
  23291. InfRefmsgid string `json:"inf_refmsgid"`
  23292. Infcode int64 `json:"infcode"`
  23293. Output struct {
  23294. Fileinfo struct {
  23295. DldEndtime string `json:"dld_endtime"`
  23296. FileQuryNo string `json:"file_qury_no"`
  23297. Filename string `json:"filename"`
  23298. } `json:"fileinfo"`
  23299. } `json:"output"`
  23300. RefmsgTime string `json:"refmsg_time"`
  23301. RespondTime string `json:"respond_time"`
  23302. Signtype interface{} `json:"signtype"`
  23303. WarnMsg interface{} `json:"warn_msg"`
  23304. }
  23305. type Result5262 struct {
  23306. ErrMsg string `json:"err_msg"`
  23307. InfRefmsgid string `json:"inf_refmsgid"`
  23308. Infcode int64 `json:"infcode"`
  23309. Output struct {
  23310. PageInfo struct {
  23311. Size int `json:"size"`
  23312. RecordCounts int `json:"record_counts"`
  23313. } `json:"page_info"`
  23314. Idetinfo []interface{} `json:"idetinfo"`
  23315. Result []struct {
  23316. SetlID string `json:"setl_id"`
  23317. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  23318. MdtrtID string `json:"mdtrt_id"`
  23319. InitSetlID string `json:"init_setl_id,omitempty"`
  23320. PsnNo string `json:"psn_no"`
  23321. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  23322. PsnName string `json:"psn_name"`
  23323. PsnCertType string `json:"psn_cert_type"`
  23324. Certno string `json:"certno"`
  23325. Gend string `json:"gend,omitempty"`
  23326. Naty string `json:"naty,omitempty"`
  23327. Brdy string `json:"brdy,omitempty"`
  23328. Age float64 `json:"age,omitempty"`
  23329. Insutype string `json:"insutype,omitempty"`
  23330. PsnType string `json:"psn_type"`
  23331. CvlservFlag string `json:"cvlserv_flag"`
  23332. CvlservLv string `json:"cvlserv_lv,omitempty"`
  23333. SpPsnType string `json:"sp_psn_type,omitempty"`
  23334. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  23335. ClctGrde string `json:"clct_grde,omitempty"`
  23336. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  23337. NwbFlag string `json:"nwb_flag,omitempty"`
  23338. InsuAdmdvs string `json:"insu_admdvs"`
  23339. EmpNo string `json:"emp_no,omitempty"`
  23340. EmpName string `json:"emp_name,omitempty"`
  23341. EmpType string `json:"emp_type,omitempty"`
  23342. EconType string `json:"econ_type,omitempty"`
  23343. AfilIndu string `json:"afil_indu,omitempty"`
  23344. AfilRlts string `json:"afil_rlts,omitempty"`
  23345. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  23346. PayLoc string `json:"pay_loc,omitempty"`
  23347. FixmedinsCode string `json:"fixmedins_code"`
  23348. FixmedinsName string `json:"fixmedins_name"`
  23349. HospLv string `json:"hosp_lv,omitempty"`
  23350. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  23351. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  23352. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  23353. Begndate string `json:"begndate"`
  23354. Enddate string `json:"enddate"`
  23355. SetlTime string `json:"setl_time"`
  23356. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  23357. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  23358. MedType string `json:"med_type"`
  23359. SetlType string `json:"setl_type,omitempty"`
  23360. ClrType string `json:"clr_type,omitempty"`
  23361. ClrWay string `json:"clr_way,omitempty"`
  23362. PsnSetlway string `json:"psn_setlway,omitempty"`
  23363. ClrOptins string `json:"clr_optins,omitempty"`
  23364. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  23365. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  23366. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  23367. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  23368. InscpAmt float64 `json:"inscp_amt,omitempty"`
  23369. DedcStd float64 `json:"dedc_std,omitempty"`
  23370. CrtDedc float64 `json:"crt_dedc,omitempty"`
  23371. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  23372. HifpPay float64 `json:"hifp_pay,omitempty"`
  23373. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  23374. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  23375. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  23376. HifesPay float64 `json:"hifes_pay,omitempty"`
  23377. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  23378. HifobPay float64 `json:"hifob_pay,omitempty"`
  23379. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  23380. MafPay float64 `json:"maf_pay,omitempty"`
  23381. OthfundPay float64 `json:"othfund_pay,omitempty"`
  23382. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  23383. PsnPay float64 `json:"psn_pay,omitempty"`
  23384. AcctPay float64 `json:"acct_pay,omitempty"`
  23385. CashPayamt float64 `json:"cash_payamt,omitempty"`
  23386. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  23387. Balc float64 `json:"balc,omitempty"`
  23388. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  23389. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  23390. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  23391. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  23392. Year string `json:"year,omitempty"`
  23393. DiseNo string `json:"dise_no,omitempty"`
  23394. DiseName string `json:"dise_name,omitempty"`
  23395. Invono string `json:"invono,omitempty"`
  23396. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  23397. ValiFlag string `json:"vali_flag,omitempty"`
  23398. Memo string `json:"memo,omitempty"`
  23399. Rid string `json:"rid"`
  23400. UpdtTime string `json:"updt_time,omitempty"`
  23401. CrterID string `json:"crter_id,omitempty"`
  23402. CrterName string `json:"crter_name,omitempty"`
  23403. CrteTime string `json:"crte_time,omitempty"`
  23404. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  23405. OpterID string `json:"opter_id,omitempty"`
  23406. OpterName string `json:"opter_name,omitempty"`
  23407. OptTime string `json:"opt_time,omitempty"`
  23408. OptinsNo string `json:"optins_no,omitempty"`
  23409. PoolareaNo string `json:"poolarea_no,omitempty"`
  23410. } `json:"result"`
  23411. } `json:"output"`
  23412. RefmsgTime string `json:"refmsg_time"`
  23413. RespondTime string `json:"respond_time"`
  23414. Signtype interface{} `json:"signtype"`
  23415. WarnInfo interface{} `json:"warn_info"`
  23416. }
  23417. type Result5267 struct {
  23418. ErrMsg string `json:"err_msg"`
  23419. InfRefmsgid string `json:"inf_refmsgid"`
  23420. Infcode int64 `json:"infcode"`
  23421. Output struct {
  23422. PageInfo struct {
  23423. Size int `json:"size"`
  23424. RecordCounts int `json:"record_counts"`
  23425. } `json:"pageinfo"`
  23426. Result []struct {
  23427. SetlID string `json:"setl_id"`
  23428. ClrOptins string `json:"clr_optins"`
  23429. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  23430. MdtrtID string `json:"mdtrt_id"`
  23431. InitSetlID string `json:"init_setl_id,omitempty"`
  23432. PsnNo string `json:"psn_no"`
  23433. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  23434. PsnName string `json:"psn_name"`
  23435. PsnCertType string `json:"psn_cert_type"`
  23436. Certno string `json:"certno"`
  23437. Gend string `json:"gend,omitempty"`
  23438. Naty string `json:"naty,omitempty"`
  23439. Brdy string `json:"brdy,omitempty"`
  23440. Age float64 `json:"age,omitempty"`
  23441. Insutype string `json:"insutype,omitempty"`
  23442. PsnType string `json:"psn_type"`
  23443. CvlservFlag string `json:"cvlserv_flag"`
  23444. CvlservLv string `json:"cvlserv_lv,omitempty"`
  23445. SpPsnType string `json:"sp_psn_type,omitempty"`
  23446. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  23447. ClctGrde string `json:"clct_grde,omitempty"`
  23448. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  23449. NwbFlag string `json:"nwb_flag,omitempty"`
  23450. InsuAdmdvs string `json:"insu_admdvs"`
  23451. EmpNo string `json:"emp_no,omitempty"`
  23452. EmpName string `json:"emp_name,omitempty"`
  23453. EmpType string `json:"emp_type,omitempty"`
  23454. EconType string `json:"econ_type,omitempty"`
  23455. AfilIndu string `json:"afil_indu,omitempty"`
  23456. AfilRlts string `json:"afil_rlts,omitempty"`
  23457. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  23458. PayLoc string `json:"pay_loc,omitempty"`
  23459. FixmedinsCode string `json:"fixmedins_code"`
  23460. FixmedinsName string `json:"fixmedins_name"`
  23461. HospLv string `json:"hosp_lv,omitempty"`
  23462. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  23463. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  23464. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  23465. Begndate string `json:"begndate,omitempty"`
  23466. Enddate string `json:"enddate,omitempty"`
  23467. SetlTime string `json:"setl_time,omitempty"`
  23468. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  23469. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  23470. MedType string `json:"med_type"`
  23471. SetlType string `json:"setl_type,omitempty"`
  23472. ClrType string `json:"clr_type,omitempty"`
  23473. ClrWay string `json:"clr_way,omitempty"`
  23474. PsnSetlway string `json:"psn_setlway,omitempty"`
  23475. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  23476. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  23477. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  23478. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  23479. InscpAmt float64 `json:"inscp_amt,omitempty"`
  23480. DedcStd float64 `json:"dedc_std,omitempty"`
  23481. CrtDedc float64 `json:"crt_dedc,omitempty"`
  23482. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  23483. HifpPay float64 `json:"hifp_pay,omitempty"`
  23484. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  23485. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  23486. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  23487. HifesPay float64 `json:"hifes_pay,omitempty"`
  23488. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  23489. HifobPay float64 `json:"hifob_pay,omitempty"`
  23490. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  23491. MafPay float64 `json:"maf_pay,omitempty"`
  23492. OthfundPay float64 `json:"othfund_pay,omitempty"`
  23493. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  23494. PsnPay float64 `json:"psn_pay,omitempty"`
  23495. AcctPay float64 `json:"acct_pay,omitempty"`
  23496. CashPayamt float64 `json:"cash_payamt,omitempty"`
  23497. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  23498. Balc float64 `json:"balc,omitempty"`
  23499. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  23500. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  23501. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  23502. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  23503. Year string `json:"year,omitempty"`
  23504. DiseNo string `json:"dise_no,omitempty"`
  23505. DiseName string `json:"dise_name,omitempty"`
  23506. Invono string `json:"invono,omitempty"`
  23507. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  23508. Memo string `json:"memo,omitempty"`
  23509. UpdtTime string `json:"updt_time,omitempty"`
  23510. OpterID string `json:"opter_id,omitempty"`
  23511. OpterName string `json:"opter_name,omitempty"`
  23512. OptTime string `json:"opt_time,omitempty"`
  23513. OptinsNo string `json:"optins_no,omitempty"`
  23514. PoolareaNo string `json:"poolarea_no,omitempty"`
  23515. } `json:"result"`
  23516. } `json:"output"`
  23517. RefmsgTime string `json:"refmsg_time"`
  23518. RespondTime string `json:"respond_time"`
  23519. Signtype interface{} `json:"signtype"`
  23520. WarnInfo interface{} `json:"warn_info"`
  23521. }
  23522. // type Autogenerated struct {
  23523. // Output struct {
  23524. // Setlinfo struct {
  23525. // SetlTime string `json:"setl_time"`
  23526. // CvlservPay float64 `json:"cvlserv_pay"`
  23527. // Year string `json:"year"`
  23528. // MedType string `json:"med_type"`
  23529. // PsnPay float64 `json:"psn_pay"`
  23530. // OpterID string `json:"opter_id"`
  23531. // Begndate string `json:"begndate"`
  23532. // FlxempeFlag string `json:"flxempe_flag"`
  23533. // HifmiPay float64 `json:"hifmi_pay"`
  23534. // PsnNo string `json:"psn_no"`
  23535. // ActPayDedc float64 `json:"act_pay_dedc"`
  23536. // MedinsSetlID interface{} `json:"medins_setl_id"`
  23537. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23538. // ClrWay string `json:"clr_way"`
  23539. // OthPay float64 `json:"oth_pay"`
  23540. // Gend string `json:"gend"`
  23541. // MdtrtID string `json:"mdtrt_id"`
  23542. // AcctPay float64 `json:"acct_pay"`
  23543. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  23544. // Insutype string `json:"insutype"`
  23545. // Invono interface{} `json:"invono"`
  23546. // Enddate string `json:"enddate"`
  23547. // CashPayamt float64 `json:"cash_payamt"`
  23548. // PsnType string `json:"psn_type"`
  23549. // FixmedinsName string `json:"fixmedins_name"`
  23550. // HifpPay float64 `json:"hifp_pay"`
  23551. // NewFlag interface{} `json:"new_flag"`
  23552. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23553. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  23554. // PayLoc string `json:"pay_loc"`
  23555. // ClrType string `json:"clr_type"`
  23556. // RefdSetlFlag string `json:"refd_setl_flag"`
  23557. // CvlservFlag string `json:"cvlserv_flag"`
  23558. // EmpName string `json:"emp_name"`
  23559. // Brdy string `json:"brdy"`
  23560. // Naty string `json:"naty"`
  23561. // Certno string `json:"certno"`
  23562. // DiseCode string `json:"dise_code"`
  23563. // FixmedinsCode string `json:"fixmedins_code"`
  23564. // DedcHospLv string `json:"dedc_hosp_lv"`
  23565. // OpterName string `json:"opter_name"`
  23566. // Balc float64 `json:"balc"`
  23567. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23568. // PsnCertType string `json:"psn_cert_type"`
  23569. // HifobPay float64 `json:"hifob_pay"`
  23570. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  23571. // HifesPay float64 `json:"hifes_pay"`
  23572. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23573. // OptTime string `json:"opt_time"`
  23574. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23575. // SetlID string `json:"setl_id"`
  23576. // MafPay float64 `json:"maf_pay"`
  23577. // PsnName string `json:"psn_name"`
  23578. // InsuOptins interface{} `json:"insu_optins"`
  23579. // PrefFundPay interface{} `json:"pref_fund_pay"`
  23580. // ClrOptins string `json:"clr_optins"`
  23581. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23582. // DiseName string `json:"dise_name"`
  23583. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23584. // Age float64 `json:"age"`
  23585. // DtrtCertType string `json:"dtrt_cert_type"`
  23586. // HospLv string `json:"hosp_lv"`
  23587. // } `json:"setlinfo"`
  23588. // Setldetail []struct {
  23589. // FundPayType string `json:"fund_pay_type"`
  23590. // FundPayamt float64 `json:"fund_payamt"`
  23591. // SetlProcInfo interface{} `json:"setl_proc_info"`
  23592. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  23593. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  23594. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  23595. // PrefFundPay interface{} `json:"pref_fund_pay"`
  23596. // } `json:"setldetail"`
  23597. // } `json:"output"`
  23598. // Infcode int `json:"infcode"`
  23599. // WarnMsg interface{} `json:"warn_msg"`
  23600. // Cainfo interface{} `json:"cainfo"`
  23601. // ErrMsg interface{} `json:"err_msg"`
  23602. // RefmsgTime string `json:"refmsg_time"`
  23603. // Signtype interface{} `json:"signtype"`
  23604. // RespondTime string `json:"respond_time"`
  23605. // InfRefmsgid string `json:"inf_refmsgid"`
  23606. // }
  23607. type Result002 struct {
  23608. Cainfo interface{} `json:"cainfo"`
  23609. ErrMsg string `json:"err_msg"`
  23610. InfRefmsgid string `json:"inf_refmsgid"`
  23611. Infcode int64 `json:"infcode"`
  23612. Output struct {
  23613. RxFile string `json:"rx_file"`
  23614. SignDigest string `json:"sign_digest"`
  23615. SignCertSn string `json:"sign_cert_sn"`
  23616. SignCertDn string `json:"sign_cert_dn"`
  23617. } `json:"output"`
  23618. RefmsgTime string `json:"refmsg_time"`
  23619. RespondTime string `json:"respond_time"`
  23620. Signtype interface{} `json:"signtype"`
  23621. WarnMsg interface{} `json:"warn_msg"`
  23622. }
  23623. type AhResult002 struct {
  23624. RxFile string `json:"rxFile"`
  23625. SignDigest string `json:"signDigest"`
  23626. SignCertSn string `json:"signCertSn"`
  23627. SignCertDn string `json:"signCertDn"`
  23628. }
  23629. type Result003 struct {
  23630. Cainfo interface{} `json:"cainfo"`
  23631. ErrMsg string `json:"err_msg"`
  23632. InfRefmsgid string `json:"inf_refmsgid"`
  23633. Infcode int64 `json:"infcode"`
  23634. Output struct {
  23635. HiRxno string `json:"hi_rxno"`
  23636. RxStasCodg string `json:"rx_stas_codg"`
  23637. RxStasName string `json:"rx_stas_name"`
  23638. } `json:"output"`
  23639. RefmsgTime string `json:"refmsg_time"`
  23640. RespondTime string `json:"respond_time"`
  23641. Signtype interface{} `json:"signtype"`
  23642. WarnMsg interface{} `json:"warn_msg"`
  23643. }
  23644. type AHResult003 struct {
  23645. HiRxno string `json:"hiRxno"`
  23646. RxStasCodg string `json:"rxStasCodg"`
  23647. RxStasName string `json:"rxStasName"`
  23648. }
  23649. type ResultEleven struct {
  23650. Cainfo string `json:"cainfo"`
  23651. ErrMsg string `json:"err_msg"`
  23652. InfRefmsgid string `json:"inf_refmsgid"`
  23653. Infcode int64 `json:"infcode"`
  23654. Output struct {
  23655. Setlinfo struct {
  23656. SetlTime string `json:"setl_time"`
  23657. CvlservPay float64 `json:"cvlserv_pay"`
  23658. Year string `json:"year"`
  23659. MedType string `json:"med_type"`
  23660. PsnPay float64 `json:"psn_pay"`
  23661. OpterID string `json:"opter_id"`
  23662. Begndate string `json:"begndate"`
  23663. FlxempeFlag string `json:"flxempe_flag"`
  23664. HifmiPay float64 `json:"hifmi_pay"`
  23665. PsnNo string `json:"psn_no"`
  23666. ActPayDedc float64 `json:"act_pay_dedc"`
  23667. MedinsSetlID interface{} `json:"medins_setl_id"`
  23668. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23669. ClrWay string `json:"clr_way"`
  23670. OthPay float64 `json:"oth_pay"`
  23671. Gend string `json:"gend"`
  23672. MdtrtID string `json:"mdtrt_id"`
  23673. AcctPay float64 `json:"acct_pay"`
  23674. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23675. Insutype string `json:"insutype"`
  23676. Invono interface{} `json:"invono"`
  23677. Enddate string `json:"enddate"`
  23678. CashPayamt float64 `json:"cash_payamt"`
  23679. PsnType string `json:"psn_type"`
  23680. FixmedinsName string `json:"fixmedins_name"`
  23681. HifpPay float64 `json:"hifp_pay"`
  23682. NewFlag interface{} `json:"new_flag"`
  23683. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23684. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23685. PayLoc string `json:"pay_loc"`
  23686. ClrType string `json:"clr_type"`
  23687. RefdSetlFlag string `json:"refd_setl_flag"`
  23688. CvlservFlag string `json:"cvlserv_flag"`
  23689. EmpName string `json:"emp_name"`
  23690. Brdy string `json:"brdy"`
  23691. Naty string `json:"naty"`
  23692. Certno string `json:"certno"`
  23693. DiseCode string `json:"dise_code"`
  23694. FixmedinsCode string `json:"fixmedins_code"`
  23695. DedcHospLv string `json:"dedc_hosp_lv"`
  23696. OpterName string `json:"opter_name"`
  23697. Balc float64 `json:"balc"`
  23698. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23699. PsnCertType string `json:"psn_cert_type"`
  23700. HifobPay float64 `json:"hifob_pay"`
  23701. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23702. HifesPay float64 `json:"hifes_pay"`
  23703. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23704. OptTime string `json:"opt_time"`
  23705. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23706. SetlID string `json:"setl_id"`
  23707. MafPay float64 `json:"maf_pay"`
  23708. PsnName string `json:"psn_name"`
  23709. InsuOptins interface{} `json:"insu_optins"`
  23710. PrefFundPay interface{} `json:"pref_fund_pay"`
  23711. ClrOptins string `json:"clr_optins"`
  23712. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23713. DiseName string `json:"dise_name"`
  23714. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23715. Age float64 `json:"age"`
  23716. DtrtCertType string `json:"dtrt_cert_type"`
  23717. HospLv string `json:"hosp_lv"`
  23718. PsnCashPay float64 `json:"psn_cash_pay"`
  23719. } `json:"setlinfo"`
  23720. } `json:"output"`
  23721. RefmsgTime string `json:"refmsg_time"`
  23722. RespondTime string `json:"respond_time"`
  23723. Signtype interface{} `json:"signtype"`
  23724. WarnMsg interface{} `json:"warn_msg"`
  23725. }
  23726. type ResultElevenah struct {
  23727. Cainfo string `json:"cainfo"`
  23728. ErrMsg string `json:"err_msg"`
  23729. InfRefmsgid string `json:"inf_refmsgid"`
  23730. Infcode int64 `json:"infcode"`
  23731. Output struct {
  23732. Setlinfo struct {
  23733. SetlTime int64 `json:"setl_time"`
  23734. CvlservPay float64 `json:"cvlserv_pay"`
  23735. Year string `json:"year"`
  23736. MedType string `json:"med_type"`
  23737. PsnPay float64 `json:"psn_pay"`
  23738. OpterID string `json:"opter_id"`
  23739. Begndate int64 `json:"begndate"`
  23740. FlxempeFlag string `json:"flxempe_flag"`
  23741. HifmiPay float64 `json:"hifmi_pay"`
  23742. PsnNo string `json:"psn_no"`
  23743. ActPayDedc float64 `json:"act_pay_dedc"`
  23744. MedinsSetlID interface{} `json:"medins_setl_id"`
  23745. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23746. ClrWay string `json:"clr_way"`
  23747. OthPay float64 `json:"oth_pay"`
  23748. Gend string `json:"gend"`
  23749. MdtrtID string `json:"mdtrt_id"`
  23750. AcctPay float64 `json:"acct_pay"`
  23751. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23752. Insutype string `json:"insutype"`
  23753. Invono interface{} `json:"invono"`
  23754. Enddate int64 `json:"enddate"`
  23755. CashPayamt float64 `json:"cash_payamt"`
  23756. PsnType string `json:"psn_type"`
  23757. FixmedinsName string `json:"fixmedins_name"`
  23758. HifpPay float64 `json:"hifp_pay"`
  23759. NewFlag interface{} `json:"new_flag"`
  23760. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23761. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23762. PayLoc string `json:"pay_loc"`
  23763. ClrType string `json:"clr_type"`
  23764. RefdSetlFlag string `json:"refd_setl_flag"`
  23765. CvlservFlag string `json:"cvlserv_flag"`
  23766. EmpName string `json:"emp_name"`
  23767. Brdy int64 `json:"brdy"`
  23768. Naty string `json:"naty"`
  23769. Certno string `json:"certno"`
  23770. DiseCode string `json:"dise_code"`
  23771. FixmedinsCode string `json:"fixmedins_code"`
  23772. DedcHospLv string `json:"dedc_hosp_lv"`
  23773. OpterName string `json:"opter_name"`
  23774. Balc float64 `json:"balc"`
  23775. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23776. PsnCertType string `json:"psn_cert_type"`
  23777. HifobPay float64 `json:"hifob_pay"`
  23778. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23779. HifesPay float64 `json:"hifes_pay"`
  23780. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23781. OptTime int64 `json:"opt_time"`
  23782. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23783. SetlID string `json:"setl_id"`
  23784. MafPay float64 `json:"maf_pay"`
  23785. PsnName string `json:"psn_name"`
  23786. InsuOptins interface{} `json:"insu_optins"`
  23787. PrefFundPay interface{} `json:"pref_fund_pay"`
  23788. ClrOptins string `json:"clr_optins"`
  23789. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23790. DiseName string `json:"dise_name"`
  23791. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23792. Age float64 `json:"age"`
  23793. DtrtCertType string `json:"dtrt_cert_type"`
  23794. HospLv string `json:"hosp_lv"`
  23795. PsnCashPay float64 `json:"psn_cash_pay"`
  23796. } `json:"setlinfo"`
  23797. } `json:"output"`
  23798. RefmsgTime string `json:"refmsg_time"`
  23799. RespondTime string `json:"respond_time"`
  23800. Signtype interface{} `json:"signtype"`
  23801. WarnMsg interface{} `json:"warn_msg"`
  23802. }
  23803. type ResultEleven10265 struct {
  23804. Cainfo string `json:"cainfo"`
  23805. ErrMsg string `json:"err_msg"`
  23806. InfRefmsgid string `json:"inf_refmsgid"`
  23807. Infcode string `json:"infcode"`
  23808. Output struct {
  23809. Setlinfo struct {
  23810. SetlTime string `json:"setl_time"`
  23811. CvlservPay float64 `json:"cvlserv_pay"`
  23812. Year string `json:"year"`
  23813. MedType string `json:"med_type"`
  23814. PsnPay float64 `json:"psn_pay"`
  23815. OpterID string `json:"opter_id"`
  23816. Begndate string `json:"begndate"`
  23817. FlxempeFlag string `json:"flxempe_flag"`
  23818. HifmiPay float64 `json:"hifmi_pay"`
  23819. PsnNo string `json:"psn_no"`
  23820. ActPayDedc float64 `json:"act_pay_dedc"`
  23821. MedinsSetlID interface{} `json:"medins_setl_id"`
  23822. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23823. ClrWay string `json:"clr_way"`
  23824. OthPay float64 `json:"oth_pay"`
  23825. Gend string `json:"gend"`
  23826. MdtrtID string `json:"mdtrt_id"`
  23827. AcctPay float64 `json:"acct_pay"`
  23828. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23829. Insutype string `json:"insutype"`
  23830. Invono interface{} `json:"invono"`
  23831. Enddate string `json:"enddate"`
  23832. CashPayamt float64 `json:"cash_payamt"`
  23833. PsnType string `json:"psn_type"`
  23834. FixmedinsName string `json:"fixmedins_name"`
  23835. HifpPay float64 `json:"hifp_pay"`
  23836. NewFlag interface{} `json:"new_flag"`
  23837. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23838. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23839. PayLoc string `json:"pay_loc"`
  23840. ClrType string `json:"clr_type"`
  23841. RefdSetlFlag string `json:"refd_setl_flag"`
  23842. CvlservFlag string `json:"cvlserv_flag"`
  23843. EmpName string `json:"emp_name"`
  23844. Brdy string `json:"brdy"`
  23845. Naty string `json:"naty"`
  23846. Certno string `json:"certno"`
  23847. DiseCode string `json:"dise_code"`
  23848. FixmedinsCode string `json:"fixmedins_code"`
  23849. DedcHospLv string `json:"dedc_hosp_lv"`
  23850. OpterName string `json:"opter_name"`
  23851. Balc float64 `json:"balc"`
  23852. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23853. PsnCertType string `json:"psn_cert_type"`
  23854. HifobPay float64 `json:"hifob_pay"`
  23855. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23856. HifesPay float64 `json:"hifes_pay"`
  23857. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23858. OptTime string `json:"opt_time"`
  23859. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23860. SetlID string `json:"setl_id"`
  23861. MafPay float64 `json:"maf_pay"`
  23862. PsnName string `json:"psn_name"`
  23863. InsuOptins interface{} `json:"insu_optins"`
  23864. PrefFundPay interface{} `json:"pref_fund_pay"`
  23865. ClrOptins string `json:"clr_optins"`
  23866. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23867. DiseName string `json:"dise_name"`
  23868. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23869. Age float64 `json:"age"`
  23870. DtrtCertType string `json:"dtrt_cert_type"`
  23871. HospLv string `json:"hosp_lv"`
  23872. PsnCashPay float64 `json:"psn_cash_pay"`
  23873. } `json:"setlinfo"`
  23874. } `json:"output"`
  23875. RefmsgTime string `json:"refmsg_time"`
  23876. RespondTime string `json:"respond_time"`
  23877. Signtype interface{} `json:"signtype"`
  23878. WarnMsg interface{} `json:"warn_msg"`
  23879. }
  23880. type ResultTwelve struct {
  23881. Cainfo string `json:"cainfo"`
  23882. ErrMsg string `json:"err_msg"`
  23883. InfRefmsgid string `json:"inf_refmsgid"`
  23884. Infcode int64 `json:"infcode"`
  23885. Output struct {
  23886. MdtrtId string `json:"mdtrt_id"`
  23887. ChrgBchno string `json:"chrg_bchno"`
  23888. PsnNo string `json:"psn_no"`
  23889. } `json:"output"`
  23890. RefmsgTime string `json:"refmsg_time"`
  23891. RespondTime string `json:"respond_time"`
  23892. Signtype interface{} `json:"signtype"`
  23893. WarnMsg interface{} `json:"warn_msg"`
  23894. }
  23895. type ResultThirteen struct {
  23896. ErrMsg string `json:"err_msg"`
  23897. InfRefmsgid string `json:"inf_refmsgid"`
  23898. Infcode int64 `json:"infcode"`
  23899. Output struct {
  23900. Result struct {
  23901. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  23902. } `json:"result"`
  23903. } `json:"output"`
  23904. RefmsgTime string `json:"refmsg_time"`
  23905. RespondTime string `json:"respond_time"`
  23906. Signtype interface{} `json:"signtype"`
  23907. WarnInfo interface{} `json:"warn_info"`
  23908. }
  23909. type ResultThirteen10265 struct {
  23910. ErrMsg string `json:"err_msg"`
  23911. InfRefmsgid string `json:"inf_refmsgid"`
  23912. Infcode string `json:"infcode"`
  23913. Output struct {
  23914. Result struct {
  23915. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  23916. } `json:"result"`
  23917. } `json:"output"`
  23918. RefmsgTime string `json:"refmsg_time"`
  23919. RespondTime string `json:"respond_time"`
  23920. Signtype interface{} `json:"signtype"`
  23921. WarnInfo interface{} `json:"warn_info"`
  23922. }
  23923. type ResultFourteen struct {
  23924. ErrMsg string `json:"err_msg"`
  23925. InfRefmsgid string `json:"inf_refmsgid"`
  23926. Infcode int64 `json:"infcode"`
  23927. Output struct {
  23928. } `json:"output"`
  23929. RefmsgTime string `json:"refmsg_time"`
  23930. RespondTime string `json:"respond_time"`
  23931. Signtype interface{} `json:"signtype"`
  23932. WarnInfo interface{} `json:"warn_info"`
  23933. }
  23934. type ResultCFYLJG001 struct {
  23935. ErrMsg string `json:"err_msg"`
  23936. InfRefmsgid string `json:"inf_refmsgid"`
  23937. Infcode int64 `json:"infcode"`
  23938. Output struct {
  23939. RxTraceCode string `json:"rx_trace_code"`
  23940. HiRxno string `json:"hi_rxno"`
  23941. } `json:"output"`
  23942. RefmsgTime string `json:"refmsg_time"`
  23943. RespondTime string `json:"respond_time"`
  23944. Signtype interface{} `json:"signtype"`
  23945. WarnInfo interface{} `json:"warn_info"`
  23946. }
  23947. type ResultCFYLJG001AH struct {
  23948. RxTraceCode string `json:"rxTraceCode"`
  23949. HiRxno string `json:"hiRxno"`
  23950. }
  23951. type ResultCFYLJG007 struct {
  23952. ErrMsg string `json:"err_msg"`
  23953. InfRefmsgid string `json:"inf_refmsgid"`
  23954. Infcode int64 `json:"infcode"`
  23955. Output struct {
  23956. HiRxno string `json:"hi_rxno"`
  23957. RxStasName string `json:"rx_stas_name"`
  23958. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  23959. Seltdelts []interface{} `json:"seltdelts"`
  23960. RxUsedStasName string `json:"rx_used_stas_name"`
  23961. RxStasCodg string `json:"rx_stas_codg"`
  23962. } `json:"output"`
  23963. RefmsgTime string `json:"refmsg_time"`
  23964. RespondTime string `json:"respond_time"`
  23965. Signtype interface{} `json:"signtype"`
  23966. WarnInfo interface{} `json:"warn_info"`
  23967. }
  23968. type ResultCFYLJG002 struct {
  23969. ErrMsg string `json:"err_msg"`
  23970. InfRefmsgid string `json:"inf_refmsgid"`
  23971. Infcode int64 `json:"infcode"`
  23972. Output struct {
  23973. RxFile string `json:"rx_file"`
  23974. SignDigest string `json:"sign_digest"`
  23975. SignCertSn string `json:"sign_cert_sn"`
  23976. SignCertDn string `json:"sign_cert_dn"`
  23977. } `json:"output"`
  23978. RefmsgTime string `json:"refmsg_time"`
  23979. RespondTime string `json:"respond_time"`
  23980. Signtype interface{} `json:"signtype"`
  23981. WarnInfo interface{} `json:"warn_info"`
  23982. }
  23983. type ResultCFYLJG003 struct {
  23984. ErrMsg string `json:"err_msg"`
  23985. InfRefmsgid string `json:"inf_refmsgid"`
  23986. Infcode int64 `json:"infcode"`
  23987. Output struct {
  23988. HiRxno string `json:"hi_rxno"`
  23989. RxStasCodg string `json:"rx_stas_codg"`
  23990. RxStasName string `json:"rx_stas_name"`
  23991. } `json:"output"`
  23992. RefmsgTime string `json:"refmsg_time"`
  23993. RespondTime string `json:"respond_time"`
  23994. Signtype interface{} `json:"signtype"`
  23995. WarnInfo interface{} `json:"warn_info"`
  23996. }
  23997. type ResultCFYLJG004 struct {
  23998. ErrMsg string `json:"err_msg"`
  23999. InfRefmsgid string `json:"inf_refmsgid"`
  24000. Infcode int64 `json:"infcode"`
  24001. Output struct {
  24002. HiRxno string `json:"hi_rxno"`
  24003. RxStasCodg string `json:"rx_stas_codg"`
  24004. RxStasName string `json:"rx_stas_name"`
  24005. } `json:"output"`
  24006. RefmsgTime string `json:"refmsg_time"`
  24007. RespondTime string `json:"respond_time"`
  24008. Signtype interface{} `json:"signtype"`
  24009. WarnInfo interface{} `json:"warn_info"`
  24010. }
  24011. type ResultCFYLJG008 struct {
  24012. ErrMsg string `json:"err_msg"`
  24013. InfRefmsgid string `json:"inf_refmsgid"`
  24014. Infcode int64 `json:"infcode"`
  24015. Output struct {
  24016. PoolareaNo string `json:"poolareaNo"`
  24017. AdmdvsName string `json:"admdvsName"`
  24018. Count string `json:"count"`
  24019. } `json:"output"`
  24020. RefmsgTime string `json:"refmsg_time"`
  24021. RespondTime string `json:"respond_time"`
  24022. Signtype interface{} `json:"signtype"`
  24023. WarnInfo interface{} `json:"warn_info"`
  24024. }
  24025. type ResultCFYLJG005 struct {
  24026. ErrMsg string `json:"err_msg"`
  24027. InfRefmsgid string `json:"inf_refmsgid"`
  24028. Infcode int64 `json:"infcode"`
  24029. Output struct {
  24030. HiRxNo string `json:"hi_rxno"`
  24031. FixMedinsCode string `json:"fixmedins_code"`
  24032. FixMedinsName string `json:"fixmedins_name"`
  24033. RxStasCodg string `json:"rx_stas_codg"`
  24034. RxStasName string `json:"rx_stas_name"`
  24035. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  24036. RxUserdStasName string `json:"rx_userd_stas_name"`
  24037. PrscTime string `json:"prsc_time"`
  24038. RxDrugCnt float64 `json:"rx_drug_cnt"`
  24039. RxUsedWayCodg string `json:"rx_used_way_codg"`
  24040. RxUsedWayName string `json:"rx_used_way_name"`
  24041. RxFrquCodg string `json:"rx_frqu_codg"`
  24042. RxFrquName string `json:"rx_frqu_name"`
  24043. RxDosunt string `json:"rx_dosunt"`
  24044. RxDoscnt float64 `json:"rx_doscnt"`
  24045. RxDrordDscr string `json:"rx_drord_dscr"`
  24046. ValiDays int64 `json:"vali_days"`
  24047. ValiEndTime string `json:"vali_end_time"`
  24048. ReptFlag string `json:"rept_flag"`
  24049. MaxReptCnt int64 `json:"max_rept_cnt"`
  24050. ReptdCnt int64 `json:"reptd_cnt"`
  24051. MinInrvDays int64 `json:"min_inrv_days"`
  24052. RxTypeCode string `json:"rx_type_code"`
  24053. RxTypeName string `json:"rx_type_name"`
  24054. LongRxFlag string `json:"long_rx_flag"`
  24055. RxDetlList []struct {
  24056. MedListCodg string `json:"med_list_codg"`
  24057. MedinsListCodg string `json:"medins_list_codg"`
  24058. HospPrepFlag string `json:"hosp_prep_flag"`
  24059. RxItemTypeCode string `json:"rx_item_type_code"`
  24060. RxItemTypeName string `json:"rx_item_type_name"`
  24061. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  24062. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  24063. TcmHerbFoote string `json:"tcmherb_foote"`
  24064. MednTypeCode string `json:"medn_type_code"`
  24065. MednTypeName string `json:"medn_type_name"`
  24066. MainMedcFlag string `json:"main_medc_flag"`
  24067. UrgtFlag string `json:"urgt_flag"`
  24068. BasMednFlag string `json:"bas_medn_flag"`
  24069. ImpDrugFlag string `json:"imp_drug_flag"`
  24070. ProdBarc string `json:"prod_barc"`
  24071. DrugProdname string `json:"drug_prodname"`
  24072. GennameCodg string `json:"genname_codg"`
  24073. DrugGenname string `json:"drug_genname"`
  24074. DrugDosform string `json:"drug_dosform"`
  24075. DrugSpec string `json:"drug_spec"`
  24076. PrdrName string `json:"prdr_name"`
  24077. MedcWayCodg string `json:"medc_way_codg"`
  24078. MedcWayDscr string `json:"medc_way_dscr"`
  24079. MedcBegntime string `json:"medc_begntime"`
  24080. MedcEndtime string `json:"medc_endtime"`
  24081. MedcDays float64 `json:"medc_days"`
  24082. DrugPric float64 `json:"drug_pric"`
  24083. DrugSumamt float64 `json:"drug_sumamt"`
  24084. DrugCnt float64 `json:"drug_cnt"`
  24085. DrugDosunt string `json:"drug_dosunt"`
  24086. SinDoscnt float64 `json:"sin_doscnt"`
  24087. SinDosunt string `json:"sin_dosunt"`
  24088. UsedFrquCodg string `json:"used_frqu_codg"`
  24089. UsedFrquName string `json:"used_frqu_name"`
  24090. DrugTotlcnt string `json:"drug_totlcnt"`
  24091. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  24092. DiseCodg string `json:"dise_codg"`
  24093. HospApprFlag string `json:"hosp_appr_flag"`
  24094. } `json:"rx_detl_list"`
  24095. RxOtpinfo struct {
  24096. MedType string `json:"med_type"`
  24097. IptOtpNo string `json:"ipt_otp_no"`
  24098. OtpIptFlag string `json:"otp_ipt_flag"`
  24099. PatnName string `json:"patn_name"`
  24100. PatnAge float64 `json:"patn_age"`
  24101. PatnHgt float64 `json:"patn_hgt"`
  24102. PatnWt float64 `json:"patn_wt"`
  24103. Gend string `json:"gend"`
  24104. GesoVal float64 `json:"geso_val"`
  24105. NwbFlag string `json:"nwb_flag"`
  24106. NwbAge string `json:"nwb_age"`
  24107. SuckPrdFlag string `json:"suck_prd_flag"`
  24108. AlgsHis string `json:"algs_his"`
  24109. Insutype string `json:"insutype"`
  24110. PrscDeptName string `json:"prsc_dept_name"`
  24111. PrscDrName string `json:"prsc_dr_name"`
  24112. PharName string `json:"phar_name"`
  24113. PharChkTime string `json:"phar_chk_time"`
  24114. MdtrtTime string `json:"mdtrt_time"`
  24115. DiseCodg string `json:"dise_codg"`
  24116. DiseName string `json:"dise_name"`
  24117. SpDiseFlag string `json:"sp_dise_flag"`
  24118. MaindiagCode string `json:"maindiag_code"`
  24119. MaindiagName string `json:"maindiag_name"`
  24120. DiseCondDscr string `json:"dise_cond_dscr"`
  24121. FstdiagFlag string `json:"fstdiag_flag"`
  24122. } `json:"rx_otpinfo"`
  24123. RxDiseList []struct {
  24124. DiagType string `json:"diag_type"`
  24125. MaindiagFlag string `json:"maindiag_flag"`
  24126. DiagSrtNo string `json:"diag_srt_no"`
  24127. DiagCode string `json:"diag_code"`
  24128. DiagName string `json:"diag_name"`
  24129. DiagDept string `json:"diag_dept"`
  24130. DiagDrNo string `json:"diag_dr_no"`
  24131. DiagDrName string `json:"diag_dr_name"`
  24132. DiagTime string `json:"diag_time"`
  24133. TcmDiseCode string `json:"tcm_dise_code"`
  24134. TcmDiseName string `json:"tcm_dise_name"`
  24135. TcmSympCode string `json:"tcmsymp_code"`
  24136. TcmSymp string `json:"tcmsymp"`
  24137. } `json:"rx_dise_list"`
  24138. } `json:"output"`
  24139. RefmsgTime string `json:"refmsg_time"`
  24140. RespondTime string `json:"respond_time"`
  24141. Signtype interface{} `json:"signtype"`
  24142. WarnInfo interface{} `json:"warn_info"`
  24143. }
  24144. type ResultCFYLJG006 struct {
  24145. ErrMsg string `json:"err_msg"`
  24146. InfRefmsgid string `json:"inf_refmsgid"`
  24147. Infcode int64 `json:"infcode"`
  24148. Output struct {
  24149. HiRxNo string `json:"hi_rxno"`
  24150. PharCode string `json:"phar_code"`
  24151. PharName string `json:"phar_name"`
  24152. RxChkOpnn string `json:"rx_chk_opnn"`
  24153. RxChkTime string `json:"rx_chk_time"`
  24154. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  24155. RxChkStasName string `json:"rx_chk_stas_name"`
  24156. RxStasCodg string `json:"rx_stas_codg"`
  24157. RxStasName string `json:"rx_stas_name"`
  24158. } `json:"output"`
  24159. RefmsgTime string `json:"refmsg_time"`
  24160. RespondTime string `json:"respond_time"`
  24161. Signtype interface{} `json:"signtype"`
  24162. WarnInfo interface{} `json:"warn_info"`
  24163. }
  24164. type ResultFourteen10265 struct {
  24165. ErrMsg string `json:"err_msg"`
  24166. InfRefmsgid string `json:"inf_refmsgid"`
  24167. Infcode string `json:"infcode"`
  24168. Output struct {
  24169. } `json:"output"`
  24170. RefmsgTime string `json:"refmsg_time"`
  24171. RespondTime string `json:"respond_time"`
  24172. Signtype interface{} `json:"signtype"`
  24173. WarnInfo interface{} `json:"warn_info"`
  24174. }
  24175. type ResultSixteen struct {
  24176. Cainfo string `json:"cainfo"`
  24177. ErrMsg string `json:"err_msg"`
  24178. InfRefmsgid string `json:"inf_refmsgid"`
  24179. Infcode int64 `json:"infcode"`
  24180. Output struct {
  24181. Setlinfo struct {
  24182. MdtrtID string `json:"mdtrt_id"`
  24183. SetlID string `json:"setl_id"`
  24184. ClrOptins string `json:"clr_optins"`
  24185. SetlTime string `json:"setl_time"`
  24186. MedfeeSumamt float64 `json:"medfee_sumamt"`
  24187. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  24188. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  24189. PreselfpayAmt float64 `json:"preselfpay_amt"`
  24190. InscpScpAmt float64 `json:"inscp_scp_amt"`
  24191. ActPayDedc float64 `json:"act_pay_dedc"`
  24192. HifpPay float64 `json:"hifp_pay"`
  24193. PoolPropSe float64 `json:"pool_prop_selfpay"`
  24194. Lfpay float64 `json:"selfpay"`
  24195. CvlservPay float64 `json:"cvlserv_pay"`
  24196. HifesPay float64 `json:"hifes_pay"`
  24197. HifmiPay float64 `json:"hifmi_pay"`
  24198. HifobPay float64 `json:"hifob_pay"`
  24199. MafPay float64 `json:"maf_pay"`
  24200. OthPay float64 `json:"oth_pay"`
  24201. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  24202. PsnPartAmt float64 `json:"psn_part_amt"`
  24203. AcctPay float64 `json:"acct_pay"`
  24204. Balc float64 `json:"balc"`
  24205. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  24206. HospPartAmt float64 `json:"hosp_part_amt"`
  24207. MedinsSetlID string `json:"medins_setl_id"`
  24208. PdnCashPay string `json:"pdn_cash_pay"`
  24209. } `json:"setlinfo"`
  24210. } `json:"output"`
  24211. RefmsgTime string `json:"refmsg_time"`
  24212. RespondTime string `json:"respond_time"`
  24213. Signtype interface{} `json:"signtype"`
  24214. WarnMsg interface{} `json:"warn_msg"`
  24215. }
  24216. type ResultSixteen10265 struct {
  24217. Cainfo string `json:"cainfo"`
  24218. ErrMsg string `json:"err_msg"`
  24219. InfRefmsgid string `json:"inf_refmsgid"`
  24220. Infcode string `json:"infcode"`
  24221. Output struct {
  24222. Setlinfo struct {
  24223. MdtrtID string `json:"mdtrt_id"`
  24224. SetlID string `json:"setl_id"`
  24225. ClrOptins string `json:"clr_optins"`
  24226. SetlTime string `json:"setl_time"`
  24227. MedfeeSumamt float64 `json:"medfee_sumamt"`
  24228. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  24229. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  24230. PreselfpayAmt float64 `json:"preselfpay_amt"`
  24231. InscpScpAmt float64 `json:"inscp_scp_amt"`
  24232. ActPayDedc float64 `json:"act_pay_dedc"`
  24233. HifpPay float64 `json:"hifp_pay"`
  24234. PoolPropSe float64 `json:"pool_prop_selfpay"`
  24235. Lfpay float64 `json:"selfpay"`
  24236. CvlservPay float64 `json:"cvlserv_pay"`
  24237. HifesPay float64 `json:"hifes_pay"`
  24238. HifmiPay float64 `json:"hifmi_pay"`
  24239. HifobPay float64 `json:"hifob_pay"`
  24240. MafPay float64 `json:"maf_pay"`
  24241. OthPay float64 `json:"oth_pay"`
  24242. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  24243. PsnPartAmt float64 `json:"psn_part_amt"`
  24244. AcctPay float64 `json:"acct_pay"`
  24245. Balc float64 `json:"balc"`
  24246. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  24247. HospPartAmt float64 `json:"hosp_part_amt"`
  24248. MedinsSetlID string `json:"medins_setl_id"`
  24249. PdnCashPay string `json:"pdn_cash_pay"`
  24250. } `json:"setlinfo"`
  24251. } `json:"output"`
  24252. RefmsgTime string `json:"refmsg_time"`
  24253. RespondTime string `json:"respond_time"`
  24254. Signtype interface{} `json:"signtype"`
  24255. WarnMsg interface{} `json:"warn_msg"`
  24256. }
  24257. type ResultSixteen10265Two struct {
  24258. Cainfo string `json:"cainfo"`
  24259. ErrMsg string `json:"err_msg"`
  24260. InfRefmsgid string `json:"inf_refmsgid"`
  24261. Infcode string `json:"infcode"`
  24262. Output struct {
  24263. Setlinfo interface{} `json:"setlinfo"`
  24264. } `json:"output"`
  24265. RefmsgTime string `json:"refmsg_time"`
  24266. RespondTime string `json:"respond_time"`
  24267. Signtype interface{} `json:"signtype"`
  24268. WarnMsg interface{} `json:"warn_msg"`
  24269. }
  24270. type ResultgzSixteen10265Two struct {
  24271. Cainfo string `json:"cainfo"`
  24272. ErrMsg string `json:"err_msg"`
  24273. InfRefmsgid string `json:"inf_refmsgid"`
  24274. Infcode int64 `json:"infcode"`
  24275. Output struct {
  24276. Setlinfo interface{} `json:"setlinfo"`
  24277. } `json:"output"`
  24278. RefmsgTime string `json:"refmsg_time"`
  24279. RespondTime string `json:"respond_time"`
  24280. Signtype interface{} `json:"signtype"`
  24281. WarnMsg interface{} `json:"warn_msg"`
  24282. }
  24283. type ResultSeventeen struct {
  24284. ErrMsg string `json:"err_msg"`
  24285. InfRefmsgid string `json:"inf_refmsgid"`
  24286. Infcode int64 `json:"infcode"`
  24287. Output struct {
  24288. SetlListId string `json:"setl_list_id"`
  24289. } `json:"output"`
  24290. RefmsgTime string `json:"refmsg_time"`
  24291. RespondTime string `json:"respond_time"`
  24292. Signtype string `json:"signtype"`
  24293. WarnInfo string `json:"warn_info"`
  24294. }
  24295. type ResultSeventeenOther struct {
  24296. ErrMsg string `json:"err_msg"`
  24297. InfRefmsgid string `json:"inf_refmsgid"`
  24298. Infcode string `json:"infcode"`
  24299. Output struct {
  24300. SetlListId string `json:"setl_list_id"`
  24301. } `json:"output"`
  24302. RefmsgTime string `json:"refmsg_time"`
  24303. RespondTime string `json:"respond_time"`
  24304. Signtype string `json:"signtype"`
  24305. WarnInfo string `json:"warn_info"`
  24306. }
  24307. type Result90991 struct {
  24308. ErrMsg string `json:"err_msg"`
  24309. InfRefmsgid string `json:"inf_refmsgid"`
  24310. Infcode int64 `json:"infcode"`
  24311. Output struct {
  24312. Result struct {
  24313. PsnNo string `json:"psn_no"`
  24314. CardStat string `json:"card_stat"`
  24315. Certno string `json:"certno"`
  24316. PsnName string `json:"psn_name"`
  24317. CheckStat string `json:"check_stat"`
  24318. SscnoCheckStat string `json:"sscno_check_stat"`
  24319. } `json:"result"`
  24320. } `json:"output"`
  24321. RefmsgTime string `json:"refmsg_time"`
  24322. RespondTime string `json:"respond_time"`
  24323. Signtype interface{} `json:"signtype"`
  24324. WarnInfo interface{} `json:"warn_info"`
  24325. }
  24326. type Result90100 struct {
  24327. ErrMsg string `json:"err_msg"`
  24328. InfRefmsgid string `json:"inf_refmsgid"`
  24329. Infcode int64 `json:"infcode"`
  24330. Output struct {
  24331. PoolareaNo string `json:"poolarea_no"`
  24332. PoolareaNoName string `json:"poolarea_no_name"`
  24333. Insutype string `json:"insutype"`
  24334. InsutypeName string `json:"insutype_name"`
  24335. ClctType string `json:"clct_type"`
  24336. ClctTypeName string `json:"clct_type_name"`
  24337. ClctFlag string `json:"clct_flag"`
  24338. ClctFlagName string `json:"clct_flag_name"`
  24339. AccrymBegn string `json:"accrym_begn"`
  24340. AccrymEnd string `json:"accrym_end"`
  24341. ClctTime string `json:"clct_time"`
  24342. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  24343. } `json:"output"`
  24344. RefmsgTime string `json:"refmsg_time"`
  24345. RespondTime string `json:"respond_time"`
  24346. Signtype interface{} `json:"signtype"`
  24347. WarnInfo interface{} `json:"warn_info"`
  24348. }
  24349. type Custom struct {
  24350. DetItemFeeSumamt string
  24351. Cut string
  24352. FeedetlSn string
  24353. Price string
  24354. MedListCodg string
  24355. Type int64
  24356. AdviceId int64
  24357. ProjectId int64
  24358. ItemId int64
  24359. }
  24360. type Result5301 struct {
  24361. ErrMsg string `json:"err_msg"`
  24362. InfRefmsgid string `json:"inf_refmsgid"`
  24363. Infcode int64 `json:"infcode"`
  24364. Output struct {
  24365. Result []struct {
  24366. OpspDiseCode string `json:"opsp_dise_code"`
  24367. OpspDiseName string `json:"opsp_dise_name"`
  24368. Begndate string `json:"begndate"`
  24369. Enddate string `json:"enddate"`
  24370. } `json:"feedetail"`
  24371. } `json:"output"`
  24372. RefmsgTime string `json:"refmsg_time"`
  24373. RespondTime string `json:"respond_time"`
  24374. Signtype interface{} `json:"signtype"`
  24375. WarnInfo interface{} `json:"warn_info"`
  24376. }
  24377. type Result5301For10265 struct {
  24378. ErrMsg string `json:"err_msg"`
  24379. InfRefmsgid string `json:"inf_refmsgid"`
  24380. Infcode string `json:"infcode"`
  24381. Output struct {
  24382. Result []struct {
  24383. OpspDiseCode string `json:"opsp_dise_code"`
  24384. OpspDiseName string `json:"opsp_dise_name"`
  24385. Begndate string `json:"begndate"`
  24386. Enddate string `json:"enddate"`
  24387. } `json:"feedetail"`
  24388. } `json:"output"`
  24389. RefmsgTime string `json:"refmsg_time"`
  24390. RespondTime string `json:"respond_time"`
  24391. Signtype interface{} `json:"signtype"`
  24392. WarnInfo interface{} `json:"warn_info"`
  24393. }
  24394. //获取个人信息----挂号-----上传就诊信息
  24395. func (c *HisApiController) GetRegisterInfo() {
  24396. id, _ := c.GetInt64("id")
  24397. record_time := c.GetString("record_time")
  24398. settlementValue, _ := c.GetInt64("settlement_value")
  24399. medical_insurance_card := c.GetString("medical_insurance_card")
  24400. name := c.GetString("name")
  24401. id_card_type, _ := c.GetInt64("id_card_type")
  24402. certificates, _ := c.GetInt64("certificates")
  24403. medical_care, _ := c.GetInt64("medical_care")
  24404. birthday := c.GetString("birthday")
  24405. id_card := c.GetString("id_card")
  24406. register_type, _ := c.GetInt64("register")
  24407. doctor, _ := c.GetInt64("doctor")
  24408. department, _ := c.GetInt64("department")
  24409. gender, _ := c.GetInt64("sex")
  24410. registration_fee, _ := c.GetFloat("registration_fee")
  24411. medical_expenses, _ := c.GetFloat("medical_expenses")
  24412. social_type, _ := c.GetInt64("social_type")
  24413. admin_user_id, _ := c.GetInt64("admin_user_id")
  24414. insuplc_admdvs := c.GetString("insuplc_admdvs")
  24415. insuplc_admdvs_tt := c.GetString("insuplc_admdvs")
  24416. mdtrt_type := c.GetString("mdtrt_type")
  24417. if id_card_type == 5 {
  24418. id_card_type = 4
  24419. }
  24420. timeLayout := "2006-01-02"
  24421. loc, _ := time.LoadLocation("Local")
  24422. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  24423. birthUnix := birthdays.Unix()
  24424. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24425. if err != nil {
  24426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24427. return
  24428. }
  24429. recordDateTime := theTime.Unix()
  24430. adminInfo := c.GetAdminUserInfo()
  24431. var patient service.Patients
  24432. if id == 0 {
  24433. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  24434. } else {
  24435. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  24436. }
  24437. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  24438. if patientPrescription.ID == 0 {
  24439. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  24440. }
  24441. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  24442. if patient.ID == 0 {
  24443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  24444. return
  24445. }
  24446. if len(patient.IdCardNo) == 0 {
  24447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  24448. return
  24449. }
  24450. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  24451. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  24452. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  24453. //就诊结算未完成,不能进行二次挂号
  24454. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  24455. if len(his) >= 1 {
  24456. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  24457. if len(his) >= 1 && order.ID == 0 {
  24458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  24459. return
  24460. }
  24461. }
  24462. var aaaa string
  24463. //var register_log string
  24464. if config.IsOpen == 1 {
  24465. var res ResultTwo
  24466. var res10265 ResultTwo10265
  24467. var PsnNo string
  24468. var PsnCertType string
  24469. var Certno string
  24470. var PsnName string
  24471. var Gend string
  24472. var Naty string
  24473. var Brdy string
  24474. var Age float64
  24475. var infoStr string
  24476. var idetinfoStr string
  24477. var infocode int64
  24478. var verify_number string
  24479. fmt.Println(verify_number)
  24480. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  24481. psn_info, _ := service.GetPsnByPatientId(id)
  24482. PsnNo = psn_info.PsnNo
  24483. PsnCertType = psn_info.PsnCertType
  24484. Certno = psn_info.Certno
  24485. PsnName = psn_info.PsnName
  24486. Gend = psn_info.Gend
  24487. Naty = psn_info.Naty
  24488. Brdy = psn_info.Brdy
  24489. Age = psn_info.Age
  24490. infoStr = psn_info.Insuinfo
  24491. idetinfoStr = psn_info.Idetinfo
  24492. infocode = 0
  24493. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  24494. psn_info, _ := service.GetPsnByPatientId(id)
  24495. PsnNo = psn_info.PsnNo
  24496. PsnCertType = psn_info.PsnCertType
  24497. Certno = psn_info.Certno
  24498. PsnName = psn_info.PsnName
  24499. Gend = psn_info.Gend
  24500. Naty = psn_info.Naty
  24501. Brdy = psn_info.Brdy
  24502. Age = psn_info.Age
  24503. infoStr = psn_info.Insuinfo
  24504. idetinfoStr = psn_info.Idetinfo
  24505. infocode = 0
  24506. verify_number = psn_info.VerifyNumber
  24507. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24508. if id_card_type == 2 {
  24509. //请求内网数据
  24510. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  24511. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24512. "&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
  24513. resp, requestErr := http.Get(api)
  24514. if requestErr != nil {
  24515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24516. return
  24517. }
  24518. body, ioErr := ioutil.ReadAll(resp.Body)
  24519. if ioErr != nil {
  24520. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24522. return
  24523. }
  24524. var respJSON map[string]interface{}
  24525. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24526. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24528. return
  24529. }
  24530. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24531. result_byte, _ := json.Marshal(respJSON)
  24532. result := string(result_byte)
  24533. var dat map[string]interface{}
  24534. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24535. fmt.Println(dat)
  24536. } else {
  24537. fmt.Println(err)
  24538. }
  24539. userJSONBytes, _ := json.Marshal(dat)
  24540. var res ResultTwo
  24541. var resTwo10265 ResultTwo10265
  24542. if miConfig.Code == "H15049901371" {
  24543. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  24544. utils.ErrorLog("解析失败:%v", err)
  24545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24546. return
  24547. }
  24548. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  24549. res.Infcode = Infcode
  24550. res.ErrMsg = resTwo10265.ErrMsg
  24551. res.Output = resTwo10265.Output
  24552. res.InfRefmsgid = resTwo10265.InfRefmsgid
  24553. res.RespondTime = resTwo10265.RespondTime
  24554. res.WarnInfo = resTwo10265.WarnInfo
  24555. } else {
  24556. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24557. utils.ErrorLog("解析失败:%v", err)
  24558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24559. return
  24560. }
  24561. }
  24562. //var insutypes []string
  24563. //var insutype string
  24564. //var is390 int = 0
  24565. //var is310 int = 0
  24566. //for _, item := range res.Output.Iinfo {
  24567. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24568. // insutypes = append(insutypes, item.Insutype)
  24569. // }
  24570. //}
  24571. //if len(insutypes) == 1 {
  24572. // insutype = insutypes[0]
  24573. //} else {
  24574. // for _, i := range insutypes {
  24575. // if i == "390" {
  24576. // is390 = 1
  24577. // }
  24578. //
  24579. // if i == "310" {
  24580. // is310 = 1
  24581. // }
  24582. // }
  24583. //}
  24584. //if is390 == 1 {
  24585. // insutype = "390"
  24586. //}
  24587. //if is310 == 1 {
  24588. // insutype = "310"
  24589. //}
  24590. //if len(insutypes) == 0 {
  24591. // insutype = "310"
  24592. //}
  24593. PsnNo = res.Output.Baseinfo.PsnNo
  24594. PsnCertType = res.Output.Baseinfo.PsnCertType
  24595. Certno = res.Output.Baseinfo.Certno
  24596. PsnName = res.Output.Baseinfo.PsnName
  24597. Gend = res.Output.Baseinfo.Gend
  24598. Naty = res.Output.Baseinfo.Naty
  24599. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24600. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24601. infoStr = string(Iinfos)
  24602. idetinfoStr = string(Idetinfos)
  24603. infocode = res.Infcode
  24604. //infocode = 0
  24605. //verify_number = psn_info.VerifyNumber
  24606. } else {
  24607. psn_info, _ := service.GetPsnByPatientId(id)
  24608. PsnNo = psn_info.PsnNo
  24609. PsnCertType = psn_info.PsnCertType
  24610. Certno = psn_info.Certno
  24611. PsnName = psn_info.PsnName
  24612. Gend = psn_info.Gend
  24613. Naty = psn_info.Naty
  24614. Brdy = psn_info.Brdy
  24615. Age = psn_info.Age
  24616. infoStr = psn_info.Insuinfo
  24617. idetinfoStr = psn_info.Idetinfo
  24618. infocode = 0
  24619. verify_number = psn_info.VerifyNumber
  24620. }
  24621. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24622. if id_card_type == 1 {
  24623. psn_info, _ := service.GetPsnByPatientId(id)
  24624. PsnNo = psn_info.PsnNo
  24625. PsnCertType = psn_info.PsnCertType
  24626. Certno = psn_info.Certno
  24627. PsnName = psn_info.PsnName
  24628. Gend = psn_info.Gend
  24629. Naty = psn_info.Naty
  24630. Brdy = psn_info.Brdy
  24631. Age = psn_info.Age
  24632. infoStr = psn_info.Insuinfo
  24633. idetinfoStr = psn_info.Idetinfo
  24634. infocode = 0
  24635. verify_number = psn_info.VerifyNumber
  24636. } else if id_card_type == 2 {
  24637. 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)
  24638. fmt.Println(errMsgLog)
  24639. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24640. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24641. utils.ErrorLog("解析失败:%v", err)
  24642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24643. return
  24644. }
  24645. PsnNo = res.Output.Baseinfo.PsnNo
  24646. PsnCertType = res.Output.Baseinfo.PsnCertType
  24647. Certno = res.Output.Baseinfo.Certno
  24648. PsnName = res.Output.Baseinfo.PsnName
  24649. Gend = res.Output.Baseinfo.Gend
  24650. Naty = res.Output.Baseinfo.Naty
  24651. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24652. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24653. infoStr = string(Iinfos)
  24654. idetinfoStr = string(Idetinfos)
  24655. infocode = res.Infcode
  24656. }
  24657. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24658. if id_card_type == 1 {
  24659. psn_info, _ := service.GetPsnByPatientId(id)
  24660. PsnNo = psn_info.PsnNo
  24661. PsnCertType = psn_info.PsnCertType
  24662. Certno = psn_info.Certno
  24663. PsnName = psn_info.PsnName
  24664. Gend = psn_info.Gend
  24665. Naty = psn_info.Naty
  24666. Brdy = psn_info.Brdy
  24667. Age = psn_info.Age
  24668. infoStr = psn_info.Insuinfo
  24669. idetinfoStr = psn_info.Idetinfo
  24670. infocode = 0
  24671. verify_number = psn_info.VerifyNumber
  24672. } else if id_card_type == 2 {
  24673. 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, "")
  24674. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24675. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24676. utils.ErrorLog("解析失败:%v", err)
  24677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24678. return
  24679. }
  24680. PsnNo = res.Output.Baseinfo.PsnNo
  24681. PsnCertType = res.Output.Baseinfo.PsnCertType
  24682. Certno = res.Output.Baseinfo.Certno
  24683. PsnName = res.Output.Baseinfo.PsnName
  24684. Gend = res.Output.Baseinfo.Gend
  24685. Naty = res.Output.Baseinfo.Naty
  24686. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24687. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24688. infoStr = string(Iinfos)
  24689. idetinfoStr = string(Idetinfos)
  24690. infocode = res.Infcode
  24691. } else {
  24692. psn_info, _ := service.GetPsnByPatientId(id)
  24693. PsnNo = psn_info.PsnNo
  24694. PsnCertType = psn_info.PsnCertType
  24695. Certno = psn_info.Certno
  24696. PsnName = psn_info.PsnName
  24697. Gend = psn_info.Gend
  24698. Naty = psn_info.Naty
  24699. Brdy = psn_info.Brdy
  24700. Age = psn_info.Age
  24701. infoStr = psn_info.Insuinfo
  24702. idetinfoStr = psn_info.Idetinfo
  24703. infocode = 0
  24704. verify_number = psn_info.VerifyNumber
  24705. }
  24706. } else if miConfig.MdtrtareaAdmvs == "361025" {
  24707. if id_card_type == 1 {
  24708. psn_info, _ := service.GetPsnByPatientId(id)
  24709. PsnNo = psn_info.PsnNo
  24710. PsnCertType = psn_info.PsnCertType
  24711. Certno = psn_info.Certno
  24712. PsnName = psn_info.PsnName
  24713. Gend = psn_info.Gend
  24714. Naty = psn_info.Naty
  24715. Brdy = psn_info.Brdy
  24716. Age = psn_info.Age
  24717. infoStr = psn_info.Insuinfo
  24718. idetinfoStr = psn_info.Idetinfo
  24719. infocode = 0
  24720. verify_number = psn_info.VerifyNumber
  24721. } else if id_card_type == 2 {
  24722. psn_info, _ := service.GetPsnByPatientId(id)
  24723. PsnNo = psn_info.PsnNo
  24724. PsnCertType = psn_info.PsnCertType
  24725. Certno = psn_info.Certno
  24726. PsnName = psn_info.PsnName
  24727. Gend = psn_info.Gend
  24728. Naty = psn_info.Naty
  24729. Brdy = psn_info.Brdy
  24730. Age = psn_info.Age
  24731. infoStr = psn_info.Insuinfo
  24732. idetinfoStr = psn_info.Idetinfo
  24733. infocode = 0
  24734. verify_number = psn_info.VerifyNumber
  24735. } else {
  24736. psn_info, _ := service.GetPsnByPatientId(id)
  24737. PsnNo = psn_info.PsnNo
  24738. PsnCertType = psn_info.PsnCertType
  24739. Certno = psn_info.Certno
  24740. PsnName = psn_info.PsnName
  24741. Gend = psn_info.Gend
  24742. Naty = psn_info.Naty
  24743. Brdy = psn_info.Brdy
  24744. Age = psn_info.Age
  24745. infoStr = psn_info.Insuinfo
  24746. idetinfoStr = psn_info.Idetinfo
  24747. infocode = 0
  24748. verify_number = psn_info.VerifyNumber
  24749. }
  24750. } else if miConfig.MdtrtareaAdmvs == "360100" {
  24751. if id_card_type == 1 {
  24752. psn_info, _ := service.GetPsnByPatientId(id)
  24753. PsnNo = psn_info.PsnNo
  24754. PsnCertType = psn_info.PsnCertType
  24755. Certno = psn_info.Certno
  24756. PsnName = psn_info.PsnName
  24757. Gend = psn_info.Gend
  24758. Naty = psn_info.Naty
  24759. Brdy = psn_info.Brdy
  24760. Age = psn_info.Age
  24761. infoStr = psn_info.Insuinfo
  24762. idetinfoStr = psn_info.Idetinfo
  24763. infocode = 0
  24764. verify_number = psn_info.VerifyNumber
  24765. } else if id_card_type == 2 {
  24766. psn_info, _ := service.GetPsnByPatientId(id)
  24767. PsnNo = psn_info.PsnNo
  24768. PsnCertType = psn_info.PsnCertType
  24769. Certno = psn_info.Certno
  24770. PsnName = psn_info.PsnName
  24771. Gend = psn_info.Gend
  24772. Naty = psn_info.Naty
  24773. Brdy = psn_info.Brdy
  24774. Age = psn_info.Age
  24775. infoStr = psn_info.Insuinfo
  24776. idetinfoStr = psn_info.Idetinfo
  24777. infocode = 0
  24778. verify_number = psn_info.VerifyNumber
  24779. } else {
  24780. psn_info, _ := service.GetPsnByPatientId(id)
  24781. PsnNo = psn_info.PsnNo
  24782. PsnCertType = psn_info.PsnCertType
  24783. Certno = psn_info.Certno
  24784. PsnName = psn_info.PsnName
  24785. Gend = psn_info.Gend
  24786. Naty = psn_info.Naty
  24787. Brdy = psn_info.Brdy
  24788. Age = psn_info.Age
  24789. infoStr = psn_info.Insuinfo
  24790. idetinfoStr = psn_info.Idetinfo
  24791. infocode = 0
  24792. verify_number = psn_info.VerifyNumber
  24793. }
  24794. } else if miConfig.MdtrtareaAdmvs == "341203" || miConfig.MdtrtareaAdmvs == "340699" {
  24795. psn_info, _ := service.GetPsnByPatientId(id)
  24796. PsnNo = psn_info.PsnNo
  24797. PsnCertType = psn_info.PsnCertType
  24798. Certno = psn_info.Certno
  24799. PsnName = psn_info.PsnName
  24800. Gend = psn_info.Gend
  24801. Naty = psn_info.Naty
  24802. Brdy = psn_info.Brdy
  24803. Age = psn_info.Age
  24804. infoStr = psn_info.Insuinfo
  24805. idetinfoStr = psn_info.Idetinfo
  24806. infocode = 0
  24807. verify_number = psn_info.VerifyNumber
  24808. idetinfoStr = psn_info.Idetinfo
  24809. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24810. if id_card_type == 1 {
  24811. psn_info, _ := service.GetPsnByPatientId(id)
  24812. PsnNo = psn_info.PsnNo
  24813. PsnCertType = psn_info.PsnCertType
  24814. Certno = psn_info.Certno
  24815. PsnName = psn_info.PsnName
  24816. Gend = psn_info.Gend
  24817. Naty = psn_info.Naty
  24818. Brdy = psn_info.Brdy
  24819. Age = psn_info.Age
  24820. infoStr = psn_info.Insuinfo
  24821. idetinfoStr = psn_info.Idetinfo
  24822. infocode = 0
  24823. verify_number = psn_info.VerifyNumber
  24824. } else if id_card_type == 2 {
  24825. 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)
  24826. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24827. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24828. utils.ErrorLog("解析失败:%v", err)
  24829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24830. return
  24831. }
  24832. PsnNo = res.Output.Baseinfo.PsnNo
  24833. PsnCertType = res.Output.Baseinfo.PsnCertType
  24834. Certno = res.Output.Baseinfo.Certno
  24835. PsnName = res.Output.Baseinfo.PsnName
  24836. Gend = res.Output.Baseinfo.Gend
  24837. Naty = res.Output.Baseinfo.Naty
  24838. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24839. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24840. infoStr = string(Iinfos)
  24841. idetinfoStr = string(Idetinfos)
  24842. infocode = res.Infcode
  24843. } else if id_card_type == 4 {
  24844. psn_info, _ := service.GetPsnByPatientId(id)
  24845. PsnNo = psn_info.PsnNo
  24846. PsnCertType = psn_info.PsnCertType
  24847. Certno = psn_info.Certno
  24848. PsnName = psn_info.PsnName
  24849. Gend = psn_info.Gend
  24850. Naty = psn_info.Naty
  24851. Brdy = psn_info.Brdy
  24852. Age = psn_info.Age
  24853. infoStr = psn_info.Insuinfo
  24854. idetinfoStr = psn_info.Idetinfo
  24855. infocode = 0
  24856. verify_number = psn_info.VerifyNumber
  24857. }
  24858. } else if miConfig.MdtrtareaAdmvs == "131023" {
  24859. var result string
  24860. var requestLog string
  24861. 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), "")
  24862. if id_card_type == 4 {
  24863. psn_info, _ := service.GetPsnByPatientId(id)
  24864. PsnNo = psn_info.PsnNo
  24865. PsnCertType = psn_info.PsnCertType
  24866. Certno = psn_info.Certno
  24867. PsnName = psn_info.PsnName
  24868. Gend = psn_info.Gend
  24869. Naty = psn_info.Naty
  24870. Brdy = psn_info.Brdy
  24871. Age = psn_info.Age
  24872. infoStr = psn_info.Insuinfo
  24873. idetinfoStr = psn_info.Idetinfo
  24874. infocode = 0
  24875. verify_number = psn_info.VerifyNumber
  24876. } else {
  24877. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24878. if miConfig.Code == "H15049901371" {
  24879. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  24880. utils.ErrorLog("解析失败:%v", err)
  24881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24882. return
  24883. }
  24884. res.ErrMsg = res10265.ErrMsg
  24885. res.Output = res10265.Output
  24886. res.InfRefmsgid = res10265.InfRefmsgid
  24887. } else {
  24888. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24889. utils.ErrorLog("解析失败:%v", err)
  24890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24891. return
  24892. }
  24893. }
  24894. PsnNo = res.Output.Baseinfo.PsnNo
  24895. PsnCertType = res.Output.Baseinfo.PsnCertType
  24896. Certno = res.Output.Baseinfo.Certno
  24897. PsnName = res.Output.Baseinfo.PsnName
  24898. Gend = res.Output.Baseinfo.Gend
  24899. Naty = res.Output.Baseinfo.Naty
  24900. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24901. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24902. infoStr = string(Iinfos)
  24903. idetinfoStr = string(Idetinfos)
  24904. if miConfig.Code == "H15049901371" {
  24905. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  24906. } else {
  24907. infocode = res.Infcode
  24908. }
  24909. }
  24910. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24911. psn_info, _ := service.GetPsnByPatientId(id)
  24912. PsnNo = psn_info.PsnNo
  24913. PsnCertType = psn_info.PsnCertType
  24914. Certno = psn_info.Certno
  24915. PsnName = psn_info.PsnName
  24916. Gend = psn_info.Gend
  24917. Naty = psn_info.Naty
  24918. Brdy = psn_info.Brdy
  24919. Age = psn_info.Age
  24920. infoStr = psn_info.Insuinfo
  24921. idetinfoStr = psn_info.Idetinfo
  24922. infocode = 0
  24923. verify_number = psn_info.VerifyNumber
  24924. } else if miConfig.MdtrtareaAdmvs == "450721" {
  24925. psn_info, _ := service.GetPsnByPatientId(id)
  24926. PsnNo = psn_info.PsnNo
  24927. PsnCertType = psn_info.PsnCertType
  24928. Certno = psn_info.Certno
  24929. PsnName = psn_info.PsnName
  24930. Gend = psn_info.Gend
  24931. Naty = psn_info.Naty
  24932. Brdy = psn_info.Brdy
  24933. Age = psn_info.Age
  24934. infoStr = psn_info.Insuinfo
  24935. idetinfoStr = psn_info.Idetinfo
  24936. infocode = 0
  24937. verify_number = psn_info.VerifyNumber
  24938. } else {
  24939. var result string
  24940. var requestLog string
  24941. //if miConfig.UserOrgId == 10138 {
  24942. if id_card_type != 4 || id_card_type != 1 {
  24943. var insa string
  24944. if len(patient.InsuplcAdmdvs) > 0 {
  24945. insa = patient.InsuplcAdmdvs
  24946. } else {
  24947. insa = miConfig.InsuplcAdmdvs
  24948. }
  24949. //psn_info, _ := service.GetPsnByPatientId(id)
  24950. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  24951. 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)
  24952. }
  24953. //}
  24954. //else {
  24955. // var insa string
  24956. // if len(patient.InsuplcAdmdvs) > 0 {
  24957. // insa = patient.InsuplcAdmdvs
  24958. // } else {
  24959. // insa = miConfig.InsuplcAdmdvs
  24960. // }
  24961. // 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)
  24962. //}
  24963. if id_card_type == 4 || id_card_type == 1 {
  24964. psn_info, _ := service.GetPsnByPatientId(id)
  24965. PsnNo = psn_info.PsnNo
  24966. PsnCertType = psn_info.PsnCertType
  24967. Certno = psn_info.Certno
  24968. PsnName = psn_info.PsnName
  24969. Gend = psn_info.Gend
  24970. Naty = psn_info.Naty
  24971. Brdy = psn_info.Brdy
  24972. Age = psn_info.Age
  24973. infoStr = psn_info.Insuinfo
  24974. idetinfoStr = psn_info.Idetinfo
  24975. infocode = 0
  24976. verify_number = psn_info.VerifyNumber
  24977. } else {
  24978. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24979. if miConfig.Code == "H15049901371" {
  24980. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  24981. utils.ErrorLog("解析失败:%v", err)
  24982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24983. return
  24984. }
  24985. res.ErrMsg = res10265.ErrMsg
  24986. res.Output = res10265.Output
  24987. res.InfRefmsgid = res10265.InfRefmsgid
  24988. } else {
  24989. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24990. utils.ErrorLog("解析失败:%v", err)
  24991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24992. return
  24993. }
  24994. }
  24995. PsnNo = res.Output.Baseinfo.PsnNo
  24996. PsnCertType = res.Output.Baseinfo.PsnCertType
  24997. Certno = res.Output.Baseinfo.Certno
  24998. PsnName = res.Output.Baseinfo.PsnName
  24999. Gend = res.Output.Baseinfo.Gend
  25000. Naty = res.Output.Baseinfo.Naty
  25001. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  25002. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  25003. infoStr = string(Iinfos)
  25004. idetinfoStr = string(Idetinfos)
  25005. if miConfig.Code == "H15049901371" {
  25006. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  25007. } else {
  25008. infocode = res.Infcode
  25009. }
  25010. }
  25011. }
  25012. if infocode == 0 {
  25013. his := models.VMHisPatient{
  25014. Name: name,
  25015. Gender: gender,
  25016. Birthday: birthUnix,
  25017. MedicalTreatmentType: medical_care,
  25018. IdType: certificates,
  25019. IdCardNo: id_card,
  25020. BalanceAccountsType: settlementValue,
  25021. SocialType: social_type,
  25022. MedicalInsuranceNumber: medical_insurance_card,
  25023. RegisterType: register_type,
  25024. RegisterCost: registration_fee,
  25025. TreatmentCost: medical_expenses,
  25026. Status: 1,
  25027. Ctime: time.Now().Unix(),
  25028. Mtime: time.Now().Unix(),
  25029. PsnNo: PsnNo,
  25030. PsnCertType: PsnCertType,
  25031. Certno: Certno,
  25032. PsnName: PsnName,
  25033. Gend: Gend,
  25034. Naty: Naty,
  25035. Brdy: Brdy,
  25036. Age: Age,
  25037. Iinfo: infoStr,
  25038. Idetinfo: idetinfoStr,
  25039. PatientId: patient.ID,
  25040. RecordDate: theTime.Unix(),
  25041. UserOrgId: adminInfo.CurrentOrgId,
  25042. AdminUserId: admin_user_id,
  25043. IsReturn: 1,
  25044. IdCardType: id_card_type,
  25045. Doctor: doctor,
  25046. Departments: department,
  25047. MdtrtGrpType: mdtrt_type,
  25048. }
  25049. timestamp := time.Now().Unix()
  25050. tempTime := time.Unix(timestamp, 0)
  25051. timeFormat := tempTime.Format("20060102150405")
  25052. chrgBchno := rand.Intn(100000) + 10000
  25053. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  25054. his.Number = ipt_otp_no
  25055. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  25056. department, _ := service.GetDepartMentDetail(department)
  25057. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  25058. IdCardNo := ""
  25059. if id_card_type == 1 {
  25060. // IdCardNo = medical_insurance_card
  25061. IdCardNo = patient.IdCardNo
  25062. } else {
  25063. IdCardNo = patient.IdCardNo
  25064. }
  25065. var rf []*ResultFive
  25066. json.Unmarshal([]byte(his.Iinfo), &rf)
  25067. var insutypes []*ResultFive
  25068. var insutype string
  25069. var insuplc_admdvs_temp string
  25070. var is390 int = 0
  25071. var is310 int = 0
  25072. for _, item := range rf {
  25073. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25074. insutypes = append(insutypes, item)
  25075. }
  25076. }
  25077. if len(insutypes) == 1 {
  25078. insutype = insutypes[0].Insutype
  25079. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  25080. if insutype == "390" {
  25081. is390 = 1
  25082. }
  25083. if insutype == "310" {
  25084. is310 = 1
  25085. }
  25086. } else {
  25087. for _, i := range insutypes {
  25088. if i.Insutype == "390" {
  25089. is390 = 1
  25090. }
  25091. if i.Insutype == "310" {
  25092. is310 = 1
  25093. }
  25094. }
  25095. }
  25096. if is390 == 1 {
  25097. insutype = "390"
  25098. }
  25099. if is310 == 1 {
  25100. insutype = "310"
  25101. }
  25102. fmt.Println(social_type)
  25103. if social_type > 0 {
  25104. insutype = strconv.FormatInt(social_type, 10)
  25105. }
  25106. var infocode int64
  25107. var resThree ResultThree
  25108. var resThree10265 ResultThree10265
  25109. if len(insuplc_admdvs) == 0 {
  25110. psn_info, _ := service.GetPsnByPatientId(id)
  25111. //if len(psn_info.InsuplcAdmdvs) > 0 {
  25112. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25113. //}
  25114. } else {
  25115. insuplc_admdvs_temp = insuplc_admdvs
  25116. }
  25117. if miConfig.MdtrtareaAdmvs == "421300" {
  25118. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25119. psn_info, _ := service.GetPsnByPatientId(id)
  25120. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25121. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25122. "&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
  25123. resp, requestErr := http.Get(api)
  25124. if requestErr != nil {
  25125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25126. return
  25127. }
  25128. body, ioErr := ioutil.ReadAll(resp.Body)
  25129. if ioErr != nil {
  25130. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25132. return
  25133. }
  25134. var respJSON map[string]interface{}
  25135. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25136. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25138. return
  25139. }
  25140. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25141. result, _ := json.Marshal(respJSON)
  25142. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25143. utils.ErrorLog("解析失败:%v", err)
  25144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25145. return
  25146. }
  25147. infocode = resThree.Infcode
  25148. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25149. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25150. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  25151. // insuplc_admdvs_temp =
  25152. //}
  25153. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  25154. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25155. //}
  25156. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25157. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25158. "&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
  25159. resp, requestErr := http.Get(api)
  25160. if requestErr != nil {
  25161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25162. return
  25163. }
  25164. body, ioErr := ioutil.ReadAll(resp.Body)
  25165. if ioErr != nil {
  25166. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25168. return
  25169. }
  25170. var respJSON map[string]interface{}
  25171. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25172. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25174. return
  25175. }
  25176. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25177. result, _ := json.Marshal(respJSON)
  25178. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25179. utils.ErrorLog("解析失败:%v", err)
  25180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25181. return
  25182. }
  25183. infocode = resThree.Infcode
  25184. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25185. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25186. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  25187. // insuplc_admdvs_temp =
  25188. //}
  25189. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  25190. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25191. //}
  25192. utils.ErrorLog("解析失败:%v", insutype)
  25193. utils.ErrorLog("解析失败:%v", PsnNo)
  25194. utils.ErrorLog("解析失败:%v", Certno)
  25195. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  25196. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  25197. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  25198. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  25199. utils.ErrorLog("解析失败:%v", PsnNo)
  25200. utils.ErrorLog("解析失败:%v", department.Number)
  25201. utils.ErrorLog("解析失败:%v", department.Name)
  25202. utils.ErrorLog("解析失败:%v", roles.UserName)
  25203. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25204. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25205. "&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
  25206. resp, requestErr := http.Get(api)
  25207. if requestErr != nil {
  25208. utils.ErrorLog("解析失败:%v", requestErr)
  25209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25210. return
  25211. }
  25212. body, ioErr := ioutil.ReadAll(resp.Body)
  25213. if ioErr != nil {
  25214. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25216. return
  25217. }
  25218. var respJSON map[string]interface{}
  25219. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25220. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25222. return
  25223. }
  25224. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25225. result, _ := json.Marshal(respJSON)
  25226. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25227. utils.ErrorLog("解析失败:%v", err)
  25228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25229. return
  25230. }
  25231. infocode = resThree.Infcode
  25232. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25233. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25234. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  25235. // insuplc_admdvs_temp =
  25236. //}
  25237. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  25238. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25239. //}
  25240. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25241. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25242. "&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
  25243. resp, requestErr := http.Get(api)
  25244. if requestErr != nil {
  25245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25246. return
  25247. }
  25248. body, ioErr := ioutil.ReadAll(resp.Body)
  25249. if ioErr != nil {
  25250. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25252. return
  25253. }
  25254. var respJSON map[string]interface{}
  25255. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25256. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25258. return
  25259. }
  25260. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25261. result, _ := json.Marshal(respJSON)
  25262. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25263. utils.ErrorLog("解析失败:%v", err)
  25264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25265. return
  25266. }
  25267. infocode = resThree.Infcode
  25268. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25269. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25270. psn_info, _ := service.GetPsnByPatientId(id)
  25271. var verify_number string
  25272. if id_card_type == 4 {
  25273. verify_number = psn_info.VerifyNumber
  25274. } else if id_card_type == 1 {
  25275. bas := strings.Split(psn_info.CardInfo, "|")
  25276. cardNumber := bas[2]
  25277. verify_number = cardNumber
  25278. }
  25279. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25280. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25281. "&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
  25282. resp, requestErr := http.Get(api)
  25283. if requestErr != nil {
  25284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25285. return
  25286. }
  25287. body, ioErr := ioutil.ReadAll(resp.Body)
  25288. if ioErr != nil {
  25289. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25291. return
  25292. }
  25293. var respJSON map[string]interface{}
  25294. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25295. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25297. return
  25298. }
  25299. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25300. result, _ := json.Marshal(respJSON)
  25301. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25302. // utils.ErrorLog("解析失败:%v", err)
  25303. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25304. // return
  25305. //}
  25306. //infocode = resThree.Infcode
  25307. //result, _ := json.Marshal(respJSON)
  25308. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25309. utils.ErrorLog("解析失败:%v", err)
  25310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25311. return
  25312. }
  25313. resThree.ErrMsg = resThree10265.ErrMsg
  25314. resThree.Output = resThree10265.Output
  25315. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25316. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25317. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  25318. psn_info, _ := service.GetPsnByPatientId(id)
  25319. his.PsnNo = psn_info.PsnNo
  25320. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25321. var cert_no string
  25322. if id_card_type == 3 {
  25323. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  25324. cert_no = IdCardNo
  25325. } else if id_card_type == 4 {
  25326. cert_no = IdCardNo
  25327. psn_info.VerifyNumber = psn_info.VerifyNumber
  25328. } else {
  25329. bas := strings.Split(psn_info.CardInfo, "|")
  25330. cert_no = bas[2]
  25331. }
  25332. var hisPrescription []*models.HisPrescription
  25333. fmt.Println(hisPrescription)
  25334. for _, item := range rf {
  25335. if item.Insutype == insutype {
  25336. //insuplc_admdvs = item.InsuplcAdmdvs
  25337. his.InsuplcAdmdvs = insuplc_admdvs
  25338. }
  25339. }
  25340. his.Insutype = insutype
  25341. var res3101 Result3101
  25342. res3101.Infcode = "0"
  25343. //res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25344. if res3101.Infcode == "0" {
  25345. fmt.Println("33333333")
  25346. if len(res3101.Output.Result) > 0 {
  25347. fmt.Println("222222")
  25348. for _, item := range res3101.Output.Result {
  25349. if len(res3101.ErrMsg) == 0 {
  25350. res3101.ErrMsg = item.VolaCont
  25351. } else {
  25352. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  25353. }
  25354. }
  25355. c.ServeSuccessJSON(map[string]interface{}{
  25356. "failed_code": -10,
  25357. "msg": res3101.ErrMsg,
  25358. })
  25359. return
  25360. } else {
  25361. fmt.Println("11111")
  25362. var api string
  25363. if miConfig.MdtrtareaAdmvs == "320830" {
  25364. ipt_otp_no = timeFormat
  25365. api = miConfig.AppSecret + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25366. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25367. "&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
  25368. } else if miConfig.MdtrtareaAdmvs == "320921" {
  25369. ipt_otp_no = timeFormat
  25370. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25371. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25372. "&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
  25373. } else {
  25374. ipt_otp_no = timeFormat
  25375. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25376. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + 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=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  25378. }
  25379. resp, requestErr := http.Get(api)
  25380. if requestErr != nil {
  25381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25382. return
  25383. }
  25384. body, ioErr := ioutil.ReadAll(resp.Body)
  25385. if ioErr != nil {
  25386. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25388. return
  25389. }
  25390. var respJSON map[string]interface{}
  25391. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25392. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25394. return
  25395. }
  25396. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25397. result, _ := json.Marshal(respJSON)
  25398. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25399. utils.ErrorLog("解析失败:%v", err)
  25400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25401. return
  25402. }
  25403. resThree.ErrMsg = resThree10265.ErrMsg
  25404. resThree.Output = resThree10265.Output
  25405. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25406. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25407. }
  25408. } else if res3101.Infcode != "0" {
  25409. c.ServeSuccessJSON(map[string]interface{}{
  25410. "failed_code": -10,
  25411. "msg": res3101.ErrMsg,
  25412. })
  25413. return
  25414. }
  25415. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25416. psn_info, _ := service.GetPsnByPatientId(id)
  25417. var cert_no string
  25418. if id_card_type == 1 {
  25419. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  25420. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25421. } else if id_card_type == 4 {
  25422. cert_no = psn_info.VerifyNumber
  25423. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25424. } else {
  25425. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25426. cert_no = psn_info.VerifyNumber
  25427. }
  25428. 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)
  25429. saveLog(result, requestLog, "2201", "挂号")
  25430. if miConfig.Code == "H15049901371" {
  25431. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25432. utils.ErrorLog("解析失败:%v", err)
  25433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25434. return
  25435. }
  25436. resThree.ErrMsg = resThree10265.ErrMsg
  25437. resThree.Output = resThree10265.Output
  25438. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25439. } else {
  25440. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25441. utils.ErrorLog("解析失败:%v", err)
  25442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25443. return
  25444. }
  25445. }
  25446. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25447. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  25448. psn_info, _ := service.GetPsnByPatientId(id)
  25449. var result string
  25450. var requestLog string
  25451. if id_card_type == 1 {
  25452. bas := strings.Split(psn_info.CardInfo, "|")
  25453. basNumber := bas[2]
  25454. card_sn := bas[3]
  25455. 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)
  25456. saveLog(result, requestLog, "2201A", "挂号")
  25457. } else if id_card_type == 2 {
  25458. 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, "", "", "", "", "", "")
  25459. saveLog(result, requestLog, "2201A", "挂号")
  25460. } else {
  25461. 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)
  25462. saveLog(result, requestLog, "2201A", "挂号")
  25463. }
  25464. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25465. utils.ErrorLog("解析失败:%v", err)
  25466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25467. return
  25468. }
  25469. infocode = resThree.Infcode
  25470. } else if miConfig.MdtrtareaAdmvs == "361025" { //江西萍乡
  25471. psn_info, _ := service.GetPsnByPatientId(id)
  25472. var result string
  25473. var requestLog string
  25474. if id_card_type == 1 {
  25475. bas := strings.Split(psn_info.CardInfo, "|")
  25476. basNumber := bas[2]
  25477. card_sn := ""
  25478. 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)
  25479. saveLog(result, requestLog, "2201A", "挂号")
  25480. } else if id_card_type == 2 {
  25481. 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, "", "", "", "", "", "")
  25482. saveLog(result, requestLog, "2201A", "挂号")
  25483. } else {
  25484. 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)
  25485. saveLog(result, requestLog, "2201A", "挂号")
  25486. }
  25487. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25488. utils.ErrorLog("解析失败:%v", err)
  25489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25490. return
  25491. }
  25492. infocode = resThree.Infcode
  25493. } else if miConfig.MdtrtareaAdmvs == "360100" { //江西萍乡
  25494. psn_info, _ := service.GetPsnByPatientId(id)
  25495. var result string
  25496. var requestLog string
  25497. if id_card_type == 1 {
  25498. bas := strings.Split(psn_info.CardInfo, "|")
  25499. basNumber := bas[2]
  25500. card_sn := ""
  25501. 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)
  25502. saveLog(result, requestLog, "2201A", "挂号")
  25503. } else if id_card_type == 2 {
  25504. 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, "", "", "", "", "", "")
  25505. saveLog(result, requestLog, "2201A", "挂号")
  25506. } else {
  25507. 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)
  25508. saveLog(result, requestLog, "2201A", "挂号")
  25509. }
  25510. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25511. utils.ErrorLog("解析失败:%v", err)
  25512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25513. return
  25514. }
  25515. infocode = resThree.Infcode
  25516. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25517. psn_info, _ := service.GetPsnByPatientId(id)
  25518. his.PsnNo = psn_info.PsnNo
  25519. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25520. var cert_no string
  25521. if id_card_type == 1 {
  25522. bas := strings.Split(psn_info.CardInfo, "|")
  25523. cert_no = bas[2]
  25524. } else if id_card_type == 4 {
  25525. cert_no = psn_info.VerifyNumber
  25526. psn_info.VerifyNumber = psn_info.VerifyNumber
  25527. IdCardNo = psn_info.VerifyNumber
  25528. } else {
  25529. cert_no = IdCardNo
  25530. psn_info.VerifyNumber = cert_no
  25531. }
  25532. for _, item := range rf {
  25533. if item.Insutype == insutype {
  25534. his.InsuplcAdmdvs = insuplc_admdvs
  25535. }
  25536. }
  25537. his.Insutype = insutype
  25538. var api string
  25539. ipt_otp_no = timeFormat
  25540. 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 +
  25541. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25542. "&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
  25543. resp, requestErr := http.Get(api)
  25544. if requestErr != nil {
  25545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25546. return
  25547. }
  25548. body, ioErr := ioutil.ReadAll(resp.Body)
  25549. if ioErr != nil {
  25550. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25552. return
  25553. }
  25554. var respJSON map[string]interface{}
  25555. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25556. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25558. return
  25559. }
  25560. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25561. if status == "0" {
  25562. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25563. c.ServeSuccessJSON(map[string]interface{}{
  25564. "failed_code": -10,
  25565. "msg": err_msg,
  25566. })
  25567. return
  25568. }
  25569. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25570. result, _ := json.Marshal(respJSON)
  25571. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25572. utils.ErrorLog("解析失败:%v", err)
  25573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25574. return
  25575. }
  25576. infocode = resThree.Infcode
  25577. } else if miConfig.MdtrtareaAdmvs == "340699" {
  25578. psn_info, _ := service.GetPsnByPatientId(id)
  25579. his.PsnNo = psn_info.PsnNo
  25580. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25581. var cert_no string
  25582. if id_card_type == 1 {
  25583. bas := strings.Split(psn_info.CardInfo, "|")
  25584. cert_no = bas[2]
  25585. } else if id_card_type == 4 {
  25586. cert_no = psn_info.VerifyNumber
  25587. psn_info.VerifyNumber = psn_info.VerifyNumber
  25588. IdCardNo = psn_info.VerifyNumber
  25589. } else {
  25590. cert_no = IdCardNo
  25591. psn_info.VerifyNumber = cert_no
  25592. }
  25593. for _, item := range rf {
  25594. if item.Insutype == insutype {
  25595. his.InsuplcAdmdvs = insuplc_admdvs
  25596. patient.InsuplcAdmdvs = insuplc_admdvs
  25597. }
  25598. }
  25599. his.Insutype = insutype
  25600. var api string
  25601. ipt_otp_no = timeFormat
  25602. 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 +
  25603. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25604. "&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
  25605. resp, requestErr := http.Get(api)
  25606. if requestErr != nil {
  25607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25608. return
  25609. }
  25610. body, ioErr := ioutil.ReadAll(resp.Body)
  25611. if ioErr != nil {
  25612. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25614. return
  25615. }
  25616. var respJSON map[string]interface{}
  25617. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25618. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25620. return
  25621. }
  25622. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25623. if status == "0" {
  25624. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25625. c.ServeSuccessJSON(map[string]interface{}{
  25626. "failed_code": -10,
  25627. "msg": err_msg,
  25628. })
  25629. return
  25630. }
  25631. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25632. result, _ := json.Marshal(respJSON)
  25633. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25634. utils.ErrorLog("解析失败:%v", err)
  25635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25636. return
  25637. }
  25638. infocode = resThree.Infcode
  25639. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25640. hour := time.Now().Format("15")
  25641. min := time.Now().Format("04")
  25642. sec := time.Now().Format("05")
  25643. begin := record_time + " " + hour + ":" + min + ":" + sec
  25644. psn_info, _ := service.GetPsnByPatientId(id)
  25645. var result string
  25646. var requestLog string
  25647. if id_card_type == 1 {
  25648. bas := strings.Split(psn_info.CardInfo, "|")
  25649. basNumber := bas[2]
  25650. card_sn := bas[3]
  25651. 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)
  25652. saveLog(result, requestLog, "2201A", "挂号")
  25653. } else if id_card_type == 2 {
  25654. 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)
  25655. saveLog(result, requestLog, "2201A", "挂号")
  25656. } else {
  25657. 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)
  25658. saveLog(result, requestLog, "2201A", "挂号")
  25659. }
  25660. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25661. utils.ErrorLog("解析失败:%v", err)
  25662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25663. return
  25664. }
  25665. infocode = resThree.Infcode
  25666. } else if miConfig.MdtrtareaAdmvs == "131023" {
  25667. psn_info, _ := service.GetPsnByPatientId(id)
  25668. 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)
  25669. saveLog(result, requestLog, "2201A", "挂号")
  25670. if miConfig.Code == "H15049901371" {
  25671. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25672. utils.ErrorLog("解析失败:%v", err)
  25673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25674. return
  25675. }
  25676. resThree.ErrMsg = resThree10265.ErrMsg
  25677. resThree.Output = resThree10265.Output
  25678. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25679. } else {
  25680. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25681. utils.ErrorLog("解析失败:%v", err)
  25682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25683. return
  25684. }
  25685. }
  25686. if miConfig.Code == "H15049901371" {
  25687. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25688. } else {
  25689. infocode = resThree.Infcode
  25690. }
  25691. } else {
  25692. psn_info, _ := service.GetPsnByPatientId(id)
  25693. if id_card_type == 4 || id_card_type == 1 {
  25694. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25695. }
  25696. var rf []*ResultFive
  25697. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  25698. var insutypes []*ResultFive
  25699. var insutype string
  25700. var is390 int = 0
  25701. var is310 int = 0
  25702. for _, item := range rf {
  25703. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25704. insutypes = append(insutypes, item)
  25705. }
  25706. }
  25707. if len(insutypes) == 1 {
  25708. insutype = insutypes[0].Insutype
  25709. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  25710. } else {
  25711. for _, i := range insutypes {
  25712. if i.Insutype == "390" {
  25713. is390 = 1
  25714. }
  25715. if i.Insutype == "310" {
  25716. is310 = 1
  25717. }
  25718. }
  25719. }
  25720. if is390 == 1 {
  25721. insutype = "390"
  25722. }
  25723. if is310 == 1 {
  25724. insutype = "310"
  25725. }
  25726. fmt.Println(len(insutypes))
  25727. if len(insutypes) == 0 {
  25728. for index, item := range rf {
  25729. if index == 0 {
  25730. insutype = item.Insutype
  25731. insuplc_admdvs = item.InsuplcAdmdvs
  25732. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25733. }
  25734. }
  25735. fmt.Println(insutype)
  25736. fmt.Println(insuplc_admdvs)
  25737. }
  25738. if social_type > 0 {
  25739. insutype = strconv.FormatInt(social_type, 10)
  25740. }
  25741. fmt.Println("--------")
  25742. fmt.Println(psn_info)
  25743. fmt.Println(psn_info.PsnNo)
  25744. for _, item := range rf {
  25745. if item.Insutype == insutype {
  25746. insutype = item.Insutype
  25747. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25748. }
  25749. }
  25750. if miConfig.MdtrtareaAdmvs == "441202" {
  25751. var hisPrescription []*models.HisPrescription
  25752. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25753. if res3101.Infcode == 0 {
  25754. fmt.Println("33333333")
  25755. if len(res3101.Output.Result) > 0 {
  25756. fmt.Println("222222")
  25757. for _, item := range res3101.Output.Result {
  25758. if len(res3101.ErrMsg) == 0 {
  25759. res3101.ErrMsg = item.VolaCont
  25760. } else {
  25761. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  25762. }
  25763. }
  25764. c.ServeSuccessJSON(map[string]interface{}{
  25765. "failed_code": -10,
  25766. "msg": res3101.ErrMsg,
  25767. })
  25768. return
  25769. } else {
  25770. hour := time.Now().Format("15")
  25771. min := time.Now().Format("04")
  25772. sec := time.Now().Format("05")
  25773. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25774. fmt.Println(record_time_two)
  25775. result, requestLog := service.Gdyb2201A(psn_info.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time_two, psn_info.VerifyNumber, admin_user_id)
  25776. saveLog(result, requestLog, "2201A", "挂号")
  25777. if miConfig.Code == "H15049901371" {
  25778. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25779. utils.ErrorLog("解析失败:%v", err)
  25780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25781. return
  25782. }
  25783. resThree.ErrMsg = resThree10265.ErrMsg
  25784. resThree.Output = resThree10265.Output
  25785. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25786. } else {
  25787. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25788. utils.ErrorLog("解析失败:%v", err)
  25789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25790. return
  25791. }
  25792. }
  25793. if miConfig.Code == "H15049901371" {
  25794. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25795. } else {
  25796. infocode = resThree.Infcode
  25797. }
  25798. }
  25799. } else if res3101.Infcode != 0 {
  25800. c.ServeSuccessJSON(map[string]interface{}{
  25801. "failed_code": -10,
  25802. "msg": res3101.ErrMsg,
  25803. })
  25804. return
  25805. }
  25806. } else if miConfig.MdtrtareaAdmvs == "440205" {
  25807. var hisPrescription []*models.HisPrescription
  25808. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25809. if res3101.Infcode == 0 {
  25810. fmt.Println("33333333")
  25811. if len(res3101.Output.Result) > 0 {
  25812. fmt.Println("222222")
  25813. for _, item := range res3101.Output.Result {
  25814. if len(res3101.ErrMsg) == 0 {
  25815. res3101.ErrMsg = item.VolaCont
  25816. } else {
  25817. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  25818. }
  25819. }
  25820. c.ServeSuccessJSON(map[string]interface{}{
  25821. "failed_code": -10,
  25822. "msg": res3101.ErrMsg,
  25823. })
  25824. return
  25825. } else {
  25826. hour := time.Now().Format("15")
  25827. min := time.Now().Format("04")
  25828. sec := time.Now().Format("05")
  25829. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25830. fmt.Println(record_time_two)
  25831. 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)
  25832. saveLog(result, requestLog, "2201A", "挂号")
  25833. if miConfig.Code == "H15049901371" {
  25834. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25835. utils.ErrorLog("解析失败:%v", err)
  25836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25837. return
  25838. }
  25839. resThree.ErrMsg = resThree10265.ErrMsg
  25840. resThree.Output = resThree10265.Output
  25841. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25842. } else {
  25843. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25844. utils.ErrorLog("解析失败:%v", err)
  25845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25846. return
  25847. }
  25848. }
  25849. if miConfig.Code == "H15049901371" {
  25850. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25851. } else {
  25852. infocode = resThree.Infcode
  25853. }
  25854. }
  25855. } else if res3101.Infcode != 0 {
  25856. c.ServeSuccessJSON(map[string]interface{}{
  25857. "failed_code": -10,
  25858. "msg": res3101.ErrMsg,
  25859. })
  25860. return
  25861. }
  25862. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25863. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25864. psn_info, _ := service.GetPsnByPatientId(id)
  25865. var verify_number string
  25866. if id_card_type == 4 {
  25867. verify_number = psn_info.VerifyNumber
  25868. } else if id_card_type == 1 {
  25869. bas := strings.Split(psn_info.CardInfo, "|")
  25870. cardNumber := bas[2]
  25871. verify_number = cardNumber
  25872. } else {
  25873. verify_number = psn_info.Certno
  25874. }
  25875. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25876. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25877. "&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
  25878. resp, requestErr := http.Get(api)
  25879. if requestErr != nil {
  25880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25881. return
  25882. }
  25883. body, ioErr := ioutil.ReadAll(resp.Body)
  25884. if ioErr != nil {
  25885. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25887. return
  25888. }
  25889. var respJSON map[string]interface{}
  25890. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25891. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25893. return
  25894. }
  25895. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25896. result, _ := json.Marshal(respJSON)
  25897. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25898. utils.ErrorLog("解析失败:%v", err)
  25899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25900. return
  25901. }
  25902. infocode = resThree.Infcode
  25903. } else {
  25904. hour := time.Now().Format("15")
  25905. min := time.Now().Format("04")
  25906. sec := time.Now().Format("05")
  25907. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25908. if id_card_type == 1 {
  25909. for _, item := range rf {
  25910. if item.Insutype == strconv.FormatInt(social_type, 10) {
  25911. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  25912. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25913. } else if strconv.FormatInt(social_type, 10) == "390" {
  25914. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25915. } else {
  25916. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25917. }
  25918. }
  25919. }
  25920. }
  25921. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  25922. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25923. }
  25924. if id_card_type == 1 {
  25925. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  25926. bas := strings.Split(psn_info.CardInfo, "|")
  25927. basNumber := bas[1]
  25928. IdCardNo = basNumber
  25929. }
  25930. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  25931. IdCardNo = psn_info.VerifyNumber
  25932. }
  25933. if len(insuplc_admdvs_temp) == 0 {
  25934. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25935. }
  25936. var result string
  25937. var requestLog string
  25938. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" {
  25939. var hisPrescription []*models.HisPrescription
  25940. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25941. if res3101.Infcode == 0 {
  25942. if len(res3101.Output.Result) > 0 {
  25943. if len(res3101.Output.Result) > 0 {
  25944. c.ServeSuccessJSON(map[string]interface{}{
  25945. "failed_code": -10,
  25946. "failed_type": 100,
  25947. "warm_type": 1,
  25948. "msg": res3101,
  25949. })
  25950. return
  25951. } else {
  25952. c.ServeSuccessJSON(map[string]interface{}{
  25953. "failed_code": -10,
  25954. "msg": res3101.ErrMsg,
  25955. })
  25956. return
  25957. }
  25958. } else {
  25959. hour := time.Now().Format("15")
  25960. min := time.Now().Format("04")
  25961. sec := time.Now().Format("05")
  25962. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25963. fmt.Println(record_time_two)
  25964. if his.IdCardType == 2 {
  25965. IdCardNo = psn_info.Certno
  25966. psn_info.VerifyNumber = psn_info.Certno
  25967. } else if his.IdCardType == 4 {
  25968. IdCardNo = psn_info.Certno
  25969. } else {
  25970. bas := strings.Split(psn_info.CardInfo, "|")
  25971. IdCardNo = bas[2]
  25972. }
  25973. aaaa = insutype
  25974. 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)
  25975. saveLog(result, requestLog, "2201A", "挂号")
  25976. if miConfig.Code == "H15049901371" {
  25977. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25978. utils.ErrorLog("解析失败:%v", err)
  25979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25980. return
  25981. }
  25982. resThree.ErrMsg = resThree10265.ErrMsg
  25983. resThree.Output = resThree10265.Output
  25984. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25985. } else {
  25986. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25987. utils.ErrorLog("解析失败:%v", err)
  25988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25989. return
  25990. }
  25991. }
  25992. if miConfig.Code == "H15049901371" {
  25993. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25994. } else {
  25995. infocode = resThree.Infcode
  25996. }
  25997. }
  25998. } else if res3101.Infcode != 0 {
  25999. c.ServeSuccessJSON(map[string]interface{}{
  26000. "failed_code": -10,
  26001. "msg": res3101.ErrMsg,
  26002. })
  26003. return
  26004. }
  26005. } else {
  26006. psn_info, _ := service.GetPsnByPatientId(id)
  26007. var rf []*ResultFive
  26008. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  26009. //var insutypes []*ResultFive
  26010. var insutype string
  26011. var insutypes []*ResultFive
  26012. var is390 int = 0
  26013. var is310 int = 0
  26014. for _, item := range rf {
  26015. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26016. insutypes = append(insutypes, item)
  26017. }
  26018. }
  26019. if len(insutypes) == 1 {
  26020. insutype = insutypes[0].Insutype
  26021. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  26022. } else {
  26023. for _, i := range insutypes {
  26024. if i.Insutype == "390" {
  26025. is390 = 1
  26026. }
  26027. if i.Insutype == "310" {
  26028. is310 = 1
  26029. }
  26030. }
  26031. }
  26032. if is390 == 1 {
  26033. insutype = "390"
  26034. }
  26035. if is310 == 1 {
  26036. insutype = "310"
  26037. }
  26038. if len(insutypes) == 0 {
  26039. insutype = "310"
  26040. }
  26041. if social_type > 0 {
  26042. insutype = strconv.FormatInt(social_type, 10)
  26043. }
  26044. for _, item := range rf {
  26045. if item.Insutype == insutype {
  26046. insuplc_admdvs_temp = item.InsuplcAdmdvs
  26047. }
  26048. }
  26049. if len(insuplc_admdvs_tt) > 0 {
  26050. insuplc_admdvs_temp = insuplc_admdvs_tt
  26051. }
  26052. 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)
  26053. saveLog(result, requestLog, "2201A", "挂号")
  26054. }
  26055. if miConfig.Code == "H15049901371" {
  26056. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  26057. utils.ErrorLog("解析失败:%v", err)
  26058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26059. return
  26060. }
  26061. resThree.ErrMsg = resThree10265.ErrMsg
  26062. resThree.Output = resThree10265.Output
  26063. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  26064. } else {
  26065. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  26066. utils.ErrorLog("解析失败:%v", err)
  26067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26068. return
  26069. }
  26070. }
  26071. if miConfig.Code == "H15049901371" {
  26072. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  26073. } else {
  26074. infocode = resThree.Infcode
  26075. }
  26076. }
  26077. }
  26078. if infocode == -1 {
  26079. adminUser := c.GetAdminUserInfo()
  26080. errlog := &models.HisOrderError{
  26081. UserOrgId: adminUser.CurrentOrgId,
  26082. Ctime: time.Now().Unix(),
  26083. Mtime: time.Now().Unix(),
  26084. ErrMsg: resThree.ErrMsg,
  26085. Status: 1,
  26086. PatientId: id,
  26087. RecordTime: recordDateTime,
  26088. Stage: 2,
  26089. }
  26090. service.CreateErrMsgLog(errlog)
  26091. c.ServeSuccessJSON(map[string]interface{}{
  26092. "failed_code": -10,
  26093. "msg": resThree.ErrMsg,
  26094. })
  26095. return
  26096. }
  26097. utils.ErrorLog("解析失败:%v", insutype)
  26098. his.Number = resThree.Output.Data.MdtrtID
  26099. his.PsnNo = resThree.Output.Data.PsnNo
  26100. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  26101. his.IdCardNo = patient.IdCardNo
  26102. his.PhoneNumber = patient.Phone
  26103. his.UserOrgId = adminInfo.CurrentOrgId
  26104. his.Insutype = insutype
  26105. if miConfig.Code == "H44030500255" {
  26106. his.Insutype = aaaa
  26107. }
  26108. his.Ctime = time.Now().Unix()
  26109. his.Mtime = time.Now().Unix()
  26110. his.InsuplcAdmdvs = insuplc_admdvs_temp
  26111. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  26112. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  26113. }
  26114. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  26115. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  26116. }
  26117. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  26118. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  26119. }
  26120. his.Status = 1
  26121. his.MdtrtGrpType = mdtrt_type
  26122. service.UpdateHisPatientStatus(&his)
  26123. service.UpdateHisPatient123(&patient)
  26124. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  26125. c.ServeSuccessJSON(map[string]interface{}{
  26126. "his_info": his,
  26127. })
  26128. } else {
  26129. adminUser := c.GetAdminUserInfo()
  26130. errlog := &models.HisOrderError{
  26131. UserOrgId: adminUser.CurrentOrgId,
  26132. Ctime: time.Now().Unix(),
  26133. Mtime: time.Now().Unix(),
  26134. ErrMsg: res.ErrMsg,
  26135. Status: 1,
  26136. PatientId: id,
  26137. RecordTime: recordDateTime,
  26138. Stage: 1,
  26139. }
  26140. service.CreateErrMsgLog(errlog)
  26141. c.ServeSuccessJSON(map[string]interface{}{
  26142. "failed_code": -10,
  26143. "msg": res.ErrMsg,
  26144. })
  26145. return
  26146. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  26147. }
  26148. }
  26149. }
  26150. func (c *HisApiController) GetUploadInfo() {
  26151. id, _ := c.GetInt64("id")
  26152. record_time := c.GetString("record_time")
  26153. his_patient_id, _ := c.GetInt64("his_patient_id")
  26154. order_id, _ := c.GetInt64("order_id")
  26155. pay_way, _ := c.GetInt64("pay_way")
  26156. pay_ways := c.GetString("pay_ways")
  26157. oth_desc := c.GetString("oth_desc")
  26158. pay_price, _ := c.GetFloat("pay_price")
  26159. pay_card_no := c.GetString("pay_card_no")
  26160. discount_price, _ := c.GetFloat("discount_price")
  26161. preferential_price, _ := c.GetFloat("preferential_price")
  26162. reality_price, _ := c.GetFloat("reality_price")
  26163. found_price, _ := c.GetFloat("found_price")
  26164. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  26165. private_price, _ := c.GetFloat("private_price")
  26166. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  26167. admin_user_id, _ := c.GetInt64("admin_user_id")
  26168. fapiao_code := c.GetString("fapiao_code")
  26169. fapiao_number := c.GetString("fapiao_number")
  26170. diagnosis_id := c.GetString("diagnosis")
  26171. sick_type, _ := c.GetInt64("sick_type")
  26172. reg_type, _ := c.GetInt64("p_type")
  26173. begin_time := c.GetString("begin_time")
  26174. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  26175. cash_pay := c.GetString("cash_pay")
  26176. band_card_pay := c.GetString("band_card_pay")
  26177. wechat_pay := c.GetString("wechat_pay")
  26178. ali_pay := c.GetString("ali_pay")
  26179. jifen_pay := c.GetString("jifen_pay")
  26180. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  26181. fmt.Println(acct_used_flag)
  26182. id_str := c.GetString("ids")
  26183. ids_arr := strings.Split(id_str, ",")
  26184. timeLayout := "2006-01-02"
  26185. loc, _ := time.LoadLocation("Local")
  26186. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  26187. if err != nil {
  26188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26189. return
  26190. }
  26191. recordDateTime := theTime.Unix()
  26192. adminUser := c.GetAdminUserInfo()
  26193. var tempOrder models.HisOrder
  26194. tempOrder, _ = service.GetHisOrderByID(order_id)
  26195. var prescriptions []*models.HisPrescription
  26196. var start_time int64
  26197. var end_time int64
  26198. //押金模块
  26199. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  26200. tmp_decimal := c.GetString("tmp_decimal")
  26201. var decimal float64 //本次使用的押金
  26202. var errmsg error
  26203. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  26204. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  26205. return
  26206. }
  26207. if len(tmp_decimal) > 0 {
  26208. if tmp_decimal[0] == 45 {
  26209. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  26210. return
  26211. }
  26212. }
  26213. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  26214. fmt.Println(errs)
  26215. decimal = tt
  26216. //if adminUser.CurrentOrgId == 10106{
  26217. // if len(fapiao_code) == 0{
  26218. // fapiao_code = "144072080589"
  26219. // }
  26220. // if len(fapiao_number) == 0{
  26221. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  26222. // if order.ID == 0{
  26223. // fapiao_number = "00001520"
  26224. // }else{
  26225. // //fapiao_code = "00001520"
  26226. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  26227. // var zero string
  26228. // if fpNumber >= 1000{
  26229. // zero = "0000" + strconv.Itoa(fpNumber)
  26230. // }else if fpNumber >= 10000{
  26231. // zero = "000" + strconv.Itoa(fpNumber)
  26232. // } else if fpNumber >= 100000{
  26233. // zero = "00" + strconv.Itoa(fpNumber)
  26234. // } else if fpNumber >= 1000000{
  26235. // zero = "0" + strconv.Itoa(fpNumber)
  26236. // }else {
  26237. // zero = strconv.Itoa(fpNumber)
  26238. // }
  26239. // fapiao_number = zero
  26240. // }
  26241. // }
  26242. //}
  26243. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26244. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  26245. var patientPrescription models.HisPrescriptionInfo
  26246. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  26247. if patientPrescription.ID == 0 {
  26248. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  26249. }
  26250. //if patientPrescription.Do
  26251. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26252. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  26253. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  26254. diagnosis_ids := strings.Split(diagnosis_id, ",")
  26255. var config []*models.HisXtDiagnoseConfig
  26256. for _, item := range diagnosis_ids {
  26257. id, _ := strconv.ParseInt(item, 10, 64)
  26258. diagnosisConfig, _ := service.FindDiagnoseById(id)
  26259. config = append(config, &diagnosisConfig)
  26260. }
  26261. sickConfig, _ := service.FindSickById(sick_type)
  26262. //if tempOrder.ID == 0 {
  26263. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  26264. //}
  26265. if tempOrder.ID == 0 {
  26266. var result string
  26267. var requestLog string
  26268. var res2 ResultSix
  26269. var res3 GZResultSix
  26270. var ressix10265 ResultSix10265
  26271. if miConfig.MdtrtareaAdmvs == "421300" {
  26272. data := make(map[string]interface{})
  26273. client := &http.Client{}
  26274. data["psn_no"] = his.PsnNo
  26275. data["mdtrt_id"] = his.Number
  26276. data["opter"] = roles.UserName
  26277. data["org_name"] = miConfig.OrgName
  26278. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26279. data["doctor_id"] = doctor_info.DoctorNumber
  26280. data["doctor_name"] = doctor_info.UserName
  26281. data["department"] = department.Name
  26282. data["fixmedins_code"] = miConfig.Code
  26283. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26284. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26285. data["secret_key"] = miConfig.SecretKey
  26286. data["sick_code"] = sickConfig.CountryCode
  26287. data["sick_name"] = sickConfig.ClassName
  26288. data["dept"] = strconv.FormatInt(department.ID, 10)
  26289. data["config"] = config
  26290. data["begin_time"] = begin_time
  26291. bytesData, _ := json.Marshal(data)
  26292. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  26293. resp, _ := client.Do(req)
  26294. defer resp.Body.Close()
  26295. body, ioErr := ioutil.ReadAll(resp.Body)
  26296. if ioErr != nil {
  26297. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26299. return
  26300. }
  26301. var respJSON map[string]interface{}
  26302. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26303. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26305. return
  26306. }
  26307. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26308. userJSONBytes, _ := json.Marshal(respJSON)
  26309. fmt.Println("log")
  26310. fmt.Println(string(userJSONBytes))
  26311. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26312. utils.ErrorLog("解析失败:%v", err)
  26313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26314. return
  26315. }
  26316. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26317. data := make(map[string]interface{})
  26318. client := &http.Client{}
  26319. data["psn_no"] = his.PsnNo
  26320. data["mdtrt_id"] = his.Number
  26321. data["opter"] = roles.UserName
  26322. data["org_name"] = miConfig.OrgName
  26323. if reg_type == 11 && his.Insutype == "390" {
  26324. data["med_type"] = "110104"
  26325. } else {
  26326. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26327. }
  26328. data["doctor_id"] = doctor_info.DoctorNumber
  26329. data["doctor_name"] = doctor_info.UserName
  26330. data["department"] = department.Name
  26331. data["fixmedins_code"] = miConfig.Code
  26332. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26333. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26334. data["secret_key"] = miConfig.SecretKey
  26335. data["sick_code"] = sickConfig.CountryCode
  26336. data["sick_name"] = sickConfig.ClassName
  26337. data["dept"] = strconv.FormatInt(department.ID, 10)
  26338. data["config"] = config
  26339. data["begin_time"] = begin_time
  26340. bytesData, _ := json.Marshal(data)
  26341. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  26342. resp, _ := client.Do(req)
  26343. defer resp.Body.Close()
  26344. body, ioErr := ioutil.ReadAll(resp.Body)
  26345. if ioErr != nil {
  26346. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26348. return
  26349. }
  26350. var respJSON map[string]interface{}
  26351. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26352. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26354. return
  26355. }
  26356. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26357. userJSONBytes, _ := json.Marshal(respJSON)
  26358. fmt.Println("log")
  26359. fmt.Println(string(userJSONBytes))
  26360. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26361. utils.ErrorLog("解析失败:%v", err)
  26362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26363. return
  26364. }
  26365. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26366. data := make(map[string]interface{})
  26367. client := &http.Client{}
  26368. data["psn_no"] = his.PsnNo
  26369. data["mdtrt_id"] = his.Number
  26370. data["opter"] = roles.UserName
  26371. data["org_name"] = miConfig.OrgName
  26372. if reg_type == 11 && his.Insutype == "390" {
  26373. data["med_type"] = "110104"
  26374. } else {
  26375. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26376. }
  26377. data["doctor_id"] = doctor_info.DoctorNumber
  26378. data["doctor_name"] = doctor_info.UserName
  26379. data["department"] = department.Name
  26380. data["fixmedins_code"] = miConfig.Code
  26381. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26382. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26383. data["secret_key"] = miConfig.SecretKey
  26384. data["sick_code"] = sickConfig.CountryCode
  26385. data["sick_name"] = sickConfig.ClassName
  26386. data["dept"] = strconv.FormatInt(department.ID, 10)
  26387. data["config"] = config
  26388. data["begin_time"] = begin_time
  26389. bytesData, _ := json.Marshal(data)
  26390. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  26391. resp, _ := client.Do(req)
  26392. defer resp.Body.Close()
  26393. body, ioErr := ioutil.ReadAll(resp.Body)
  26394. if ioErr != nil {
  26395. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26397. return
  26398. }
  26399. var respJSON map[string]interface{}
  26400. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26401. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26403. return
  26404. }
  26405. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26406. userJSONBytes, _ := json.Marshal(respJSON)
  26407. fmt.Println("log")
  26408. fmt.Println(string(userJSONBytes))
  26409. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26410. utils.ErrorLog("解析失败:%v", err)
  26411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26412. return
  26413. }
  26414. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26415. data := make(map[string]interface{})
  26416. client := &http.Client{}
  26417. data["psn_no"] = his.PsnNo
  26418. data["mdtrt_id"] = his.Number
  26419. data["opter"] = roles.UserName
  26420. data["org_name"] = miConfig.OrgName
  26421. if reg_type == 11 && his.Insutype == "390" {
  26422. data["med_type"] = "110104"
  26423. } else {
  26424. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26425. }
  26426. data["doctor_id"] = doctor_info.DoctorNumber
  26427. data["doctor_name"] = doctor_info.UserName
  26428. data["department"] = department.Name
  26429. data["fixmedins_code"] = miConfig.Code
  26430. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26431. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26432. data["secret_key"] = miConfig.SecretKey
  26433. data["sick_code"] = sickConfig.CountryCode
  26434. data["sick_name"] = sickConfig.ClassName
  26435. data["dept"] = strconv.FormatInt(department.ID, 10)
  26436. data["config"] = config
  26437. data["begin_time"] = begin_time
  26438. bytesData, _ := json.Marshal(data)
  26439. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  26440. resp, _ := client.Do(req)
  26441. defer resp.Body.Close()
  26442. body, ioErr := ioutil.ReadAll(resp.Body)
  26443. if ioErr != nil {
  26444. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26446. return
  26447. }
  26448. var respJSON map[string]interface{}
  26449. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26450. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26452. return
  26453. }
  26454. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26455. userJSONBytes, _ := json.Marshal(respJSON)
  26456. fmt.Println("log")
  26457. fmt.Println(string(userJSONBytes))
  26458. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26459. utils.ErrorLog("解析失败:%v", err)
  26460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26461. return
  26462. }
  26463. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  26464. utils.ErrorLog("解析失败:%v", doctor_info)
  26465. data := make(map[string]interface{})
  26466. client := &http.Client{}
  26467. data["psn_no"] = his.PsnNo
  26468. data["mdtrt_id"] = his.Number
  26469. data["doctor"] = roles.UserName
  26470. data["department"] = department.Name
  26471. data["org_name"] = miConfig.OrgName
  26472. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26473. data["doctor_id"] = doctor_info.DoctorNumber
  26474. data["new_doctor_name"] = doctor_info.UserName
  26475. data["fixmedins_code"] = miConfig.Code
  26476. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26477. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26478. data["secret_key"] = miConfig.SecretKey
  26479. data["sick_code"] = sickConfig.CountryCode
  26480. data["sick_name"] = sickConfig.ClassName
  26481. data["url"] = miConfig.Url
  26482. data["ak"] = miConfig.AccessKey
  26483. data["begin_time"] = begin_time
  26484. data["cainfo"] = miConfig.Cainfo
  26485. data["dept"] = strconv.FormatInt(department.ID, 10)
  26486. data["config"] = config
  26487. bytesData, _ := json.Marshal(data)
  26488. var req *http.Request
  26489. if miConfig.MdtrtareaAdmvs == "320830" {
  26490. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2203", bytes.NewReader(bytesData))
  26491. //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 +
  26492. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  26493. } else if miConfig.MdtrtareaAdmvs == "320921" {
  26494. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  26495. //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 +
  26496. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  26497. } else {
  26498. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  26499. }
  26500. resp, _ := client.Do(req)
  26501. defer resp.Body.Close()
  26502. body, ioErr := ioutil.ReadAll(resp.Body)
  26503. if ioErr != nil {
  26504. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26506. return
  26507. }
  26508. var respJSON map[string]interface{}
  26509. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26510. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26512. return
  26513. }
  26514. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26515. userJSONBytes, _ := json.Marshal(respJSON)
  26516. fmt.Println("log")
  26517. fmt.Println(string(userJSONBytes))
  26518. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  26519. utils.ErrorLog("解析失败:%v", err)
  26520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26521. return
  26522. }
  26523. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26524. res2.Output = ressix10265.Output
  26525. res2.ErrMsg = ressix10265.ErrMsg
  26526. res2.Cainfo = ressix10265.Cainfo
  26527. res2.WarnMsg = ressix10265.WarnMsg
  26528. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26529. res2.Infcode = infocode
  26530. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26531. data := make(map[string]interface{})
  26532. client := &http.Client{}
  26533. data["psn_no"] = his.PsnNo
  26534. data["mdtrt_id"] = his.Number
  26535. data["doctor"] = roles.UserName
  26536. data["department"] = department.Name
  26537. data["org_name"] = miConfig.OrgName
  26538. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26539. data["doctor_id"] = doctor_info.DoctorNumber
  26540. data["new_doctor_name"] = doctor_info.UserName
  26541. data["fixmedins_code"] = miConfig.Code
  26542. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26543. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26544. data["secret_key"] = miConfig.SecretKey
  26545. data["sick_code"] = sickConfig.CountryCode
  26546. data["sick_name"] = sickConfig.ClassName
  26547. data["url"] = miConfig.Url
  26548. data["ak"] = miConfig.AccessKey
  26549. data["begin_time"] = begin_time
  26550. data["cainfo"] = miConfig.Cainfo
  26551. data["dept"] = strconv.FormatInt(department.ID, 10)
  26552. data["config"] = config
  26553. bytesData, _ := json.Marshal(data)
  26554. var req *http.Request
  26555. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  26556. resp, _ := client.Do(req)
  26557. defer resp.Body.Close()
  26558. body, ioErr := ioutil.ReadAll(resp.Body)
  26559. if ioErr != nil {
  26560. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26562. return
  26563. }
  26564. var respJSON map[string]interface{}
  26565. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26566. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26568. return
  26569. }
  26570. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26571. userJSONBytes, _ := json.Marshal(respJSON)
  26572. fmt.Println("log")
  26573. fmt.Println(string(userJSONBytes))
  26574. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  26575. utils.ErrorLog("解析失败:%v", err)
  26576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26577. return
  26578. }
  26579. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26580. res2.Output = ressix10265.Output
  26581. res2.ErrMsg = ressix10265.ErrMsg
  26582. res2.Cainfo = ressix10265.Cainfo
  26583. res2.WarnMsg = ressix10265.WarnMsg
  26584. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26585. res2.Infcode = infocode
  26586. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26587. 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)
  26588. saveLog(result, requestLog, "2203", "上传就诊信息")
  26589. var respJSON2 map[string]interface{}
  26590. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26591. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26593. return
  26594. }
  26595. userJSONBytes2, _ := json.Marshal(respJSON2)
  26596. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26597. utils.ErrorLog("解析失败:%v", err)
  26598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26599. return
  26600. }
  26601. 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)
  26602. fmt.Println(result2)
  26603. fmt.Println(src_request)
  26604. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26605. data := make(map[string]interface{})
  26606. client := &http.Client{}
  26607. data["psn_no"] = his.PsnNo
  26608. data["mdtrt_id"] = his.Number
  26609. data["doctor"] = roles.UserName
  26610. data["department"] = department.Name
  26611. data["org_name"] = miConfig.OrgName
  26612. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26613. data["doctor_id"] = doctor_info.DoctorNumber
  26614. data["new_doctor_name"] = doctor_info.UserName
  26615. data["fixmedins_code"] = miConfig.Code
  26616. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26617. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26618. data["secret_key"] = miConfig.SecretKey
  26619. data["sick_code"] = sickConfig.CountryCode
  26620. data["sick_name"] = sickConfig.ClassName
  26621. data["url"] = miConfig.Url
  26622. data["ak"] = miConfig.AccessKey
  26623. data["begin_time"] = begin_time
  26624. data["cainfo"] = miConfig.Cainfo
  26625. data["dept"] = strconv.FormatInt(department.ID, 10)
  26626. data["config"] = config
  26627. bytesData, _ := json.Marshal(data)
  26628. var req *http.Request
  26629. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  26630. resp, _ := client.Do(req)
  26631. defer resp.Body.Close()
  26632. body, ioErr := ioutil.ReadAll(resp.Body)
  26633. if ioErr != nil {
  26634. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26636. return
  26637. }
  26638. var respJSON map[string]interface{}
  26639. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26640. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26642. return
  26643. }
  26644. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26645. userJSONBytes, _ := json.Marshal(respJSON)
  26646. fmt.Println("log")
  26647. fmt.Println(string(userJSONBytes))
  26648. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26649. utils.ErrorLog("解析失败:%v", err)
  26650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26651. return
  26652. }
  26653. } else {
  26654. if miConfig.MdtrtareaAdmvs == "440781" { //
  26655. 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)
  26656. } else {
  26657. if miConfig.Code == "H15049901371" {
  26658. //赤峰地区国家医保医疗类别
  26659. //职工透析:医疗类别选特殊情况门诊990502
  26660. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26661. var med_type string
  26662. if his.Insutype == "390" {
  26663. if reg_type == 14 {
  26664. med_type = "9933"
  26665. } else if reg_type == 11 {
  26666. med_type = "11"
  26667. }
  26668. } else if his.Insutype == "310" {
  26669. if reg_type == 14 {
  26670. med_type = "990502"
  26671. } else if reg_type == 11 {
  26672. med_type = "11"
  26673. }
  26674. }
  26675. 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)
  26676. } else {
  26677. 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)
  26678. }
  26679. }
  26680. saveLog(result, requestLog, "2203", "上传就诊信息")
  26681. var respJSON2 map[string]interface{}
  26682. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26683. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26685. return
  26686. }
  26687. userJSONBytes2, _ := json.Marshal(respJSON2)
  26688. if miConfig.Code == "H15049901371" {
  26689. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  26690. utils.ErrorLog("解析失败:%v", err)
  26691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26692. return
  26693. }
  26694. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26695. res2.Output = ressix10265.Output
  26696. res2.ErrMsg = ressix10265.ErrMsg
  26697. res2.Cainfo = ressix10265.Cainfo
  26698. res2.WarnMsg = ressix10265.WarnMsg
  26699. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26700. res2.Infcode = infocode
  26701. } else {
  26702. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26703. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  26704. utils.ErrorLog("解析失败:%v", err)
  26705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26706. return
  26707. }
  26708. res2.Infcode = res3.Infcode
  26709. } else {
  26710. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26711. utils.ErrorLog("解析失败:%v", err)
  26712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26713. return
  26714. }
  26715. }
  26716. }
  26717. }
  26718. if res2.Infcode == -1 {
  26719. adminUser := c.GetAdminUserInfo()
  26720. errlog := &models.HisOrderError{
  26721. UserOrgId: adminUser.CurrentOrgId,
  26722. Ctime: time.Now().Unix(),
  26723. Mtime: time.Now().Unix(),
  26724. ErrMsg: res2.ErrMsg,
  26725. Status: 1,
  26726. PatientId: id,
  26727. RecordTime: recordDateTime,
  26728. Stage: 3,
  26729. }
  26730. service.CreateErrMsgLog(errlog)
  26731. c.ServeSuccessJSON(map[string]interface{}{
  26732. "failed_code": -10,
  26733. "msg": res2.ErrMsg,
  26734. })
  26735. return
  26736. } else {
  26737. his.Diagnosis = diagnosis_id
  26738. his.SickType = sickConfig.ID
  26739. //var p_type int64
  26740. //if reg_type == 1111 || reg_type == 1112 {
  26741. // p_type = 11
  26742. //
  26743. //}
  26744. his.PType = fmt.Sprintf("%d", reg_type)
  26745. service.UpdateHisPatientThree(&his)
  26746. data := make(map[string]interface{})
  26747. if settle_accounts_type == 1 { //日结
  26748. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  26749. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  26750. } else {
  26751. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  26752. }
  26753. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  26754. data["pre"] = prescriptions
  26755. } else { //月结
  26756. start_time_str := c.GetString("start_time")
  26757. end_time_str := c.GetString("end_time")
  26758. timeLayout := "2006-01-02"
  26759. loc, _ := time.LoadLocation("Local")
  26760. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  26761. if err != nil {
  26762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26763. return
  26764. }
  26765. recordStartTime := theStartTime.Unix()
  26766. start_time = recordStartTime
  26767. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  26768. if err != nil {
  26769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26770. return
  26771. }
  26772. recordEndTime := theEndTime.Unix()
  26773. end_time = recordEndTime
  26774. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  26775. data["pre"] = prescriptions
  26776. }
  26777. timestamp := time.Now().Unix()
  26778. tempTime := time.Unix(timestamp, 0)
  26779. timeFormat := tempTime.Format("20060102150405")
  26780. chrgBchno := rand.Intn(100000) + 10000
  26781. new_chrg_bchno := ""
  26782. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  26783. new_chrg_bchno = chrg_bchno
  26784. strconv.FormatInt(his.PatientId, 10)
  26785. client := &http.Client{}
  26786. if adminUser.CurrentOrgId == 10265 {
  26787. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  26788. new_chrg_bchno = "0000"
  26789. }
  26790. }
  26791. data["psn_no"] = his.PsnNo
  26792. data["mdtrt_id"] = his.Number
  26793. data["chrg_bchno"] = new_chrg_bchno
  26794. data["org_name"] = miConfig.OrgName
  26795. data["doctor"] = doctor_info.UserName
  26796. data["doctor_id"] = doctor_info.DoctorNumber
  26797. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  26798. data["fixmedins_code"] = miConfig.Code
  26799. data["dept_code"] = department.Number
  26800. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26801. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26802. data["secret_key"] = miConfig.SecretKey
  26803. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  26804. data["url"] = miConfig.Url
  26805. data["ak"] = miConfig.AccessKey
  26806. data["new_doctor_name"] = patientPrescription.Doctor
  26807. data["diag_code"] = sickConfig.CountryCode
  26808. data["cainfo"] = miConfig.Cainfo
  26809. data["opter"] = roles.UserName
  26810. var ids []int64
  26811. for _, item := range prescriptions {
  26812. ids = append(ids, item.ID)
  26813. }
  26814. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26815. if config.IsOpen == 1 { //对接了医保,走医保流程
  26816. var res ResultFour
  26817. var resFour10265 ResultFour10265
  26818. if miConfig.MdtrtareaAdmvs == "421300" {
  26819. bytesData, _ := json.Marshal(data)
  26820. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  26821. resp, _ := client.Do(req)
  26822. defer resp.Body.Close()
  26823. body, ioErr := ioutil.ReadAll(resp.Body)
  26824. if ioErr != nil {
  26825. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26827. return
  26828. }
  26829. var respJSON map[string]interface{}
  26830. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26831. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26833. return
  26834. }
  26835. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26836. userJSONBytes, _ := json.Marshal(respJSON)
  26837. fmt.Println("log")
  26838. fmt.Println(string(userJSONBytes))
  26839. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26840. utils.ErrorLog("解析失败:%v", err)
  26841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26842. return
  26843. }
  26844. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26845. bytesData, _ := json.Marshal(data)
  26846. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  26847. resp, _ := client.Do(req)
  26848. defer resp.Body.Close()
  26849. body, ioErr := ioutil.ReadAll(resp.Body)
  26850. if ioErr != nil {
  26851. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26853. return
  26854. }
  26855. var respJSON map[string]interface{}
  26856. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26857. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26859. return
  26860. }
  26861. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26862. userJSONBytes, _ := json.Marshal(respJSON)
  26863. fmt.Println("log")
  26864. fmt.Println(string(userJSONBytes))
  26865. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26866. utils.ErrorLog("解析失败:%v", err)
  26867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26868. return
  26869. }
  26870. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26871. bytesData, _ := json.Marshal(data)
  26872. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  26873. resp, _ := client.Do(req)
  26874. defer resp.Body.Close()
  26875. body, ioErr := ioutil.ReadAll(resp.Body)
  26876. if ioErr != nil {
  26877. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26879. return
  26880. }
  26881. var respJSON map[string]interface{}
  26882. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26883. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26885. return
  26886. }
  26887. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26888. userJSONBytes, _ := json.Marshal(respJSON)
  26889. fmt.Println("log")
  26890. fmt.Println(string(userJSONBytes))
  26891. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26892. utils.ErrorLog("解析失败:%v", err)
  26893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26894. return
  26895. }
  26896. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26897. bytesData, _ := json.Marshal(data)
  26898. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  26899. resp, _ := client.Do(req)
  26900. defer resp.Body.Close()
  26901. body, ioErr := ioutil.ReadAll(resp.Body)
  26902. if ioErr != nil {
  26903. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26905. return
  26906. }
  26907. var respJSON map[string]interface{}
  26908. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26909. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26911. return
  26912. }
  26913. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26914. userJSONBytes, _ := json.Marshal(respJSON)
  26915. fmt.Println("log")
  26916. fmt.Println(string(userJSONBytes))
  26917. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26918. utils.ErrorLog("解析失败:%v", err)
  26919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26920. return
  26921. }
  26922. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  26923. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  26924. var result3101 Result3101
  26925. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  26926. result3101.Infcode = "0"
  26927. if result3101.Infcode == "0" {
  26928. if len(result3101.Output.Result) > 0 {
  26929. var errMsgs []string
  26930. for _, item := range result3101.Output.Result {
  26931. errMsgs = append(errMsgs, item.VolaCont)
  26932. }
  26933. c.ServeSuccessJSON(map[string]interface{}{
  26934. "failed_code": -10,
  26935. "msg": errMsgs,
  26936. })
  26937. return
  26938. }
  26939. }
  26940. bytesData, _ := json.Marshal(data)
  26941. var req *http.Request
  26942. if miConfig.MdtrtareaAdmvs == "320830" {
  26943. data["diag_code"] = sickConfig.CountryCode
  26944. fmt.Println(data)
  26945. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2204", bytes.NewReader(bytesData))
  26946. } else if miConfig.MdtrtareaAdmvs == "320921" {
  26947. data["diag_code"] = sickConfig.CountryCode
  26948. fmt.Println(data)
  26949. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26950. } else {
  26951. data["diag_code"] = sickConfig.CountryCode
  26952. fmt.Println(data)
  26953. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26954. }
  26955. resp, _ := client.Do(req)
  26956. defer resp.Body.Close()
  26957. body, ioErr := ioutil.ReadAll(resp.Body)
  26958. if ioErr != nil {
  26959. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26961. return
  26962. }
  26963. var respJSON map[string]interface{}
  26964. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26965. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26967. return
  26968. }
  26969. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26970. userJSONBytes, _ := json.Marshal(respJSON)
  26971. fmt.Println("log")
  26972. fmt.Println(string(userJSONBytes))
  26973. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26974. utils.ErrorLog("解析失败:%v", err)
  26975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26976. return
  26977. }
  26978. res.InfRefmsgid = resFour10265.InfRefmsgid
  26979. res.Output = resFour10265.Output
  26980. res.ErrMsg = resFour10265.ErrMsg
  26981. res.Cainfo = resFour10265.Cainfo
  26982. res.WarnMsg = resFour10265.WarnMsg
  26983. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26984. res.Infcode = infocode
  26985. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26986. var pagesize int = 2
  26987. var start int = 1
  26988. var stop int
  26989. var pagecount int
  26990. var curpage int
  26991. var isSuccess bool = true
  26992. data["doctor_id"] = doctor_info.DoctorNumber
  26993. //总页数,向上取整,注意除之前要先转换类型为float64
  26994. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  26995. for curpage = 1; curpage <= pagecount; curpage++ {
  26996. if curpage == 1 {
  26997. start = 1
  26998. } else {
  26999. start = (curpage-1)*pagesize + 1
  27000. }
  27001. stop = curpage * pagesize
  27002. if stop > len(prescriptions) {
  27003. stop = len(prescriptions)
  27004. }
  27005. //var requestLog string
  27006. data["pre"] = prescriptions[start-1 : stop]
  27007. fmt.Println(data["pre"])
  27008. bytesData, _ := json.Marshal(data)
  27009. var req *http.Request
  27010. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  27011. resp, _ := client.Do(req)
  27012. defer resp.Body.Close()
  27013. body, ioErr := ioutil.ReadAll(resp.Body)
  27014. if ioErr != nil {
  27015. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27017. return
  27018. }
  27019. var respJSON map[string]interface{}
  27020. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27021. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27023. return
  27024. }
  27025. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27026. userJSONBytes, _ := json.Marshal(respJSON)
  27027. fmt.Println("log")
  27028. fmt.Println(string(userJSONBytes))
  27029. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27030. utils.ErrorLog("解析失败:%v", err)
  27031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27032. return
  27033. }
  27034. res.InfRefmsgid = resFour10265.InfRefmsgid
  27035. res.Output = resFour10265.Output
  27036. res.ErrMsg = resFour10265.ErrMsg
  27037. res.Cainfo = resFour10265.Cainfo
  27038. res.WarnMsg = resFour10265.WarnMsg
  27039. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27040. res.Infcode = infocode
  27041. if infocode == 0 {
  27042. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  27043. } else {
  27044. isSuccess = false
  27045. errlog := &models.HisOrderError{
  27046. UserOrgId: adminUser.CurrentOrgId,
  27047. Ctime: time.Now().Unix(),
  27048. Mtime: time.Now().Unix(),
  27049. Number: chrg_bchno,
  27050. ErrMsg: "",
  27051. Status: 1,
  27052. PatientId: id,
  27053. RecordTime: recordDateTime,
  27054. Stage: 4,
  27055. }
  27056. service.CreateErrMsgLog(errlog)
  27057. c.ServeSuccessJSON(map[string]interface{}{
  27058. "failed_code": -10,
  27059. "msg": res.ErrMsg,
  27060. })
  27061. return
  27062. }
  27063. }
  27064. if isSuccess {
  27065. res.Infcode = 0
  27066. }
  27067. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27068. 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)
  27069. var dat map[string]interface{}
  27070. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27071. fmt.Println(dat)
  27072. } else {
  27073. fmt.Println(err)
  27074. }
  27075. saveLog(result, request_log, "2204", "上传费用明细")
  27076. userJSONBytes, _ := json.Marshal(dat)
  27077. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27078. utils.ErrorLog("解析失败:%v", err)
  27079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27080. return
  27081. }
  27082. res.InfRefmsgid = resFour10265.InfRefmsgid
  27083. res.Output = resFour10265.Output
  27084. res.ErrMsg = resFour10265.ErrMsg
  27085. res.Cainfo = resFour10265.Cainfo
  27086. res.WarnMsg = resFour10265.WarnMsg
  27087. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27088. res.Infcode = infocode
  27089. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27090. bytesData, _ := json.Marshal(data)
  27091. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  27092. resp, _ := client.Do(req)
  27093. defer resp.Body.Close()
  27094. body, ioErr := ioutil.ReadAll(resp.Body)
  27095. if ioErr != nil {
  27096. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27098. return
  27099. }
  27100. var respJSON map[string]interface{}
  27101. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27102. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27104. return
  27105. }
  27106. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27107. userJSONBytes, _ := json.Marshal(respJSON)
  27108. fmt.Println("log")
  27109. fmt.Println(string(userJSONBytes))
  27110. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27111. utils.ErrorLog("解析失败:%v", err)
  27112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27113. return
  27114. }
  27115. } else {
  27116. if miConfig.Code == "H15049901371" {
  27117. 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)
  27118. var dat map[string]interface{}
  27119. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27120. fmt.Println(dat)
  27121. } else {
  27122. fmt.Println(err)
  27123. }
  27124. saveLog(result, request_log, "2204", "上传费用明细")
  27125. userJSONBytes, _ := json.Marshal(dat)
  27126. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27127. utils.ErrorLog("解析失败:%v", err)
  27128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27129. return
  27130. }
  27131. res.InfRefmsgid = resFour10265.InfRefmsgid
  27132. res.Output = resFour10265.Output
  27133. res.ErrMsg = resFour10265.ErrMsg
  27134. res.Cainfo = resFour10265.Cainfo
  27135. res.WarnMsg = resFour10265.WarnMsg
  27136. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27137. res.Infcode = infocode
  27138. } else {
  27139. 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)
  27140. var dat map[string]interface{}
  27141. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27142. fmt.Println(dat)
  27143. } else {
  27144. fmt.Println(err)
  27145. }
  27146. saveLog(result, request_log, "2204", "上传费用明细")
  27147. userJSONBytes, _ := json.Marshal(dat)
  27148. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27149. utils.ErrorLog("解析失败:%v", err)
  27150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27151. return
  27152. }
  27153. }
  27154. }
  27155. if res.Infcode == 0 {
  27156. order := &models.HisOrder{
  27157. UserOrgId: adminUser.CurrentOrgId,
  27158. HisPatientId: his.ID,
  27159. PatientId: his.PatientId,
  27160. SettleAccountsDate: recordDateTime,
  27161. MdtrtId: his.Number,
  27162. PsnNo: his.PsnNo,
  27163. MedType: strconv.FormatInt(reg_type, 10),
  27164. Ctime: time.Now().Unix(),
  27165. Mtime: time.Now().Unix(),
  27166. Status: 1,
  27167. Number: chrg_bchno,
  27168. Infcode: res.Infcode,
  27169. WarnMsg: res.WarnMsg,
  27170. Cainfo: res.Cainfo,
  27171. ErrMsg: res.ErrMsg,
  27172. RespondTime: res.RefmsgTime,
  27173. InfRefmsgid: res.InfRefmsgid,
  27174. OrderStatus: 1,
  27175. PayWay: pay_way,
  27176. PayWays: pay_ways,
  27177. OthDesc: oth_desc,
  27178. PayPrice: pay_price,
  27179. PayCardNo: pay_card_no,
  27180. DiscountPrice: discount_price,
  27181. PreferentialPrice: preferential_price,
  27182. RealityPrice: reality_price,
  27183. FoundPrice: found_price,
  27184. MedicalInsurancePrice: medical_insurance_price,
  27185. PrivatePrice: private_price,
  27186. IsMedicineInsurance: 1,
  27187. SettleType: settle_accounts_type,
  27188. SettleStartTime: start_time,
  27189. SettleEndTime: end_time,
  27190. Creator: roles.AdminUserId,
  27191. Modify: roles.AdminUserId,
  27192. FaPiaoNumber: fapiao_number,
  27193. FaPiaoCode: fapiao_code,
  27194. PType: 2,
  27195. Diagnosis: diagnosis_id,
  27196. CashPay: cash_pay,
  27197. WechatPay: wechat_pay,
  27198. AliPay: ali_pay,
  27199. JifenPay: jifen_pay,
  27200. BandCardPay: band_card_pay,
  27201. }
  27202. err = service.CreateOrder(order)
  27203. if err != nil {
  27204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  27205. return
  27206. }
  27207. for _, item := range res.Output.Result {
  27208. temp := strings.Split(item.FeedetlSn, "-")
  27209. var advice_id int64 = 0
  27210. var project_id int64 = 0
  27211. var types int64 = 0
  27212. id, _ := strconv.ParseInt(temp[2], 10, 64)
  27213. types, _ = strconv.ParseInt(temp[1], 10, 64)
  27214. if temp[1] == "1" {
  27215. advice_id = id
  27216. project_id = 0
  27217. } else if temp[1] == "2" {
  27218. advice_id = 0
  27219. project_id = id
  27220. }
  27221. if item.MedChrgitmType == "9" {
  27222. item.MedChrgitmType = "09"
  27223. }
  27224. info := &models.HisOrderInfo{
  27225. OrderNumber: order.Number,
  27226. FeedetlSn: item.FeedetlSn,
  27227. UploadDate: time.Now().Unix(),
  27228. AdviceId: advice_id,
  27229. DetItemFeeSumamt: item.DetItemFeeSumamt,
  27230. Cnt: item.Cnt,
  27231. Pric: float64(item.Pric),
  27232. PatientId: his.PatientId,
  27233. PricUplmtAmt: item.PricUplmtAmt,
  27234. SelfpayProp: item.SelfpayProp,
  27235. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  27236. OverlmtAmt: item.OverlmtAmt,
  27237. PreselfpayAmt: item.PreselfpayAmt,
  27238. BasMednFlag: item.BasMednFlag,
  27239. MedChrgitmType: item.MedChrgitmType,
  27240. HiNegoDrugFlag: item.HiNegoDrugFlag,
  27241. Status: 1,
  27242. Memo: item.Memo,
  27243. Mtime: time.Now().Unix(),
  27244. InscpScpAmt: item.InscpScpAmt,
  27245. DrtReimFlag: item.DrtReimFlag,
  27246. Ctime: time.Now().Unix(),
  27247. ListSpItemFlag: item.ListSpItemFlag,
  27248. ChldMedcFlag: item.ChldMedcFlag,
  27249. LmtUsedFlag: item.LmtUsedFlag,
  27250. ChrgitmLv: item.ChrgitmLv,
  27251. UserOrgId: adminUser.CurrentOrgId,
  27252. HisPatientId: his.ID,
  27253. OrderId: order.ID,
  27254. ProjectId: project_id,
  27255. Type: types,
  27256. }
  27257. service.CreateOrderInfo(info)
  27258. }
  27259. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  27260. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  27261. var total float64
  27262. for _, item := range prescriptions {
  27263. if item.Type == 1 { //药品
  27264. for _, subItem := range item.HisDoctorAdviceInfo {
  27265. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  27266. total_one := price * subItem.PrescribingNumber
  27267. total = total + total_one
  27268. }
  27269. }
  27270. if item.Type == 2 { //项目
  27271. for _, subItem := range item.HisPrescriptionProject {
  27272. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  27273. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  27274. total_one := price * cnt
  27275. total = total + total_one
  27276. }
  27277. }
  27278. }
  27279. allTotal := fmt.Sprintf("%.2f", total)
  27280. //if adminUser.CurrentOrgId == 9919 {
  27281. //
  27282. // allTotal = fmt.Sprintf("%.2f", total)
  27283. //
  27284. //} else {
  27285. //
  27286. // allTotal = fmt.Sprintf("%.2f", total)
  27287. //
  27288. //}
  27289. if res.Infcode == 0 {
  27290. var rf []*ResultFive
  27291. json.Unmarshal([]byte(his.Iinfo), &rf)
  27292. chrg_bchno := chrg_bchno
  27293. cert_no := his.Certno
  27294. var insutypes []string
  27295. var insutype string
  27296. var is390 int = 0
  27297. var is310 int = 0
  27298. for _, item := range rf {
  27299. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27300. insutypes = append(insutypes, item.Insutype)
  27301. }
  27302. }
  27303. if len(insutypes) == 1 {
  27304. insutype = insutypes[0]
  27305. } else {
  27306. for _, i := range insutypes {
  27307. if i == "390" {
  27308. is390 = 1
  27309. }
  27310. if i == "310" {
  27311. is310 = 1
  27312. }
  27313. }
  27314. }
  27315. if is390 == 1 {
  27316. insutype = "390"
  27317. }
  27318. if is310 == 1 {
  27319. insutype = "310"
  27320. }
  27321. if len(insutypes) == 0 {
  27322. insutype = "310"
  27323. }
  27324. if len(insutypes) == 2 {
  27325. insutype = strconv.FormatInt(his.SocialType, 10)
  27326. }
  27327. insutype = strconv.FormatInt(his.SocialType, 10)
  27328. //insutype = "390"
  27329. if his.IdCardType == 1 {
  27330. // cert_no = his.MedicalInsuranceNumber
  27331. cert_no = his.Certno
  27332. } else {
  27333. cert_no = his.Certno
  27334. }
  27335. var res ResultSeven
  27336. var resSeven10265 ResultSeven10265
  27337. var gzresSeven10265Two GZResultSeven10265Two
  27338. var src_resquest string
  27339. var result2 string
  27340. if miConfig.MdtrtareaAdmvs == "421300" {
  27341. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27342. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27343. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27344. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27345. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27346. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27347. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27348. resp, requestErr := http.Get(api)
  27349. if requestErr != nil {
  27350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27351. return
  27352. }
  27353. body, ioErr := ioutil.ReadAll(resp.Body)
  27354. if ioErr != nil {
  27355. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27357. return
  27358. }
  27359. var respJSON map[string]interface{}
  27360. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27361. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27363. return
  27364. }
  27365. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27366. result, _ := json.Marshal(respJSON)
  27367. if miConfig.Code == "H15049901371" {
  27368. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27369. utils.ErrorLog("解析失败:%v", err)
  27370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27371. return
  27372. }
  27373. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27374. res.Output = resSeven10265.Output
  27375. res.ErrMsg = resSeven10265.ErrMsg
  27376. res.Cainfo = resSeven10265.Cainfo
  27377. res.WarnMsg = resSeven10265.WarnMsg
  27378. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27379. res.Infcode = infocode
  27380. } else {
  27381. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27382. utils.ErrorLog("解析失败:%v", err)
  27383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27384. return
  27385. }
  27386. }
  27387. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27388. if reg_type == 11 && his.Insutype == "390" {
  27389. reg_type = 110104
  27390. }
  27391. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27392. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27393. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27394. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27395. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27396. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27397. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27398. resp, requestErr := http.Get(api)
  27399. if requestErr != nil {
  27400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27401. return
  27402. }
  27403. body, ioErr := ioutil.ReadAll(resp.Body)
  27404. if ioErr != nil {
  27405. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27407. return
  27408. }
  27409. var respJSON map[string]interface{}
  27410. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27411. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27413. return
  27414. }
  27415. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27416. result, _ := json.Marshal(respJSON)
  27417. if miConfig.Code == "H15049901371" {
  27418. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27419. utils.ErrorLog("解析失败:%v", err)
  27420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27421. return
  27422. }
  27423. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27424. res.Output = resSeven10265.Output
  27425. res.ErrMsg = resSeven10265.ErrMsg
  27426. res.Cainfo = resSeven10265.Cainfo
  27427. res.WarnMsg = resSeven10265.WarnMsg
  27428. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27429. res.Infcode = infocode
  27430. } else {
  27431. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27432. utils.ErrorLog("解析失败:%v", err)
  27433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27434. return
  27435. }
  27436. }
  27437. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27438. if reg_type == 11 && his.Insutype == "390" {
  27439. reg_type = 110104
  27440. }
  27441. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27442. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27443. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27444. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27445. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27446. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27447. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27448. resp, requestErr := http.Get(api)
  27449. if requestErr != nil {
  27450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27451. return
  27452. }
  27453. body, ioErr := ioutil.ReadAll(resp.Body)
  27454. if ioErr != nil {
  27455. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27457. return
  27458. }
  27459. var respJSON map[string]interface{}
  27460. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27461. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27463. return
  27464. }
  27465. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27466. result, _ := json.Marshal(respJSON)
  27467. if miConfig.Code == "H15049901371" {
  27468. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27469. utils.ErrorLog("解析失败:%v", err)
  27470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27471. return
  27472. }
  27473. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27474. res.Output = resSeven10265.Output
  27475. res.ErrMsg = resSeven10265.ErrMsg
  27476. res.Cainfo = resSeven10265.Cainfo
  27477. res.WarnMsg = resSeven10265.WarnMsg
  27478. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27479. res.Infcode = infocode
  27480. } else {
  27481. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27482. utils.ErrorLog("解析失败:%v", err)
  27483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27484. return
  27485. }
  27486. }
  27487. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27488. if reg_type == 11 && his.Insutype == "390" {
  27489. reg_type = 110104
  27490. }
  27491. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27492. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27493. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27494. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27495. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27496. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27497. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27498. resp, requestErr := http.Get(api)
  27499. if requestErr != nil {
  27500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27501. return
  27502. }
  27503. body, ioErr := ioutil.ReadAll(resp.Body)
  27504. if ioErr != nil {
  27505. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27507. return
  27508. }
  27509. var respJSON map[string]interface{}
  27510. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27511. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27513. return
  27514. }
  27515. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27516. result, _ := json.Marshal(respJSON)
  27517. if miConfig.Code == "H15049901371" {
  27518. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27519. utils.ErrorLog("解析失败:%v", err)
  27520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27521. return
  27522. }
  27523. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27524. res.Output = resSeven10265.Output
  27525. res.ErrMsg = resSeven10265.ErrMsg
  27526. res.Cainfo = resSeven10265.Cainfo
  27527. res.WarnMsg = resSeven10265.WarnMsg
  27528. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27529. res.Infcode = infocode
  27530. } else {
  27531. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27532. utils.ErrorLog("解析失败:%v", err)
  27533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27534. return
  27535. }
  27536. }
  27537. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  27538. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  27539. var result3101 Result3101
  27540. //utils.ErrorLog("解析失败:%v", result3101)
  27541. result3101.Infcode = "0"
  27542. if result3101.Infcode == "0" {
  27543. if len(result3101.Output.Result) > 0 {
  27544. var errMsgs []string
  27545. for _, item := range result3101.Output.Result {
  27546. errMsgs = append(errMsgs, item.VolaCont)
  27547. }
  27548. c.ServeSuccessJSON(map[string]interface{}{
  27549. "failed_code": -10,
  27550. "msg": errMsgs,
  27551. })
  27552. return
  27553. } else {
  27554. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27555. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27556. bas := strings.Split(psn_info.CardInfo, "|")
  27557. if his.IdCardType == 1 {
  27558. cert_no = bas[2]
  27559. } else if his.IdCardType == 3 {
  27560. cert_no = his.Certno
  27561. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27562. } else if his.IdCardType == 4 {
  27563. cert_no = his.Certno
  27564. psn_info.VerifyNumber = psn_info.VerifyNumber
  27565. }
  27566. var api string
  27567. if miConfig.MdtrtareaAdmvs == "320830" {
  27568. api = miConfig.AppSecret + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27569. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27570. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27571. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27572. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27573. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27574. "&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
  27575. } else if miConfig.MdtrtareaAdmvs == "320921" {
  27576. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27577. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27578. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27579. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27580. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27581. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27582. "&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
  27583. } else {
  27584. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27585. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27586. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27587. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27588. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27589. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27590. "&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
  27591. }
  27592. resp, requestErr := http.Get(api)
  27593. if requestErr != nil {
  27594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27595. return
  27596. }
  27597. body, ioErr := ioutil.ReadAll(resp.Body)
  27598. if ioErr != nil {
  27599. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27601. return
  27602. }
  27603. var respJSON map[string]interface{}
  27604. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27605. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27607. return
  27608. }
  27609. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27610. result, _ := json.Marshal(respJSON)
  27611. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27612. utils.ErrorLog("解析失败:%v", err)
  27613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27614. return
  27615. }
  27616. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27617. res.Output = resSeven10265.Output
  27618. res.ErrMsg = resSeven10265.ErrMsg
  27619. res.Cainfo = resSeven10265.Cainfo
  27620. res.WarnMsg = resSeven10265.WarnMsg
  27621. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27622. res.Infcode = infocode
  27623. }
  27624. }
  27625. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27626. psn_info, _ := service.GetPsnByPatientId(id)
  27627. var verify_number string
  27628. if psn_info.IdCardType == 4 {
  27629. verify_number = psn_info.VerifyNumber
  27630. } else if psn_info.IdCardType == 1 {
  27631. bas := strings.Split(psn_info.CardInfo, "|")
  27632. cardNumber := bas[2]
  27633. verify_number = cardNumber
  27634. } else {
  27635. psn_info.IdCardType = 2
  27636. verify_number = psn_info.Certno
  27637. }
  27638. var api string
  27639. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27640. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27641. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27642. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27643. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27644. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27645. "&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
  27646. resp, requestErr := http.Get(api)
  27647. if requestErr != nil {
  27648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27649. return
  27650. }
  27651. body, ioErr := ioutil.ReadAll(resp.Body)
  27652. if ioErr != nil {
  27653. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27655. return
  27656. }
  27657. var respJSON map[string]interface{}
  27658. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27659. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27661. return
  27662. }
  27663. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27664. result, _ := json.Marshal(respJSON)
  27665. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27666. utils.ErrorLog("解析失败:%v", err)
  27667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27668. return
  27669. }
  27670. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27671. res.Output = resSeven10265.Output
  27672. res.ErrMsg = resSeven10265.ErrMsg
  27673. res.Cainfo = resSeven10265.Cainfo
  27674. res.WarnMsg = resSeven10265.WarnMsg
  27675. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27676. res.Infcode = infocode
  27677. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27678. var cert_no string
  27679. if his.IdCardType == 4 {
  27680. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27681. cert_no = psn_info.VerifyNumber
  27682. 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)
  27683. } else if his.IdCardType == 1 {
  27684. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27685. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27686. 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)
  27687. }
  27688. //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)
  27689. var dat map[string]interface{}
  27690. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27691. fmt.Println(dat)
  27692. } else {
  27693. fmt.Println(err)
  27694. }
  27695. saveLog(result2, src_resquest, "2207", "结算")
  27696. userJSONBytes, _ := json.Marshal(dat)
  27697. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27698. utils.ErrorLog("解析失败:%v", err)
  27699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27700. return
  27701. }
  27702. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27703. res.Output = resSeven10265.Output
  27704. res.ErrMsg = resSeven10265.ErrMsg
  27705. res.Cainfo = resSeven10265.Cainfo
  27706. res.WarnMsg = resSeven10265.WarnMsg
  27707. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27708. res.Infcode = infocode
  27709. } else if miConfig.MdtrtareaAdmvs == "450721" {
  27710. res2 := c.GetoleInfo()
  27711. if res2.Infcode == 0 {
  27712. var result string
  27713. var request_log string
  27714. var result_log string
  27715. if res2.Output.MdtrtCertType == "02" {
  27716. 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)
  27717. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27718. } else if res2.Output.MdtrtCertType == "01" {
  27719. 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)
  27720. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27721. } else {
  27722. 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)
  27723. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27724. }
  27725. var dat map[string]interface{}
  27726. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27727. fmt.Println(dat)
  27728. } else {
  27729. fmt.Println(err)
  27730. }
  27731. userJSONBytes, _ := json.Marshal(dat)
  27732. var res5 ResultTwo
  27733. //var resTwo10265 ResultTwo10265
  27734. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  27735. utils.ErrorLog("解析失败:%v", err)
  27736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27737. return
  27738. }
  27739. if res5.Infcode == -1 {
  27740. c.ServeSuccessJSON(map[string]interface{}{
  27741. "failed_code": -10,
  27742. "msg": res5.ErrMsg,
  27743. })
  27744. return
  27745. }
  27746. var insutypes []string
  27747. var insutype string
  27748. var is390 int = 0
  27749. var is310 int = 0
  27750. for _, item := range res5.Output.Iinfo {
  27751. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27752. insutypes = append(insutypes, item.Insutype)
  27753. }
  27754. }
  27755. if len(insutypes) == 1 {
  27756. insutype = insutypes[0]
  27757. } else {
  27758. for _, i := range insutypes {
  27759. if i == "390" {
  27760. is390 = 1
  27761. }
  27762. if i == "310" {
  27763. is310 = 1
  27764. }
  27765. }
  27766. }
  27767. if is390 == 1 {
  27768. insutype = "390"
  27769. }
  27770. if is310 == 1 {
  27771. insutype = "310"
  27772. }
  27773. if len(insutypes) == 0 {
  27774. insutype = "310"
  27775. }
  27776. fmt.Println(insutype)
  27777. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  27778. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  27779. infoStr := string(Iinfos)
  27780. idetinfoStr := string(Idetinfos)
  27781. psn := &models.HisPsn{
  27782. PsnNo: res5.Output.Baseinfo.PsnNo,
  27783. PatientId: id,
  27784. Certno: res5.Output.Baseinfo.Certno,
  27785. Gend: res5.Output.Baseinfo.Gend,
  27786. Naty: res5.Output.Baseinfo.Naty,
  27787. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  27788. PsnName: res5.Output.Baseinfo.PsnName,
  27789. Idetinfo: idetinfoStr,
  27790. Insuinfo: infoStr,
  27791. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  27792. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  27793. VerifyNumber: res2.Output.EcToken,
  27794. }
  27795. if res2.Output.MdtrtCertType == "01" {
  27796. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27797. psn.VerifyNumber = res2.Output.EcToken
  27798. } else if res2.Output.MdtrtCertType == "02" {
  27799. psn.VerifyNumber = res2.Output.CardNo
  27800. } else {
  27801. psn.VerifyNumber = res2.Output.MdtrtCertNo
  27802. }
  27803. service.CreateHisPsn(psn)
  27804. if res2.Output.MdtrtCertType == "01" {
  27805. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27806. token := res2.Output.EcToken
  27807. 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)
  27808. } else if res2.Output.MdtrtCertType == "02" {
  27809. 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)
  27810. } else {
  27811. 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)
  27812. }
  27813. var dat2 map[string]interface{}
  27814. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  27815. fmt.Println(dat2)
  27816. } else {
  27817. fmt.Println(err)
  27818. }
  27819. userJSONBytes3, _ := json.Marshal(dat2)
  27820. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  27821. utils.ErrorLog("解析失败:%v", err)
  27822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27823. return
  27824. }
  27825. saveLog(result2, src_resquest, "2207", "结算")
  27826. } else {
  27827. c.ServeSuccessJSON(map[string]interface{}{
  27828. "failed_code": -10,
  27829. "msg": res2.ErrMsg,
  27830. })
  27831. return
  27832. }
  27833. } else {
  27834. if miConfig.Code == "H15049901371" {
  27835. //赤峰地区国家医保医疗类别
  27836. //职工透析:医疗类别选特殊情况门诊990502
  27837. //居民定额血透门慢: 医疗类别选门诊慢病140104
  27838. var med_type string
  27839. if his.Insutype == "390" {
  27840. if reg_type == 14 {
  27841. med_type = "9933"
  27842. } else if reg_type == 11 {
  27843. med_type = "11"
  27844. }
  27845. } else if his.Insutype == "310" {
  27846. if reg_type == 14 {
  27847. med_type = "990502"
  27848. } else if reg_type == 11 {
  27849. med_type = "11"
  27850. }
  27851. }
  27852. 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)
  27853. } else {
  27854. if his.IdCardType == 4 {
  27855. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27856. var token string
  27857. token = psn_info.VerifyNumber
  27858. 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)
  27859. } else {
  27860. if his.IdCardType == 1 {
  27861. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27862. bas := strings.Split(psn_info.CardInfo, "|")
  27863. basNumber := bas[2]
  27864. cert_no = basNumber
  27865. }
  27866. 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)
  27867. }
  27868. }
  27869. //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)
  27870. var dat map[string]interface{}
  27871. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27872. fmt.Println(dat)
  27873. } else {
  27874. fmt.Println(err)
  27875. }
  27876. saveLog(result2, src_resquest, "2207", "结算")
  27877. userJSONBytes, _ := json.Marshal(dat)
  27878. if miConfig.Code == "H15049901371" {
  27879. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27880. utils.ErrorLog("解析失败:%v", err)
  27881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27882. return
  27883. }
  27884. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27885. res.Output = resSeven10265.Output
  27886. res.ErrMsg = resSeven10265.ErrMsg
  27887. res.Cainfo = resSeven10265.Cainfo
  27888. res.WarnMsg = resSeven10265.WarnMsg
  27889. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27890. res.Infcode = infocode
  27891. } else {
  27892. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  27893. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  27894. utils.ErrorLog("解析失败:%v", err)
  27895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27896. return
  27897. }
  27898. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  27899. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  27900. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  27901. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27902. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  27903. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  27904. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  27905. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27906. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  27907. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27908. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27909. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27910. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27911. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27912. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  27913. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  27914. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  27915. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  27916. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  27917. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  27918. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27919. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  27920. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  27921. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  27922. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  27923. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  27924. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  27925. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  27926. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  27927. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  27928. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  27929. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  27930. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  27931. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  27932. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27933. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  27934. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  27935. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  27936. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27937. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  27938. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  27939. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  27940. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  27941. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  27942. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  27943. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  27944. res.ErrMsg = gzresSeven10265Two.ErrMsg
  27945. res.Cainfo = gzresSeven10265Two.Cainfo
  27946. res.WarnMsg = gzresSeven10265Two.WarnMsg
  27947. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  27948. //res.Infcode = infocode
  27949. } else {
  27950. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27951. utils.ErrorLog("解析失败:%v", err)
  27952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27953. return
  27954. }
  27955. }
  27956. }
  27957. }
  27958. if res.Infcode == -1 {
  27959. errlog := &models.HisOrderError{
  27960. UserOrgId: adminUser.CurrentOrgId,
  27961. Ctime: time.Now().Unix(),
  27962. Mtime: time.Now().Unix(),
  27963. Number: chrg_bchno,
  27964. ErrMsg: res.ErrMsg,
  27965. Status: 1,
  27966. PatientId: id,
  27967. RecordTime: recordDateTime,
  27968. Stage: 6,
  27969. }
  27970. service.CreateErrMsgLog(errlog)
  27971. c.ServeSuccessJSON(map[string]interface{}{
  27972. "failed_code": -10,
  27973. "msg": res.ErrMsg,
  27974. })
  27975. return
  27976. } else {
  27977. sickConfig, _ := service.FindSickById(his.SickType)
  27978. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  27979. order.OrderStatus = 2
  27980. order.Status = 1
  27981. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  27982. order.SetlId = res.Output.Setlinfo.SetlID
  27983. order.PsnNo = res.Output.Setlinfo.PsnNo
  27984. order.PsnName = res.Output.Setlinfo.PsnName
  27985. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  27986. order.Certno = res.Output.Setlinfo.Certno
  27987. order.Gend = res.Output.Setlinfo.Gend
  27988. order.Naty = res.Output.Setlinfo.Naty
  27989. order.Age = res.Output.Setlinfo.Age
  27990. order.Insutype = res.Output.Setlinfo.Insutype
  27991. order.PsnType = res.Output.Setlinfo.PsnType
  27992. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  27993. order.SetlTime = res.Output.Setlinfo.SetlTime
  27994. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  27995. if res.Output.Setlinfo.MedType == "140101" {
  27996. order.MedType = "14"
  27997. } else {
  27998. if res.Output.Setlinfo.MedType == "110104" {
  27999. order.MedType = "11"
  28000. } else {
  28001. order.MedType = res.Output.Setlinfo.MedType
  28002. }
  28003. }
  28004. if reg_type == 1112 {
  28005. order.MedType = "1112"
  28006. }
  28007. if reg_type == 1111 {
  28008. order.MedType = "1111"
  28009. }
  28010. order.ClrType = res.Output.Setlinfo.ClrType
  28011. if adminUser.CurrentOrgId == 10480 {
  28012. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  28013. order.ClrType = "11"
  28014. } else {
  28015. order.ClrType = "9903"
  28016. }
  28017. }
  28018. if adminUser.CurrentOrgId == 10721 {
  28019. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  28020. order.ClrType = "11"
  28021. } else {
  28022. order.ClrType = "9903"
  28023. }
  28024. }
  28025. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  28026. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  28027. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  28028. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  28029. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  28030. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  28031. order.HifpPay = res.Output.Setlinfo.HifpPay
  28032. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  28033. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  28034. order.HifesPay = res.Output.Setlinfo.HifesPay
  28035. order.HifobPay = res.Output.Setlinfo.HifobPay
  28036. order.MafPay = res.Output.Setlinfo.MafPay
  28037. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  28038. order.OthPay = res.Output.Setlinfo.OthPay
  28039. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  28040. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  28041. order.AcctPay = res.Output.Setlinfo.AcctPay
  28042. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  28043. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  28044. order.Balc = res.Output.Setlinfo.Balc
  28045. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  28046. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  28047. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  28048. //order.ClrType = res.Output.Setlinfo.ClrType
  28049. order.ClrWay = res.Output.Setlinfo.ClrWay
  28050. order.Creator = order.Creator
  28051. order.Modify = roles.AdminUserId
  28052. order.RequestLog = src_resquest
  28053. order.FaPiaoNumber = fapiao_number
  28054. order.FaPiaoCode = fapiao_code
  28055. order.SickName = sickConfig.ClassName
  28056. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  28057. //detailStr := string(setlDetail)
  28058. //order.SetlDetail = detailStr
  28059. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  28060. err = service.UpDateOrder(order)
  28061. if err == nil {
  28062. //判断是否使用了押金
  28063. if dec_way == "true" {
  28064. tmpstring := strconv.FormatInt(order.ID, 10)
  28065. order.Decimal = decimal
  28066. service.UpDateOrder(order)
  28067. //扣押金
  28068. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  28069. if errmsg != nil {
  28070. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  28071. return
  28072. }
  28073. }
  28074. c.ServeSuccessJSON(map[string]interface{}{
  28075. "msg": "结算成功",
  28076. })
  28077. } else {
  28078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  28079. return
  28080. }
  28081. }
  28082. } else {
  28083. adminUser := c.GetAdminUserInfo()
  28084. errlog := &models.HisOrderError{
  28085. UserOrgId: adminUser.CurrentOrgId,
  28086. Ctime: time.Now().Unix(),
  28087. Mtime: time.Now().Unix(),
  28088. ErrMsg: res.ErrMsg,
  28089. Status: 1,
  28090. PatientId: id,
  28091. RecordTime: recordDateTime,
  28092. Stage: 4,
  28093. }
  28094. service.CreateErrMsgLog(errlog)
  28095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  28096. return
  28097. }
  28098. } else {
  28099. adminUser := c.GetAdminUserInfo()
  28100. errlog := &models.HisOrderError{
  28101. UserOrgId: adminUser.CurrentOrgId,
  28102. Ctime: time.Now().Unix(),
  28103. Mtime: time.Now().Unix(),
  28104. ErrMsg: res.ErrMsg,
  28105. Status: 1,
  28106. PatientId: id,
  28107. RecordTime: recordDateTime,
  28108. Stage: 4,
  28109. }
  28110. service.CreateErrMsgLog(errlog)
  28111. c.ServeSuccessJSON(map[string]interface{}{
  28112. "failed_code": -10,
  28113. "msg": res.ErrMsg,
  28114. })
  28115. return
  28116. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  28117. //return
  28118. }
  28119. }
  28120. }
  28121. } else if tempOrder.ID > 0 {
  28122. if tempOrder.IsPre == 1 {
  28123. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  28124. var rf []*ResultFive
  28125. json.Unmarshal([]byte(his.Iinfo), &rf)
  28126. chrg_bchno := tempOrder.Number
  28127. cert_no := his.Certno
  28128. var insutypes []string
  28129. var insutype string
  28130. var is390 int = 0
  28131. var is310 int = 0
  28132. for _, item := range rf {
  28133. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28134. insutypes = append(insutypes, item.Insutype)
  28135. }
  28136. }
  28137. if len(insutypes) == 1 {
  28138. insutype = insutypes[0]
  28139. } else {
  28140. for _, i := range insutypes {
  28141. if i == "390" {
  28142. is390 = 1
  28143. }
  28144. if i == "310" {
  28145. is310 = 1
  28146. }
  28147. }
  28148. }
  28149. if is390 == 1 {
  28150. insutype = "390"
  28151. }
  28152. if is310 == 1 {
  28153. insutype = "310"
  28154. }
  28155. if len(insutypes) == 0 {
  28156. insutype = "310"
  28157. }
  28158. if len(insutypes) == 2 {
  28159. insutype = strconv.FormatInt(his.SocialType, 10)
  28160. }
  28161. //insutype = "390"
  28162. if his.IdCardType == 1 {
  28163. // cert_no = his.MedicalInsuranceNumber
  28164. cert_no = his.Certno
  28165. } else {
  28166. cert_no = his.Certno
  28167. }
  28168. var res ResultSeven
  28169. var ahres ResultSevenAH
  28170. var resSeven10265 ResultSeven10265
  28171. var gzresSeven10265Two GZResultSeven10265Two
  28172. var src_resquest string
  28173. var result2 string
  28174. if miConfig.MdtrtareaAdmvs == "450721" {
  28175. res2 := c.GetoleInfo()
  28176. if res2.Infcode == 0 {
  28177. var result string
  28178. var request_log string
  28179. var result_log string
  28180. if res2.Output.MdtrtCertType == "02" {
  28181. 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)
  28182. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  28183. } else if res2.Output.MdtrtCertType == "01" {
  28184. 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)
  28185. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  28186. } else {
  28187. 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)
  28188. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  28189. }
  28190. var dat map[string]interface{}
  28191. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28192. fmt.Println(dat)
  28193. } else {
  28194. fmt.Println(err)
  28195. }
  28196. userJSONBytes, _ := json.Marshal(dat)
  28197. var res5 ResultTwo
  28198. //var resTwo10265 ResultTwo10265
  28199. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  28200. utils.ErrorLog("解析失败:%v", err)
  28201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28202. return
  28203. }
  28204. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  28205. if res5.Infcode == -1 {
  28206. c.ServeSuccessJSON(map[string]interface{}{
  28207. "failed_code": -10,
  28208. "msg": res5.ErrMsg,
  28209. })
  28210. return
  28211. }
  28212. var insutypes []string
  28213. var insutype string
  28214. var is390 int = 0
  28215. var is310 int = 0
  28216. for _, item := range res5.Output.Iinfo {
  28217. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28218. insutypes = append(insutypes, item.Insutype)
  28219. }
  28220. }
  28221. if len(insutypes) == 1 {
  28222. insutype = insutypes[0]
  28223. } else {
  28224. for _, i := range insutypes {
  28225. if i == "390" {
  28226. is390 = 1
  28227. }
  28228. if i == "310" {
  28229. is310 = 1
  28230. }
  28231. }
  28232. }
  28233. if is390 == 1 {
  28234. insutype = "390"
  28235. }
  28236. if is310 == 1 {
  28237. insutype = "310"
  28238. }
  28239. if len(insutypes) == 0 {
  28240. insutype = "310"
  28241. }
  28242. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  28243. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  28244. infoStr := string(Iinfos)
  28245. idetinfoStr := string(Idetinfos)
  28246. psn := &models.HisPsn{
  28247. PsnNo: res5.Output.Baseinfo.PsnNo,
  28248. PatientId: id,
  28249. Certno: res5.Output.Baseinfo.Certno,
  28250. Gend: res5.Output.Baseinfo.Gend,
  28251. Naty: res5.Output.Baseinfo.Naty,
  28252. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  28253. PsnName: res5.Output.Baseinfo.PsnName,
  28254. Idetinfo: idetinfoStr,
  28255. Insuinfo: infoStr,
  28256. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  28257. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  28258. VerifyNumber: res2.Output.EcToken,
  28259. }
  28260. service.CreateHisPsn(psn)
  28261. if res2.Output.MdtrtCertType == "01" {
  28262. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28263. token := res2.Output.EcToken
  28264. 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)
  28265. } else if res2.Output.MdtrtCertType == "02" {
  28266. 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)
  28267. } else {
  28268. 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)
  28269. }
  28270. var dat2 map[string]interface{}
  28271. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28272. fmt.Println(dat2)
  28273. } else {
  28274. fmt.Println(err)
  28275. }
  28276. userJSONBytes3, _ := json.Marshal(dat2)
  28277. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28278. utils.ErrorLog("解析失败:%v", err)
  28279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28280. return
  28281. }
  28282. saveLog(result2, src_resquest, "2207", "结算")
  28283. } else {
  28284. c.ServeSuccessJSON(map[string]interface{}{
  28285. "failed_code": -10,
  28286. "msg": res2.ErrMsg,
  28287. })
  28288. return
  28289. }
  28290. } else if miConfig.MdtrtareaAdmvs == "421300" {
  28291. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28292. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28293. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28294. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28295. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28296. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28297. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28298. resp, requestErr := http.Get(api)
  28299. if requestErr != nil {
  28300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28301. return
  28302. }
  28303. body, ioErr := ioutil.ReadAll(resp.Body)
  28304. if ioErr != nil {
  28305. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28307. return
  28308. }
  28309. var respJSON map[string]interface{}
  28310. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28311. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28313. return
  28314. }
  28315. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28316. result, _ := json.Marshal(respJSON)
  28317. fmt.Println("log")
  28318. fmt.Println(string(result))
  28319. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28320. utils.ErrorLog("解析失败:%v", err)
  28321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28322. return
  28323. }
  28324. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28325. if reg_type == 11 && his.Insutype == "390" {
  28326. reg_type = 110104
  28327. }
  28328. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28329. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28330. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28331. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28332. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28333. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28334. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28335. resp, requestErr := http.Get(api)
  28336. if requestErr != nil {
  28337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28338. return
  28339. }
  28340. body, ioErr := ioutil.ReadAll(resp.Body)
  28341. if ioErr != nil {
  28342. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28344. return
  28345. }
  28346. var respJSON map[string]interface{}
  28347. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28348. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28350. return
  28351. }
  28352. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28353. result, _ := json.Marshal(respJSON)
  28354. fmt.Println("log")
  28355. fmt.Println(string(result))
  28356. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28357. utils.ErrorLog("解析失败:%v", err)
  28358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28359. return
  28360. }
  28361. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28362. if reg_type == 11 && his.Insutype == "390" {
  28363. reg_type = 110104
  28364. }
  28365. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28366. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28367. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28368. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28369. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28370. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28371. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28372. resp, requestErr := http.Get(api)
  28373. if requestErr != nil {
  28374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28375. return
  28376. }
  28377. body, ioErr := ioutil.ReadAll(resp.Body)
  28378. if ioErr != nil {
  28379. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28381. return
  28382. }
  28383. var respJSON map[string]interface{}
  28384. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28385. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28387. return
  28388. }
  28389. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28390. result, _ := json.Marshal(respJSON)
  28391. fmt.Println("log")
  28392. fmt.Println(string(result))
  28393. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28394. utils.ErrorLog("解析失败:%v", err)
  28395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28396. return
  28397. }
  28398. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28399. if reg_type == 11 && his.Insutype == "390" {
  28400. reg_type = 110104
  28401. }
  28402. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28403. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28404. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28405. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28406. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28407. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28408. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28409. resp, requestErr := http.Get(api)
  28410. if requestErr != nil {
  28411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28412. return
  28413. }
  28414. body, ioErr := ioutil.ReadAll(resp.Body)
  28415. if ioErr != nil {
  28416. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28418. return
  28419. }
  28420. var respJSON map[string]interface{}
  28421. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28422. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28424. return
  28425. }
  28426. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28427. result, _ := json.Marshal(respJSON)
  28428. fmt.Println("log")
  28429. fmt.Println(string(result))
  28430. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28431. utils.ErrorLog("解析失败:%v", err)
  28432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28433. return
  28434. }
  28435. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  28436. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  28437. var result3101 Result3101
  28438. //utils.ErrorLog("解析失败:%v", result3101)
  28439. result3101.Infcode = "0"
  28440. if result3101.Infcode == "0" {
  28441. if len(result3101.Output.Result) > 0 {
  28442. var errMsgs []string
  28443. for _, item := range result3101.Output.Result {
  28444. errMsgs = append(errMsgs, item.VolaCont)
  28445. }
  28446. c.ServeSuccessJSON(map[string]interface{}{
  28447. "failed_code": -10,
  28448. "msg": errMsgs,
  28449. })
  28450. return
  28451. } else {
  28452. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28453. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28454. bas := strings.Split(psn_info.CardInfo, "|")
  28455. if his.IdCardType == 1 {
  28456. cert_no = bas[2]
  28457. } else if his.IdCardType == 3 {
  28458. cert_no = his.Certno
  28459. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  28460. } else if his.IdCardType == 4 {
  28461. cert_no = his.Certno
  28462. psn_info.VerifyNumber = psn_info.VerifyNumber
  28463. }
  28464. //江苏地区国家医保医疗类别
  28465. //职工透析:医疗类别选特殊情况门诊9933
  28466. //居民血透门慢: 医疗类别选门诊慢病1402
  28467. //var med_type string
  28468. //if his.Insutype == "310" {
  28469. // if reg_type == 14 {
  28470. // med_type = "9933"
  28471. // } else if reg_type == 11 {
  28472. // med_type = "11"
  28473. //
  28474. // }
  28475. //} else if his.Insutype == "390" {
  28476. // if reg_type == 14 {
  28477. // med_type = "1402"
  28478. // } else if reg_type == 11 {
  28479. // med_type = "11"
  28480. // }
  28481. //}
  28482. var api string
  28483. if miConfig.MdtrtareaAdmvs == "320830" {
  28484. api = miConfig.AppSecret + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28485. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28486. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28487. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28488. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28489. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28490. "&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
  28491. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28492. } else if miConfig.MdtrtareaAdmvs == "320921" {
  28493. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28494. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28495. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28496. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28497. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28498. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28499. "&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
  28500. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28501. } else {
  28502. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28503. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28504. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28505. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28506. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28507. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28508. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28509. "&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
  28510. }
  28511. resp, requestErr := http.Get(api)
  28512. if requestErr != nil {
  28513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28514. return
  28515. }
  28516. body, ioErr := ioutil.ReadAll(resp.Body)
  28517. if ioErr != nil {
  28518. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28520. return
  28521. }
  28522. var respJSON map[string]interface{}
  28523. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28524. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28526. return
  28527. }
  28528. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28529. result, _ := json.Marshal(respJSON)
  28530. fmt.Println("log")
  28531. fmt.Println(string(result))
  28532. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  28533. utils.ErrorLog("解析失败:%v", err)
  28534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28535. return
  28536. }
  28537. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28538. res.Output = resSeven10265.Output
  28539. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28540. res.ErrMsg = resSeven10265.ErrMsg
  28541. res.Cainfo = resSeven10265.Cainfo
  28542. res.WarnMsg = resSeven10265.WarnMsg
  28543. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28544. res.Infcode = infocode
  28545. }
  28546. }
  28547. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28548. psn_info, _ := service.GetPsnByPatientId(id)
  28549. var verify_number string
  28550. if psn_info.IdCardType == 4 {
  28551. verify_number = psn_info.VerifyNumber
  28552. } else if psn_info.IdCardType == 1 {
  28553. bas := strings.Split(psn_info.CardInfo, "|")
  28554. cardNumber := bas[2]
  28555. verify_number = cardNumber
  28556. } else {
  28557. verify_number = psn_info.Certno
  28558. psn_info.IdCardType = 2
  28559. }
  28560. var api string
  28561. new_chrg_bchno := chrg_bchno
  28562. if adminUser.CurrentOrgId == 10265 {
  28563. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  28564. new_chrg_bchno = "0000"
  28565. }
  28566. }
  28567. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28568. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  28569. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28570. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28571. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  28572. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28573. "&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
  28574. resp, requestErr := http.Get(api)
  28575. if requestErr != nil {
  28576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28577. return
  28578. }
  28579. body, ioErr := ioutil.ReadAll(resp.Body)
  28580. if ioErr != nil {
  28581. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28583. return
  28584. }
  28585. var respJSON map[string]interface{}
  28586. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28587. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28589. return
  28590. }
  28591. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28592. result, _ := json.Marshal(respJSON)
  28593. fmt.Println("log")
  28594. fmt.Println(string(result))
  28595. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  28596. utils.ErrorLog("解析失败:%v", err)
  28597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28598. return
  28599. }
  28600. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28601. res.Output = resSeven10265.Output
  28602. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28603. res.ErrMsg = resSeven10265.ErrMsg
  28604. res.Cainfo = resSeven10265.Cainfo
  28605. res.WarnMsg = resSeven10265.WarnMsg
  28606. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28607. res.Infcode = infocode
  28608. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28609. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28610. var cert_no string
  28611. if his.IdCardType == 1 {
  28612. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28613. } else {
  28614. cert_no = psn_info.VerifyNumber
  28615. }
  28616. 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)
  28617. var dat map[string]interface{}
  28618. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28619. fmt.Println(dat)
  28620. } else {
  28621. fmt.Println(err)
  28622. }
  28623. saveLog(result2, src_resquest, "2207", "结算")
  28624. userJSONBytes, _ := json.Marshal(dat)
  28625. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28626. utils.ErrorLog("解析失败:%v", err)
  28627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28628. return
  28629. }
  28630. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28631. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28632. var cert_no string
  28633. var card_sn string
  28634. if his.IdCardType == 1 {
  28635. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28636. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28637. bas := strings.Split(psn_info.CardInfo, "|")
  28638. card_sn = bas[3]
  28639. } else if his.IdCardType == 2 {
  28640. cert_no = his.IdCardNo
  28641. } else {
  28642. cert_no = psn_info.VerifyNumber
  28643. }
  28644. var rf []*ResultFive
  28645. json.Unmarshal([]byte(his.Iinfo), &rf)
  28646. var psn_type string
  28647. for _, item := range rf {
  28648. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28649. psn_type = item.PsnType
  28650. }
  28651. }
  28652. result2, src_resquest := service.Jxyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdCardType, acct_used_flag, miConfig.Url, miConfig.AccessKey, cert_no, "", card_sn, his.PsnCertType, his.Certno, psn_type, his.PsnName)
  28653. var dat map[string]interface{}
  28654. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28655. fmt.Println(dat)
  28656. } else {
  28657. fmt.Println(err)
  28658. }
  28659. saveLog(result2, src_resquest, "2207", "结算")
  28660. userJSONBytes, _ := json.Marshal(dat)
  28661. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28662. utils.ErrorLog("解析失败:%v", err)
  28663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28664. return
  28665. }
  28666. } else if miConfig.MdtrtareaAdmvs == "361025" {
  28667. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28668. var cert_no string
  28669. var card_sn string
  28670. if his.IdCardType == 1 {
  28671. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28672. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28673. //bas := strings.Split(psn_info.CardInfo, "|")
  28674. card_sn = ""
  28675. } else if his.IdCardType == 2 {
  28676. cert_no = his.IdCardNo
  28677. } else {
  28678. cert_no = psn_info.VerifyNumber
  28679. }
  28680. var rf []*ResultFive
  28681. json.Unmarshal([]byte(his.Iinfo), &rf)
  28682. var psn_type string
  28683. for _, item := range rf {
  28684. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28685. psn_type = item.PsnType
  28686. }
  28687. }
  28688. 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)
  28689. var dat map[string]interface{}
  28690. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28691. fmt.Println(dat)
  28692. } else {
  28693. fmt.Println(err)
  28694. }
  28695. saveLog(result2, src_resquest, "2207", "结算")
  28696. userJSONBytes, _ := json.Marshal(dat)
  28697. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28698. utils.ErrorLog("解析失败:%v", err)
  28699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28700. return
  28701. }
  28702. } else if miConfig.MdtrtareaAdmvs == "360100" {
  28703. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28704. var cert_no string
  28705. var card_sn string
  28706. if his.IdCardType == 1 {
  28707. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28708. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28709. //bas := strings.Split(psn_info.CardInfo, "|")
  28710. card_sn = ""
  28711. } else if his.IdCardType == 2 {
  28712. cert_no = his.IdCardNo
  28713. } else {
  28714. cert_no = psn_info.VerifyNumber
  28715. }
  28716. var rf []*ResultFive
  28717. json.Unmarshal([]byte(his.Iinfo), &rf)
  28718. var psn_type string
  28719. for _, item := range rf {
  28720. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28721. psn_type = item.PsnType
  28722. }
  28723. }
  28724. 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)
  28725. var dat map[string]interface{}
  28726. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28727. fmt.Println(dat)
  28728. } else {
  28729. fmt.Println(err)
  28730. }
  28731. saveLog(result2, src_resquest, "2207", "结算")
  28732. userJSONBytes, _ := json.Marshal(dat)
  28733. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28734. utils.ErrorLog("解析失败:%v", err)
  28735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28736. return
  28737. }
  28738. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28739. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28740. if his.IdCardType == 1 {
  28741. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28742. bas := strings.Split(psn_info.CardInfo, "|")
  28743. cert_no = bas[2]
  28744. } else if his.IdCardType == 3 {
  28745. cert_no = his.Certno
  28746. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  28747. } else if his.IdCardType == 4 {
  28748. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28749. cert_no = psn_info.VerifyNumber
  28750. psn_info.VerifyNumber = psn_info.VerifyNumber
  28751. } else {
  28752. cert_no = his.Certno
  28753. psn_info.VerifyNumber = his.Certno
  28754. }
  28755. var api string
  28756. var med_type string
  28757. if his.Insutype == "390" {
  28758. if reg_type == 992102 {
  28759. med_type = "992102"
  28760. }
  28761. if reg_type == 1104 {
  28762. med_type = "1104"
  28763. }
  28764. if reg_type == 1104 {
  28765. med_type = "1104"
  28766. }
  28767. if reg_type == 140104 {
  28768. med_type = "140104"
  28769. }
  28770. if reg_type == 140201 {
  28771. med_type = "140201"
  28772. }
  28773. if reg_type == 14 {
  28774. med_type = "14"
  28775. }
  28776. } else if his.Insutype == "310" {
  28777. if reg_type == 1104 {
  28778. med_type = "1104"
  28779. }
  28780. if reg_type == 992102 {
  28781. med_type = "992102"
  28782. }
  28783. if reg_type == 140104 {
  28784. med_type = "140104"
  28785. }
  28786. if reg_type == 140201 {
  28787. med_type = "140201"
  28788. }
  28789. if reg_type == 14 {
  28790. med_type = "14"
  28791. }
  28792. }
  28793. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28794. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28795. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28796. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28797. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28798. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28799. "&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
  28800. resp, requestErr := http.Get(api)
  28801. if requestErr != nil {
  28802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28803. return
  28804. }
  28805. body, ioErr := ioutil.ReadAll(resp.Body)
  28806. if ioErr != nil {
  28807. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28809. return
  28810. }
  28811. var respJSON map[string]interface{}
  28812. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28813. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28815. return
  28816. }
  28817. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28818. if status == "0" {
  28819. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28820. c.ServeSuccessJSON(map[string]interface{}{
  28821. "failed_code": -10,
  28822. "msg": err_msg,
  28823. })
  28824. return
  28825. }
  28826. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28827. result, _ := json.Marshal(respJSON)
  28828. fmt.Println("log")
  28829. fmt.Println(string(result))
  28830. if err := json.Unmarshal(result, &ahres); err != nil {
  28831. utils.ErrorLog("解析失败:%v", err)
  28832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28833. return
  28834. }
  28835. res.InfRefmsgid = ahres.InfRefmsgid
  28836. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  28837. // 创建对应的Time类型
  28838. t := time.UnixMilli(timestamp)
  28839. // 格式化成指定的日期字符串
  28840. str := t.Format("2006-01-02 15:04:05")
  28841. res.Output.Setlinfo.SetlTime = str
  28842. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  28843. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  28844. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28845. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  28846. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  28847. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  28848. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28849. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  28850. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  28851. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  28852. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  28853. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28854. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  28855. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  28856. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  28857. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  28858. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  28859. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  28860. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28861. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  28862. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  28863. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  28864. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  28865. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  28866. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  28867. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  28868. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  28869. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  28870. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  28871. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  28872. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  28873. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  28874. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  28875. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  28876. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  28877. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  28878. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  28879. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  28880. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  28881. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  28882. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  28883. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  28884. res.Output.Setldetail = ahres.Output.Setldetail
  28885. res.ErrMsg = ahres.ErrMsg
  28886. res.Cainfo = ahres.Cainfo
  28887. res.WarnMsg = ahres.WarnMsg
  28888. res.Infcode = ahres.Infcode
  28889. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  28890. res.Output.Setlinfo.ClrType = "11"
  28891. } else {
  28892. res.Output.Setlinfo.ClrType = "9903"
  28893. }
  28894. } else if miConfig.MdtrtareaAdmvs == "340699" {
  28895. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28896. if his.IdCardType == 1 {
  28897. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28898. bas := strings.Split(psn_info.CardInfo, "|")
  28899. cert_no = bas[2]
  28900. } else if his.IdCardType == 3 {
  28901. cert_no = his.Certno
  28902. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  28903. } else if his.IdCardType == 4 {
  28904. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28905. cert_no = his.Certno
  28906. psn_info.VerifyNumber = psn_info.VerifyNumber
  28907. } else {
  28908. cert_no = his.Certno
  28909. psn_info.VerifyNumber = his.Certno
  28910. }
  28911. var api string
  28912. var med_type string
  28913. if his.Insutype == "390" {
  28914. if reg_type == 1104 {
  28915. med_type = "1104"
  28916. }
  28917. if reg_type == 992102 {
  28918. med_type = "992102"
  28919. }
  28920. if reg_type == 140104 {
  28921. med_type = "140104"
  28922. }
  28923. if reg_type == 14 {
  28924. med_type = "14"
  28925. }
  28926. if reg_type == 140201 {
  28927. med_type = "140201"
  28928. }
  28929. } else if his.Insutype == "310" {
  28930. if reg_type == 1104 {
  28931. med_type = "1104"
  28932. }
  28933. if reg_type == 992102 {
  28934. med_type = "992102"
  28935. }
  28936. if reg_type == 14 {
  28937. med_type = "14"
  28938. }
  28939. if reg_type == 140104 {
  28940. med_type = "140104"
  28941. }
  28942. if reg_type == 140201 {
  28943. med_type = "140201"
  28944. }
  28945. }
  28946. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28947. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28948. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28949. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28950. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28951. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28952. "&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
  28953. resp, requestErr := http.Get(api)
  28954. if requestErr != nil {
  28955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28956. return
  28957. }
  28958. body, ioErr := ioutil.ReadAll(resp.Body)
  28959. if ioErr != nil {
  28960. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28962. return
  28963. }
  28964. var respJSON map[string]interface{}
  28965. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28966. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28968. return
  28969. }
  28970. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28971. if status == "0" {
  28972. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28973. c.ServeSuccessJSON(map[string]interface{}{
  28974. "failed_code": -10,
  28975. "msg": err_msg,
  28976. })
  28977. return
  28978. }
  28979. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28980. result, _ := json.Marshal(respJSON)
  28981. fmt.Println("log")
  28982. fmt.Println(string(result))
  28983. if err := json.Unmarshal(result, &ahres); err != nil {
  28984. utils.ErrorLog("解析失败:%v", err)
  28985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28986. return
  28987. }
  28988. res.InfRefmsgid = ahres.InfRefmsgid
  28989. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  28990. // 创建对应的Time类型
  28991. t := time.UnixMilli(timestamp)
  28992. // 格式化成指定的日期字符串
  28993. str := t.Format("2006-01-02 15:04:05")
  28994. res.Output.Setlinfo.SetlTime = str
  28995. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  28996. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  28997. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28998. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  28999. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  29000. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  29001. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  29002. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  29003. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  29004. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  29005. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  29006. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29007. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  29008. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  29009. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  29010. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  29011. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  29012. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  29013. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29014. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  29015. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  29016. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  29017. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  29018. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  29019. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  29020. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  29021. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  29022. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  29023. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  29024. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  29025. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  29026. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  29027. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  29028. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  29029. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  29030. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  29031. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  29032. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  29033. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  29034. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  29035. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  29036. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  29037. res.Output.Setldetail = ahres.Output.Setldetail
  29038. res.ErrMsg = ahres.ErrMsg
  29039. res.Cainfo = ahres.Cainfo
  29040. res.WarnMsg = ahres.WarnMsg
  29041. res.Infcode = ahres.Infcode
  29042. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  29043. res.Output.Setlinfo.ClrType = "11"
  29044. } else {
  29045. res.Output.Setlinfo.ClrType = "9903"
  29046. }
  29047. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29048. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29049. var cert_no string
  29050. if his.IdCardType == 1 {
  29051. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  29052. } else if his.IdCardType == 2 {
  29053. cert_no = his.IdCardNo
  29054. } else {
  29055. cert_no = psn_info.VerifyNumber
  29056. }
  29057. 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, "")
  29058. var dat map[string]interface{}
  29059. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29060. fmt.Println(dat)
  29061. } else {
  29062. fmt.Println(err)
  29063. }
  29064. saveLog(result2, src_resquest, "2207", "结算")
  29065. userJSONBytes, _ := json.Marshal(dat)
  29066. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29067. utils.ErrorLog("解析失败:%v", err)
  29068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29069. return
  29070. }
  29071. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29072. psn_info, _ := service.GetPsnByPatientId(id)
  29073. var verify_number string
  29074. if psn_info.IdCardType == 4 {
  29075. verify_number = psn_info.VerifyNumber
  29076. } else if psn_info.IdCardType == 1 {
  29077. bas := strings.Split(psn_info.CardInfo, "|")
  29078. cardNumber := bas[2]
  29079. verify_number = cardNumber
  29080. } else {
  29081. verify_number = psn_info.Certno
  29082. psn_info.IdCardType = 2
  29083. }
  29084. var api string
  29085. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29086. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29087. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29088. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29089. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  29090. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29091. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  29092. resp, requestErr := http.Get(api)
  29093. if requestErr != nil {
  29094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29095. return
  29096. }
  29097. body, ioErr := ioutil.ReadAll(resp.Body)
  29098. if ioErr != nil {
  29099. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29101. return
  29102. }
  29103. var respJSON map[string]interface{}
  29104. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29105. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29107. return
  29108. }
  29109. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29110. result, _ := json.Marshal(respJSON)
  29111. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29112. utils.ErrorLog("解析失败:%v", err)
  29113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29114. return
  29115. }
  29116. } else {
  29117. var src_resquest string
  29118. if miConfig.Code == "H15049901371" {
  29119. //赤峰地区国家医保医疗类别
  29120. //职工透析:医疗类别选特殊情况门诊990502
  29121. //居民定额血透门慢: 医疗类别选门诊慢病140104
  29122. var med_type string
  29123. if his.Insutype == "390" {
  29124. if reg_type == 14 {
  29125. med_type = "9933"
  29126. } else if reg_type == 11 {
  29127. med_type = "11"
  29128. }
  29129. } else if his.Insutype == "310" {
  29130. if reg_type == 14 {
  29131. med_type = "990502"
  29132. } else if reg_type == 11 {
  29133. med_type = "11"
  29134. }
  29135. }
  29136. 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)
  29137. } else {
  29138. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" {
  29139. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  29140. if result3101.Infcode == 0 {
  29141. if len(result3101.Output.Result) > 0 {
  29142. c.ServeSuccessJSON(map[string]interface{}{
  29143. "failed_code": -10,
  29144. "failed_type": 100,
  29145. "warm_type": 2,
  29146. "msg": result3101,
  29147. })
  29148. return
  29149. }
  29150. } else {
  29151. c.ServeSuccessJSON(map[string]interface{}{
  29152. "failed_code": -10,
  29153. "msg": result3101.ErrMsg,
  29154. })
  29155. return
  29156. }
  29157. }
  29158. if his.IdCardType == 4 {
  29159. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29160. token := psn_info.VerifyNumber
  29161. 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)
  29162. } else {
  29163. 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)
  29164. }
  29165. }
  29166. var dat map[string]interface{}
  29167. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29168. fmt.Println(dat)
  29169. } else {
  29170. fmt.Println(err)
  29171. }
  29172. saveLog(result2, src_resquest, "2207", "结算")
  29173. userJSONBytes, _ := json.Marshal(dat)
  29174. if miConfig.Code == "H15049901371" {
  29175. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  29176. utils.ErrorLog("解析失败:%v", err)
  29177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29178. return
  29179. }
  29180. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29181. res.Output = resSeven10265.Output
  29182. res.ErrMsg = resSeven10265.ErrMsg
  29183. res.Cainfo = resSeven10265.Cainfo
  29184. res.WarnMsg = resSeven10265.WarnMsg
  29185. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29186. res.Infcode = infocode
  29187. } else {
  29188. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  29189. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  29190. utils.ErrorLog("解析失败:%v", err)
  29191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29192. return
  29193. }
  29194. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  29195. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  29196. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  29197. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  29198. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  29199. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  29200. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  29201. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  29202. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  29203. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29204. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29205. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29206. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29207. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  29208. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  29209. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  29210. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  29211. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  29212. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  29213. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  29214. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29215. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  29216. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  29217. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  29218. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  29219. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  29220. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  29221. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  29222. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  29223. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  29224. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  29225. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  29226. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  29227. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  29228. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  29229. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  29230. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  29231. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  29232. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29233. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  29234. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  29235. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  29236. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  29237. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  29238. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  29239. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  29240. res.ErrMsg = gzresSeven10265Two.ErrMsg
  29241. res.Cainfo = gzresSeven10265Two.Cainfo
  29242. res.WarnMsg = gzresSeven10265Two.WarnMsg
  29243. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  29244. //res.Infcode = infocode
  29245. } else {
  29246. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29247. utils.ErrorLog("解析失败:%v", err)
  29248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29249. return
  29250. }
  29251. }
  29252. }
  29253. }
  29254. if res.Infcode == -1 {
  29255. errlog := &models.HisOrderError{
  29256. UserOrgId: adminUser.CurrentOrgId,
  29257. Ctime: time.Now().Unix(),
  29258. Mtime: time.Now().Unix(),
  29259. Number: chrg_bchno,
  29260. ErrMsg: res.ErrMsg,
  29261. Status: 1,
  29262. PatientId: id,
  29263. RecordTime: recordDateTime,
  29264. Stage: 6,
  29265. }
  29266. service.CreateErrMsgLog(errlog)
  29267. c.ServeSuccessJSON(map[string]interface{}{
  29268. "failed_code": -10,
  29269. "msg": res.ErrMsg,
  29270. })
  29271. return
  29272. } else {
  29273. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  29274. order.OrderStatus = 2
  29275. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  29276. order.SetlId = res.Output.Setlinfo.SetlID
  29277. order.PsnNo = res.Output.Setlinfo.PsnNo
  29278. order.PsnName = res.Output.Setlinfo.PsnName
  29279. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  29280. order.Certno = res.Output.Setlinfo.Certno
  29281. order.Gend = res.Output.Setlinfo.Gend
  29282. order.Naty = res.Output.Setlinfo.Naty
  29283. order.Age = res.Output.Setlinfo.Age
  29284. order.Insutype = res.Output.Setlinfo.Insutype
  29285. order.PsnType = res.Output.Setlinfo.PsnType
  29286. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  29287. order.SetlTime = res.Output.Setlinfo.SetlTime
  29288. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  29289. order.PayWays = pay_ways
  29290. order.AcctUsedFlag = acct_used_flag
  29291. order.WechatPay = wechat_pay
  29292. order.AliPay = ali_pay
  29293. order.JifenPay = jifen_pay
  29294. order.BandCardPay = band_card_pay
  29295. order.CashPay = cash_pay
  29296. order.OthDesc = oth_desc
  29297. //order.MedType = res.Output.Setlinfo.MedType
  29298. if reg_type == 1112 {
  29299. order.MedType = "1112"
  29300. }
  29301. if reg_type == 1111 {
  29302. order.MedType = "1111"
  29303. }
  29304. order.ClrType = res.Output.Setlinfo.ClrType
  29305. if adminUser.CurrentOrgId == 10480 {
  29306. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  29307. order.ClrType = "11"
  29308. } else {
  29309. order.ClrType = "9903"
  29310. }
  29311. }
  29312. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  29313. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  29314. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  29315. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  29316. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  29317. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  29318. order.HifpPay = res.Output.Setlinfo.HifpPay
  29319. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  29320. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  29321. order.HifesPay = res.Output.Setlinfo.HifesPay
  29322. order.HifobPay = res.Output.Setlinfo.HifobPay
  29323. order.MafPay = res.Output.Setlinfo.MafPay
  29324. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  29325. order.OthPay = res.Output.Setlinfo.OthPay
  29326. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  29327. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  29328. order.AcctPay = res.Output.Setlinfo.AcctPay
  29329. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  29330. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  29331. order.Balc = res.Output.Setlinfo.Balc
  29332. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  29333. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  29334. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  29335. order.ClrWay = res.Output.Setlinfo.ClrWay
  29336. order.Creator = order.Creator
  29337. order.Modify = roles.AdminUserId
  29338. order.RequestLog = src_resquest
  29339. order.Diagnosis = diagnosis_id
  29340. order.FaPiaoNumber = fapiao_number
  29341. order.FaPiaoCode = fapiao_code
  29342. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  29343. detailStr := string(setlDetail)
  29344. order.SetlDetail = detailStr
  29345. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  29346. err = service.UpDateOrder(order)
  29347. if err == nil {
  29348. //判断是否使用了押金
  29349. if dec_way == "true" {
  29350. tmpstring := strconv.FormatInt(order.ID, 10)
  29351. //扣押金
  29352. order.Decimal = decimal
  29353. service.UpDateOrder(order)
  29354. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  29355. if errmsg != nil {
  29356. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  29357. return
  29358. }
  29359. }
  29360. c.ServeSuccessJSON(map[string]interface{}{
  29361. "msg": "结算成功",
  29362. })
  29363. } else {
  29364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  29365. return
  29366. }
  29367. }
  29368. }
  29369. }
  29370. }
  29371. // 上传明细-预结算-
  29372. func (c *HisApiController) GetPreUploadInfo() {
  29373. id, _ := c.GetInt64("id")
  29374. record_time := c.GetString("record_time")
  29375. his_patient_id, _ := c.GetInt64("his_patient_id")
  29376. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  29377. admin_user_id, _ := c.GetInt64("admin_user_id")
  29378. diagnosis_id := c.GetString("diagnosis")
  29379. sick_type, _ := c.GetInt64("sick_type")
  29380. reg_type, _ := c.GetInt64("p_type")
  29381. begin_time := c.GetString("begin_time")
  29382. acct_used_flag := c.GetString("acct_used_flag")
  29383. id_str := c.GetString("ids")
  29384. ids_arr := strings.Split(id_str, ",")
  29385. timeLayout := "2006-01-02"
  29386. loc, _ := time.LoadLocation("Local")
  29387. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  29388. if err != nil {
  29389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  29390. return
  29391. }
  29392. recordDateTime := theTime.Unix()
  29393. adminUser := c.GetAdminUserInfo()
  29394. diagnosis_ids := strings.Split(diagnosis_id, ",")
  29395. var config []*models.HisXtDiagnoseConfig
  29396. for _, item := range diagnosis_ids {
  29397. id, _ := strconv.ParseInt(item, 10, 64)
  29398. if id > 0 {
  29399. diagnosisConfig, _ := service.FindDiagnoseById(id)
  29400. config = append(config, &diagnosisConfig)
  29401. }
  29402. }
  29403. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  29404. sickConfig, _ := service.FindSickById(sick_type)
  29405. var prescriptions []*models.HisPrescription
  29406. var start_time int64
  29407. var end_time int64
  29408. var isSuccess bool = true
  29409. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29410. fmt.Println(his_patient_id)
  29411. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  29412. timestamp := time.Now().Unix()
  29413. tempTime := time.Unix(timestamp, 0)
  29414. timeFormat := tempTime.Format("20060102150405")
  29415. chrgBchno := rand.Intn(100000) + 10000
  29416. new_chrg_bchno := ""
  29417. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  29418. new_chrg_bchno = chrg_bchno
  29419. if adminUser.CurrentOrgId == 10265 {
  29420. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  29421. new_chrg_bchno = "0000"
  29422. }
  29423. }
  29424. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29425. var patientPrescription models.HisPrescriptionInfo
  29426. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  29427. if patientPrescription.ID == 0 {
  29428. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  29429. }
  29430. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29431. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  29432. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  29433. strconv.FormatInt(his.PatientId, 10)
  29434. var res2406 Result2406
  29435. //安徽单病种处理
  29436. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  29437. data := make(map[string]interface{})
  29438. client := &http.Client{}
  29439. data["psn_no"] = his.PsnNo
  29440. data["mdtrt_id"] = his.Number
  29441. data["operator"] = roles.UserName
  29442. data["cert_no"] = his.IdCardNo
  29443. data["org_name"] = miConfig.OrgName
  29444. data["psn_name"] = his.Name
  29445. data["ipt_otp_no"] = his.IptOtpNo
  29446. data["ipt_psn_sp_flag_type"] = "0901"
  29447. data["ipt_psn_sp_flag"] = "1"
  29448. data["fixmedins_code"] = miConfig.Code
  29449. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29450. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29451. data["url"] = miConfig.Url
  29452. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  29453. bytesData, _ := json.Marshal(data)
  29454. var req *http.Request
  29455. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  29456. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  29457. resp, _ := client.Do(req)
  29458. defer resp.Body.Close()
  29459. body, ioErr := ioutil.ReadAll(resp.Body)
  29460. if ioErr != nil {
  29461. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29463. return
  29464. }
  29465. var respJSON map[string]interface{}
  29466. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29467. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29469. return
  29470. }
  29471. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29472. if status == "0" {
  29473. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29474. c.ServeSuccessJSON(map[string]interface{}{
  29475. "failed_code": -10,
  29476. "msg": err_msg,
  29477. })
  29478. return
  29479. }
  29480. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29481. userJSONBytes, _ := json.Marshal(respJSON)
  29482. fmt.Println("log")
  29483. fmt.Println(string(userJSONBytes))
  29484. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  29485. utils.ErrorLog("解析失败:%v", err)
  29486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29487. return
  29488. }
  29489. } else if miConfig.MdtrtareaAdmvs == "340699" && reg_type == 992102 {
  29490. data := make(map[string]interface{})
  29491. client := &http.Client{}
  29492. data["psn_no"] = his.PsnNo
  29493. data["mdtrt_id"] = his.Number
  29494. data["operator"] = roles.UserName
  29495. data["cert_no"] = his.IdCardNo
  29496. data["org_name"] = miConfig.OrgName
  29497. data["psn_name"] = his.Name
  29498. data["ipt_otp_no"] = his.IptOtpNo
  29499. data["ipt_psn_sp_flag_type"] = "0901"
  29500. data["ipt_psn_sp_flag"] = "1"
  29501. data["fixmedins_code"] = miConfig.Code
  29502. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29503. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29504. data["url"] = miConfig.Url
  29505. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  29506. bytesData, _ := json.Marshal(data)
  29507. var req *http.Request
  29508. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  29509. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  29510. resp, _ := client.Do(req)
  29511. defer resp.Body.Close()
  29512. body, ioErr := ioutil.ReadAll(resp.Body)
  29513. if ioErr != nil {
  29514. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29516. return
  29517. }
  29518. var respJSON map[string]interface{}
  29519. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29520. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29522. return
  29523. }
  29524. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29525. if status == "0" {
  29526. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29527. c.ServeSuccessJSON(map[string]interface{}{
  29528. "failed_code": -10,
  29529. "msg": err_msg,
  29530. })
  29531. return
  29532. }
  29533. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29534. userJSONBytes, _ := json.Marshal(respJSON)
  29535. fmt.Println("log")
  29536. fmt.Println(string(userJSONBytes))
  29537. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  29538. utils.ErrorLog("解析失败:%v", err)
  29539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29540. return
  29541. }
  29542. }
  29543. if res2406.Infcode != 0 {
  29544. adminUser := c.GetAdminUserInfo()
  29545. errlog := &models.HisOrderError{
  29546. UserOrgId: adminUser.CurrentOrgId,
  29547. Ctime: time.Now().Unix(),
  29548. Mtime: time.Now().Unix(),
  29549. ErrMsg: res2406.ErrMsg,
  29550. Status: 1,
  29551. PatientId: id,
  29552. RecordTime: recordDateTime,
  29553. Stage: 3,
  29554. }
  29555. service.CreateErrMsgLog(errlog)
  29556. c.ServeSuccessJSON(map[string]interface{}{
  29557. "failed_code": -10,
  29558. "msg": res2406.ErrMsg,
  29559. })
  29560. return
  29561. }
  29562. var res2 ResultSix
  29563. var res3 GZResultSix
  29564. var resSix10265 ResultSix10265
  29565. //var time_stamp string
  29566. if miConfig.MdtrtareaAdmvs == "421300" {
  29567. data := make(map[string]interface{})
  29568. client := &http.Client{}
  29569. data["psn_no"] = his.PsnNo
  29570. data["mdtrt_id"] = his.Number
  29571. data["department"] = department.Name
  29572. data["org_name"] = miConfig.OrgName
  29573. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29574. data["doctor_id"] = doctor_info.DoctorNumber
  29575. data["doctor_name"] = roles.UserName
  29576. data["fixmedins_code"] = miConfig.Code
  29577. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29578. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29579. data["secret_key"] = miConfig.SecretKey
  29580. data["sick_code"] = sickConfig.CountryCode
  29581. data["sick_name"] = sickConfig.ClassName
  29582. data["begin_time"] = begin_time
  29583. data["dept"] = strconv.FormatInt(department.ID, 10)
  29584. data["config"] = config
  29585. data["opter"] = roles.UserName
  29586. fmt.Println(data)
  29587. bytesData, _ := json.Marshal(data)
  29588. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  29589. resp, _ := client.Do(req)
  29590. defer resp.Body.Close()
  29591. body, ioErr := ioutil.ReadAll(resp.Body)
  29592. if ioErr != nil {
  29593. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29595. return
  29596. }
  29597. var respJSON map[string]interface{}
  29598. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29599. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29601. return
  29602. }
  29603. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29604. userJSONBytes, _ := json.Marshal(respJSON)
  29605. fmt.Println("log")
  29606. fmt.Println(string(userJSONBytes))
  29607. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29608. utils.ErrorLog("解析失败:%v", err)
  29609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29610. return
  29611. }
  29612. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29613. data := make(map[string]interface{})
  29614. client := &http.Client{}
  29615. data["psn_no"] = his.PsnNo
  29616. data["mdtrt_id"] = his.Number
  29617. data["department"] = department.Name
  29618. data["org_name"] = miConfig.OrgName
  29619. if reg_type == 11 && his.Insutype == "390" {
  29620. data["med_type"] = "110104"
  29621. } else {
  29622. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29623. }
  29624. data["doctor_id"] = doctor_info.DoctorNumber
  29625. data["doctor_name"] = roles.UserName
  29626. data["fixmedins_code"] = miConfig.Code
  29627. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29628. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29629. data["secret_key"] = miConfig.SecretKey
  29630. data["sick_code"] = sickConfig.CountryCode
  29631. data["sick_name"] = sickConfig.ClassName
  29632. data["begin_time"] = begin_time
  29633. data["dept"] = strconv.FormatInt(department.ID, 10)
  29634. data["config"] = config
  29635. data["opter"] = roles.UserName
  29636. fmt.Println(data)
  29637. bytesData, _ := json.Marshal(data)
  29638. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  29639. resp, _ := client.Do(req)
  29640. defer resp.Body.Close()
  29641. body, ioErr := ioutil.ReadAll(resp.Body)
  29642. if ioErr != nil {
  29643. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29645. return
  29646. }
  29647. var respJSON map[string]interface{}
  29648. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29649. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29651. return
  29652. }
  29653. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29654. userJSONBytes, _ := json.Marshal(respJSON)
  29655. fmt.Println("log")
  29656. fmt.Println(string(userJSONBytes))
  29657. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29658. utils.ErrorLog("解析失败:%v", err)
  29659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29660. return
  29661. }
  29662. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29663. data := make(map[string]interface{})
  29664. client := &http.Client{}
  29665. data["psn_no"] = his.PsnNo
  29666. data["mdtrt_id"] = his.Number
  29667. data["department"] = department.Name
  29668. data["org_name"] = miConfig.OrgName
  29669. if reg_type == 11 && his.Insutype == "390" {
  29670. data["med_type"] = "110104"
  29671. } else {
  29672. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29673. }
  29674. data["doctor_id"] = doctor_info.DoctorNumber
  29675. data["doctor_name"] = roles.UserName
  29676. data["fixmedins_code"] = miConfig.Code
  29677. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29678. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29679. data["secret_key"] = miConfig.SecretKey
  29680. data["sick_code"] = sickConfig.CountryCode
  29681. data["sick_name"] = sickConfig.ClassName
  29682. data["begin_time"] = begin_time
  29683. data["dept"] = strconv.FormatInt(department.ID, 10)
  29684. data["config"] = config
  29685. data["opter"] = roles.UserName
  29686. fmt.Println(data)
  29687. bytesData, _ := json.Marshal(data)
  29688. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  29689. resp, _ := client.Do(req)
  29690. defer resp.Body.Close()
  29691. body, ioErr := ioutil.ReadAll(resp.Body)
  29692. if ioErr != nil {
  29693. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29695. return
  29696. }
  29697. var respJSON map[string]interface{}
  29698. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29699. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29701. return
  29702. }
  29703. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29704. userJSONBytes, _ := json.Marshal(respJSON)
  29705. fmt.Println("log")
  29706. fmt.Println(string(userJSONBytes))
  29707. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29708. utils.ErrorLog("解析失败:%v", err)
  29709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29710. return
  29711. }
  29712. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29713. data := make(map[string]interface{})
  29714. client := &http.Client{}
  29715. data["psn_no"] = his.PsnNo
  29716. data["mdtrt_id"] = his.Number
  29717. data["department"] = department.Name
  29718. data["org_name"] = miConfig.OrgName
  29719. if reg_type == 11 && his.Insutype == "390" {
  29720. data["med_type"] = "110104"
  29721. } else {
  29722. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29723. }
  29724. data["doctor_id"] = doctor_info.DoctorNumber
  29725. data["doctor_name"] = roles.UserName
  29726. data["fixmedins_code"] = miConfig.Code
  29727. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29728. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29729. data["secret_key"] = miConfig.SecretKey
  29730. data["sick_code"] = sickConfig.CountryCode
  29731. data["sick_name"] = sickConfig.ClassName
  29732. data["begin_time"] = begin_time
  29733. data["dept"] = strconv.FormatInt(department.ID, 10)
  29734. data["config"] = config
  29735. data["opter"] = roles.UserName
  29736. fmt.Println(data)
  29737. bytesData, _ := json.Marshal(data)
  29738. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  29739. resp, _ := client.Do(req)
  29740. defer resp.Body.Close()
  29741. body, ioErr := ioutil.ReadAll(resp.Body)
  29742. if ioErr != nil {
  29743. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29745. return
  29746. }
  29747. var respJSON map[string]interface{}
  29748. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29749. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29751. return
  29752. }
  29753. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29754. userJSONBytes, _ := json.Marshal(respJSON)
  29755. fmt.Println("log")
  29756. fmt.Println(string(userJSONBytes))
  29757. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29758. utils.ErrorLog("解析失败:%v", err)
  29759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29760. return
  29761. }
  29762. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  29763. utils.ErrorLog("解析失败:%v", doctor_info)
  29764. data := make(map[string]interface{})
  29765. client := &http.Client{}
  29766. data["psn_no"] = his.PsnNo
  29767. data["mdtrt_id"] = his.Number
  29768. data["doctor"] = roles.UserName
  29769. data["department"] = department.Name
  29770. data["org_name"] = miConfig.OrgName
  29771. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29772. data["doctor_id"] = doctor_info.DoctorNumber
  29773. data["new_doctor_name"] = doctor_info.UserName
  29774. data["fixmedins_code"] = miConfig.Code
  29775. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29776. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29777. data["secret_key"] = miConfig.SecretKey
  29778. data["sick_code"] = sickConfig.CountryCode
  29779. data["sick_name"] = sickConfig.ClassName
  29780. data["url"] = miConfig.Url
  29781. data["ak"] = miConfig.AccessKey
  29782. data["begin_time"] = begin_time
  29783. data["cainfo"] = miConfig.Cainfo
  29784. data["dept"] = strconv.FormatInt(department.ID, 10)
  29785. data["config"] = config
  29786. bytesData, _ := json.Marshal(data)
  29787. var req *http.Request
  29788. if miConfig.MdtrtareaAdmvs == "320830" {
  29789. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2203", bytes.NewReader(bytesData))
  29790. } else if miConfig.MdtrtareaAdmvs == "320921" {
  29791. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  29792. } else {
  29793. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  29794. }
  29795. resp, _ := client.Do(req)
  29796. defer resp.Body.Close()
  29797. body, ioErr := ioutil.ReadAll(resp.Body)
  29798. if ioErr != nil {
  29799. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29801. return
  29802. }
  29803. var respJSON map[string]interface{}
  29804. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29805. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29807. return
  29808. }
  29809. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  29810. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  29811. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  29812. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29813. userJSONBytes, _ := json.Marshal(respJSON)
  29814. fmt.Println("log")
  29815. fmt.Println(string(userJSONBytes))
  29816. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  29817. utils.ErrorLog("解析失败:%v", err)
  29818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29819. return
  29820. }
  29821. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29822. res2.Output = resSix10265.Output
  29823. res2.ErrMsg = resSix10265.ErrMsg
  29824. res2.Cainfo = resSix10265.Cainfo
  29825. res2.WarnMsg = resSix10265.WarnMsg
  29826. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29827. res2.Infcode = infocode
  29828. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29829. data := make(map[string]interface{})
  29830. client := &http.Client{}
  29831. data["psn_no"] = his.PsnNo
  29832. data["mdtrt_id"] = his.Number
  29833. data["doctor"] = roles.UserName
  29834. data["department"] = department.Name
  29835. data["org_name"] = miConfig.OrgName
  29836. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29837. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  29838. data["fixmedins_code"] = miConfig.Code
  29839. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29840. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29841. data["secret_key"] = miConfig.SecretKey
  29842. data["sick_code"] = sickConfig.CountryCode
  29843. data["sick_name"] = sickConfig.ClassName
  29844. data["begin_time"] = begin_time
  29845. data["dept"] = strconv.FormatInt(department.ID, 10)
  29846. data["config"] = config
  29847. //data["url"] = miConfig.Url
  29848. //data["ak"] = miConfig.AccessKey
  29849. data["cainfo"] = miConfig.Cainfo
  29850. fmt.Println(data)
  29851. bytesData, _ := json.Marshal(data)
  29852. var req *http.Request
  29853. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  29854. resp, _ := client.Do(req)
  29855. defer resp.Body.Close()
  29856. body, ioErr := ioutil.ReadAll(resp.Body)
  29857. if ioErr != nil {
  29858. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29860. return
  29861. }
  29862. var respJSON map[string]interface{}
  29863. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29866. return
  29867. }
  29868. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  29869. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  29870. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  29871. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29872. userJSONBytes, _ := json.Marshal(respJSON)
  29873. fmt.Println("log")
  29874. fmt.Println(string(userJSONBytes))
  29875. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  29876. utils.ErrorLog("解析失败:%v", err)
  29877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29878. return
  29879. }
  29880. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29881. res2.Output = resSix10265.Output
  29882. res2.ErrMsg = resSix10265.ErrMsg
  29883. res2.Cainfo = resSix10265.Cainfo
  29884. res2.WarnMsg = resSix10265.WarnMsg
  29885. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29886. res2.Infcode = infocode
  29887. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29888. 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)
  29889. saveLog(result, requestLog, "2203", "上传就诊信息")
  29890. var respJSON2 map[string]interface{}
  29891. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29892. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29894. return
  29895. }
  29896. userJSONBytes2, _ := json.Marshal(respJSON2)
  29897. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29898. utils.ErrorLog("解析失败:%v", err)
  29899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29900. return
  29901. }
  29902. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29903. var result string
  29904. var requestLog string
  29905. 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, "")
  29906. saveLog(result, requestLog, "2203", "上传就诊信息")
  29907. var respJSON2 map[string]interface{}
  29908. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29909. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29911. return
  29912. }
  29913. userJSONBytes2, _ := json.Marshal(respJSON2)
  29914. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29915. utils.ErrorLog("解析失败:%v", err)
  29916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29917. return
  29918. }
  29919. } else if miConfig.MdtrtareaAdmvs == "361025" {
  29920. var result string
  29921. var requestLog string
  29922. 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, "")
  29923. saveLog(result, requestLog, "2203", "上传就诊信息")
  29924. var respJSON2 map[string]interface{}
  29925. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29926. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29928. return
  29929. }
  29930. userJSONBytes2, _ := json.Marshal(respJSON2)
  29931. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29932. utils.ErrorLog("解析失败:%v", err)
  29933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29934. return
  29935. }
  29936. } else if miConfig.MdtrtareaAdmvs == "360100" {
  29937. var result string
  29938. var requestLog string
  29939. 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, "")
  29940. saveLog(result, requestLog, "2203", "上传就诊信息")
  29941. var respJSON2 map[string]interface{}
  29942. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29943. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29945. return
  29946. }
  29947. userJSONBytes2, _ := json.Marshal(respJSON2)
  29948. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29949. utils.ErrorLog("解析失败:%v", err)
  29950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29951. return
  29952. }
  29953. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29954. data := make(map[string]interface{})
  29955. client := &http.Client{}
  29956. data["psn_no"] = his.PsnNo
  29957. data["mdtrt_id"] = his.Number
  29958. data["operator"] = roles.UserName
  29959. data["department"] = department.Name
  29960. data["org_name"] = miConfig.OrgName
  29961. var med_type string
  29962. if his.Insutype == "390" {
  29963. if reg_type == 992102 {
  29964. med_type = "992102"
  29965. data["sick_code"] = "ZDZ940"
  29966. data["sick_name"] = "慢性肾衰竭"
  29967. }
  29968. if reg_type == 140104 {
  29969. med_type = "140104"
  29970. data["sick_code"] = sickConfig.CountryCode
  29971. data["sick_name"] = sickConfig.ClassName
  29972. }
  29973. if reg_type == 14 {
  29974. med_type = "140104"
  29975. data["sick_code"] = sickConfig.CountryCode
  29976. data["sick_name"] = sickConfig.ClassName
  29977. }
  29978. if reg_type == 1104 {
  29979. med_type = "1104"
  29980. data["sick_code"] = sickConfig.CountryCode
  29981. data["sick_name"] = sickConfig.ClassName
  29982. }
  29983. } else if his.Insutype == "310" {
  29984. if reg_type == 992102 {
  29985. med_type = "992102"
  29986. data["sick_code"] = "ZDZ940"
  29987. data["sick_name"] = "慢性肾衰竭"
  29988. }
  29989. if reg_type == 140104 {
  29990. med_type = "140104"
  29991. data["sick_code"] = sickConfig.CountryCode
  29992. data["sick_name"] = sickConfig.ClassName
  29993. }
  29994. if reg_type == 14 {
  29995. med_type = "14"
  29996. data["sick_code"] = sickConfig.CountryCode
  29997. data["sick_name"] = sickConfig.ClassName
  29998. }
  29999. if reg_type == 1104 {
  30000. med_type = "1104"
  30001. data["sick_code"] = sickConfig.CountryCode
  30002. data["sick_name"] = sickConfig.ClassName
  30003. }
  30004. }
  30005. data["med_type"] = med_type
  30006. data["doctor_number"] = doctor_info.DoctorNumber
  30007. data["doctor_name"] = doctor_info.UserName
  30008. data["fixmedins_code"] = miConfig.Code
  30009. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30010. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30011. data["secret_key"] = miConfig.SecretKey
  30012. data["begin_time"] = begin_time
  30013. data["dept"] = strconv.FormatInt(department.ID, 10)
  30014. data["config"] = config
  30015. data["url"] = miConfig.Url
  30016. data["ak"] = miConfig.AccessKey
  30017. data["cainfo"] = miConfig.Cainfo
  30018. bytesData, _ := json.Marshal(data)
  30019. var req *http.Request
  30020. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  30021. resp, _ := client.Do(req)
  30022. defer resp.Body.Close()
  30023. body, ioErr := ioutil.ReadAll(resp.Body)
  30024. if ioErr != nil {
  30025. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30027. return
  30028. }
  30029. var respJSON map[string]interface{}
  30030. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30031. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30033. return
  30034. }
  30035. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30036. if status == "0" {
  30037. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30038. c.ServeSuccessJSON(map[string]interface{}{
  30039. "failed_code": -10,
  30040. "msg": err_msg,
  30041. })
  30042. return
  30043. }
  30044. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30045. userJSONBytes, _ := json.Marshal(respJSON)
  30046. fmt.Println("log")
  30047. fmt.Println(string(userJSONBytes))
  30048. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30049. utils.ErrorLog("解析失败:%v", err)
  30050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30051. return
  30052. }
  30053. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30054. data := make(map[string]interface{})
  30055. client := &http.Client{}
  30056. data["psn_no"] = his.PsnNo
  30057. data["mdtrt_id"] = his.Number
  30058. data["operator"] = roles.UserName
  30059. data["department"] = department.Name
  30060. data["org_name"] = miConfig.OrgName
  30061. var med_type string
  30062. if his.Insutype == "390" {
  30063. if reg_type == 992102 {
  30064. med_type = "992102"
  30065. data["sick_code"] = sickConfig.CountryCode
  30066. data["sick_name"] = sickConfig.ClassName
  30067. }
  30068. if reg_type == 140104 {
  30069. med_type = "140104"
  30070. data["sick_code"] = sickConfig.CountryCode
  30071. data["sick_name"] = sickConfig.ClassName
  30072. }
  30073. if reg_type == 140201 {
  30074. med_type = "140201"
  30075. data["sick_code"] = sickConfig.CountryCode
  30076. data["sick_name"] = sickConfig.ClassName
  30077. }
  30078. if reg_type == 14 {
  30079. med_type = "14"
  30080. data["sick_code"] = sickConfig.CountryCode
  30081. data["sick_name"] = sickConfig.ClassName
  30082. }
  30083. if reg_type == 11 {
  30084. med_type = "11"
  30085. data["sick_code"] = sickConfig.CountryCode
  30086. data["sick_name"] = sickConfig.ClassName
  30087. }
  30088. } else if his.Insutype == "310" {
  30089. if reg_type == 992102 {
  30090. med_type = "992102"
  30091. data["sick_code"] = sickConfig.CountryCode
  30092. data["sick_name"] = sickConfig.ClassName
  30093. }
  30094. if reg_type == 140104 {
  30095. med_type = "140104"
  30096. data["sick_code"] = sickConfig.CountryCode
  30097. data["sick_name"] = sickConfig.ClassName
  30098. }
  30099. if reg_type == 140201 {
  30100. med_type = "140201"
  30101. data["sick_code"] = sickConfig.CountryCode
  30102. data["sick_name"] = sickConfig.ClassName
  30103. }
  30104. if reg_type == 14 {
  30105. med_type = "14"
  30106. data["sick_code"] = sickConfig.CountryCode
  30107. data["sick_name"] = sickConfig.ClassName
  30108. }
  30109. if reg_type == 11 {
  30110. med_type = "11"
  30111. data["sick_code"] = sickConfig.CountryCode
  30112. data["sick_name"] = sickConfig.ClassName
  30113. }
  30114. }
  30115. data["med_type"] = med_type
  30116. data["doctor_number"] = doctor_info.DoctorNumber
  30117. data["doctor_name"] = doctor_info.UserName
  30118. data["fixmedins_code"] = miConfig.Code
  30119. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30120. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30121. data["secret_key"] = miConfig.SecretKey
  30122. data["begin_time"] = begin_time
  30123. data["dept"] = strconv.FormatInt(department.ID, 10)
  30124. data["config"] = config
  30125. data["url"] = miConfig.Url
  30126. data["ak"] = miConfig.AccessKey
  30127. data["cainfo"] = miConfig.Cainfo
  30128. bytesData, _ := json.Marshal(data)
  30129. var req *http.Request
  30130. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  30131. resp, _ := client.Do(req)
  30132. defer resp.Body.Close()
  30133. body, ioErr := ioutil.ReadAll(resp.Body)
  30134. if ioErr != nil {
  30135. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30137. return
  30138. }
  30139. var respJSON map[string]interface{}
  30140. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30141. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30143. return
  30144. }
  30145. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30146. if status == "0" {
  30147. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30148. c.ServeSuccessJSON(map[string]interface{}{
  30149. "failed_code": -10,
  30150. "msg": err_msg,
  30151. })
  30152. return
  30153. }
  30154. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30155. userJSONBytes, _ := json.Marshal(respJSON)
  30156. fmt.Println("log")
  30157. fmt.Println(string(userJSONBytes))
  30158. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30159. utils.ErrorLog("解析失败:%v", err)
  30160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30161. return
  30162. }
  30163. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30164. var result string
  30165. var requestLog string
  30166. 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)
  30167. saveLog(result, requestLog, "2203", "上传就诊信息")
  30168. var respJSON2 map[string]interface{}
  30169. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30170. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30172. return
  30173. }
  30174. userJSONBytes2, _ := json.Marshal(respJSON2)
  30175. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30176. utils.ErrorLog("解析失败:%v", err)
  30177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30178. return
  30179. }
  30180. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30181. data := make(map[string]interface{})
  30182. client := &http.Client{}
  30183. data["psn_no"] = his.PsnNo
  30184. data["mdtrt_id"] = his.Number
  30185. data["doctor"] = roles.UserName
  30186. data["department"] = department.Name
  30187. data["org_name"] = miConfig.OrgName
  30188. data["med_type"] = strconv.FormatInt(reg_type, 10)
  30189. data["doctor_id"] = doctor_info.DoctorNumber
  30190. data["fixmedins_code"] = miConfig.Code
  30191. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30192. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30193. data["secret_key"] = miConfig.SecretKey
  30194. data["sick_code"] = sickConfig.CountryCode
  30195. data["sick_name"] = sickConfig.ClassName
  30196. data["begin_time"] = begin_time
  30197. data["new_doctor_name"] = doctor_info.UserName
  30198. data["dept"] = strconv.FormatInt(department.ID, 10)
  30199. data["config"] = config
  30200. bytesData, _ := json.Marshal(data)
  30201. var req *http.Request
  30202. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  30203. resp, _ := client.Do(req)
  30204. defer resp.Body.Close()
  30205. body, ioErr := ioutil.ReadAll(resp.Body)
  30206. if ioErr != nil {
  30207. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30209. return
  30210. }
  30211. var respJSON map[string]interface{}
  30212. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30213. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30215. return
  30216. }
  30217. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30218. userJSONBytes, _ := json.Marshal(respJSON)
  30219. fmt.Println("log")
  30220. fmt.Println(string(userJSONBytes))
  30221. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30222. utils.ErrorLog("解析失败:%v", err)
  30223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30224. return
  30225. }
  30226. } else {
  30227. var result string
  30228. var requestLog string
  30229. if miConfig.MdtrtareaAdmvs == "440781" { //
  30230. 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)
  30231. } else {
  30232. if miConfig.Code == "H15049901371" {
  30233. //赤峰地区国家医保医疗类别
  30234. //职工透析:医疗类别选特殊情况门诊990502
  30235. //居民定额血透门慢: 医疗类别选门诊慢病140104
  30236. var med_type string
  30237. if his.Insutype == "390" {
  30238. if reg_type == 14 {
  30239. med_type = "9933"
  30240. } else if reg_type == 11 {
  30241. med_type = "11"
  30242. }
  30243. } else if his.Insutype == "310" {
  30244. if reg_type == 14 {
  30245. med_type = "990502"
  30246. } else if reg_type == 11 {
  30247. med_type = "11"
  30248. }
  30249. }
  30250. 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)
  30251. } else {
  30252. 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)
  30253. }
  30254. saveLog(result, requestLog, "2203", "上传就诊信息")
  30255. var respJSON2 map[string]interface{}
  30256. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30257. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30259. return
  30260. }
  30261. userJSONBytes2, _ := json.Marshal(respJSON2)
  30262. if miConfig.Code == "H15049901371" {
  30263. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  30264. utils.ErrorLog("解析失败:%v", err)
  30265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30266. return
  30267. }
  30268. res2.InfRefmsgid = resSix10265.InfRefmsgid
  30269. res2.Output = resSix10265.Output
  30270. res2.ErrMsg = resSix10265.ErrMsg
  30271. res2.Cainfo = resSix10265.Cainfo
  30272. res2.WarnMsg = resSix10265.WarnMsg
  30273. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30274. res2.Infcode = infocode
  30275. } else {
  30276. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  30277. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  30278. utils.ErrorLog("解析失败:%v", err)
  30279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30280. return
  30281. }
  30282. res2.Infcode = res3.Infcode
  30283. } else {
  30284. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30285. utils.ErrorLog("解析失败:%v", err)
  30286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30287. return
  30288. }
  30289. }
  30290. }
  30291. }
  30292. }
  30293. if res2.Infcode == -1 {
  30294. adminUser := c.GetAdminUserInfo()
  30295. errlog := &models.HisOrderError{
  30296. UserOrgId: adminUser.CurrentOrgId,
  30297. Ctime: time.Now().Unix(),
  30298. Mtime: time.Now().Unix(),
  30299. ErrMsg: res2.ErrMsg,
  30300. Status: 1,
  30301. PatientId: id,
  30302. RecordTime: recordDateTime,
  30303. Stage: 3,
  30304. }
  30305. service.CreateErrMsgLog(errlog)
  30306. c.ServeSuccessJSON(map[string]interface{}{
  30307. "failed_code": -10,
  30308. "msg": res2.ErrMsg,
  30309. })
  30310. return
  30311. }
  30312. if res2.Infcode != 0 {
  30313. adminUser := c.GetAdminUserInfo()
  30314. errlog := &models.HisOrderError{
  30315. UserOrgId: adminUser.CurrentOrgId,
  30316. Ctime: time.Now().Unix(),
  30317. Mtime: time.Now().Unix(),
  30318. ErrMsg: res2.ErrMsg,
  30319. Status: 1,
  30320. PatientId: id,
  30321. RecordTime: recordDateTime,
  30322. Stage: 3,
  30323. }
  30324. service.CreateErrMsgLog(errlog)
  30325. c.ServeSuccessJSON(map[string]interface{}{
  30326. "failed_code": -10,
  30327. "msg": res2.ErrMsg,
  30328. })
  30329. return
  30330. } else {
  30331. his.Diagnosis = diagnosis_id
  30332. his.SickType = sickConfig.ID
  30333. his.PType = fmt.Sprintf("%d", reg_type)
  30334. service.UpdateHisPatientThree(&his)
  30335. data := make(map[string]interface{})
  30336. if settle_accounts_type == 1 { //日结
  30337. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  30338. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  30339. } else {
  30340. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  30341. }
  30342. data["pre"] = prescriptions
  30343. } else { //月结
  30344. start_time_str := c.GetString("start_time")
  30345. end_time_str := c.GetString("end_time")
  30346. timeLayout := "2006-01-02"
  30347. loc, _ := time.LoadLocation("Local")
  30348. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  30349. if err != nil {
  30350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30351. return
  30352. }
  30353. recordStartTime := theStartTime.Unix()
  30354. start_time = recordStartTime
  30355. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  30356. if err != nil {
  30357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30358. return
  30359. }
  30360. recordEndTime := theEndTime.Unix()
  30361. end_time = recordEndTime
  30362. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  30363. data["pre"] = prescriptions
  30364. }
  30365. client := &http.Client{}
  30366. data["psn_no"] = his.PsnNo
  30367. data["mdtrt_id"] = his.Number
  30368. data["chrg_bchno"] = new_chrg_bchno
  30369. data["org_name"] = miConfig.OrgName
  30370. data["doctor"] = doctor_info.UserName
  30371. data["doctor_id"] = doctor_info.DoctorNumber
  30372. data["dept"] = department.Name
  30373. data["fixmedins_code"] = miConfig.Code
  30374. data["opter"] = roles.UserName
  30375. data["dept_code"] = department.Number
  30376. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30377. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30378. data["secret_key"] = miConfig.SecretKey
  30379. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  30380. data["url"] = miConfig.Url
  30381. data["ak"] = miConfig.AccessKey
  30382. data["new_doctor_name"] = patientPrescription.Doctor
  30383. if his.Insutype == "390" {
  30384. if reg_type == 992102 {
  30385. data["diag_code"] = "ZDZ940"
  30386. }
  30387. if reg_type == 140104 {
  30388. data["diag_code"] = sickConfig.CountryCode
  30389. }
  30390. if reg_type == 140201 {
  30391. data["diag_code"] = sickConfig.CountryCode
  30392. }
  30393. if reg_type == 14 {
  30394. data["diag_code"] = sickConfig.CountryCode
  30395. }
  30396. if reg_type == 1104 {
  30397. data["diag_code"] = sickConfig.CountryCode
  30398. }
  30399. } else if his.Insutype == "310" {
  30400. if miConfig.MdtrtareaAdmvs == "341203" {
  30401. if reg_type == 992102 {
  30402. data["diag_code"] = "ZDZ940"
  30403. }
  30404. if reg_type != 992102 {
  30405. data["diag_code"] = sickConfig.CountryCode
  30406. }
  30407. } else {
  30408. data["diag_code"] = sickConfig.CountryCode
  30409. }
  30410. }
  30411. data["cainfo"] = miConfig.Cainfo
  30412. data["opter"] = roles.UserName
  30413. var ids []int64
  30414. for _, item := range prescriptions {
  30415. ids = append(ids, item.ID)
  30416. }
  30417. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30418. if config.IsOpen == 1 { //对接了医保,走医保流程
  30419. var res ResultFour
  30420. var resFour10265 ResultFour10265
  30421. if miConfig.MdtrtareaAdmvs == "421300" {
  30422. bytesData, _ := json.Marshal(data)
  30423. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  30424. resp, _ := client.Do(req)
  30425. defer resp.Body.Close()
  30426. body, ioErr := ioutil.ReadAll(resp.Body)
  30427. if ioErr != nil {
  30428. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30430. return
  30431. }
  30432. var respJSON map[string]interface{}
  30433. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30434. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30436. return
  30437. }
  30438. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30439. userJSONBytes, _ := json.Marshal(respJSON)
  30440. fmt.Println("log")
  30441. fmt.Println(string(userJSONBytes))
  30442. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30443. utils.ErrorLog("解析失败:%v", err)
  30444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30445. return
  30446. }
  30447. } else if miConfig.MdtrtareaAdmvs == "420200" {
  30448. bytesData, _ := json.Marshal(data)
  30449. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  30450. resp, _ := client.Do(req)
  30451. defer resp.Body.Close()
  30452. body, ioErr := ioutil.ReadAll(resp.Body)
  30453. if ioErr != nil {
  30454. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30456. return
  30457. }
  30458. var respJSON map[string]interface{}
  30459. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30460. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30462. return
  30463. }
  30464. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30465. userJSONBytes, _ := json.Marshal(respJSON)
  30466. fmt.Println("log")
  30467. fmt.Println(string(userJSONBytes))
  30468. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30469. utils.ErrorLog("解析失败:%v", err)
  30470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30471. return
  30472. }
  30473. } else if miConfig.MdtrtareaAdmvs == "420902" {
  30474. bytesData, _ := json.Marshal(data)
  30475. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  30476. resp, _ := client.Do(req)
  30477. defer resp.Body.Close()
  30478. body, ioErr := ioutil.ReadAll(resp.Body)
  30479. if ioErr != nil {
  30480. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30482. return
  30483. }
  30484. var respJSON map[string]interface{}
  30485. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30486. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30488. return
  30489. }
  30490. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30491. userJSONBytes, _ := json.Marshal(respJSON)
  30492. fmt.Println("log")
  30493. fmt.Println(string(userJSONBytes))
  30494. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30495. utils.ErrorLog("解析失败:%v", err)
  30496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30497. return
  30498. }
  30499. } else if miConfig.MdtrtareaAdmvs == "421182" {
  30500. bytesData, _ := json.Marshal(data)
  30501. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  30502. resp, _ := client.Do(req)
  30503. defer resp.Body.Close()
  30504. body, ioErr := ioutil.ReadAll(resp.Body)
  30505. if ioErr != nil {
  30506. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30508. return
  30509. }
  30510. var respJSON map[string]interface{}
  30511. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30512. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30514. return
  30515. }
  30516. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30517. userJSONBytes, _ := json.Marshal(respJSON)
  30518. fmt.Println("log")
  30519. fmt.Println(string(userJSONBytes))
  30520. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30521. utils.ErrorLog("解析失败:%v", err)
  30522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30523. return
  30524. }
  30525. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  30526. var result3101 Result3101
  30527. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30528. result3101.Infcode = "0"
  30529. if result3101.Infcode == "0" {
  30530. if len(result3101.Output.Result) > 0 {
  30531. var errMsgs []string
  30532. for _, item := range result3101.Output.Result {
  30533. errMsgs = append(errMsgs, item.VolaCont)
  30534. }
  30535. c.ServeSuccessJSON(map[string]interface{}{
  30536. "failed_code": -10,
  30537. "msg": errMsgs,
  30538. })
  30539. return
  30540. } else {
  30541. if miConfig.MdtrtareaAdmvs == "320921" {
  30542. data["doctor_id"] = doctor_info.DoctorNumber
  30543. } else {
  30544. data["doctor_id"] = doctor_info.DoctorNumber
  30545. }
  30546. bytesData, _ := json.Marshal(data)
  30547. var req *http.Request
  30548. if miConfig.MdtrtareaAdmvs == "320830" {
  30549. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2204", bytes.NewReader(bytesData))
  30550. } else if miConfig.MdtrtareaAdmvs == "320921" {
  30551. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30552. } else {
  30553. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30554. }
  30555. resp, _ := client.Do(req)
  30556. defer resp.Body.Close()
  30557. body, ioErr := ioutil.ReadAll(resp.Body)
  30558. if ioErr != nil {
  30559. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30561. return
  30562. }
  30563. var respJSON map[string]interface{}
  30564. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30565. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30567. return
  30568. }
  30569. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30570. userJSONBytes, _ := json.Marshal(respJSON)
  30571. fmt.Println("log")
  30572. fmt.Println(string(userJSONBytes))
  30573. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  30574. utils.ErrorLog("解析失败:%v", err)
  30575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30576. return
  30577. }
  30578. res.InfRefmsgid = resFour10265.InfRefmsgid
  30579. res.Output = resFour10265.Output
  30580. res.ErrMsg = resFour10265.ErrMsg
  30581. res.Cainfo = resFour10265.Cainfo
  30582. res.WarnMsg = resFour10265.WarnMsg
  30583. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  30584. res.Infcode = infocode
  30585. }
  30586. }
  30587. } else if miConfig.MdtrtareaAdmvs == "150499" {
  30588. var pagesize int = 5
  30589. var start int = 1
  30590. var stop int
  30591. var pagecount int
  30592. var curpage int
  30593. data["doctor_id"] = doctor_info.DoctorNumber
  30594. var res2 ResultFour
  30595. //var result res.
  30596. //总页数,向上取整,注意除之前要先转换类型为float64
  30597. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  30598. for curpage = 1; curpage <= pagecount; curpage++ {
  30599. if curpage == 1 {
  30600. start = 1
  30601. } else {
  30602. start = (curpage-1)*pagesize + 1
  30603. }
  30604. stop = curpage * pagesize
  30605. if stop > len(prescriptions) {
  30606. stop = len(prescriptions)
  30607. }
  30608. //var requestLog string
  30609. data["pre"] = prescriptions[start-1 : stop]
  30610. fmt.Println(data["pre"])
  30611. bytesData, _ := json.Marshal(data)
  30612. var req *http.Request
  30613. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  30614. resp, _ := client.Do(req)
  30615. defer resp.Body.Close()
  30616. body, ioErr := ioutil.ReadAll(resp.Body)
  30617. if ioErr != nil {
  30618. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30620. return
  30621. }
  30622. var respJSON map[string]interface{}
  30623. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30624. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30626. return
  30627. }
  30628. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30629. userJSONBytes, _ := json.Marshal(respJSON)
  30630. fmt.Println("log")
  30631. fmt.Println(string(userJSONBytes))
  30632. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  30633. utils.ErrorLog("解析失败:%v", err)
  30634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30635. return
  30636. }
  30637. res.InfRefmsgid = resFour10265.InfRefmsgid
  30638. res.Output = resFour10265.Output
  30639. res.ErrMsg = resFour10265.ErrMsg
  30640. res.Cainfo = resFour10265.Cainfo
  30641. res.WarnMsg = resFour10265.WarnMsg
  30642. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  30643. res.Infcode = infocode
  30644. if infocode == 0 {
  30645. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  30646. } else {
  30647. isSuccess = false
  30648. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  30649. res.Infcode = -1
  30650. res.ErrMsg = resFour10265.ErrMsg
  30651. errlog := &models.HisOrderError{
  30652. UserOrgId: adminUser.CurrentOrgId,
  30653. Ctime: time.Now().Unix(),
  30654. Mtime: time.Now().Unix(),
  30655. Number: chrg_bchno,
  30656. ErrMsg: "",
  30657. Status: 1,
  30658. PatientId: id,
  30659. RecordTime: recordDateTime,
  30660. Stage: 4,
  30661. }
  30662. service.CreateErrMsgLog(errlog)
  30663. }
  30664. }
  30665. if isSuccess {
  30666. res.Infcode = 0
  30667. res.Output.Result = res2.Output.Result
  30668. } else {
  30669. order := &models.HisOrder{
  30670. UserOrgId: adminUser.CurrentOrgId,
  30671. HisPatientId: his.ID,
  30672. PatientId: his.PatientId,
  30673. SettleAccountsDate: recordDateTime,
  30674. Ctime: time.Now().Unix(),
  30675. Mtime: time.Now().Unix(),
  30676. MdtrtId: his.Number,
  30677. PsnNo: his.PsnNo,
  30678. MedType: strconv.FormatInt(reg_type, 10),
  30679. Status: 1,
  30680. Number: chrg_bchno,
  30681. Infcode: res.Infcode,
  30682. WarnMsg: res.WarnMsg,
  30683. Cainfo: res.Cainfo,
  30684. ErrMsg: res.ErrMsg,
  30685. RespondTime: res.RefmsgTime,
  30686. InfRefmsgid: res.InfRefmsgid,
  30687. OrderStatus: 1,
  30688. IsMedicineInsurance: 1,
  30689. SettleType: settle_accounts_type,
  30690. SettleStartTime: start_time,
  30691. SettleEndTime: end_time,
  30692. Creator: roles.AdminUserId,
  30693. Modify: roles.AdminUserId,
  30694. PType: 2,
  30695. Diagnosis: diagnosis_id,
  30696. }
  30697. err = service.CreateOrder(order)
  30698. if err != nil {
  30699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  30700. return
  30701. }
  30702. c.ServeSuccessJSON(map[string]interface{}{
  30703. "failed_code": -10,
  30704. "msg": res2.ErrMsg,
  30705. })
  30706. return
  30707. }
  30708. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30709. 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)
  30710. var dat map[string]interface{}
  30711. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30712. fmt.Println(dat)
  30713. } else {
  30714. fmt.Println(err)
  30715. }
  30716. saveLog(result, request_log, "2204", "上传费用明细")
  30717. userJSONBytes, _ := json.Marshal(dat)
  30718. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30719. utils.ErrorLog("解析失败:%v", err)
  30720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30721. return
  30722. }
  30723. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30724. 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, "", "")
  30725. var dat map[string]interface{}
  30726. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30727. fmt.Println(dat)
  30728. } else {
  30729. fmt.Println(err)
  30730. }
  30731. saveLog(result, request_log, "2204", "上传费用明细")
  30732. userJSONBytes, _ := json.Marshal(dat)
  30733. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30734. utils.ErrorLog("解析失败:%v", err)
  30735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30736. return
  30737. }
  30738. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30739. 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, "", "")
  30740. var dat map[string]interface{}
  30741. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30742. fmt.Println(dat)
  30743. } else {
  30744. fmt.Println(err)
  30745. }
  30746. saveLog(result, request_log, "2204", "上传费用明细")
  30747. userJSONBytes, _ := json.Marshal(dat)
  30748. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30749. utils.ErrorLog("解析失败:%v", err)
  30750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30751. return
  30752. }
  30753. } else if miConfig.MdtrtareaAdmvs == "360100" {
  30754. 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, "", "")
  30755. var dat map[string]interface{}
  30756. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30757. fmt.Println(dat)
  30758. } else {
  30759. fmt.Println(err)
  30760. }
  30761. saveLog(result, request_log, "2204", "上传费用明细")
  30762. userJSONBytes, _ := json.Marshal(dat)
  30763. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30764. utils.ErrorLog("解析失败:%v", err)
  30765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30766. return
  30767. }
  30768. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30769. bytesData, _ := json.Marshal(data)
  30770. var req *http.Request
  30771. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  30772. resp, _ := client.Do(req)
  30773. defer resp.Body.Close()
  30774. body, ioErr := ioutil.ReadAll(resp.Body)
  30775. if ioErr != nil {
  30776. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30778. return
  30779. }
  30780. var respJSON map[string]interface{}
  30781. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30782. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30784. return
  30785. }
  30786. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30787. if status == "0" {
  30788. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30789. c.ServeSuccessJSON(map[string]interface{}{
  30790. "failed_code": -10,
  30791. "msg": err_msg,
  30792. })
  30793. return
  30794. }
  30795. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30796. userJSONBytes, _ := json.Marshal(respJSON)
  30797. fmt.Println("log")
  30798. fmt.Println(string(userJSONBytes))
  30799. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30800. utils.ErrorLog("解析失败:%v", err)
  30801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30802. return
  30803. }
  30804. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30805. bytesData, _ := json.Marshal(data)
  30806. var req *http.Request
  30807. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  30808. resp, _ := client.Do(req)
  30809. defer resp.Body.Close()
  30810. body, ioErr := ioutil.ReadAll(resp.Body)
  30811. if ioErr != nil {
  30812. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30814. return
  30815. }
  30816. var respJSON map[string]interface{}
  30817. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30818. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30820. return
  30821. }
  30822. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30823. if status == "0" {
  30824. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30825. c.ServeSuccessJSON(map[string]interface{}{
  30826. "failed_code": -10,
  30827. "msg": err_msg,
  30828. })
  30829. return
  30830. }
  30831. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30832. userJSONBytes, _ := json.Marshal(respJSON)
  30833. fmt.Println("log")
  30834. fmt.Println(string(userJSONBytes))
  30835. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30836. utils.ErrorLog("解析失败:%v", err)
  30837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30838. return
  30839. }
  30840. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30841. 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, "", "")
  30842. var dat map[string]interface{}
  30843. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30844. fmt.Println(dat)
  30845. } else {
  30846. fmt.Println(err)
  30847. }
  30848. saveLog(result, request_log, "2204", "上传费用明细")
  30849. userJSONBytes, _ := json.Marshal(dat)
  30850. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30851. utils.ErrorLog("解析失败:%v", err)
  30852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30853. return
  30854. }
  30855. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30856. bytesData, _ := json.Marshal(data)
  30857. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  30858. resp, _ := client.Do(req)
  30859. defer resp.Body.Close()
  30860. body, ioErr := ioutil.ReadAll(resp.Body)
  30861. if ioErr != nil {
  30862. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30864. return
  30865. }
  30866. var respJSON map[string]interface{}
  30867. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30868. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30870. return
  30871. }
  30872. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30873. userJSONBytes, _ := json.Marshal(respJSON)
  30874. fmt.Println("log")
  30875. fmt.Println(string(userJSONBytes))
  30876. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30877. utils.ErrorLog("解析失败:%v", err)
  30878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30879. return
  30880. }
  30881. } else {
  30882. if miConfig.MdtrtareaAdmvs == "441202" {
  30883. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30884. if result3101.Infcode == 0 {
  30885. if len(result3101.Output.Result) > 0 {
  30886. var errMsgs []string
  30887. for _, item := range result3101.Output.Result {
  30888. errMsgs = append(errMsgs, item.VolaCont)
  30889. }
  30890. c.ServeSuccessJSON(map[string]interface{}{
  30891. "failed_code": -10,
  30892. "msg": errMsgs,
  30893. })
  30894. return
  30895. } else {
  30896. 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)
  30897. var dat map[string]interface{}
  30898. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30899. fmt.Println(dat)
  30900. } else {
  30901. fmt.Println(err)
  30902. }
  30903. saveLog(result, request_log, "2204", "上传费用明细")
  30904. userJSONBytes, _ := json.Marshal(dat)
  30905. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30906. utils.ErrorLog("解析失败:%v", err)
  30907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30908. return
  30909. }
  30910. }
  30911. } else {
  30912. c.ServeSuccessJSON(map[string]interface{}{
  30913. "failed_code": -10,
  30914. "msg": result3101.ErrMsg,
  30915. })
  30916. return
  30917. }
  30918. } else if miConfig.MdtrtareaAdmvs == "440205" {
  30919. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30920. if result3101.Infcode == 0 {
  30921. if len(result3101.Output.Result) > 0 {
  30922. var errMsgs []string
  30923. for _, item := range result3101.Output.Result {
  30924. errMsgs = append(errMsgs, item.VolaCont)
  30925. }
  30926. c.ServeSuccessJSON(map[string]interface{}{
  30927. "failed_code": -10,
  30928. "msg": errMsgs,
  30929. })
  30930. return
  30931. } else {
  30932. 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)
  30933. var dat map[string]interface{}
  30934. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30935. fmt.Println(dat)
  30936. } else {
  30937. fmt.Println(err)
  30938. }
  30939. saveLog(result, request_log, "2204", "上传费用明细")
  30940. userJSONBytes, _ := json.Marshal(dat)
  30941. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30942. utils.ErrorLog("解析失败:%v", err)
  30943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30944. return
  30945. }
  30946. }
  30947. } else {
  30948. c.ServeSuccessJSON(map[string]interface{}{
  30949. "failed_code": -10,
  30950. "msg": result3101.ErrMsg,
  30951. })
  30952. return
  30953. }
  30954. } else {
  30955. if miConfig.Code == "H15049901371" {
  30956. 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)
  30957. var dat map[string]interface{}
  30958. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30959. fmt.Println(dat)
  30960. } else {
  30961. fmt.Println(err)
  30962. }
  30963. saveLog(result, request_log, "2204", "上传费用明细")
  30964. userJSONBytes, _ := json.Marshal(dat)
  30965. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  30966. utils.ErrorLog("解析失败:%v", err)
  30967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30968. return
  30969. }
  30970. res.InfRefmsgid = resFour10265.InfRefmsgid
  30971. res.Output = resFour10265.Output
  30972. res.ErrMsg = resFour10265.ErrMsg
  30973. res.Cainfo = resFour10265.Cainfo
  30974. res.WarnMsg = resFour10265.WarnMsg
  30975. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  30976. res.Infcode = infocode
  30977. } else {
  30978. if miConfig.Code == "H44030903432" || miConfig.Code == "H44030501364" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" {
  30979. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30980. if result3101.Infcode == 0 {
  30981. if len(result3101.Output.Result) > 0 {
  30982. c.ServeSuccessJSON(map[string]interface{}{
  30983. "failed_code": -10,
  30984. "failed_type": 100,
  30985. "warm_type": 1,
  30986. "msg": result3101,
  30987. })
  30988. return
  30989. } else {
  30990. 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)
  30991. var dat map[string]interface{}
  30992. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30993. fmt.Println(dat)
  30994. } else {
  30995. fmt.Println(err)
  30996. }
  30997. saveLog(result, request_log, "2204", "上传费用明细")
  30998. userJSONBytes, _ := json.Marshal(dat)
  30999. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31000. utils.ErrorLog("解析失败:%v", err)
  31001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31002. return
  31003. }
  31004. }
  31005. } else {
  31006. c.ServeSuccessJSON(map[string]interface{}{
  31007. "failed_code": -10,
  31008. "msg": result3101.ErrMsg,
  31009. })
  31010. return
  31011. }
  31012. } else {
  31013. 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)
  31014. var dat map[string]interface{}
  31015. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31016. fmt.Println(dat)
  31017. } else {
  31018. fmt.Println(err)
  31019. }
  31020. saveLog(result, request_log, "2204", "上传费用明细")
  31021. userJSONBytes, _ := json.Marshal(dat)
  31022. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31023. utils.ErrorLog("解析失败:%v", err)
  31024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31025. return
  31026. }
  31027. }
  31028. }
  31029. }
  31030. }
  31031. var total_two float64
  31032. if res.Infcode == -1 {
  31033. errlog := &models.HisOrderError{
  31034. UserOrgId: adminUser.CurrentOrgId,
  31035. Ctime: time.Now().Unix(),
  31036. Mtime: time.Now().Unix(),
  31037. Number: chrg_bchno,
  31038. ErrMsg: res.ErrMsg,
  31039. Status: 1,
  31040. PatientId: id,
  31041. RecordTime: recordDateTime,
  31042. Stage: 4,
  31043. }
  31044. service.CreateErrMsgLog(errlog)
  31045. c.ServeSuccessJSON(map[string]interface{}{
  31046. "failed_code": -10,
  31047. "msg": res.ErrMsg,
  31048. })
  31049. return
  31050. }
  31051. if res.Infcode == 0 {
  31052. order := &models.HisOrder{
  31053. UserOrgId: adminUser.CurrentOrgId,
  31054. HisPatientId: his.ID,
  31055. PatientId: his.PatientId,
  31056. SettleAccountsDate: recordDateTime,
  31057. Ctime: time.Now().Unix(),
  31058. Mtime: time.Now().Unix(),
  31059. MdtrtId: his.Number,
  31060. PsnNo: his.PsnNo,
  31061. MedType: strconv.FormatInt(reg_type, 10),
  31062. Status: 1,
  31063. Number: chrg_bchno,
  31064. Infcode: res.Infcode,
  31065. WarnMsg: res.WarnMsg,
  31066. Cainfo: res.Cainfo,
  31067. ErrMsg: res.ErrMsg,
  31068. RespondTime: res.RefmsgTime,
  31069. InfRefmsgid: res.InfRefmsgid,
  31070. OrderStatus: 1,
  31071. IsMedicineInsurance: 1,
  31072. SettleType: settle_accounts_type,
  31073. SettleStartTime: start_time,
  31074. SettleEndTime: end_time,
  31075. Creator: roles.AdminUserId,
  31076. Modify: roles.AdminUserId,
  31077. PType: 2,
  31078. Diagnosis: diagnosis_id,
  31079. }
  31080. err = service.CreateOrder(order)
  31081. if err != nil {
  31082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  31083. return
  31084. }
  31085. for _, item := range res.Output.Result {
  31086. temp := strings.Split(item.FeedetlSn, "-")
  31087. var advice_id int64 = 0
  31088. var project_id int64 = 0
  31089. var types int64 = 0
  31090. id, _ := strconv.ParseInt(temp[2], 10, 64)
  31091. types, _ = strconv.ParseInt(temp[1], 10, 64)
  31092. if temp[1] == "1" {
  31093. advice_id = id
  31094. project_id = 0
  31095. } else if temp[1] == "2" {
  31096. advice_id = 0
  31097. project_id = id
  31098. }
  31099. total_two = total_two + item.DetItemFeeSumamt
  31100. info := &models.HisOrderInfo{
  31101. OrderNumber: order.Number,
  31102. FeedetlSn: item.FeedetlSn,
  31103. UploadDate: time.Now().Unix(),
  31104. AdviceId: advice_id,
  31105. DetItemFeeSumamt: item.DetItemFeeSumamt,
  31106. Cnt: item.Cnt,
  31107. Pric: float64(item.Pric),
  31108. PatientId: his.PatientId,
  31109. PricUplmtAmt: item.PricUplmtAmt,
  31110. SelfpayProp: item.SelfpayProp,
  31111. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  31112. OverlmtAmt: item.OverlmtAmt,
  31113. PreselfpayAmt: item.PreselfpayAmt,
  31114. BasMednFlag: item.BasMednFlag,
  31115. MedChrgitmType: item.MedChrgitmType,
  31116. HiNegoDrugFlag: item.HiNegoDrugFlag,
  31117. Status: 1,
  31118. Memo: item.Memo,
  31119. Mtime: time.Now().Unix(),
  31120. InscpScpAmt: item.InscpScpAmt,
  31121. DrtReimFlag: item.DrtReimFlag,
  31122. Ctime: time.Now().Unix(),
  31123. ListSpItemFlag: item.ListSpItemFlag,
  31124. ChldMedcFlag: item.ChldMedcFlag,
  31125. LmtUsedFlag: item.LmtUsedFlag,
  31126. ChrgitmLv: item.ChrgitmLv,
  31127. UserOrgId: adminUser.CurrentOrgId,
  31128. HisPatientId: his.ID,
  31129. OrderId: order.ID,
  31130. ProjectId: project_id,
  31131. Type: types,
  31132. }
  31133. service.CreateOrderInfo(info)
  31134. }
  31135. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  31136. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  31137. var total float64
  31138. for _, item := range prescriptions {
  31139. if item.Type == 1 { //药品
  31140. for _, subItem := range item.HisDoctorAdviceInfo {
  31141. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  31142. total_one := price * subItem.PrescribingNumber
  31143. fmt.Println("subItem")
  31144. fmt.Println(subItem.Price)
  31145. fmt.Println("price")
  31146. fmt.Println(price)
  31147. fmt.Println("total_one")
  31148. fmt.Println(total_one)
  31149. total = total + total_one
  31150. fmt.Println(total)
  31151. }
  31152. }
  31153. if item.Type == 2 { //项目
  31154. for _, subItem := range item.HisPrescriptionProject {
  31155. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  31156. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  31157. total_one := price * cnt
  31158. total = total + total_one
  31159. }
  31160. }
  31161. }
  31162. allTotal := fmt.Sprintf("%.2f", total)
  31163. if res.Infcode == 0 {
  31164. var rf []*ResultFive
  31165. json.Unmarshal([]byte(his.Iinfo), &rf)
  31166. chrg_bchno := chrg_bchno
  31167. cert_no := his.Certno
  31168. var insutypes []string
  31169. var insutype string
  31170. var is390 int = 0
  31171. var is310 int = 0
  31172. for _, item := range rf {
  31173. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  31174. insutypes = append(insutypes, item.Insutype)
  31175. }
  31176. }
  31177. if len(insutypes) == 1 {
  31178. insutype = insutypes[0]
  31179. } else {
  31180. for _, i := range insutypes {
  31181. if i == "390" {
  31182. is390 = 1
  31183. }
  31184. if i == "310" {
  31185. is310 = 1
  31186. }
  31187. }
  31188. }
  31189. if is390 == 1 {
  31190. insutype = "390"
  31191. }
  31192. if is310 == 1 {
  31193. insutype = "310"
  31194. }
  31195. if len(insutypes) == 0 {
  31196. insutype = "390"
  31197. }
  31198. if len(insutypes) == 2 {
  31199. insutype = strconv.FormatInt(his.SocialType, 10)
  31200. }
  31201. //insutype = "390"
  31202. if his.IdCardType == 1 {
  31203. cert_no = his.MedicalInsuranceNumber
  31204. } else {
  31205. cert_no = his.Certno
  31206. }
  31207. var res ResultSeven
  31208. var ahres ResultSevenAH
  31209. var resSeven10265 ResultSeven10265
  31210. var resSeven10265Two ResultSeven10265Two
  31211. var resSeven10633Three ResultSeven10633Three
  31212. var gzresSeven10265Two GZResultSeven10265Two
  31213. if miConfig.MdtrtareaAdmvs == "421300" {
  31214. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  31215. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31216. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31217. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31218. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31219. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31220. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31221. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31222. resp, requestErr := http.Get(api)
  31223. if requestErr != nil {
  31224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31225. return
  31226. }
  31227. body, ioErr := ioutil.ReadAll(resp.Body)
  31228. if ioErr != nil {
  31229. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31231. return
  31232. }
  31233. var respJSON map[string]interface{}
  31234. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31235. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31237. return
  31238. }
  31239. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31240. result, _ := json.Marshal(respJSON)
  31241. fmt.Println("log")
  31242. fmt.Println(string(result))
  31243. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31244. utils.ErrorLog("解析失败:%v", err)
  31245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31246. return
  31247. }
  31248. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31249. if reg_type == 11 && his.Insutype == "390" {
  31250. reg_type = 110104
  31251. }
  31252. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31253. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31254. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31255. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31256. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31257. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31258. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31259. resp, requestErr := http.Get(api)
  31260. if requestErr != nil {
  31261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31262. return
  31263. }
  31264. body, ioErr := ioutil.ReadAll(resp.Body)
  31265. if ioErr != nil {
  31266. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31268. return
  31269. }
  31270. var respJSON map[string]interface{}
  31271. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31272. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31274. return
  31275. }
  31276. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31277. result, _ := json.Marshal(respJSON)
  31278. fmt.Println("log")
  31279. fmt.Println(string(result))
  31280. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31281. utils.ErrorLog("解析失败:%v", err)
  31282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31283. return
  31284. }
  31285. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31286. if reg_type == 11 && his.Insutype == "390" {
  31287. reg_type = 110104
  31288. }
  31289. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31290. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31291. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31292. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31293. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31294. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31295. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31296. resp, requestErr := http.Get(api)
  31297. if requestErr != nil {
  31298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31299. return
  31300. }
  31301. body, ioErr := ioutil.ReadAll(resp.Body)
  31302. if ioErr != nil {
  31303. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31305. return
  31306. }
  31307. var respJSON map[string]interface{}
  31308. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31309. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31311. return
  31312. }
  31313. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31314. result, _ := json.Marshal(respJSON)
  31315. fmt.Println("log")
  31316. fmt.Println(string(result))
  31317. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31318. utils.ErrorLog("解析失败:%v", err)
  31319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31320. return
  31321. }
  31322. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31323. if reg_type == 11 && his.Insutype == "390" {
  31324. reg_type = 110104
  31325. }
  31326. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31327. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31328. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31329. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31330. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31331. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31332. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31333. resp, requestErr := http.Get(api)
  31334. if requestErr != nil {
  31335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31336. return
  31337. }
  31338. body, ioErr := ioutil.ReadAll(resp.Body)
  31339. if ioErr != nil {
  31340. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31342. return
  31343. }
  31344. var respJSON map[string]interface{}
  31345. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31346. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31348. return
  31349. }
  31350. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31351. result, _ := json.Marshal(respJSON)
  31352. fmt.Println("log")
  31353. fmt.Println(string(result))
  31354. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31355. utils.ErrorLog("解析失败:%v", err)
  31356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31357. return
  31358. }
  31359. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  31360. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  31361. var result3101 Result3101
  31362. //utils.ErrorLog("解析失败:%v", result3101)
  31363. result3101.Infcode = "0"
  31364. if result3101.Infcode == "0" {
  31365. if len(result3101.Output.Result) > 0 {
  31366. var errMsgs []string
  31367. for _, item := range result3101.Output.Result {
  31368. errMsgs = append(errMsgs, item.VolaCont)
  31369. }
  31370. c.ServeSuccessJSON(map[string]interface{}{
  31371. "failed_code": -10,
  31372. "msg": errMsgs,
  31373. })
  31374. return
  31375. } else {
  31376. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31377. if his.IdCardType != 4 {
  31378. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  31379. bas := strings.Split(psn_info.CardInfo, "|")
  31380. if his.IdCardType == 1 {
  31381. cert_no = bas[2]
  31382. } else {
  31383. cert_no = bas[1]
  31384. }
  31385. } else {
  31386. cert_no = his.Certno
  31387. }
  31388. //江苏地区国家医保医疗类别
  31389. //职工透析:医疗类别选特殊情况门诊9933
  31390. //居民血透门慢: 医疗类别选门诊慢病1402
  31391. //var med_type string
  31392. //if his.Insutype == "310" {
  31393. // if reg_type == 14 {
  31394. // med_type = "9933"
  31395. // } else if reg_type == 11 {
  31396. // med_type = "11"
  31397. //
  31398. // }
  31399. //} else if his.Insutype == "390" {
  31400. // if reg_type == 14 {
  31401. // med_type = "1402"
  31402. // } else if reg_type == 11 {
  31403. // med_type = "11"
  31404. // }
  31405. //}
  31406. var api string
  31407. if miConfig.MdtrtareaAdmvs == "320830" {
  31408. api = miConfig.AppSecret + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31409. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31410. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31411. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31412. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31413. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31414. "&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
  31415. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31416. } else if miConfig.MdtrtareaAdmvs == "320921" {
  31417. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31418. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31419. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31420. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31421. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31422. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31423. "&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
  31424. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31425. } else {
  31426. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31427. api = "http://192.168.5.251:9532/" + "jsyb/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) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  31434. }
  31435. resp, requestErr := http.Get(api)
  31436. if requestErr != nil {
  31437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31438. return
  31439. }
  31440. body, ioErr := ioutil.ReadAll(resp.Body)
  31441. if ioErr != nil {
  31442. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31444. return
  31445. }
  31446. var respJSON map[string]interface{}
  31447. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31448. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31450. return
  31451. }
  31452. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31453. result, _ := json.Marshal(respJSON)
  31454. fmt.Println("log")
  31455. fmt.Println(string(result))
  31456. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  31457. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  31458. utils.ErrorLog("解析失败:%v", err)
  31459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31460. return
  31461. }
  31462. res.InfRefmsgid = resSeven10265.InfRefmsgid
  31463. res.Output = resSeven10265.Output
  31464. res.ErrMsg = resSeven10265.ErrMsg
  31465. res.Cainfo = resSeven10265.Cainfo
  31466. res.WarnMsg = resSeven10265.WarnMsg
  31467. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  31468. res.Infcode = infocode
  31469. } else {
  31470. if miConfig.MdtrtareaAdmvs == "320830" {
  31471. if strings.HasPrefix(his.InsuplcAdmdvs[0:3], "320") && !strings.HasPrefix(his.InsuplcAdmdvs[0:4], "3208") {
  31472. if err := json.Unmarshal([]byte(result), &resSeven10633Three); err != nil {
  31473. utils.ErrorLog("解析失败:%v", err)
  31474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31475. return
  31476. }
  31477. res.InfRefmsgid = resSeven10633Three.InfRefmsgid
  31478. AcctMulaidPay, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.AcctMulaidPay, 64)
  31479. res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  31480. res.Output.Setlinfo.AcctPay = resSeven10633Three.Output.Setlinfo.AcctPay
  31481. res.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31482. res.Output.Setlinfo.ActPayDedc = resSeven10633Three.Output.Setlinfo.ActPayDedc
  31483. res.Output.Setlinfo.Age = resSeven10633Three.Output.Setlinfo.Age
  31484. res.Output.Setlinfo.Balc = resSeven10633Three.Output.Setlinfo.Balc
  31485. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31486. res.Output.Setlinfo.Certno = resSeven10633Three.Output.Setlinfo.Certno
  31487. res.Output.Setlinfo.ClrOptins = resSeven10633Three.Output.Setlinfo.ClrOptins
  31488. res.Output.Setlinfo.ClrType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31489. res.Output.Setlinfo.ClrWay = resSeven10633Three.Output.Setlinfo.ClrOptins
  31490. res.Output.Setlinfo.CvlservFlag = resSeven10633Three.Output.Setlinfo.ClrOptins
  31491. res.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31492. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10633Three.Output.Setlinfo.FulamtOwnpayAmt
  31493. res.Output.Setlinfo.FundPaySumamt = resSeven10633Three.Output.Setlinfo.FundPaySumamt
  31494. res.Output.Setlinfo.Gend = resSeven10633Three.Output.Setlinfo.Gend
  31495. res.Output.Setlinfo.HifesPay = resSeven10633Three.Output.Setlinfo.HifesPay
  31496. res.Output.Setlinfo.HifmiPay = resSeven10633Three.Output.Setlinfo.HifmiPay
  31497. res.Output.Setlinfo.HifpPay = resSeven10633Three.Output.Setlinfo.HifpPay
  31498. HospPartAmt, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.HospPartAmt, 64)
  31499. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  31500. res.Output.Setlinfo.InscpScpAmt = resSeven10633Three.Output.Setlinfo.InscpScpAmt
  31501. res.Output.Setlinfo.Insutype = resSeven10633Three.Output.Setlinfo.Insutype
  31502. res.Output.Setlinfo.MafPay = resSeven10633Three.Output.Setlinfo.MafPay
  31503. res.Output.Setlinfo.MdtrtCertType = resSeven10633Three.Output.Setlinfo.MdtrtCertType
  31504. res.Output.Setlinfo.HifobPay = resSeven10633Three.Output.Setlinfo.HifobPay
  31505. res.Output.Setlinfo.MdtrtID = resSeven10633Three.Output.Setlinfo.MdtrtID
  31506. res.Output.Setlinfo.MedType = resSeven10633Three.Output.Setlinfo.MedType
  31507. res.Output.Setlinfo.MedfeeSumamt = resSeven10633Three.Output.Setlinfo.MedfeeSumamt
  31508. res.Output.Setlinfo.MedinsSetlID = resSeven10633Three.Output.Setlinfo.MedinsSetlID
  31509. res.Output.Setlinfo.Naty = resSeven10633Three.Output.Setlinfo.Naty
  31510. res.Output.Setlinfo.OthPay = resSeven10633Three.Output.Setlinfo.OthPay
  31511. res.Output.Setlinfo.OverlmtSelfpay = resSeven10633Three.Output.Setlinfo.OverlmtSelfpay
  31512. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.PoolPropSelfpay, 64)
  31513. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  31514. res.Output.Setlinfo.PreselfpayAmt = resSeven10633Three.Output.Setlinfo.PreselfpayAmt
  31515. res.Output.Setlinfo.PsnCashPay = resSeven10633Three.Output.Setlinfo.PsnCashPay
  31516. res.Output.Setlinfo.PsnCertType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31517. res.Output.Setlinfo.PsnName = resSeven10633Three.Output.Setlinfo.PsnName
  31518. res.Output.Setlinfo.PsnNo = resSeven10633Three.Output.Setlinfo.PsnNo
  31519. res.Output.Setlinfo.PsnPartAmt = resSeven10633Three.Output.Setlinfo.PsnPartAmt
  31520. res.Output.Setlinfo.PsnType = resSeven10633Three.Output.Setlinfo.PsnType
  31521. res.Output.Setlinfo.SetlID = resSeven10633Three.Output.Setlinfo.SetlID
  31522. res.Output.Setlinfo.SetlTime = resSeven10633Three.Output.Setlinfo.SetlTime
  31523. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31524. res.ErrMsg = resSeven10633Three.ErrMsg
  31525. res.Cainfo = resSeven10633Three.Cainfo
  31526. res.WarnMsg = resSeven10633Three.WarnMsg
  31527. infocode, _ := strconv.ParseInt(resSeven10633Three.Infcode, 10, 64)
  31528. res.Infcode = infocode
  31529. } else {
  31530. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  31531. utils.ErrorLog("解析失败:%v", err)
  31532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31533. return
  31534. }
  31535. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  31536. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  31537. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  31538. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  31539. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  31540. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  31541. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  31542. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  31543. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31544. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  31545. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  31546. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  31547. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  31548. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  31549. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  31550. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  31551. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  31552. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  31553. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  31554. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  31555. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  31556. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  31557. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  31558. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  31559. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  31560. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  31561. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  31562. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  31563. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  31564. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  31565. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  31566. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  31567. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  31568. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  31569. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  31570. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  31571. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  31572. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  31573. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  31574. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  31575. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  31576. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  31577. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31578. res.ErrMsg = resSeven10265Two.ErrMsg
  31579. res.Cainfo = resSeven10265Two.Cainfo
  31580. res.WarnMsg = resSeven10265Two.WarnMsg
  31581. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  31582. res.Infcode = infocode
  31583. }
  31584. } else {
  31585. if strings.HasPrefix(his.InsuplcAdmdvs[0:3], "320") && !strings.HasPrefix(his.InsuplcAdmdvs[0:4], "3209") {
  31586. if err := json.Unmarshal([]byte(result), &resSeven10633Three); err != nil {
  31587. utils.ErrorLog("解析失败:%v", err)
  31588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31589. return
  31590. }
  31591. res.InfRefmsgid = resSeven10633Three.InfRefmsgid
  31592. AcctMulaidPay, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.AcctMulaidPay, 64)
  31593. res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  31594. res.Output.Setlinfo.AcctPay = resSeven10633Three.Output.Setlinfo.AcctPay
  31595. res.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31596. res.Output.Setlinfo.ActPayDedc = resSeven10633Three.Output.Setlinfo.ActPayDedc
  31597. res.Output.Setlinfo.Age = resSeven10633Three.Output.Setlinfo.Age
  31598. res.Output.Setlinfo.Balc = resSeven10633Three.Output.Setlinfo.Balc
  31599. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31600. res.Output.Setlinfo.Certno = resSeven10633Three.Output.Setlinfo.Certno
  31601. res.Output.Setlinfo.ClrOptins = resSeven10633Three.Output.Setlinfo.ClrOptins
  31602. res.Output.Setlinfo.ClrType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31603. res.Output.Setlinfo.ClrWay = resSeven10633Three.Output.Setlinfo.ClrOptins
  31604. res.Output.Setlinfo.CvlservFlag = resSeven10633Three.Output.Setlinfo.ClrOptins
  31605. res.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31606. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10633Three.Output.Setlinfo.FulamtOwnpayAmt
  31607. res.Output.Setlinfo.FundPaySumamt = resSeven10633Three.Output.Setlinfo.FundPaySumamt
  31608. res.Output.Setlinfo.Gend = resSeven10633Three.Output.Setlinfo.Gend
  31609. res.Output.Setlinfo.HifesPay = resSeven10633Three.Output.Setlinfo.HifesPay
  31610. res.Output.Setlinfo.HifmiPay = resSeven10633Three.Output.Setlinfo.HifmiPay
  31611. res.Output.Setlinfo.HifpPay = resSeven10633Three.Output.Setlinfo.HifpPay
  31612. HospPartAmt, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.HospPartAmt, 64)
  31613. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  31614. res.Output.Setlinfo.InscpScpAmt = resSeven10633Three.Output.Setlinfo.InscpScpAmt
  31615. res.Output.Setlinfo.Insutype = resSeven10633Three.Output.Setlinfo.Insutype
  31616. res.Output.Setlinfo.MafPay = resSeven10633Three.Output.Setlinfo.MafPay
  31617. res.Output.Setlinfo.MdtrtCertType = resSeven10633Three.Output.Setlinfo.MdtrtCertType
  31618. res.Output.Setlinfo.HifobPay = resSeven10633Three.Output.Setlinfo.HifobPay
  31619. res.Output.Setlinfo.MdtrtID = resSeven10633Three.Output.Setlinfo.MdtrtID
  31620. res.Output.Setlinfo.MedType = resSeven10633Three.Output.Setlinfo.MedType
  31621. res.Output.Setlinfo.MedfeeSumamt = resSeven10633Three.Output.Setlinfo.MedfeeSumamt
  31622. res.Output.Setlinfo.MedinsSetlID = resSeven10633Three.Output.Setlinfo.MedinsSetlID
  31623. res.Output.Setlinfo.Naty = resSeven10633Three.Output.Setlinfo.Naty
  31624. res.Output.Setlinfo.OthPay = resSeven10633Three.Output.Setlinfo.OthPay
  31625. res.Output.Setlinfo.OverlmtSelfpay = resSeven10633Three.Output.Setlinfo.OverlmtSelfpay
  31626. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.PoolPropSelfpay, 64)
  31627. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  31628. res.Output.Setlinfo.PreselfpayAmt = resSeven10633Three.Output.Setlinfo.PreselfpayAmt
  31629. res.Output.Setlinfo.PsnCashPay = resSeven10633Three.Output.Setlinfo.PsnCashPay
  31630. res.Output.Setlinfo.PsnCertType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31631. res.Output.Setlinfo.PsnName = resSeven10633Three.Output.Setlinfo.PsnName
  31632. res.Output.Setlinfo.PsnNo = resSeven10633Three.Output.Setlinfo.PsnNo
  31633. res.Output.Setlinfo.PsnPartAmt = resSeven10633Three.Output.Setlinfo.PsnPartAmt
  31634. res.Output.Setlinfo.PsnType = resSeven10633Three.Output.Setlinfo.PsnType
  31635. res.Output.Setlinfo.SetlID = resSeven10633Three.Output.Setlinfo.SetlID
  31636. res.Output.Setlinfo.SetlTime = resSeven10633Three.Output.Setlinfo.SetlTime
  31637. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31638. res.ErrMsg = resSeven10633Three.ErrMsg
  31639. res.Cainfo = resSeven10633Three.Cainfo
  31640. res.WarnMsg = resSeven10633Three.WarnMsg
  31641. infocode, _ := strconv.ParseInt(resSeven10633Three.Infcode, 10, 64)
  31642. res.Infcode = infocode
  31643. } else {
  31644. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  31645. utils.ErrorLog("解析失败:%v", err)
  31646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31647. return
  31648. }
  31649. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  31650. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  31651. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  31652. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  31653. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  31654. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  31655. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  31656. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  31657. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31658. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  31659. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  31660. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  31661. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  31662. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  31663. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  31664. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  31665. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  31666. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  31667. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  31668. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  31669. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  31670. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  31671. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  31672. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  31673. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  31674. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  31675. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  31676. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  31677. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  31678. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  31679. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  31680. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  31681. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  31682. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  31683. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  31684. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  31685. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  31686. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  31687. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  31688. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  31689. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  31690. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  31691. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31692. res.ErrMsg = resSeven10265Two.ErrMsg
  31693. res.Cainfo = resSeven10265Two.Cainfo
  31694. res.WarnMsg = resSeven10265Two.WarnMsg
  31695. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  31696. res.Infcode = infocode
  31697. }
  31698. }
  31699. }
  31700. }
  31701. }
  31702. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31703. psn_info, _ := service.GetPsnByPatientId(id)
  31704. var verify_number string
  31705. if psn_info.IdCardType == 4 {
  31706. verify_number = psn_info.VerifyNumber
  31707. } else if psn_info.IdCardType == 1 {
  31708. bas := strings.Split(psn_info.CardInfo, "|")
  31709. cardNumber := bas[2]
  31710. verify_number = cardNumber
  31711. } else {
  31712. psn_info.IdCardType = 2
  31713. verify_number = psn_info.Certno
  31714. }
  31715. var api string
  31716. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31717. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  31718. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31719. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31720. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  31721. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31722. "&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
  31723. resp, requestErr := http.Get(api)
  31724. if requestErr != nil {
  31725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31726. return
  31727. }
  31728. body, ioErr := ioutil.ReadAll(resp.Body)
  31729. if ioErr != nil {
  31730. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31732. return
  31733. }
  31734. var respJSON map[string]interface{}
  31735. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31736. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31738. return
  31739. }
  31740. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31741. result, _ := json.Marshal(respJSON)
  31742. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  31743. utils.ErrorLog("解析失败:%v", err)
  31744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31745. return
  31746. }
  31747. res.InfRefmsgid = resSeven10265.InfRefmsgid
  31748. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  31749. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  31750. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  31751. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  31752. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  31753. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  31754. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  31755. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  31756. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  31757. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  31758. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  31759. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  31760. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  31761. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  31762. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  31763. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  31764. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  31765. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  31766. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  31767. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31768. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  31769. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  31770. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  31771. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  31772. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  31773. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  31774. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  31775. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  31776. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  31777. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  31778. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  31779. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  31780. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  31781. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  31782. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  31783. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  31784. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  31785. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  31786. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  31787. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  31788. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  31789. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  31790. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  31791. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  31792. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  31793. res.ErrMsg = resSeven10265.ErrMsg
  31794. res.Cainfo = resSeven10265.Cainfo
  31795. res.WarnMsg = resSeven10265.WarnMsg
  31796. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  31797. res.Infcode = infocode
  31798. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31799. acct_used_flag := "1"
  31800. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  31801. var result string
  31802. var request_log string
  31803. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  31804. 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)
  31805. } else {
  31806. 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)
  31807. }
  31808. var dat map[string]interface{}
  31809. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31810. fmt.Println(dat)
  31811. } else {
  31812. fmt.Println(err)
  31813. }
  31814. saveLog(result, request_log, "2206", "预结算")
  31815. userJSONBytes, _ := json.Marshal(dat)
  31816. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31817. utils.ErrorLog("解析失败:%v", err)
  31818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31819. return
  31820. }
  31821. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31822. var result string
  31823. var request_log string
  31824. if his.IdCardType == 2 {
  31825. insutype = strconv.FormatInt(his.SocialType, 10)
  31826. 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, "")
  31827. } else if his.IdCardType == 1 {
  31828. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31829. bas := strings.Split(psn_info.CardInfo, "|")
  31830. basNumber := bas[2]
  31831. card_sn := bas[3]
  31832. var rf []*ResultFive
  31833. json.Unmarshal([]byte(his.Iinfo), &rf)
  31834. var psn_type string
  31835. for _, item := range rf {
  31836. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31837. psn_type = item.PsnType
  31838. }
  31839. }
  31840. insutype = strconv.FormatInt(his.SocialType, 10)
  31841. 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)
  31842. } else {
  31843. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31844. //bas := strings.Split(psn_info.CardInfo, "|")
  31845. //basNumber := bas[2]
  31846. //card_sn := bas[3]
  31847. var rf []*ResultFive
  31848. json.Unmarshal([]byte(his.Iinfo), &rf)
  31849. var psn_type string
  31850. for _, item := range rf {
  31851. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31852. psn_type = item.PsnType
  31853. }
  31854. }
  31855. insutype = strconv.FormatInt(his.SocialType, 10)
  31856. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31857. 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)
  31858. }
  31859. var dat map[string]interface{}
  31860. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31861. fmt.Println(dat)
  31862. } else {
  31863. fmt.Println(err)
  31864. }
  31865. saveLog(result, request_log, "2206", "预结算")
  31866. userJSONBytes, _ := json.Marshal(dat)
  31867. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31868. utils.ErrorLog("解析失败:%v", err)
  31869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31870. return
  31871. }
  31872. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31873. var result string
  31874. var request_log string
  31875. if his.IdCardType == 2 {
  31876. insutype = strconv.FormatInt(his.SocialType, 10)
  31877. 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, "")
  31878. } else if his.IdCardType == 1 {
  31879. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31880. bas := strings.Split(psn_info.CardInfo, "|")
  31881. basNumber := bas[0]
  31882. card_sn := ""
  31883. var rf []*ResultFive
  31884. json.Unmarshal([]byte(his.Iinfo), &rf)
  31885. var psn_type string
  31886. for _, item := range rf {
  31887. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31888. psn_type = item.PsnType
  31889. }
  31890. }
  31891. insutype = strconv.FormatInt(his.SocialType, 10)
  31892. 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)
  31893. } else {
  31894. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31895. //bas := strings.Split(psn_info.CardInfo, "|")
  31896. //basNumber := bas[2]
  31897. //card_sn := bas[3]
  31898. var rf []*ResultFive
  31899. json.Unmarshal([]byte(his.Iinfo), &rf)
  31900. var psn_type string
  31901. for _, item := range rf {
  31902. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31903. psn_type = item.PsnType
  31904. }
  31905. }
  31906. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31907. 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)
  31908. }
  31909. var dat map[string]interface{}
  31910. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31911. fmt.Println(dat)
  31912. } else {
  31913. fmt.Println(err)
  31914. }
  31915. saveLog(result, request_log, "2206", "预结算")
  31916. userJSONBytes, _ := json.Marshal(dat)
  31917. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31918. utils.ErrorLog("解析失败:%v", err)
  31919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31920. return
  31921. }
  31922. } else if miConfig.MdtrtareaAdmvs == "360100" {
  31923. var result string
  31924. var request_log string
  31925. if his.IdCardType == 2 {
  31926. insutype = strconv.FormatInt(his.SocialType, 10)
  31927. 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, "")
  31928. } else if his.IdCardType == 1 {
  31929. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31930. bas := strings.Split(psn_info.CardInfo, "|")
  31931. basNumber := bas[0]
  31932. card_sn := ""
  31933. var rf []*ResultFive
  31934. json.Unmarshal([]byte(his.Iinfo), &rf)
  31935. var psn_type string
  31936. for _, item := range rf {
  31937. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31938. psn_type = item.PsnType
  31939. }
  31940. }
  31941. insutype = strconv.FormatInt(his.SocialType, 10)
  31942. 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)
  31943. } else {
  31944. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31945. //bas := strings.Split(psn_info.CardInfo, "|")
  31946. //basNumber := bas[2]
  31947. //card_sn := bas[3]
  31948. var rf []*ResultFive
  31949. json.Unmarshal([]byte(his.Iinfo), &rf)
  31950. var psn_type string
  31951. for _, item := range rf {
  31952. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31953. psn_type = item.PsnType
  31954. }
  31955. }
  31956. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31957. 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)
  31958. }
  31959. var dat map[string]interface{}
  31960. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31961. fmt.Println(dat)
  31962. } else {
  31963. fmt.Println(err)
  31964. }
  31965. saveLog(result, request_log, "2206", "预结算")
  31966. userJSONBytes, _ := json.Marshal(dat)
  31967. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31968. utils.ErrorLog("解析失败:%v", err)
  31969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31970. return
  31971. }
  31972. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31973. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31974. if his.IdCardType == 4 {
  31975. psn_info.VerifyNumber = psn_info.VerifyNumber
  31976. cert_no = psn_info.VerifyNumber
  31977. } else if his.IdCardType == 2 {
  31978. cert_no = psn_info.Certno
  31979. psn_info.VerifyNumber = psn_info.Certno
  31980. } else {
  31981. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  31982. bas := strings.Split(psn_info.CardInfo, "|")
  31983. if his.IdCardType == 1 {
  31984. cert_no = bas[2]
  31985. } else {
  31986. cert_no = bas[1]
  31987. }
  31988. }
  31989. var api string
  31990. var med_type string
  31991. if his.Insutype == "390" {
  31992. if reg_type == 992102 {
  31993. med_type = "992102"
  31994. }
  31995. if reg_type == 140104 {
  31996. med_type = "140104"
  31997. }
  31998. if reg_type == 140201 {
  31999. med_type = "140201"
  32000. }
  32001. if reg_type == 14 {
  32002. med_type = "140104"
  32003. }
  32004. if reg_type == 1104 {
  32005. med_type = "1104"
  32006. }
  32007. } else if his.Insutype == "310" {
  32008. if reg_type == 1104 {
  32009. med_type = "1104"
  32010. }
  32011. if reg_type == 992102 {
  32012. med_type = "992102"
  32013. }
  32014. if reg_type == 140104 {
  32015. med_type = "140104"
  32016. }
  32017. if reg_type == 140201 {
  32018. med_type = "140201"
  32019. }
  32020. if reg_type == 14 {
  32021. med_type = "140104"
  32022. }
  32023. }
  32024. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  32025. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  32026. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32027. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32028. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  32029. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  32030. "&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
  32031. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32032. resp, requestErr := http.Get(api)
  32033. if requestErr != nil {
  32034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32035. return
  32036. }
  32037. body, ioErr := ioutil.ReadAll(resp.Body)
  32038. if ioErr != nil {
  32039. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32041. return
  32042. }
  32043. var respJSON map[string]interface{}
  32044. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32045. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32047. return
  32048. }
  32049. status := respJSON["data"].(map[string]interface{})["status"].(string)
  32050. if status == "0" {
  32051. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  32052. c.ServeSuccessJSON(map[string]interface{}{
  32053. "failed_code": -10,
  32054. "msg": err_msg,
  32055. })
  32056. return
  32057. }
  32058. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32059. result, _ := json.Marshal(respJSON)
  32060. fmt.Println("log")
  32061. fmt.Println(string(result))
  32062. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  32063. utils.ErrorLog("解析失败:%v", err)
  32064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32065. return
  32066. }
  32067. res.InfRefmsgid = ahres.InfRefmsgid
  32068. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  32069. // 创建对应的Time类型
  32070. t := time.UnixMilli(timestamp)
  32071. // 格式化成指定的日期字符串
  32072. str := t.Format("2006-01-02 15:04:05")
  32073. res.Output.Setlinfo.SetlTime = str
  32074. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  32075. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  32076. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32077. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  32078. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  32079. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  32080. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32081. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  32082. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  32083. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  32084. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  32085. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  32086. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32087. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  32088. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  32089. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  32090. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  32091. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  32092. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  32093. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32094. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  32095. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  32096. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  32097. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  32098. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  32099. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  32100. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  32101. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  32102. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  32103. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  32104. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  32105. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  32106. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  32107. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  32108. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  32109. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  32110. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  32111. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  32112. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  32113. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  32114. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  32115. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  32116. //res.Output.Setldetail = ahres.Output.Setldetail
  32117. res.ErrMsg = ahres.ErrMsg
  32118. res.Cainfo = ahres.Cainfo
  32119. res.WarnMsg = ahres.WarnMsg
  32120. res.Infcode = ahres.Infcode
  32121. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32122. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32123. if his.IdCardType == 4 {
  32124. psn_info.VerifyNumber = psn_info.VerifyNumber
  32125. cert_no = psn_info.Certno
  32126. } else if his.IdCardType == 2 {
  32127. cert_no = psn_info.Certno
  32128. psn_info.VerifyNumber = psn_info.Certno
  32129. } else {
  32130. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  32131. bas := strings.Split(psn_info.CardInfo, "|")
  32132. if his.IdCardType == 1 {
  32133. cert_no = bas[2]
  32134. } else {
  32135. cert_no = bas[1]
  32136. }
  32137. }
  32138. var api string
  32139. var med_type string
  32140. if his.Insutype == "390" {
  32141. if reg_type == 992102 {
  32142. med_type = "992102"
  32143. }
  32144. if reg_type == 140104 {
  32145. med_type = "140104"
  32146. }
  32147. if reg_type == 140201 {
  32148. med_type = "140201"
  32149. }
  32150. if reg_type == 14 {
  32151. med_type = "14"
  32152. }
  32153. } else if his.Insutype == "310" {
  32154. if reg_type == 992102 {
  32155. med_type = "992102"
  32156. }
  32157. if reg_type == 140104 {
  32158. med_type = "140104"
  32159. }
  32160. if reg_type == 140201 {
  32161. med_type = "140201"
  32162. }
  32163. if reg_type == 14 {
  32164. med_type = "14"
  32165. }
  32166. }
  32167. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  32168. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  32169. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32170. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32171. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  32172. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  32173. "&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
  32174. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32175. resp, requestErr := http.Get(api)
  32176. if requestErr != nil {
  32177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32178. return
  32179. }
  32180. body, ioErr := ioutil.ReadAll(resp.Body)
  32181. if ioErr != nil {
  32182. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32184. return
  32185. }
  32186. var respJSON map[string]interface{}
  32187. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32188. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32190. return
  32191. }
  32192. status := respJSON["data"].(map[string]interface{})["status"].(string)
  32193. if status == "0" {
  32194. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  32195. c.ServeSuccessJSON(map[string]interface{}{
  32196. "failed_code": -10,
  32197. "msg": err_msg,
  32198. })
  32199. return
  32200. }
  32201. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32202. result, _ := json.Marshal(respJSON)
  32203. fmt.Println("log")
  32204. fmt.Println(string(result))
  32205. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  32206. utils.ErrorLog("解析失败:%v", err)
  32207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32208. return
  32209. }
  32210. res.InfRefmsgid = ahres.InfRefmsgid
  32211. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  32212. // 创建对应的Time类型
  32213. t := time.UnixMilli(timestamp)
  32214. // 格式化成指定的日期字符串
  32215. str := t.Format("2006-01-02 15:04:05")
  32216. res.Output.Setlinfo.SetlTime = str
  32217. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  32218. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  32219. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32220. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  32221. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  32222. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  32223. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32224. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  32225. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  32226. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  32227. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  32228. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  32229. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32230. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  32231. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  32232. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  32233. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  32234. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  32235. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  32236. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32237. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  32238. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  32239. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  32240. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  32241. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  32242. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  32243. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  32244. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  32245. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  32246. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  32247. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  32248. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  32249. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  32250. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  32251. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  32252. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  32253. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  32254. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  32255. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  32256. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  32257. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  32258. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  32259. //res.Output.Setldetail = ahres.Output.Setldetail
  32260. res.ErrMsg = ahres.ErrMsg
  32261. res.Cainfo = ahres.Cainfo
  32262. res.WarnMsg = ahres.WarnMsg
  32263. res.Infcode = ahres.Infcode
  32264. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32265. var result string
  32266. var request_log string
  32267. if his.IdCardType == 2 {
  32268. 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")
  32269. } else if his.IdCardType == 1 {
  32270. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32271. bas := strings.Split(psn_info.CardInfo, "|")
  32272. basNumber := bas[2]
  32273. card_sn := bas[3]
  32274. 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")
  32275. } else {
  32276. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32277. 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")
  32278. }
  32279. var dat map[string]interface{}
  32280. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32281. fmt.Println(dat)
  32282. } else {
  32283. fmt.Println(err)
  32284. }
  32285. saveLog(result, request_log, "2206", "预结算")
  32286. userJSONBytes, _ := json.Marshal(dat)
  32287. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32288. utils.ErrorLog("解析失败:%v", err)
  32289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32290. return
  32291. }
  32292. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32293. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  32294. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  32295. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32296. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32297. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  32298. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  32299. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  32300. resp, requestErr := http.Get(api)
  32301. if requestErr != nil {
  32302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32303. return
  32304. }
  32305. body, ioErr := ioutil.ReadAll(resp.Body)
  32306. if ioErr != nil {
  32307. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32309. return
  32310. }
  32311. var respJSON map[string]interface{}
  32312. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32313. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32315. return
  32316. }
  32317. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32318. result, _ := json.Marshal(respJSON)
  32319. fmt.Println("log")
  32320. fmt.Println(string(result))
  32321. if err := json.Unmarshal([]byte(result), &res); err != nil {
  32322. utils.ErrorLog("解析失败:%v", err)
  32323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32324. return
  32325. }
  32326. } else {
  32327. if miConfig.MdtrtareaAdmvs == "441202" {
  32328. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  32329. if result3101.Infcode == 0 {
  32330. if len(result3101.Output.Result) > 0 {
  32331. c.ServeSuccessJSON(map[string]interface{}{
  32332. "failed_code": -10,
  32333. "failed_type": 100,
  32334. "msg": result3101.Output.Result,
  32335. })
  32336. return
  32337. } else {
  32338. var result string
  32339. var request_log string
  32340. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32341. allTotal = fmt.Sprintf("%.2f", total_two)
  32342. if his.IdCardType == 4 {
  32343. 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)
  32344. } else {
  32345. 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)
  32346. }
  32347. var dat map[string]interface{}
  32348. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32349. fmt.Println(dat)
  32350. } else {
  32351. fmt.Println(err)
  32352. }
  32353. saveLog(result, request_log, "2206", "预结算")
  32354. //userJSONBytes, _ := json.Marshal(dat)
  32355. //
  32356. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32357. // utils.ErrorLog("解析失败:%v", err)
  32358. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32359. // return
  32360. //}
  32361. userJSONBytes, _ := json.Marshal(dat)
  32362. if miConfig.Code == "H15049901371" {
  32363. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  32364. utils.ErrorLog("解析失败:%v", err)
  32365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32366. return
  32367. }
  32368. res.InfRefmsgid = resSeven10265.InfRefmsgid
  32369. res.Output = resSeven10265.Output
  32370. res.ErrMsg = resSeven10265.ErrMsg
  32371. res.Cainfo = resSeven10265.Cainfo
  32372. res.WarnMsg = resSeven10265.WarnMsg
  32373. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32374. res.Infcode = infocode
  32375. } else {
  32376. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32377. utils.ErrorLog("解析失败:%v", err)
  32378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32379. return
  32380. }
  32381. }
  32382. }
  32383. } else {
  32384. c.ServeSuccessJSON(map[string]interface{}{
  32385. "failed_code": -10,
  32386. "msg": result3101.ErrMsg,
  32387. })
  32388. return
  32389. }
  32390. } else if miConfig.MdtrtareaAdmvs == "440205" {
  32391. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  32392. if result3101.Infcode == 0 {
  32393. if len(result3101.Output.Result) > 0 {
  32394. var errMsgs []string
  32395. for _, item := range result3101.Output.Result {
  32396. errMsgs = append(errMsgs, item.VolaCont)
  32397. }
  32398. c.ServeSuccessJSON(map[string]interface{}{
  32399. "failed_code": -10,
  32400. "msg": errMsgs,
  32401. })
  32402. return
  32403. } else {
  32404. var result string
  32405. var request_log string
  32406. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32407. allTotal = fmt.Sprintf("%.2f", total_two)
  32408. if his.IdCardType == 4 {
  32409. 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)
  32410. } else {
  32411. 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)
  32412. }
  32413. var dat map[string]interface{}
  32414. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32415. fmt.Println(dat)
  32416. } else {
  32417. fmt.Println(err)
  32418. }
  32419. saveLog(result, request_log, "2206", "预结算")
  32420. //userJSONBytes, _ := json.Marshal(dat)
  32421. //
  32422. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32423. // utils.ErrorLog("解析失败:%v", err)
  32424. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32425. // return
  32426. //}
  32427. userJSONBytes, _ := json.Marshal(dat)
  32428. if miConfig.Code == "H15049901371" {
  32429. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  32430. utils.ErrorLog("解析失败:%v", err)
  32431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32432. return
  32433. }
  32434. res.InfRefmsgid = resSeven10265.InfRefmsgid
  32435. res.Output = resSeven10265.Output
  32436. res.ErrMsg = resSeven10265.ErrMsg
  32437. res.Cainfo = resSeven10265.Cainfo
  32438. res.WarnMsg = resSeven10265.WarnMsg
  32439. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32440. res.Infcode = infocode
  32441. } else {
  32442. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32443. utils.ErrorLog("解析失败:%v", err)
  32444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32445. return
  32446. }
  32447. }
  32448. }
  32449. } else {
  32450. c.ServeSuccessJSON(map[string]interface{}{
  32451. "failed_code": -10,
  32452. "msg": result3101.ErrMsg,
  32453. })
  32454. return
  32455. }
  32456. } else {
  32457. var result string
  32458. var request_log string
  32459. var dat map[string]interface{}
  32460. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32461. allTotal = fmt.Sprintf("%.2f", total_two)
  32462. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" {
  32463. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  32464. if result3101.Infcode == 0 {
  32465. if len(result3101.Output.Result) > 0 {
  32466. c.ServeSuccessJSON(map[string]interface{}{
  32467. "failed_code": -10,
  32468. "failed_type": 100,
  32469. "warm_type": 2,
  32470. "msg": result3101,
  32471. })
  32472. return
  32473. } else {
  32474. var result string
  32475. var request_log string
  32476. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32477. allTotal = fmt.Sprintf("%.2f", total_two)
  32478. if his.IdCardType == 4 {
  32479. 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)
  32480. } else {
  32481. if his.IdCardType == 2 {
  32482. cert_no = psn_info.Certno
  32483. psn_info.VerifyNumber = psn_info.Certno
  32484. } else {
  32485. bas := strings.Split(psn_info.CardInfo, "|")
  32486. cert_no = bas[2]
  32487. }
  32488. 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)
  32489. }
  32490. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32491. fmt.Println(dat)
  32492. } else {
  32493. fmt.Println(err)
  32494. }
  32495. saveLog(result, request_log, "2206", "预结算")
  32496. }
  32497. } else {
  32498. c.ServeSuccessJSON(map[string]interface{}{
  32499. "failed_code": -10,
  32500. "msg": result3101.ErrMsg,
  32501. })
  32502. return
  32503. }
  32504. } else {
  32505. if his.IdCardType == 4 {
  32506. 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)
  32507. } else {
  32508. if his.IdCardType == 2 {
  32509. cert_no = psn_info.Certno
  32510. psn_info.VerifyNumber = psn_info.Certno
  32511. } else {
  32512. bas := strings.Split(psn_info.CardInfo, "|")
  32513. cert_no = bas[2]
  32514. }
  32515. 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)
  32516. }
  32517. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32518. fmt.Println(dat)
  32519. } else {
  32520. fmt.Println(err)
  32521. }
  32522. saveLog(result, request_log, "2206", "预结算")
  32523. }
  32524. //userJSONBytes, _ := json.Marshal(dat)
  32525. //
  32526. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32527. // utils.ErrorLog("解析失败:%v", err)
  32528. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32529. // return
  32530. //}
  32531. userJSONBytes, _ := json.Marshal(dat)
  32532. if miConfig.Code == "H15049901371" {
  32533. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  32534. utils.ErrorLog("解析失败:%v", err)
  32535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32536. return
  32537. }
  32538. res.InfRefmsgid = resSeven10265.InfRefmsgid
  32539. res.Output = resSeven10265.Output
  32540. res.ErrMsg = resSeven10265.ErrMsg
  32541. res.Cainfo = resSeven10265.Cainfo
  32542. res.WarnMsg = resSeven10265.WarnMsg
  32543. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32544. res.Infcode = infocode
  32545. } else {
  32546. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32547. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  32548. utils.ErrorLog("解析失败:%v", err)
  32549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32550. return
  32551. }
  32552. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  32553. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  32554. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  32555. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  32556. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  32557. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  32558. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  32559. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32560. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  32561. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32562. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32563. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32564. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32565. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  32566. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  32567. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  32568. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  32569. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  32570. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  32571. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  32572. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32573. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  32574. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  32575. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  32576. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  32577. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  32578. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  32579. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  32580. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  32581. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  32582. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  32583. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  32584. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  32585. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  32586. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  32587. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  32588. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  32589. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  32590. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32591. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  32592. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  32593. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  32594. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  32595. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  32596. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  32597. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  32598. res.ErrMsg = gzresSeven10265Two.ErrMsg
  32599. res.Cainfo = gzresSeven10265Two.Cainfo
  32600. res.WarnMsg = gzresSeven10265Two.WarnMsg
  32601. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  32602. //res.Infcode = infocode
  32603. } else {
  32604. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32605. utils.ErrorLog("解析失败:%v", err)
  32606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32607. return
  32608. }
  32609. }
  32610. }
  32611. }
  32612. }
  32613. utils.ErrorLog("解析失败:%v", res.Infcode)
  32614. if res.Infcode == -1 {
  32615. errlog := &models.HisOrderError{
  32616. UserOrgId: adminUser.CurrentOrgId,
  32617. Ctime: time.Now().Unix(),
  32618. Mtime: time.Now().Unix(),
  32619. Number: chrg_bchno,
  32620. ErrMsg: res.ErrMsg,
  32621. Status: 1,
  32622. PatientId: id,
  32623. RecordTime: recordDateTime,
  32624. Stage: 20,
  32625. }
  32626. service.CreateErrMsgLog(errlog)
  32627. c.ServeSuccessJSON(map[string]interface{}{
  32628. "failed_code": -10,
  32629. "msg": res.ErrMsg,
  32630. })
  32631. return
  32632. }
  32633. if res.Infcode != 0 {
  32634. errlog := &models.HisOrderError{
  32635. UserOrgId: adminUser.CurrentOrgId,
  32636. Ctime: time.Now().Unix(),
  32637. Mtime: time.Now().Unix(),
  32638. Number: chrg_bchno,
  32639. ErrMsg: res.ErrMsg,
  32640. Status: 1,
  32641. PatientId: id,
  32642. RecordTime: recordDateTime,
  32643. Stage: 20,
  32644. }
  32645. service.CreateErrMsgLog(errlog)
  32646. c.ServeSuccessJSON(map[string]interface{}{
  32647. "failed_code": -10,
  32648. "msg": res.ErrMsg,
  32649. })
  32650. return
  32651. } else {
  32652. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  32653. order.OrderStatus = 1
  32654. order.IsPre = 1
  32655. order.Status = 1
  32656. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  32657. order.SetlId = res.Output.Setlinfo.SetlID
  32658. order.PsnNo = res.Output.Setlinfo.PsnNo
  32659. order.PsnName = res.Output.Setlinfo.PsnName
  32660. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  32661. order.Certno = res.Output.Setlinfo.Certno
  32662. order.Gend = res.Output.Setlinfo.Gend
  32663. order.Naty = res.Output.Setlinfo.Naty
  32664. order.Age = res.Output.Setlinfo.Age
  32665. order.Insutype = res.Output.Setlinfo.Insutype
  32666. order.PsnType = res.Output.Setlinfo.PsnType
  32667. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  32668. order.SetlTime = res.Output.Setlinfo.SetlTime
  32669. order.AcctUsedFlag = acct_used_flag
  32670. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  32671. if res.Output.Setlinfo.MedType == "140101" {
  32672. order.MedType = "14"
  32673. } else {
  32674. if res.Output.Setlinfo.MedType == "110104" {
  32675. order.MedType = "11"
  32676. } else {
  32677. order.MedType = res.Output.Setlinfo.MedType
  32678. }
  32679. }
  32680. if res.Output.Setlinfo.MedType == "992102" {
  32681. order.MedType = "992102"
  32682. }
  32683. if res.Output.Setlinfo.MedType == "140104" {
  32684. order.MedType = "140104"
  32685. }
  32686. if res.Output.Setlinfo.MedType == "1104" {
  32687. order.MedType = "1104"
  32688. }
  32689. if res.Output.Setlinfo.MedType == "140201" {
  32690. order.MedType = "140201"
  32691. }
  32692. if res.Output.Setlinfo.MedType == "14" {
  32693. order.MedType = "14"
  32694. }
  32695. if reg_type == 1112 {
  32696. order.MedType = "1112"
  32697. }
  32698. if reg_type == 1111 {
  32699. order.MedType = "1111"
  32700. }
  32701. order.ClrType = res.Output.Setlinfo.ClrType
  32702. if adminUser.CurrentOrgId == 10480 {
  32703. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  32704. order.ClrType = "11"
  32705. } else {
  32706. order.ClrType = "9903"
  32707. }
  32708. }
  32709. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  32710. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  32711. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  32712. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  32713. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  32714. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  32715. order.HifpPay = res.Output.Setlinfo.HifpPay
  32716. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  32717. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  32718. order.HifesPay = res.Output.Setlinfo.HifesPay
  32719. order.HifobPay = res.Output.Setlinfo.HifobPay
  32720. order.MafPay = res.Output.Setlinfo.MafPay
  32721. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  32722. order.OthPay = res.Output.Setlinfo.OthPay
  32723. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  32724. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  32725. order.AcctPay = res.Output.Setlinfo.AcctPay
  32726. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  32727. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  32728. order.Balc = res.Output.Setlinfo.Balc
  32729. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  32730. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  32731. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  32732. order.ClrWay = res.Output.Setlinfo.ClrWay
  32733. order.Creator = order.Creator
  32734. order.Modify = roles.AdminUserId
  32735. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  32736. //detailStr := string(setlDetail)
  32737. //order.SetlDetail = detailStr
  32738. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  32739. err = service.UpDateOrder(order)
  32740. if err == nil {
  32741. c.ServeSuccessJSON(map[string]interface{}{
  32742. "msg": "预结算成功",
  32743. })
  32744. } else {
  32745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  32746. return
  32747. }
  32748. }
  32749. } else {
  32750. adminUser := c.GetAdminUserInfo()
  32751. errlog := &models.HisOrderError{
  32752. UserOrgId: adminUser.CurrentOrgId,
  32753. Ctime: time.Now().Unix(),
  32754. Mtime: time.Now().Unix(),
  32755. ErrMsg: res.ErrMsg,
  32756. Status: 1,
  32757. PatientId: id,
  32758. RecordTime: recordDateTime,
  32759. Stage: 4,
  32760. }
  32761. service.CreateErrMsgLog(errlog)
  32762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  32763. return
  32764. }
  32765. } else {
  32766. if miConfig.MdtrtareaAdmvs == "150499" {
  32767. order := &models.HisOrder{
  32768. UserOrgId: adminUser.CurrentOrgId,
  32769. HisPatientId: his.ID,
  32770. PatientId: his.PatientId,
  32771. SettleAccountsDate: recordDateTime,
  32772. Ctime: time.Now().Unix(),
  32773. Mtime: time.Now().Unix(),
  32774. MdtrtId: his.Number,
  32775. PsnNo: his.PsnNo,
  32776. MedType: strconv.FormatInt(reg_type, 10),
  32777. Status: 1,
  32778. Number: chrg_bchno,
  32779. Infcode: res.Infcode,
  32780. WarnMsg: res.WarnMsg,
  32781. Cainfo: res.Cainfo,
  32782. ErrMsg: res.ErrMsg,
  32783. RespondTime: res.RefmsgTime,
  32784. InfRefmsgid: res.InfRefmsgid,
  32785. OrderStatus: 1,
  32786. IsMedicineInsurance: 1,
  32787. SettleType: settle_accounts_type,
  32788. SettleStartTime: start_time,
  32789. SettleEndTime: end_time,
  32790. Creator: roles.AdminUserId,
  32791. Modify: roles.AdminUserId,
  32792. PType: 2,
  32793. Diagnosis: diagnosis_id,
  32794. }
  32795. err = service.CreateOrder(order)
  32796. if err != nil {
  32797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  32798. return
  32799. }
  32800. }
  32801. adminUser := c.GetAdminUserInfo()
  32802. errlog := &models.HisOrderError{
  32803. UserOrgId: adminUser.CurrentOrgId,
  32804. Ctime: time.Now().Unix(),
  32805. Mtime: time.Now().Unix(),
  32806. ErrMsg: res.ErrMsg,
  32807. Status: 1,
  32808. PatientId: id,
  32809. RecordTime: recordDateTime,
  32810. Stage: 4,
  32811. }
  32812. service.CreateErrMsgLog(errlog)
  32813. c.ServeSuccessJSON(map[string]interface{}{
  32814. "failed_code": -10,
  32815. "msg": res.ErrMsg,
  32816. })
  32817. return
  32818. }
  32819. }
  32820. }
  32821. }
  32822. // 退款
  32823. func (c *HisApiController) Refund() {
  32824. order_id, _ := c.GetInt64("order_id")
  32825. admin_user_id, _ := c.GetInt64("admin_user_id")
  32826. adminUser := c.GetAdminUserInfo()
  32827. var order models.HisOrder
  32828. order, _ = service.GetHisOrderByID(order_id)
  32829. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  32830. if fapiao.ID > 0 {
  32831. c.ServeSuccessJSON(map[string]interface{}{
  32832. "failed_code": -10,
  32833. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  32834. })
  32835. return
  32836. }
  32837. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32838. if order.ID == 0 {
  32839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32840. return
  32841. }
  32842. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  32843. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32844. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32845. if config.IsOpen == 1 { //对接了医保,走医保流程
  32846. var res ResultSixteen
  32847. var ahres ResultSevenAH
  32848. var resSixteen10265 ResultSixteen10265
  32849. var resSixteen10265Two ResultSixteen10265Two
  32850. var gz ResultgzSixteen10265Two
  32851. var src_resquest string
  32852. var result string
  32853. if miConfig.MdtrtareaAdmvs == "421300" {
  32854. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  32855. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32856. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32857. resp3, requestErr3 := http.Get(api3)
  32858. if requestErr3 != nil {
  32859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32860. return
  32861. }
  32862. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32863. if ioErr3 != nil {
  32864. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32866. return
  32867. }
  32868. var respJSON3 map[string]interface{}
  32869. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32870. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32872. return
  32873. }
  32874. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32875. userJSONBytes3, _ := json.Marshal(respJSON3)
  32876. fmt.Println("log")
  32877. fmt.Println(string(userJSONBytes3))
  32878. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32879. utils.ErrorLog("解析失败:%v", err)
  32880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32881. return
  32882. }
  32883. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32884. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  32885. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32886. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32887. resp3, requestErr3 := http.Get(api3)
  32888. if requestErr3 != nil {
  32889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32890. return
  32891. }
  32892. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32893. if ioErr3 != nil {
  32894. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32896. return
  32897. }
  32898. var respJSON3 map[string]interface{}
  32899. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32900. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32902. return
  32903. }
  32904. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32905. userJSONBytes3, _ := json.Marshal(respJSON3)
  32906. fmt.Println("log")
  32907. fmt.Println(string(userJSONBytes3))
  32908. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32909. utils.ErrorLog("解析失败:%v", err)
  32910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32911. return
  32912. }
  32913. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32914. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  32915. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32916. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32917. resp3, requestErr3 := http.Get(api3)
  32918. if requestErr3 != nil {
  32919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32920. return
  32921. }
  32922. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32923. if ioErr3 != nil {
  32924. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32926. return
  32927. }
  32928. var respJSON3 map[string]interface{}
  32929. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32930. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32932. return
  32933. }
  32934. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32935. userJSONBytes3, _ := json.Marshal(respJSON3)
  32936. fmt.Println("log")
  32937. fmt.Println(string(userJSONBytes3))
  32938. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32939. utils.ErrorLog("解析失败:%v", err)
  32940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32941. return
  32942. }
  32943. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32944. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  32945. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32946. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32947. resp3, requestErr3 := http.Get(api3)
  32948. if requestErr3 != nil {
  32949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32950. return
  32951. }
  32952. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32953. if ioErr3 != nil {
  32954. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32956. return
  32957. }
  32958. var respJSON3 map[string]interface{}
  32959. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32960. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32962. return
  32963. }
  32964. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32965. userJSONBytes3, _ := json.Marshal(respJSON3)
  32966. fmt.Println("log")
  32967. fmt.Println(string(userJSONBytes3))
  32968. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32969. utils.ErrorLog("解析失败:%v", err)
  32970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32971. return
  32972. }
  32973. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  32974. var api3 string
  32975. if miConfig.MdtrtareaAdmvs == "320830" {
  32976. api3 = miConfig.AppSecret + "jsyb/2208?psn_no=" + order.PsnNo +
  32977. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32978. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32979. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32980. } else if miConfig.MdtrtareaAdmvs == "320921" {
  32981. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  32982. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32983. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32984. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32985. } else {
  32986. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32987. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  32988. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32989. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32990. }
  32991. resp3, requestErr3 := http.Get(api3)
  32992. if requestErr3 != nil {
  32993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32994. return
  32995. }
  32996. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32997. if ioErr3 != nil {
  32998. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33000. return
  33001. }
  33002. var respJSON3 map[string]interface{}
  33003. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33004. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33006. return
  33007. }
  33008. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33009. userJSONBytes3, _ := json.Marshal(respJSON3)
  33010. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  33011. utils.ErrorLog("解析失败:%v", err)
  33012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33013. return
  33014. }
  33015. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  33016. res.Output = resSixteen10265.Output
  33017. res.ErrMsg = resSixteen10265.ErrMsg
  33018. res.Cainfo = resSixteen10265.Cainfo
  33019. res.WarnMsg = resSixteen10265.WarnMsg
  33020. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  33021. res.Infcode = infocode
  33022. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33023. var api3 string
  33024. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  33025. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33026. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33027. resp3, requestErr3 := http.Get(api3)
  33028. if requestErr3 != nil {
  33029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33030. return
  33031. }
  33032. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33033. if ioErr3 != nil {
  33034. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33036. return
  33037. }
  33038. var respJSON3 map[string]interface{}
  33039. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33040. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33042. return
  33043. }
  33044. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33045. userJSONBytes3, _ := json.Marshal(respJSON3)
  33046. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  33047. utils.ErrorLog("解析失败:%v", err)
  33048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33049. return
  33050. }
  33051. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  33052. res.Output = resSixteen10265.Output
  33053. res.ErrMsg = resSixteen10265.ErrMsg
  33054. res.Cainfo = resSixteen10265.Cainfo
  33055. res.WarnMsg = resSixteen10265.WarnMsg
  33056. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  33057. res.Infcode = infocode
  33058. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33059. 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)
  33060. var dat map[string]interface{}
  33061. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33062. fmt.Println(dat)
  33063. } else {
  33064. fmt.Println(err)
  33065. }
  33066. saveLog(result, src_resquest, "2208", "退费")
  33067. userJSONBytes, _ := json.Marshal(dat)
  33068. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33069. utils.ErrorLog("解析失败:%v", err)
  33070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33071. return
  33072. }
  33073. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33074. 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, "")
  33075. var dat map[string]interface{}
  33076. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33077. fmt.Println(dat)
  33078. } else {
  33079. fmt.Println(err)
  33080. }
  33081. saveLog(result, src_resquest, "2208", "退费")
  33082. userJSONBytes, _ := json.Marshal(dat)
  33083. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33084. utils.ErrorLog("解析失败:%v", err)
  33085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33086. return
  33087. }
  33088. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33089. 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, "")
  33090. var dat map[string]interface{}
  33091. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33092. fmt.Println(dat)
  33093. } else {
  33094. fmt.Println(err)
  33095. }
  33096. saveLog(result, src_resquest, "2208", "退费")
  33097. userJSONBytes, _ := json.Marshal(dat)
  33098. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33099. utils.ErrorLog("解析失败:%v", err)
  33100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33101. return
  33102. }
  33103. } else if miConfig.MdtrtareaAdmvs == "360100" {
  33104. 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, "")
  33105. var dat map[string]interface{}
  33106. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33107. fmt.Println(dat)
  33108. } else {
  33109. fmt.Println(err)
  33110. }
  33111. saveLog(result, src_resquest, "2208", "退费")
  33112. userJSONBytes, _ := json.Marshal(dat)
  33113. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33114. utils.ErrorLog("解析失败:%v", err)
  33115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33116. return
  33117. }
  33118. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33119. var api3 string
  33120. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  33121. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33122. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33123. resp3, requestErr3 := http.Get(api3)
  33124. if requestErr3 != nil {
  33125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33126. return
  33127. }
  33128. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33129. if ioErr3 != nil {
  33130. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33132. return
  33133. }
  33134. var respJSON3 map[string]interface{}
  33135. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33136. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33138. return
  33139. }
  33140. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33141. if status == "0" {
  33142. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33143. c.ServeSuccessJSON(map[string]interface{}{
  33144. "failed_code": -10,
  33145. "msg": err_msg,
  33146. })
  33147. return
  33148. }
  33149. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33150. userJSONBytes3, _ := json.Marshal(respJSON3)
  33151. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33152. // utils.ErrorLog("解析失败:%v", err)
  33153. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33154. // return
  33155. //}
  33156. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  33157. utils.ErrorLog("解析失败:%v", err)
  33158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33159. return
  33160. }
  33161. res.InfRefmsgid = ahres.InfRefmsgid
  33162. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  33163. // 创建对应的Time类型
  33164. t := time.UnixMilli(timestamp)
  33165. // 格式化成指定的日期字符串
  33166. str := t.Format("2006-01-02 15:04:05")
  33167. res.Output.Setlinfo.SetlTime = str
  33168. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  33169. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  33170. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33171. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  33172. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  33173. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  33174. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  33175. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  33176. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  33177. //
  33178. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  33179. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  33180. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  33181. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33182. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  33183. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  33184. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  33185. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  33186. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  33187. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  33188. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  33189. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  33190. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  33191. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  33192. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  33193. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  33194. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  33195. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  33196. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  33197. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  33198. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  33199. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  33200. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  33201. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  33202. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  33203. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  33204. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  33205. //res.Output.Setldetail = ahres.Output.Setldetail
  33206. res.ErrMsg = ahres.ErrMsg
  33207. res.Cainfo = ahres.Cainfo
  33208. res.WarnMsg = ahres.WarnMsg
  33209. res.Infcode = ahres.Infcode
  33210. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33211. var api3 string
  33212. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  33213. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33214. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33215. resp3, requestErr3 := http.Get(api3)
  33216. if requestErr3 != nil {
  33217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33218. return
  33219. }
  33220. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33221. if ioErr3 != nil {
  33222. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33224. return
  33225. }
  33226. var respJSON3 map[string]interface{}
  33227. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33228. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33230. return
  33231. }
  33232. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33233. if status == "0" {
  33234. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33235. c.ServeSuccessJSON(map[string]interface{}{
  33236. "failed_code": -10,
  33237. "msg": err_msg,
  33238. })
  33239. return
  33240. }
  33241. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33242. userJSONBytes3, _ := json.Marshal(respJSON3)
  33243. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33244. // utils.ErrorLog("解析失败:%v", err)
  33245. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33246. // return
  33247. //}
  33248. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  33249. utils.ErrorLog("解析失败:%v", err)
  33250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33251. return
  33252. }
  33253. res.InfRefmsgid = ahres.InfRefmsgid
  33254. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  33255. // 创建对应的Time类型
  33256. t := time.UnixMilli(timestamp)
  33257. // 格式化成指定的日期字符串
  33258. str := t.Format("2006-01-02 15:04:05")
  33259. res.Output.Setlinfo.SetlTime = str
  33260. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  33261. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  33262. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33263. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  33264. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  33265. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  33266. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  33267. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  33268. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  33269. //
  33270. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  33271. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  33272. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  33273. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33274. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  33275. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  33276. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  33277. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  33278. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  33279. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  33280. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  33281. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  33282. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  33283. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  33284. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  33285. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  33286. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  33287. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  33288. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  33289. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  33290. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  33291. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  33292. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  33293. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  33294. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  33295. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  33296. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  33297. //res.Output.Setldetail = ahres.Output.Setldetail
  33298. res.ErrMsg = ahres.ErrMsg
  33299. res.Cainfo = ahres.Cainfo
  33300. res.WarnMsg = ahres.WarnMsg
  33301. res.Infcode = ahres.Infcode
  33302. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33303. 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, "")
  33304. var dat map[string]interface{}
  33305. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33306. fmt.Println(dat)
  33307. } else {
  33308. fmt.Println(err)
  33309. }
  33310. saveLog(result, src_resquest, "2208", "退费")
  33311. userJSONBytes, _ := json.Marshal(dat)
  33312. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33313. utils.ErrorLog("解析失败:%v", err)
  33314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33315. return
  33316. }
  33317. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33318. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  33319. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33320. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33321. resp3, requestErr3 := http.Get(api3)
  33322. if requestErr3 != nil {
  33323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33324. return
  33325. }
  33326. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33327. if ioErr3 != nil {
  33328. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33330. return
  33331. }
  33332. var respJSON3 map[string]interface{}
  33333. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33334. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33336. return
  33337. }
  33338. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33339. userJSONBytes3, _ := json.Marshal(respJSON3)
  33340. fmt.Println("log")
  33341. fmt.Println(string(userJSONBytes3))
  33342. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33343. utils.ErrorLog("解析失败:%v", err)
  33344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33345. return
  33346. }
  33347. } else {
  33348. if miConfig.Code == "H15049901371" {
  33349. 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)
  33350. var dat map[string]interface{}
  33351. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33352. fmt.Println(dat)
  33353. } else {
  33354. fmt.Println(err)
  33355. }
  33356. saveLog(result, src_resquest, "2208", "退费")
  33357. if strings.Contains(result, "Post") {
  33358. res.Infcode = -1
  33359. res.ErrMsg = result
  33360. }
  33361. userJSONBytes, _ := json.Marshal(dat)
  33362. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  33363. utils.ErrorLog("解析失败:%v", err)
  33364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33365. return
  33366. }
  33367. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  33368. res.Output = resSixteen10265.Output
  33369. res.ErrMsg = resSixteen10265.ErrMsg
  33370. res.Cainfo = resSixteen10265.Cainfo
  33371. res.WarnMsg = resSixteen10265.WarnMsg
  33372. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  33373. res.Infcode = infocode
  33374. } else {
  33375. 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)
  33376. var dat map[string]interface{}
  33377. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33378. fmt.Println(dat)
  33379. } else {
  33380. fmt.Println(err)
  33381. }
  33382. saveLog(result, src_resquest, "2208", "退费")
  33383. userJSONBytes, _ := json.Marshal(dat)
  33384. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  33385. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  33386. utils.ErrorLog("解析失败:%v", err)
  33387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33388. return
  33389. }
  33390. res.Infcode = gz.Infcode
  33391. } else {
  33392. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33393. utils.ErrorLog("解析失败:%v", err)
  33394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33395. return
  33396. }
  33397. }
  33398. if strings.Contains(result, "Post") {
  33399. res.Infcode = -1
  33400. res.ErrMsg = result
  33401. }
  33402. }
  33403. }
  33404. if res.Infcode == -1 {
  33405. c.ServeSuccessJSON(map[string]interface{}{
  33406. "failed_code": -10,
  33407. "msg": res.ErrMsg,
  33408. })
  33409. return
  33410. }
  33411. if res.Infcode != -1 {
  33412. var res2 ResultSix
  33413. var resSix10265 ResultSix10265
  33414. if miConfig.MdtrtareaAdmvs == "421300" {
  33415. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  33416. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33417. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33418. resp3, requestErr3 := http.Get(api3)
  33419. if requestErr3 != nil {
  33420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33421. return
  33422. }
  33423. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33424. if ioErr3 != nil {
  33425. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33427. return
  33428. }
  33429. var respJSON3 map[string]interface{}
  33430. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33431. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33433. return
  33434. }
  33435. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33436. userJSONBytes3, _ := json.Marshal(respJSON3)
  33437. fmt.Println("log")
  33438. fmt.Println(string(userJSONBytes3))
  33439. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33440. utils.ErrorLog("解析失败:%v", err)
  33441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33442. return
  33443. }
  33444. } else if miConfig.MdtrtareaAdmvs == "420200" {
  33445. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  33446. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33447. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33448. resp3, requestErr3 := http.Get(api3)
  33449. if requestErr3 != nil {
  33450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33451. return
  33452. }
  33453. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33454. if ioErr3 != nil {
  33455. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33457. return
  33458. }
  33459. var respJSON3 map[string]interface{}
  33460. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33461. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33463. return
  33464. }
  33465. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33466. userJSONBytes3, _ := json.Marshal(respJSON3)
  33467. fmt.Println("log")
  33468. fmt.Println(string(userJSONBytes3))
  33469. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33470. utils.ErrorLog("解析失败:%v", err)
  33471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33472. return
  33473. }
  33474. } else if miConfig.MdtrtareaAdmvs == "420902" {
  33475. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  33476. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33477. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33478. resp3, requestErr3 := http.Get(api3)
  33479. if requestErr3 != nil {
  33480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33481. return
  33482. }
  33483. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33484. if ioErr3 != nil {
  33485. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33487. return
  33488. }
  33489. var respJSON3 map[string]interface{}
  33490. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33491. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33493. return
  33494. }
  33495. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33496. userJSONBytes3, _ := json.Marshal(respJSON3)
  33497. fmt.Println("log")
  33498. fmt.Println(string(userJSONBytes3))
  33499. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33500. utils.ErrorLog("解析失败:%v", err)
  33501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33502. return
  33503. }
  33504. } else if miConfig.MdtrtareaAdmvs == "421182" {
  33505. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  33506. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33507. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33508. resp3, requestErr3 := http.Get(api3)
  33509. if requestErr3 != nil {
  33510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33511. return
  33512. }
  33513. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33514. if ioErr3 != nil {
  33515. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33517. return
  33518. }
  33519. var respJSON3 map[string]interface{}
  33520. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33521. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33523. return
  33524. }
  33525. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33526. userJSONBytes3, _ := json.Marshal(respJSON3)
  33527. fmt.Println("log")
  33528. fmt.Println(string(userJSONBytes3))
  33529. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33530. utils.ErrorLog("解析失败:%v", err)
  33531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33532. return
  33533. }
  33534. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  33535. var api3 string
  33536. if miConfig.MdtrtareaAdmvs == "320830" {
  33537. api3 = miConfig.AppSecret + "jsyb/2205?psn_no=" + order.PsnNo +
  33538. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + "0000" + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33539. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33540. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33541. } else if miConfig.MdtrtareaAdmvs == "320921" {
  33542. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  33543. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33544. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33545. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33546. } else {
  33547. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33548. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  33549. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33550. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33551. }
  33552. resp3, requestErr3 := http.Get(api3)
  33553. if requestErr3 != nil {
  33554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33555. return
  33556. }
  33557. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33558. if ioErr3 != nil {
  33559. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33561. return
  33562. }
  33563. var respJSON3 map[string]interface{}
  33564. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33565. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33567. return
  33568. }
  33569. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33570. userJSONBytes3, _ := json.Marshal(respJSON3)
  33571. fmt.Println("log")
  33572. fmt.Println(string(userJSONBytes3))
  33573. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33574. utils.ErrorLog("解析失败:%v", err)
  33575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33576. return
  33577. }
  33578. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33579. res2.Output = resSix10265.Output
  33580. res2.ErrMsg = resSix10265.ErrMsg
  33581. res2.Cainfo = resSix10265.Cainfo
  33582. res2.WarnMsg = resSix10265.WarnMsg
  33583. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33584. res2.Infcode = infocode
  33585. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33586. var api3 string
  33587. new_chrg_bchno := order.Number
  33588. if adminUser.CurrentOrgId == 10265 {
  33589. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  33590. new_chrg_bchno = "0000"
  33591. }
  33592. }
  33593. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  33594. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33595. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33596. resp3, requestErr3 := http.Get(api3)
  33597. if requestErr3 != nil {
  33598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33599. return
  33600. }
  33601. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33602. if ioErr3 != nil {
  33603. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33605. return
  33606. }
  33607. var respJSON3 map[string]interface{}
  33608. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33609. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33611. return
  33612. }
  33613. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33614. userJSONBytes3, _ := json.Marshal(respJSON3)
  33615. fmt.Println("log")
  33616. fmt.Println(string(userJSONBytes3))
  33617. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33618. utils.ErrorLog("解析失败:%v", err)
  33619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33620. return
  33621. }
  33622. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33623. res2.Output = resSix10265.Output
  33624. res2.ErrMsg = resSix10265.ErrMsg
  33625. res2.Cainfo = resSix10265.Cainfo
  33626. res2.WarnMsg = resSix10265.WarnMsg
  33627. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33628. res2.Infcode = infocode
  33629. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33630. 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)
  33631. var dat map[string]interface{}
  33632. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33633. fmt.Println(dat)
  33634. } else {
  33635. fmt.Println(err)
  33636. }
  33637. saveLog(result2, src_request, "2205", "撤销明细")
  33638. userJSONBytes, _ := json.Marshal(dat)
  33639. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33640. utils.ErrorLog("解析失败:%v", err)
  33641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33642. return
  33643. }
  33644. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33645. 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, "")
  33646. var dat map[string]interface{}
  33647. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33648. fmt.Println(dat)
  33649. } else {
  33650. fmt.Println(err)
  33651. }
  33652. saveLog(result2, src_request, "2205", "撤销明细")
  33653. userJSONBytes, _ := json.Marshal(dat)
  33654. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33655. utils.ErrorLog("解析失败:%v", err)
  33656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33657. return
  33658. }
  33659. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33660. 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, "")
  33661. var dat map[string]interface{}
  33662. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33663. fmt.Println(dat)
  33664. } else {
  33665. fmt.Println(err)
  33666. }
  33667. saveLog(result2, src_request, "2205", "撤销明细")
  33668. userJSONBytes, _ := json.Marshal(dat)
  33669. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33670. utils.ErrorLog("解析失败:%v", err)
  33671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33672. return
  33673. }
  33674. } else if miConfig.MdtrtareaAdmvs == "360100" {
  33675. 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, "")
  33676. var dat map[string]interface{}
  33677. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33678. fmt.Println(dat)
  33679. } else {
  33680. fmt.Println(err)
  33681. }
  33682. saveLog(result2, src_request, "2205", "撤销明细")
  33683. userJSONBytes, _ := json.Marshal(dat)
  33684. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33685. utils.ErrorLog("解析失败:%v", err)
  33686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33687. return
  33688. }
  33689. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33690. var api3 string
  33691. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  33692. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33693. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33694. resp3, requestErr3 := http.Get(api3)
  33695. if requestErr3 != nil {
  33696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33697. return
  33698. }
  33699. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33700. if ioErr3 != nil {
  33701. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33703. return
  33704. }
  33705. var respJSON3 map[string]interface{}
  33706. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33707. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33709. return
  33710. }
  33711. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33712. if status == "0" {
  33713. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33714. c.ServeSuccessJSON(map[string]interface{}{
  33715. "failed_code": -10,
  33716. "msg": err_msg,
  33717. })
  33718. return
  33719. }
  33720. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33721. userJSONBytes3, _ := json.Marshal(respJSON3)
  33722. fmt.Println("log")
  33723. fmt.Println(string(userJSONBytes3))
  33724. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33725. utils.ErrorLog("解析失败:%v", err)
  33726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33727. return
  33728. }
  33729. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33730. 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, "")
  33731. var dat map[string]interface{}
  33732. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33733. fmt.Println(dat)
  33734. } else {
  33735. fmt.Println(err)
  33736. }
  33737. saveLog(result2, src_request, "2205", "撤销明细")
  33738. userJSONBytes, _ := json.Marshal(dat)
  33739. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33740. utils.ErrorLog("解析失败:%v", err)
  33741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33742. return
  33743. }
  33744. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33745. 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, "")
  33746. var dat map[string]interface{}
  33747. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33748. fmt.Println(dat)
  33749. } else {
  33750. fmt.Println(err)
  33751. }
  33752. saveLog(result2, src_request, "2205", "撤销明细")
  33753. userJSONBytes, _ := json.Marshal(dat)
  33754. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33755. utils.ErrorLog("解析失败:%v", err)
  33756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33757. return
  33758. }
  33759. } else if miConfig.MdtrtareaAdmvs == "360100" {
  33760. 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, "")
  33761. var dat map[string]interface{}
  33762. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33763. fmt.Println(dat)
  33764. } else {
  33765. fmt.Println(err)
  33766. }
  33767. saveLog(result2, src_request, "2205", "撤销明细")
  33768. userJSONBytes, _ := json.Marshal(dat)
  33769. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33770. utils.ErrorLog("解析失败:%v", err)
  33771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33772. return
  33773. }
  33774. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33775. var api3 string
  33776. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  33777. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33778. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33779. resp3, requestErr3 := http.Get(api3)
  33780. if requestErr3 != nil {
  33781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33782. return
  33783. }
  33784. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33785. if ioErr3 != nil {
  33786. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33788. return
  33789. }
  33790. var respJSON3 map[string]interface{}
  33791. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33792. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33794. return
  33795. }
  33796. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33797. if status == "0" {
  33798. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33799. c.ServeSuccessJSON(map[string]interface{}{
  33800. "failed_code": -10,
  33801. "msg": err_msg,
  33802. })
  33803. return
  33804. }
  33805. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33806. userJSONBytes3, _ := json.Marshal(respJSON3)
  33807. fmt.Println("log")
  33808. fmt.Println(string(userJSONBytes3))
  33809. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33810. utils.ErrorLog("解析失败:%v", err)
  33811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33812. return
  33813. }
  33814. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33815. 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, "")
  33816. var dat map[string]interface{}
  33817. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33818. fmt.Println(dat)
  33819. } else {
  33820. fmt.Println(err)
  33821. }
  33822. saveLog(result2, src_request, "2205", "撤销明细")
  33823. userJSONBytes, _ := json.Marshal(dat)
  33824. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33825. utils.ErrorLog("解析失败:%v", err)
  33826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33827. return
  33828. }
  33829. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33830. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  33831. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33832. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33833. resp3, requestErr3 := http.Get(api3)
  33834. if requestErr3 != nil {
  33835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33836. return
  33837. }
  33838. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33839. if ioErr3 != nil {
  33840. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33842. return
  33843. }
  33844. var respJSON3 map[string]interface{}
  33845. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33846. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33848. return
  33849. }
  33850. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33851. userJSONBytes3, _ := json.Marshal(respJSON3)
  33852. fmt.Println("log")
  33853. fmt.Println(string(userJSONBytes3))
  33854. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33855. utils.ErrorLog("解析失败:%v", err)
  33856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33857. return
  33858. }
  33859. } else {
  33860. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  33861. res2.Infcode = 0
  33862. } else {
  33863. 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)
  33864. var dat map[string]interface{}
  33865. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33866. fmt.Println(dat)
  33867. } else {
  33868. fmt.Println(err)
  33869. }
  33870. saveLog(result2, src_request, "2205", "撤销明细")
  33871. userJSONBytes, _ := json.Marshal(dat)
  33872. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33873. utils.ErrorLog("解析失败:%v", err)
  33874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33875. return
  33876. }
  33877. }
  33878. }
  33879. if res2.Infcode == -1 {
  33880. c.ServeSuccessJSON(map[string]interface{}{
  33881. "failed_code": -10,
  33882. "msg": res2.ErrMsg,
  33883. })
  33884. return
  33885. }
  33886. if res2.Infcode == 0 {
  33887. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  33888. if err == nil {
  33889. //当押金不为零时产生退费记录
  33890. if order.Decimal != 0 {
  33891. tmp := strconv.FormatInt(order.ID, 10)
  33892. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  33893. if err != nil {
  33894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33895. return
  33896. }
  33897. }
  33898. c.ServeSuccessJSON(map[string]interface{}{
  33899. "msg": "退费成功",
  33900. })
  33901. } else {
  33902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33903. return
  33904. }
  33905. } else {
  33906. c.ServeSuccessJSON(map[string]interface{}{
  33907. "failed_code": -10,
  33908. "msg": res2.ErrMsg,
  33909. })
  33910. }
  33911. } else {
  33912. c.ServeSuccessJSON(map[string]interface{}{
  33913. "failed_code": -10,
  33914. "msg": res.ErrMsg,
  33915. })
  33916. }
  33917. }
  33918. }
  33919. func (c *HisApiController) RefundNumber() {
  33920. record_time := c.GetString("record_time")
  33921. //patient_id, _ := c.GetInt64("patient_id")
  33922. admin_user_id, _ := c.GetInt64("admin_user_id")
  33923. his_patient_id, _ := c.GetInt64("id")
  33924. timeLayout := "2006-01-02"
  33925. loc, _ := time.LoadLocation("Local")
  33926. adminUser := c.GetAdminUserInfo()
  33927. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  33928. fmt.Println(err)
  33929. if err != nil {
  33930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  33931. return
  33932. }
  33933. recordDateTime := theTime.Unix()
  33934. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  33935. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  33936. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  33937. //order, _ := service.GetHisOrderByID(order_id)
  33938. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33939. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33940. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33941. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  33942. if count > 0 {
  33943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  33944. return
  33945. }
  33946. if config.IsOpen == 1 { //对接了医保,走医保流程
  33947. var res2 ResultSix
  33948. var res3 GZResultSix
  33949. var resSix10265 ResultSix10265
  33950. if miConfig.MdtrtareaAdmvs == "421300" {
  33951. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  33952. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33953. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33954. resp3, requestErr3 := http.Get(api3)
  33955. if requestErr3 != nil {
  33956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33957. return
  33958. }
  33959. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33960. if ioErr3 != nil {
  33961. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33963. return
  33964. }
  33965. var respJSON3 map[string]interface{}
  33966. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33967. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33969. return
  33970. }
  33971. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33972. userJSONBytes3, _ := json.Marshal(respJSON3)
  33973. fmt.Println("log")
  33974. fmt.Println(string(userJSONBytes3))
  33975. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33976. utils.ErrorLog("解析失败:%v", err)
  33977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33978. return
  33979. }
  33980. } else if miConfig.MdtrtareaAdmvs == "420200" {
  33981. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  33982. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33983. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33984. resp3, requestErr3 := http.Get(api3)
  33985. if requestErr3 != nil {
  33986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33987. return
  33988. }
  33989. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33990. if ioErr3 != nil {
  33991. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33993. return
  33994. }
  33995. var respJSON3 map[string]interface{}
  33996. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33997. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33999. return
  34000. }
  34001. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34002. userJSONBytes3, _ := json.Marshal(respJSON3)
  34003. fmt.Println("log")
  34004. fmt.Println(string(userJSONBytes3))
  34005. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34006. utils.ErrorLog("解析失败:%v", err)
  34007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34008. return
  34009. }
  34010. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34011. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  34012. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34013. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34014. resp3, requestErr3 := http.Get(api3)
  34015. if requestErr3 != nil {
  34016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34017. return
  34018. }
  34019. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34020. if ioErr3 != nil {
  34021. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34023. return
  34024. }
  34025. var respJSON3 map[string]interface{}
  34026. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34027. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34029. return
  34030. }
  34031. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34032. userJSONBytes3, _ := json.Marshal(respJSON3)
  34033. fmt.Println("log")
  34034. fmt.Println(string(userJSONBytes3))
  34035. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34036. utils.ErrorLog("解析失败:%v", err)
  34037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34038. return
  34039. }
  34040. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34041. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  34042. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34043. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34044. resp3, requestErr3 := http.Get(api3)
  34045. if requestErr3 != nil {
  34046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34047. return
  34048. }
  34049. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34050. if ioErr3 != nil {
  34051. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34053. return
  34054. }
  34055. var respJSON3 map[string]interface{}
  34056. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34057. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34059. return
  34060. }
  34061. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34062. userJSONBytes3, _ := json.Marshal(respJSON3)
  34063. fmt.Println("log")
  34064. fmt.Println(string(userJSONBytes3))
  34065. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34066. utils.ErrorLog("解析失败:%v", err)
  34067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34068. return
  34069. }
  34070. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  34071. var api3 string
  34072. if miConfig.MdtrtareaAdmvs == "320830" {
  34073. api3 = miConfig.AppSecret + "jsyb/2202?psn_no=" + his.PsnNo +
  34074. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34075. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34076. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34077. } else if miConfig.MdtrtareaAdmvs == "320921" {
  34078. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  34079. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34080. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34081. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34082. } else {
  34083. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34084. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  34085. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34086. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34087. }
  34088. resp3, requestErr3 := http.Get(api3)
  34089. if requestErr3 != nil {
  34090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34091. return
  34092. }
  34093. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34094. if ioErr3 != nil {
  34095. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34097. return
  34098. }
  34099. var respJSON3 map[string]interface{}
  34100. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34101. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34103. return
  34104. }
  34105. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34106. userJSONBytes3, _ := json.Marshal(respJSON3)
  34107. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34108. utils.ErrorLog("解析失败:%v", err)
  34109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34110. return
  34111. }
  34112. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34113. res2.Output = resSix10265.Output
  34114. res2.ErrMsg = resSix10265.ErrMsg
  34115. res2.Cainfo = resSix10265.Cainfo
  34116. res2.WarnMsg = resSix10265.WarnMsg
  34117. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34118. res2.Infcode = infocode
  34119. } else if miConfig.MdtrtareaAdmvs == "150499" {
  34120. var api3 string
  34121. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  34122. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34123. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34124. resp3, requestErr3 := http.Get(api3)
  34125. if requestErr3 != nil {
  34126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34127. return
  34128. }
  34129. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34130. if ioErr3 != nil {
  34131. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34133. return
  34134. }
  34135. var respJSON3 map[string]interface{}
  34136. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34137. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34139. return
  34140. }
  34141. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34142. userJSONBytes3, _ := json.Marshal(respJSON3)
  34143. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34144. utils.ErrorLog("解析失败:%v", err)
  34145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34146. return
  34147. }
  34148. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34149. res2.Output = resSix10265.Output
  34150. res2.ErrMsg = resSix10265.ErrMsg
  34151. res2.Cainfo = resSix10265.Cainfo
  34152. res2.WarnMsg = resSix10265.WarnMsg
  34153. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34154. res2.Infcode = infocode
  34155. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34156. 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)
  34157. var dat map[string]interface{}
  34158. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34159. fmt.Println(dat)
  34160. } else {
  34161. fmt.Println(err)
  34162. }
  34163. saveLog(result, request, "2202", "退号")
  34164. userJSONBytes, _ := json.Marshal(dat)
  34165. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34166. utils.ErrorLog("解析失败:%v", err)
  34167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34168. return
  34169. }
  34170. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34171. 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, "")
  34172. var dat map[string]interface{}
  34173. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34174. fmt.Println(dat)
  34175. } else {
  34176. fmt.Println(err)
  34177. }
  34178. saveLog(result, request, "2202", "退号")
  34179. userJSONBytes, _ := json.Marshal(dat)
  34180. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34181. utils.ErrorLog("解析失败:%v", err)
  34182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34183. return
  34184. }
  34185. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34186. 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, "")
  34187. var dat map[string]interface{}
  34188. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34189. fmt.Println(dat)
  34190. } else {
  34191. fmt.Println(err)
  34192. }
  34193. saveLog(result, request, "2202", "退号")
  34194. userJSONBytes, _ := json.Marshal(dat)
  34195. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34196. utils.ErrorLog("解析失败:%v", err)
  34197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34198. return
  34199. }
  34200. } else if miConfig.MdtrtareaAdmvs == "360100" {
  34201. 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, "")
  34202. var dat map[string]interface{}
  34203. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34204. fmt.Println(dat)
  34205. } else {
  34206. fmt.Println(err)
  34207. }
  34208. saveLog(result, request, "2202", "退号")
  34209. userJSONBytes, _ := json.Marshal(dat)
  34210. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34211. utils.ErrorLog("解析失败:%v", err)
  34212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34213. return
  34214. }
  34215. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34216. var api3 string
  34217. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  34218. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34219. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34220. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34221. resp3, requestErr3 := http.Get(api3)
  34222. if requestErr3 != nil {
  34223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34224. return
  34225. }
  34226. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34227. if ioErr3 != nil {
  34228. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34230. return
  34231. }
  34232. var respJSON3 map[string]interface{}
  34233. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34234. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34236. return
  34237. }
  34238. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34239. if status == "0" {
  34240. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34241. c.ServeSuccessJSON(map[string]interface{}{
  34242. "failed_code": -10,
  34243. "msg": err_msg,
  34244. })
  34245. return
  34246. }
  34247. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34248. userJSONBytes3, _ := json.Marshal(respJSON3)
  34249. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34250. utils.ErrorLog("解析失败:%v", err)
  34251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34252. return
  34253. }
  34254. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  34255. } else if miConfig.MdtrtareaAdmvs == "340699" {
  34256. var api3 string
  34257. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  34258. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34259. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34260. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34261. resp3, requestErr3 := http.Get(api3)
  34262. if requestErr3 != nil {
  34263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34264. return
  34265. }
  34266. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34267. if ioErr3 != nil {
  34268. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34270. return
  34271. }
  34272. var respJSON3 map[string]interface{}
  34273. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34274. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34276. return
  34277. }
  34278. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34279. if status == "0" {
  34280. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34281. c.ServeSuccessJSON(map[string]interface{}{
  34282. "failed_code": -10,
  34283. "msg": err_msg,
  34284. })
  34285. return
  34286. }
  34287. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34288. userJSONBytes3, _ := json.Marshal(respJSON3)
  34289. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34290. utils.ErrorLog("解析失败:%v", err)
  34291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34292. return
  34293. }
  34294. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  34295. } else if miConfig.MdtrtareaAdmvs == "430800" {
  34296. 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, "")
  34297. var dat map[string]interface{}
  34298. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34299. fmt.Println(dat)
  34300. } else {
  34301. fmt.Println(err)
  34302. }
  34303. saveLog(result, request, "2202", "退号")
  34304. userJSONBytes, _ := json.Marshal(dat)
  34305. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34306. utils.ErrorLog("解析失败:%v", err)
  34307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34308. return
  34309. }
  34310. } else if miConfig.MdtrtareaAdmvs == "441799" {
  34311. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  34312. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34313. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  34314. resp3, requestErr3 := http.Get(api3)
  34315. if requestErr3 != nil {
  34316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34317. return
  34318. }
  34319. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34320. if ioErr3 != nil {
  34321. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34323. return
  34324. }
  34325. var respJSON3 map[string]interface{}
  34326. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34327. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34329. return
  34330. }
  34331. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34332. userJSONBytes3, _ := json.Marshal(respJSON3)
  34333. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34334. utils.ErrorLog("解析失败:%v", err)
  34335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34336. return
  34337. }
  34338. } else {
  34339. var api3 string
  34340. if miConfig.Code == "H15049901371" {
  34341. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  34342. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34343. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34344. } else {
  34345. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  34346. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34347. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  34348. }
  34349. resp3, requestErr3 := http.Get(api3)
  34350. if requestErr3 != nil {
  34351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34352. return
  34353. }
  34354. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34355. if ioErr3 != nil {
  34356. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34358. return
  34359. }
  34360. var respJSON3 map[string]interface{}
  34361. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34362. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34364. return
  34365. }
  34366. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34367. userJSONBytes3, _ := json.Marshal(respJSON3)
  34368. if miConfig.Code == "H15049901371" {
  34369. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34370. utils.ErrorLog("解析失败:%v", err)
  34371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34372. return
  34373. }
  34374. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34375. res2.Output = resSix10265.Output
  34376. res2.ErrMsg = resSix10265.ErrMsg
  34377. res2.Cainfo = resSix10265.Cainfo
  34378. res2.WarnMsg = resSix10265.WarnMsg
  34379. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34380. res2.Infcode = infocode
  34381. } else {
  34382. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  34383. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  34384. utils.ErrorLog("解析失败:%v", err)
  34385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34386. return
  34387. }
  34388. res2.Infcode = res3.Infcode
  34389. } else {
  34390. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34391. utils.ErrorLog("解析失败:%v", err)
  34392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34393. return
  34394. }
  34395. }
  34396. }
  34397. }
  34398. if res2.Infcode == -1 {
  34399. c.ServeSuccessJSON(map[string]interface{}{
  34400. "failed_code": -10,
  34401. "msg": res2.ErrMsg,
  34402. })
  34403. return
  34404. }
  34405. if res2.Infcode == 0 {
  34406. if err == nil {
  34407. c.ServeSuccessJSON(map[string]interface{}{
  34408. "msg": "退号成功",
  34409. })
  34410. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  34411. //service.UpdataOrderStatusTen(his., recordDateTime, adminUser.CurrentOrgId)
  34412. } else {
  34413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34414. return
  34415. }
  34416. }
  34417. } else {
  34418. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  34419. //if err == nil {
  34420. // c.ServeSuccessJSON(map[string]interface{}{
  34421. // "msg": "退费成功",
  34422. // })
  34423. //} else {
  34424. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34425. // return
  34426. //}
  34427. }
  34428. }
  34429. func (c *HisApiController) RefundDetail() {
  34430. order_id, _ := c.GetInt64("order_id")
  34431. admin_user_id, _ := c.GetInt64("admin_user_id")
  34432. //his_patient_id, _ := c.GetInt64("his_patient_id")
  34433. number := c.GetString("number")
  34434. record_time := c.GetString("record_time")
  34435. patient_id, _ := c.GetInt64("patient_id")
  34436. //med_type, _ := c.GetInt64("med_type")
  34437. timeLayout := "2006-01-02"
  34438. loc, _ := time.LoadLocation("Local")
  34439. adminUser := c.GetAdminUserInfo()
  34440. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34441. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  34442. fmt.Println(err)
  34443. if err != nil {
  34444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  34445. return
  34446. }
  34447. recordDateTime := theTime.Unix()
  34448. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  34449. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  34450. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34451. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34452. var order models.HisOrder
  34453. order, _ = service.GetHisOrderByID(order_id)
  34454. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34455. if config.IsOpen == 1 { //对接了医保,走医保流程
  34456. var res2 ResultSix
  34457. if miConfig.MdtrtareaAdmvs == "421300" {
  34458. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  34459. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34460. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34461. resp3, requestErr3 := http.Get(api3)
  34462. if requestErr3 != nil {
  34463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34464. return
  34465. }
  34466. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34467. if ioErr3 != nil {
  34468. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34470. return
  34471. }
  34472. var respJSON3 map[string]interface{}
  34473. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34474. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34476. return
  34477. }
  34478. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34479. userJSONBytes3, _ := json.Marshal(respJSON3)
  34480. fmt.Println("log")
  34481. fmt.Println(string(userJSONBytes3))
  34482. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34483. utils.ErrorLog("解析失败:%v", err)
  34484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34485. return
  34486. }
  34487. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34488. if err == nil {
  34489. c.ServeSuccessJSON(map[string]interface{}{
  34490. "msg": "撤销明细成功",
  34491. })
  34492. return
  34493. } else {
  34494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34495. return
  34496. }
  34497. } else if miConfig.MdtrtareaAdmvs == "420200" {
  34498. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  34499. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34500. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34501. resp3, requestErr3 := http.Get(api3)
  34502. if requestErr3 != nil {
  34503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34504. return
  34505. }
  34506. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34507. if ioErr3 != nil {
  34508. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34510. return
  34511. }
  34512. var respJSON3 map[string]interface{}
  34513. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34514. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34516. return
  34517. }
  34518. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34519. userJSONBytes3, _ := json.Marshal(respJSON3)
  34520. fmt.Println("log")
  34521. fmt.Println(string(userJSONBytes3))
  34522. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34523. utils.ErrorLog("解析失败:%v", err)
  34524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34525. return
  34526. }
  34527. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34528. if err == nil {
  34529. c.ServeSuccessJSON(map[string]interface{}{
  34530. "msg": "撤销明细成功",
  34531. })
  34532. return
  34533. } else {
  34534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34535. return
  34536. }
  34537. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34538. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  34539. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34540. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34541. resp3, requestErr3 := http.Get(api3)
  34542. if requestErr3 != nil {
  34543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34544. return
  34545. }
  34546. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34547. if ioErr3 != nil {
  34548. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34550. return
  34551. }
  34552. var respJSON3 map[string]interface{}
  34553. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34554. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34556. return
  34557. }
  34558. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34559. userJSONBytes3, _ := json.Marshal(respJSON3)
  34560. fmt.Println("log")
  34561. fmt.Println(string(userJSONBytes3))
  34562. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34563. utils.ErrorLog("解析失败:%v", err)
  34564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34565. return
  34566. }
  34567. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34568. if err == nil {
  34569. c.ServeSuccessJSON(map[string]interface{}{
  34570. "msg": "撤销明细成功",
  34571. })
  34572. return
  34573. } else {
  34574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34575. return
  34576. }
  34577. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34578. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  34579. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34580. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34581. resp3, requestErr3 := http.Get(api3)
  34582. if requestErr3 != nil {
  34583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34584. return
  34585. }
  34586. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34587. if ioErr3 != nil {
  34588. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34590. return
  34591. }
  34592. var respJSON3 map[string]interface{}
  34593. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34594. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34596. return
  34597. }
  34598. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34599. userJSONBytes3, _ := json.Marshal(respJSON3)
  34600. fmt.Println("log")
  34601. fmt.Println(string(userJSONBytes3))
  34602. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34603. utils.ErrorLog("解析失败:%v", err)
  34604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34605. return
  34606. }
  34607. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34608. if err == nil {
  34609. c.ServeSuccessJSON(map[string]interface{}{
  34610. "msg": "撤销明细成功",
  34611. })
  34612. return
  34613. } else {
  34614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34615. return
  34616. }
  34617. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  34618. var resSix10265 ResultSix10265
  34619. var api3 string
  34620. if miConfig.MdtrtareaAdmvs == "320830" {
  34621. api3 = miConfig.AppSecret + "jsyb/2205?psn_no=" + order.PsnNo +
  34622. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + "0000" + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34623. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34624. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34625. } else if miConfig.MdtrtareaAdmvs == "320921" {
  34626. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  34627. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34628. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34629. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34630. } else {
  34631. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34632. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  34633. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34634. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34635. }
  34636. resp3, requestErr3 := http.Get(api3)
  34637. utils.ErrorLog("接口: %v", requestErr3)
  34638. if requestErr3 != nil {
  34639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34640. return
  34641. }
  34642. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34643. if ioErr3 != nil {
  34644. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34646. return
  34647. }
  34648. var respJSON3 map[string]interface{}
  34649. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34650. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34652. return
  34653. }
  34654. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34655. userJSONBytes3, _ := json.Marshal(respJSON3)
  34656. fmt.Println("log")
  34657. fmt.Println(string(userJSONBytes3))
  34658. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34659. utils.ErrorLog("解析失败:%v", err)
  34660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34661. return
  34662. }
  34663. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34664. res2.Output = resSix10265.Output
  34665. res2.ErrMsg = resSix10265.ErrMsg
  34666. res2.Cainfo = resSix10265.Cainfo
  34667. res2.WarnMsg = resSix10265.WarnMsg
  34668. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34669. res2.Infcode = infocode
  34670. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34671. if err == nil {
  34672. c.ServeSuccessJSON(map[string]interface{}{
  34673. "msg": "撤销明细成功",
  34674. })
  34675. return
  34676. } else {
  34677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34678. return
  34679. }
  34680. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34681. var api3 string
  34682. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  34683. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34684. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34685. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34686. resp3, requestErr3 := http.Get(api3)
  34687. utils.ErrorLog("接口: %v", requestErr3)
  34688. if requestErr3 != nil {
  34689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34690. return
  34691. }
  34692. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34693. if ioErr3 != nil {
  34694. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34696. return
  34697. }
  34698. var respJSON3 map[string]interface{}
  34699. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34700. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34702. return
  34703. }
  34704. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34705. if status == "0" {
  34706. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34707. c.ServeSuccessJSON(map[string]interface{}{
  34708. "failed_code": -10,
  34709. "msg": err_msg,
  34710. })
  34711. return
  34712. }
  34713. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34714. userJSONBytes3, _ := json.Marshal(respJSON3)
  34715. fmt.Println("log")
  34716. fmt.Println(string(userJSONBytes3))
  34717. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34718. utils.ErrorLog("解析失败:%v", err)
  34719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34720. return
  34721. }
  34722. fmt.Println(res2.Infcode)
  34723. if res2.Infcode == -1 {
  34724. c.ServeSuccessJSON(map[string]interface{}{
  34725. "failed_code": -10,
  34726. "msg": res2.ErrMsg,
  34727. })
  34728. return
  34729. }
  34730. if res2.Infcode == 0 {
  34731. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34732. if err == nil {
  34733. c.ServeSuccessJSON(map[string]interface{}{
  34734. "msg": "撤销明细成功",
  34735. })
  34736. return
  34737. } else {
  34738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34739. return
  34740. }
  34741. } else {
  34742. c.ServeSuccessJSON(map[string]interface{}{
  34743. "failed_code": -10,
  34744. "msg": res2.ErrMsg,
  34745. })
  34746. }
  34747. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34748. if err == nil {
  34749. c.ServeSuccessJSON(map[string]interface{}{
  34750. "msg": "撤销明细成功",
  34751. })
  34752. return
  34753. } else {
  34754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34755. return
  34756. }
  34757. } else if miConfig.MdtrtareaAdmvs == "340699" {
  34758. var api3 string
  34759. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  34760. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34761. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34762. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34763. resp3, requestErr3 := http.Get(api3)
  34764. utils.ErrorLog("接口: %v", requestErr3)
  34765. if requestErr3 != nil {
  34766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34767. return
  34768. }
  34769. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34770. if ioErr3 != nil {
  34771. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34773. return
  34774. }
  34775. var respJSON3 map[string]interface{}
  34776. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34777. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34779. return
  34780. }
  34781. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34782. if status == "0" {
  34783. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34784. c.ServeSuccessJSON(map[string]interface{}{
  34785. "failed_code": -10,
  34786. "msg": err_msg,
  34787. })
  34788. return
  34789. }
  34790. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34791. userJSONBytes3, _ := json.Marshal(respJSON3)
  34792. fmt.Println("log")
  34793. fmt.Println(string(userJSONBytes3))
  34794. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34795. utils.ErrorLog("解析失败:%v", err)
  34796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34797. return
  34798. }
  34799. fmt.Println(res2.Infcode)
  34800. if res2.Infcode == -1 {
  34801. c.ServeSuccessJSON(map[string]interface{}{
  34802. "failed_code": -10,
  34803. "msg": res2.ErrMsg,
  34804. })
  34805. return
  34806. }
  34807. if res2.Infcode == 0 {
  34808. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34809. if err == nil {
  34810. c.ServeSuccessJSON(map[string]interface{}{
  34811. "msg": "撤销明细成功",
  34812. })
  34813. return
  34814. } else {
  34815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34816. return
  34817. }
  34818. } else {
  34819. c.ServeSuccessJSON(map[string]interface{}{
  34820. "failed_code": -10,
  34821. "msg": res2.ErrMsg,
  34822. })
  34823. }
  34824. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34825. if err == nil {
  34826. c.ServeSuccessJSON(map[string]interface{}{
  34827. "msg": "撤销明细成功",
  34828. })
  34829. return
  34830. } else {
  34831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34832. return
  34833. }
  34834. } else if miConfig.MdtrtareaAdmvs == "150499" {
  34835. var resSix10265 ResultSix10265
  34836. new_chrg_bchno := order.Number
  34837. if adminUser.CurrentOrgId == 10265 {
  34838. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  34839. new_chrg_bchno = "0000"
  34840. }
  34841. }
  34842. var api3 string
  34843. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  34844. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34845. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34846. resp3, requestErr3 := http.Get(api3)
  34847. if requestErr3 != nil {
  34848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34849. return
  34850. }
  34851. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34852. if ioErr3 != nil {
  34853. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34855. return
  34856. }
  34857. var respJSON3 map[string]interface{}
  34858. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34859. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34861. return
  34862. }
  34863. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34864. userJSONBytes3, _ := json.Marshal(respJSON3)
  34865. fmt.Println("log")
  34866. fmt.Println(string(userJSONBytes3))
  34867. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34868. utils.ErrorLog("解析失败:%v", err)
  34869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34870. return
  34871. }
  34872. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34873. res2.Output = resSix10265.Output
  34874. res2.ErrMsg = resSix10265.ErrMsg
  34875. res2.Cainfo = resSix10265.Cainfo
  34876. res2.WarnMsg = resSix10265.WarnMsg
  34877. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34878. res2.Infcode = infocode
  34879. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34880. if err == nil {
  34881. c.ServeSuccessJSON(map[string]interface{}{
  34882. "msg": "撤销明细成功",
  34883. })
  34884. return
  34885. } else {
  34886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34887. return
  34888. }
  34889. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34890. 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)
  34891. var dat map[string]interface{}
  34892. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34893. fmt.Println(dat)
  34894. } else {
  34895. fmt.Println(err)
  34896. }
  34897. saveLog(result2, src_request, "2205", "撤销明细")
  34898. userJSONBytes, _ := json.Marshal(dat)
  34899. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34900. utils.ErrorLog("解析失败:%v", err)
  34901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34902. return
  34903. }
  34904. if res2.Infcode == 0 {
  34905. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34906. if err == nil {
  34907. c.ServeSuccessJSON(map[string]interface{}{
  34908. "msg": "撤销明细成功",
  34909. })
  34910. return
  34911. } else {
  34912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34913. return
  34914. }
  34915. } else {
  34916. c.ServeSuccessJSON(map[string]interface{}{
  34917. "failed_code": -10,
  34918. "msg": res2.ErrMsg,
  34919. })
  34920. }
  34921. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34922. 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, "")
  34923. var dat map[string]interface{}
  34924. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34925. fmt.Println(dat)
  34926. } else {
  34927. fmt.Println(err)
  34928. }
  34929. saveLog(result2, src_request, "2205", "撤销明细")
  34930. userJSONBytes, _ := json.Marshal(dat)
  34931. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34932. utils.ErrorLog("解析失败:%v", err)
  34933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34934. return
  34935. }
  34936. if res2.Infcode == 0 {
  34937. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34938. if err == nil {
  34939. c.ServeSuccessJSON(map[string]interface{}{
  34940. "msg": "撤销明细成功",
  34941. })
  34942. return
  34943. } else {
  34944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34945. return
  34946. }
  34947. } else {
  34948. c.ServeSuccessJSON(map[string]interface{}{
  34949. "failed_code": -10,
  34950. "msg": res2.ErrMsg,
  34951. })
  34952. }
  34953. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34954. 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, "")
  34955. var dat map[string]interface{}
  34956. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34957. fmt.Println(dat)
  34958. } else {
  34959. fmt.Println(err)
  34960. }
  34961. saveLog(result2, src_request, "2205", "撤销明细")
  34962. userJSONBytes, _ := json.Marshal(dat)
  34963. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34964. utils.ErrorLog("解析失败:%v", err)
  34965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34966. return
  34967. }
  34968. if res2.Infcode == 0 {
  34969. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34970. if err == nil {
  34971. c.ServeSuccessJSON(map[string]interface{}{
  34972. "msg": "撤销明细成功",
  34973. })
  34974. return
  34975. } else {
  34976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34977. return
  34978. }
  34979. } else {
  34980. c.ServeSuccessJSON(map[string]interface{}{
  34981. "failed_code": -10,
  34982. "msg": res2.ErrMsg,
  34983. })
  34984. }
  34985. } else if miConfig.MdtrtareaAdmvs == "360100" {
  34986. 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, "")
  34987. var dat map[string]interface{}
  34988. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34989. fmt.Println(dat)
  34990. } else {
  34991. fmt.Println(err)
  34992. }
  34993. saveLog(result2, src_request, "2205", "撤销明细")
  34994. userJSONBytes, _ := json.Marshal(dat)
  34995. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34996. utils.ErrorLog("解析失败:%v", err)
  34997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34998. return
  34999. }
  35000. if res2.Infcode == 0 {
  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 {
  35012. c.ServeSuccessJSON(map[string]interface{}{
  35013. "failed_code": -10,
  35014. "msg": res2.ErrMsg,
  35015. })
  35016. }
  35017. } else if miConfig.MdtrtareaAdmvs == "430800" {
  35018. 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, "")
  35019. var dat map[string]interface{}
  35020. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  35021. fmt.Println(dat)
  35022. } else {
  35023. fmt.Println(err)
  35024. }
  35025. saveLog(result2, src_request, "2205", "撤销明细")
  35026. userJSONBytes, _ := json.Marshal(dat)
  35027. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35028. utils.ErrorLog("解析失败:%v", err)
  35029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35030. return
  35031. }
  35032. if res2.Infcode == 0 {
  35033. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35034. if err == nil {
  35035. c.ServeSuccessJSON(map[string]interface{}{
  35036. "msg": "撤销明细成功",
  35037. })
  35038. return
  35039. } else {
  35040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35041. return
  35042. }
  35043. } else {
  35044. c.ServeSuccessJSON(map[string]interface{}{
  35045. "failed_code": -10,
  35046. "msg": res2.ErrMsg,
  35047. })
  35048. }
  35049. } else if miConfig.MdtrtareaAdmvs == "441799" {
  35050. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  35051. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  35052. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35053. resp2, requestErr2 := http.Get(api2)
  35054. if requestErr2 != nil {
  35055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35056. return
  35057. }
  35058. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  35059. if ioErr2 != nil {
  35060. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  35061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35062. return
  35063. }
  35064. var respJSON2 map[string]interface{}
  35065. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  35066. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35068. return
  35069. }
  35070. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35071. userJSONBytes3, _ := json.Marshal(respJSON2)
  35072. fmt.Println("log")
  35073. fmt.Println(string(userJSONBytes3))
  35074. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  35075. utils.ErrorLog("解析失败:%v", err)
  35076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35077. return
  35078. }
  35079. if res2.Infcode == 0 {
  35080. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35081. if err == nil {
  35082. c.ServeSuccessJSON(map[string]interface{}{
  35083. "msg": "撤销明细成功",
  35084. })
  35085. return
  35086. } else {
  35087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35088. return
  35089. }
  35090. } else {
  35091. c.ServeSuccessJSON(map[string]interface{}{
  35092. "failed_code": -10,
  35093. "msg": res2.ErrMsg,
  35094. })
  35095. }
  35096. } else {
  35097. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  35098. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  35099. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  35100. resp2, requestErr2 := http.Get(api2)
  35101. if requestErr2 != nil {
  35102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35103. return
  35104. }
  35105. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  35106. if ioErr2 != nil {
  35107. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  35108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35109. return
  35110. }
  35111. var respJSON2 map[string]interface{}
  35112. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  35113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35115. return
  35116. }
  35117. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35118. userJSONBytes3, _ := json.Marshal(respJSON2)
  35119. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  35120. utils.ErrorLog("解析失败:%v", err)
  35121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35122. return
  35123. }
  35124. if res2.Infcode == -1 {
  35125. c.ServeSuccessJSON(map[string]interface{}{
  35126. "failed_code": -10,
  35127. "msg": res2.ErrMsg,
  35128. })
  35129. return
  35130. } else {
  35131. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35132. if err == nil {
  35133. c.ServeSuccessJSON(map[string]interface{}{
  35134. "msg": "撤销明细成功",
  35135. })
  35136. return
  35137. } else {
  35138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35139. return
  35140. }
  35141. }
  35142. }
  35143. } else {
  35144. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35145. if err == nil {
  35146. c.ServeSuccessJSON(map[string]interface{}{
  35147. "msg": "退费成功",
  35148. })
  35149. } else {
  35150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35151. return
  35152. }
  35153. }
  35154. }
  35155. // 对账
  35156. func (c *HisApiController) GetCheckAccount() {
  35157. start_time := c.GetString("start_time")
  35158. end_time := c.GetString("end_time")
  35159. insutype := c.GetString("insutype")
  35160. clr_type := c.GetString("clr_type")
  35161. clr_org := c.GetString("clr_optins")
  35162. admin_user_id, _ := c.GetInt64("admin_user_id")
  35163. adminUser := c.GetAdminUserInfo()
  35164. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35165. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35166. if len(clr_org) == 0 {
  35167. clr_org = miConfig.InsuplcAdmdvs
  35168. }
  35169. timeLayout := "2006-01-02"
  35170. loc, _ := time.LoadLocation("Local")
  35171. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  35172. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  35173. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35174. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35175. fixmedins_setl_cnt := int64(len(orders))
  35176. var medfee_sumamt float64
  35177. var acct_pay float64
  35178. var fund_pay_sumamt float64
  35179. for _, item := range orders {
  35180. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35181. acct_pay = acct_pay + item.AcctPay
  35182. if miConfig.MdtrtareaAdmvs == "361025" || miConfig.MdtrtareaAdmvs == "360100" {
  35183. fund_pay_sumamt = fund_pay_sumamt + item.HifpPay + item.HifmiPay + item.MafPay + item.HifobPay + item.HifesPay
  35184. } else {
  35185. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35186. }
  35187. }
  35188. var user_name string
  35189. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35190. if role.ID == 0 {
  35191. user_name = "xxx"
  35192. } else {
  35193. user_name = role.UserName
  35194. }
  35195. var res ResultEight
  35196. var res10188 ResultEightFor10188
  35197. if config.IsOpen == 1 {
  35198. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  35199. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  35200. "insutype=" + insutype +
  35201. "&clr_type=" + clr_type +
  35202. "&setl_optins=" + clr_org +
  35203. "&stmt_begndate=" + start_time +
  35204. "&stm_enddate=" + end_time +
  35205. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35206. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35207. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35208. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35209. "&fixmedins_code=" + miConfig.Code +
  35210. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35211. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35212. "&secret_key=" + miConfig.SecretKey +
  35213. "&org_name=" + miConfig.OrgName +
  35214. "&doctor=" + user_name +
  35215. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35216. fmt.Println(api)
  35217. resp, requestErr := http.Get(api)
  35218. if requestErr != nil {
  35219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35220. return
  35221. }
  35222. body, ioErr := ioutil.ReadAll(resp.Body)
  35223. fmt.Println(body)
  35224. if ioErr != nil {
  35225. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35227. return
  35228. }
  35229. var respJSON map[string]interface{}
  35230. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35231. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35233. return
  35234. }
  35235. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35236. userJSONBytes, _ := json.Marshal(respJSON)
  35237. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35238. utils.ErrorLog("解析失败:%v", err)
  35239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35240. return
  35241. }
  35242. res.InfRefmsgid = res10188.InfRefmsgid
  35243. res.Output = res10188.Output
  35244. res.ErrMsg = res10188.ErrMsg
  35245. res.Cainfo = res10188.Cainfo
  35246. res.WarnMsg = res10188.WarnMsg
  35247. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  35248. res.Infcode = infocode
  35249. } else if miConfig.MdtrtareaAdmvs == "150499" {
  35250. if clr_type != "9903" {
  35251. clr_type = "99" // 就诊 ID(来自2201接口返回)
  35252. }
  35253. if clr_type == "9903" {
  35254. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  35255. }
  35256. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  35257. "insutype=" + insutype +
  35258. "&clr_type=" + clr_type +
  35259. "&setl_optins=" + clr_org +
  35260. "&stmt_begndate=" + start_time +
  35261. "&stm_enddate=" + end_time +
  35262. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35263. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35264. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35265. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35266. "&fixmedins_code=" + miConfig.Code +
  35267. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35268. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35269. "&secret_key=" + miConfig.SecretKey +
  35270. "&org_name=" + miConfig.OrgName +
  35271. "&doctor=" + user_name
  35272. resp, requestErr := http.Get(api)
  35273. if requestErr != nil {
  35274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35275. return
  35276. }
  35277. body, ioErr := ioutil.ReadAll(resp.Body)
  35278. if ioErr != nil {
  35279. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35281. return
  35282. }
  35283. var respJSON map[string]interface{}
  35284. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35285. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35287. return
  35288. }
  35289. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35290. result, _ := json.Marshal(respJSON)
  35291. fmt.Println("log")
  35292. fmt.Println(string(result))
  35293. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  35294. utils.ErrorLog("解析失败:%v", err)
  35295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35296. return
  35297. }
  35298. res.InfRefmsgid = res10188.InfRefmsgid
  35299. res.Output = res10188.Output
  35300. res.ErrMsg = res10188.ErrMsg
  35301. res.Cainfo = res10188.Cainfo
  35302. res.WarnMsg = res10188.WarnMsg
  35303. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  35304. res.Infcode = infocode
  35305. } else if miConfig.MdtrtareaAdmvs == "350500" {
  35306. var baseParams models.BaseParams
  35307. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35308. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35309. baseParams.SecretKey = miConfig.SecretKey
  35310. baseParams.OrgName = miConfig.OrgName
  35311. baseParams.FixmedinsCode = miConfig.Code
  35312. baseParams.EncKey = miConfig.EncKey
  35313. baseParams.AppSecret = miConfig.AppSecret
  35314. baseParams.SignKey = miConfig.SignKey
  35315. baseParams.AppID = miConfig.Code
  35316. baseParams.Doctor = role.UserName
  35317. baseParams.RequestUrl = miConfig.Url
  35318. businessParams := models.BusinessParams{
  35319. Insutype: insutype,
  35320. ClrType: clr_type,
  35321. SetlOptins: clr_org,
  35322. StmtBegndate: start_time,
  35323. StmtEnddate: end_time,
  35324. MedfeeSumamt: medfee_sumamt,
  35325. FundPaySumamt: fund_pay_sumamt,
  35326. AcctPay: acct_pay,
  35327. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35328. }
  35329. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  35330. fmt.Println(requestLog)
  35331. fmt.Println(result)
  35332. fmt.Println(err_msg)
  35333. var dat map[string]interface{}
  35334. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35335. fmt.Println(dat)
  35336. } else {
  35337. fmt.Println(err)
  35338. }
  35339. userJSONBytes, _ := json.Marshal(dat)
  35340. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35341. utils.ErrorLog("解析失败:%v", err)
  35342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35343. return
  35344. }
  35345. } else if miConfig.MdtrtareaAdmvs == "430800" {
  35346. var baseParams models.BaseParams
  35347. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35348. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35349. baseParams.SecretKey = miConfig.SecretKey
  35350. baseParams.OrgName = miConfig.OrgName
  35351. baseParams.FixmedinsCode = miConfig.Code
  35352. baseParams.EncKey = miConfig.EncKey
  35353. baseParams.AppSecret = miConfig.AppSecret
  35354. baseParams.SignKey = miConfig.SignKey
  35355. baseParams.AppID = miConfig.Code
  35356. baseParams.Doctor = role.UserName
  35357. baseParams.RequestUrl = miConfig.Url
  35358. baseParams.AccessKey = miConfig.AccessKey
  35359. businessParams := models.BusinessParams{
  35360. Insutype: insutype,
  35361. ClrType: clr_type,
  35362. SetlOptins: "430822",
  35363. StmtBegndate: start_time,
  35364. StmtEnddate: end_time,
  35365. MedfeeSumamt: medfee_sumamt,
  35366. FundPaySumamt: fund_pay_sumamt,
  35367. AcctPay: acct_pay,
  35368. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35369. }
  35370. 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)
  35371. fmt.Println(requestLog)
  35372. fmt.Println(result)
  35373. var dat map[string]interface{}
  35374. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35375. fmt.Println(dat)
  35376. } else {
  35377. fmt.Println(err)
  35378. }
  35379. userJSONBytes, _ := json.Marshal(dat)
  35380. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35381. utils.ErrorLog("解析失败:%v", err)
  35382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35383. return
  35384. }
  35385. } else if miConfig.MdtrtareaAdmvs == "350500" {
  35386. var baseParams models.BaseParams
  35387. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35388. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35389. baseParams.SecretKey = miConfig.SecretKey
  35390. baseParams.OrgName = miConfig.OrgName
  35391. baseParams.FixmedinsCode = miConfig.Code
  35392. baseParams.EncKey = miConfig.EncKey
  35393. baseParams.AppSecret = miConfig.AppSecret
  35394. baseParams.SignKey = miConfig.SignKey
  35395. baseParams.AppID = miConfig.Code
  35396. baseParams.Doctor = role.UserName
  35397. baseParams.RequestUrl = miConfig.Url
  35398. businessParams := models.BusinessParams{
  35399. Insutype: insutype,
  35400. ClrType: clr_type,
  35401. SetlOptins: clr_org,
  35402. StmtBegndate: start_time,
  35403. StmtEnddate: end_time,
  35404. MedfeeSumamt: medfee_sumamt,
  35405. FundPaySumamt: fund_pay_sumamt,
  35406. AcctPay: acct_pay,
  35407. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35408. }
  35409. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  35410. fmt.Println(requestLog)
  35411. fmt.Println(result)
  35412. fmt.Println(err_msg)
  35413. var dat map[string]interface{}
  35414. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35415. fmt.Println(dat)
  35416. } else {
  35417. fmt.Println(err)
  35418. }
  35419. userJSONBytes, _ := json.Marshal(dat)
  35420. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35421. utils.ErrorLog("解析失败:%v", err)
  35422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35423. return
  35424. }
  35425. } else if miConfig.MdtrtareaAdmvs == "441799" {
  35426. if len(clr_type) == 0 {
  35427. clr_type = "11"
  35428. }
  35429. api := miConfig.Url + "gdyb/ten?" +
  35430. "insutype=" + insutype +
  35431. "&clr_type=" + clr_type +
  35432. "&setl_optins=" + clr_org +
  35433. "&stmt_begndate=" + start_time +
  35434. "&stm_enddate=" + end_time +
  35435. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35436. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35437. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35438. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  35439. "&fixmedins_code=" + miConfig.Code +
  35440. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35441. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35442. "&secret_key=" + miConfig.SecretKey +
  35443. "&org_name=" + miConfig.OrgName +
  35444. "&doctor=" + user_name
  35445. fmt.Println(api)
  35446. resp, requestErr := http.Get(api)
  35447. if requestErr != nil {
  35448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35449. return
  35450. }
  35451. body, ioErr := ioutil.ReadAll(resp.Body)
  35452. fmt.Println(body)
  35453. if ioErr != nil {
  35454. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35456. return
  35457. }
  35458. var respJSON map[string]interface{}
  35459. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35460. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35462. return
  35463. }
  35464. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35465. userJSONBytes, _ := json.Marshal(respJSON)
  35466. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35467. utils.ErrorLog("解析失败:%v", err)
  35468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35469. return
  35470. }
  35471. } else if miConfig.MdtrtareaAdmvs == "360302" {
  35472. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35473. //fixmedins_setl_cnt := int64(len(orders_two))
  35474. //var medfee_sumamt float64
  35475. //var acct_pay float64
  35476. //var fund_pay_sumamt float64
  35477. //for _, item := range orders_two {
  35478. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35479. // acct_pay = acct_pay + item.AcctPay
  35480. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35481. //}
  35482. var baseParams models.BaseParams
  35483. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35484. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35485. baseParams.SecretKey = miConfig.SecretKey
  35486. baseParams.OrgName = miConfig.OrgName
  35487. baseParams.FixmedinsCode = miConfig.Code
  35488. baseParams.EncKey = miConfig.EncKey
  35489. baseParams.AppSecret = miConfig.AppSecret
  35490. baseParams.SignKey = miConfig.SignKey
  35491. baseParams.AppID = miConfig.Code
  35492. baseParams.Doctor = role.UserName
  35493. baseParams.RequestUrl = miConfig.Url
  35494. if clr_type == "9903" {
  35495. clr_type = "9901"
  35496. }
  35497. businessParams := models.BusinessParams{
  35498. Insutype: insutype,
  35499. ClrType: clr_type,
  35500. SetlOptins: "360302",
  35501. StmtBegndate: start_time,
  35502. StmtEnddate: end_time,
  35503. MedfeeSumamt: 0,
  35504. FundPaySumamt: 0,
  35505. AcctPay: 0,
  35506. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35507. }
  35508. 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))
  35509. fmt.Println(requestLog)
  35510. fmt.Println(result)
  35511. var dat map[string]interface{}
  35512. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35513. fmt.Println(dat)
  35514. } else {
  35515. fmt.Println(err)
  35516. }
  35517. userJSONBytes, _ := json.Marshal(dat)
  35518. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35519. utils.ErrorLog("解析失败:%v", err)
  35520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35521. return
  35522. }
  35523. } else if miConfig.MdtrtareaAdmvs == "361025" {
  35524. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35525. //fixmedins_setl_cnt := int64(len(orders_two))
  35526. //var medfee_sumamt float64
  35527. //var acct_pay float64
  35528. //var fund_pay_sumamt float64
  35529. //for _, item := range orders_two {
  35530. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35531. // acct_pay = acct_pay + item.AcctPay
  35532. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35533. //}
  35534. var baseParams models.BaseParams
  35535. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35536. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35537. baseParams.SecretKey = miConfig.SecretKey
  35538. baseParams.OrgName = miConfig.OrgName
  35539. baseParams.FixmedinsCode = miConfig.Code
  35540. baseParams.EncKey = miConfig.EncKey
  35541. baseParams.AppSecret = miConfig.AppSecret
  35542. baseParams.SignKey = miConfig.SignKey
  35543. baseParams.AppID = miConfig.Code
  35544. baseParams.Doctor = role.UserName
  35545. baseParams.RequestUrl = miConfig.Url
  35546. if clr_type == "9903" {
  35547. clr_type = "9994"
  35548. }
  35549. businessParams := models.BusinessParams{
  35550. Insutype: insutype,
  35551. ClrType: clr_type,
  35552. SetlOptins: "361025",
  35553. StmtBegndate: start_time,
  35554. StmtEnddate: end_time,
  35555. MedfeeSumamt: 0,
  35556. FundPaySumamt: 0,
  35557. AcctPay: 0,
  35558. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35559. }
  35560. 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))
  35561. fmt.Println(requestLog)
  35562. fmt.Println(result)
  35563. var dat map[string]interface{}
  35564. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35565. fmt.Println(dat)
  35566. } else {
  35567. fmt.Println(err)
  35568. }
  35569. userJSONBytes, _ := json.Marshal(dat)
  35570. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35571. utils.ErrorLog("解析失败:%v", err)
  35572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35573. return
  35574. }
  35575. } else if miConfig.MdtrtareaAdmvs == "360100" {
  35576. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35577. //fixmedins_setl_cnt := int64(len(orders_two))
  35578. //var medfee_sumamt float64
  35579. //var acct_pay float64
  35580. //var fund_pay_sumamt float64
  35581. //for _, item := range orders_two {
  35582. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35583. // acct_pay = acct_pay + item.AcctPay
  35584. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35585. //}
  35586. var baseParams models.BaseParams
  35587. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35588. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35589. baseParams.SecretKey = miConfig.SecretKey
  35590. baseParams.OrgName = miConfig.OrgName
  35591. baseParams.FixmedinsCode = miConfig.Code
  35592. baseParams.EncKey = miConfig.EncKey
  35593. baseParams.AppSecret = miConfig.AppSecret
  35594. baseParams.SignKey = miConfig.SignKey
  35595. baseParams.AppID = miConfig.Code
  35596. baseParams.Doctor = role.UserName
  35597. baseParams.RequestUrl = miConfig.Url
  35598. if clr_type == "9903" {
  35599. clr_type = "9994"
  35600. }
  35601. businessParams := models.BusinessParams{
  35602. Insutype: insutype,
  35603. ClrType: clr_type,
  35604. SetlOptins: "360100",
  35605. StmtBegndate: start_time,
  35606. StmtEnddate: end_time,
  35607. MedfeeSumamt: 0,
  35608. FundPaySumamt: 0,
  35609. AcctPay: 0,
  35610. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35611. }
  35612. 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))
  35613. fmt.Println(requestLog)
  35614. fmt.Println(result)
  35615. var dat map[string]interface{}
  35616. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35617. fmt.Println(dat)
  35618. } else {
  35619. fmt.Println(err)
  35620. }
  35621. userJSONBytes, _ := json.Marshal(dat)
  35622. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35623. utils.ErrorLog("解析失败:%v", err)
  35624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35625. return
  35626. }
  35627. } else if miConfig.MdtrtareaAdmvs == "341203" {
  35628. var api string
  35629. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  35630. "&clr_type=" + clr_type +
  35631. "&setl_optins=" + clr_org +
  35632. "&stmt_begndate=" + start_time +
  35633. "&stm_enddate=" + end_time +
  35634. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35635. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35636. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35637. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35638. "&fixmedins_code=" + miConfig.Code +
  35639. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35640. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35641. "&secret_key=" + miConfig.SecretKey +
  35642. "&org_name=" + miConfig.OrgName +
  35643. "&doctor=" + user_name + "&url=" + miConfig.Url
  35644. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35645. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35646. resp, requestErr := http.Get(api)
  35647. if requestErr != nil {
  35648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35649. return
  35650. }
  35651. body, ioErr := ioutil.ReadAll(resp.Body)
  35652. if ioErr != nil {
  35653. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35655. return
  35656. }
  35657. var respJSON map[string]interface{}
  35658. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35659. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35661. return
  35662. }
  35663. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35664. if status == "0" {
  35665. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35666. c.ServeSuccessJSON(map[string]interface{}{
  35667. "failed_code": -10,
  35668. "msg": err_msg,
  35669. })
  35670. return
  35671. }
  35672. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35673. userJSONBytes, _ := json.Marshal(respJSON)
  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 == "340699" {
  35680. var api string
  35681. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  35682. "&clr_type=" + clr_type +
  35683. "&setl_optins=" + clr_org +
  35684. "&stmt_begndate=" + start_time +
  35685. "&stm_enddate=" + end_time +
  35686. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35687. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35688. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35689. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35690. "&fixmedins_code=" + miConfig.Code +
  35691. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35692. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35693. "&secret_key=" + miConfig.SecretKey +
  35694. "&org_name=" + miConfig.OrgName +
  35695. "&doctor=" + user_name + "&url=" + miConfig.Url
  35696. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35697. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35698. resp, requestErr := http.Get(api)
  35699. if requestErr != nil {
  35700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35701. return
  35702. }
  35703. body, ioErr := ioutil.ReadAll(resp.Body)
  35704. if ioErr != nil {
  35705. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35707. return
  35708. }
  35709. var respJSON map[string]interface{}
  35710. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35711. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35713. return
  35714. }
  35715. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35716. if status == "0" {
  35717. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35718. c.ServeSuccessJSON(map[string]interface{}{
  35719. "failed_code": -10,
  35720. "msg": err_msg,
  35721. })
  35722. return
  35723. }
  35724. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35725. userJSONBytes, _ := json.Marshal(respJSON)
  35726. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35727. utils.ErrorLog("解析失败:%v", err)
  35728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35729. return
  35730. }
  35731. } else {
  35732. if len(clr_type) == 0 {
  35733. clr_type = "11"
  35734. }
  35735. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  35736. "insutype=" + insutype +
  35737. "&clr_type=" + clr_type +
  35738. "&setl_optins=" + clr_org +
  35739. "&stmt_begndate=" + start_time +
  35740. "&stm_enddate=" + end_time +
  35741. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35742. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35743. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35744. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  35745. "&fixmedins_code=" + miConfig.Code +
  35746. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35747. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35748. "&secret_key=" + miConfig.SecretKey +
  35749. "&org_name=" + miConfig.OrgName +
  35750. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  35751. fmt.Println(api)
  35752. resp, requestErr := http.Get(api)
  35753. if requestErr != nil {
  35754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35755. return
  35756. }
  35757. body, ioErr := ioutil.ReadAll(resp.Body)
  35758. fmt.Println(body)
  35759. if ioErr != nil {
  35760. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35762. return
  35763. }
  35764. var respJSON map[string]interface{}
  35765. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35766. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35768. return
  35769. }
  35770. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35771. userJSONBytes, _ := json.Marshal(respJSON)
  35772. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35773. utils.ErrorLog("解析失败:%v", err)
  35774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35775. return
  35776. }
  35777. }
  35778. if res.Infcode == 0 {
  35779. if res.Output.Stmtinfo.StmtRslt == "0" {
  35780. micc := &models.MedicalInsuranceCostCompare{
  35781. StartTime: startime.Unix(),
  35782. EndTime: endtime.Unix(),
  35783. Insutype: insutype,
  35784. CheckType: 1,
  35785. Num: fixmedins_setl_cnt,
  35786. Mtime: time.Now().Unix(),
  35787. Status: 1,
  35788. UserOrgId: adminUser.CurrentOrgId,
  35789. CostTotal: medfee_sumamt,
  35790. FuncTotal: fund_pay_sumamt,
  35791. PsnPay: acct_pay,
  35792. Creator: admin_user_id,
  35793. Ctime: time.Now().Unix(),
  35794. ClrType: clr_type,
  35795. }
  35796. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  35797. if err == nil {
  35798. c.ServeSuccessJSON(map[string]interface{}{
  35799. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  35800. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  35801. })
  35802. } else {
  35803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35804. }
  35805. } else {
  35806. c.ServeSuccessJSON(map[string]interface{}{
  35807. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  35808. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  35809. })
  35810. }
  35811. } else {
  35812. c.ServeSuccessJSON(map[string]interface{}{
  35813. "failed_code": -10,
  35814. "msg": res.ErrMsg,
  35815. })
  35816. }
  35817. }
  35818. }
  35819. func (c *HisApiController) Check310() {
  35820. adminUser := c.GetAdminUserInfo()
  35821. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35822. var user_name string
  35823. user_name = "高慧裕"
  35824. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  35825. "insutype=" + "310" +
  35826. "&clr_type=" + "" +
  35827. "&setl_optins=" + "441202" +
  35828. "&stmt_begndate=" + "2022-03-01" +
  35829. "&stm_enddate=" + "2022-03-31" +
  35830. "&medfee_sumamt=" + "194930.12" +
  35831. "&fund_pay_sumamt=" + "188741.46" +
  35832. "&acct_pay=" + "0" +
  35833. "&fixmedins_setl_cnt=" + "452" +
  35834. "&fixmedins_code=" + miConfig.Code +
  35835. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35836. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35837. "&secret_key=" + miConfig.SecretKey +
  35838. "&org_name=" + miConfig.OrgName +
  35839. "&doctor=" + user_name
  35840. fmt.Println(api)
  35841. resp, requestErr := http.Get(api)
  35842. if requestErr != nil {
  35843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35844. return
  35845. }
  35846. body, ioErr := ioutil.ReadAll(resp.Body)
  35847. fmt.Println(body)
  35848. if ioErr != nil {
  35849. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35851. return
  35852. }
  35853. var respJSON map[string]interface{}
  35854. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35855. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35857. return
  35858. }
  35859. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35860. userJSONBytes, _ := json.Marshal(respJSON)
  35861. var res ResultEight
  35862. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35863. utils.ErrorLog("解析失败:%v", err)
  35864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35865. return
  35866. }
  35867. }
  35868. func (c *HisApiController) Check390() {
  35869. adminUser := c.GetAdminUserInfo()
  35870. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35871. var user_name string
  35872. user_name = "高慧裕"
  35873. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  35874. "insutype=" + "390" +
  35875. "&clr_type=" + "" +
  35876. "&setl_optins=" + "441202" +
  35877. "&stmt_begndate=" + "2022-03-01" +
  35878. "&stm_enddate=" + "2022-03-31" +
  35879. "&medfee_sumamt=" + "1068448.89" +
  35880. "&fund_pay_sumamt=" + "1014677.62" +
  35881. "&acct_pay=" + "0" +
  35882. "&fixmedins_setl_cnt=" + "1950" +
  35883. "&fixmedins_code=" + miConfig.Code +
  35884. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35885. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35886. "&secret_key=" + miConfig.SecretKey +
  35887. "&org_name=" + miConfig.OrgName +
  35888. "&doctor=" + user_name
  35889. fmt.Println(api)
  35890. resp, requestErr := http.Get(api)
  35891. if requestErr != nil {
  35892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35893. return
  35894. }
  35895. body, ioErr := ioutil.ReadAll(resp.Body)
  35896. fmt.Println(body)
  35897. if ioErr != nil {
  35898. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35900. return
  35901. }
  35902. var respJSON map[string]interface{}
  35903. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35904. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35906. return
  35907. }
  35908. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35909. userJSONBytes, _ := json.Marshal(respJSON)
  35910. var res ResultEight
  35911. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35912. utils.ErrorLog("解析失败:%v", err)
  35913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35914. return
  35915. }
  35916. }
  35917. // 对账明细
  35918. func (c *HisApiController) GetCheckDetailAccount() {
  35919. start_time := c.GetString("start_time")
  35920. end_time := c.GetString("end_time")
  35921. admin_user_id, _ := c.GetInt64("admin_user_id")
  35922. adminUser := c.GetAdminUserInfo()
  35923. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35924. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35925. timeLayout := "2006-01-02"
  35926. loc, _ := time.LoadLocation("Local")
  35927. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  35928. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  35929. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  35930. rand.Seed(time.Now().UnixNano())
  35931. num := rand.Intn(30000)
  35932. Mkdir(miConfig.OrgName)
  35933. file := strconv.FormatInt(int64(num), 10)
  35934. file_name := file + ".txt"
  35935. zip_name := file + ".zip"
  35936. zip_path := miConfig.OrgName + "/" + zip_name
  35937. file_path := miConfig.OrgName + "/" + file_name
  35938. decimal.DivisionPrecision = 2
  35939. var medfee_sumamt float64
  35940. var psn_cash_pay float64
  35941. var fund_pay_sumamt float64
  35942. fixmedins_setl_cnt := int64(len(orders))
  35943. for _, item := range orders {
  35944. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35945. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  35946. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35947. }
  35948. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  35949. defer f.Close()
  35950. if err != nil {
  35951. fmt.Println(err.Error())
  35952. } else {
  35953. for _, item := range orders {
  35954. var refd_setl_flag string
  35955. if item.OrderStatus == 2 {
  35956. refd_setl_flag = "0"
  35957. var str string
  35958. str = item.SetlId + " " +
  35959. item.MdtrtId + " " +
  35960. item.PsnNo + " " +
  35961. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  35962. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  35963. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  35964. _, err = f.Write([]byte(str))
  35965. }
  35966. if item.OrderStatus == 3 {
  35967. var str string
  35968. str = item.SetlId + " " +
  35969. item.MdtrtId + " " +
  35970. item.PsnNo + " " +
  35971. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  35972. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  35973. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  35974. _, err = f.Write([]byte(str))
  35975. var str2 string
  35976. str2 = item.SetlId + " " +
  35977. item.MdtrtId + " " +
  35978. item.PsnNo + " " +
  35979. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  35980. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  35981. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  35982. _, err = f.Write([]byte(str2))
  35983. }
  35984. }
  35985. }
  35986. Zip(file_path, zip_path)
  35987. fmt.Println(ReadFile(zip_path))
  35988. fmt.Println(string(ReadFile(zip_path)))
  35989. if config.IsOpen == 1 {
  35990. var user_name string
  35991. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35992. if role.ID == 0 {
  35993. user_name = "管理员"
  35994. } else {
  35995. user_name = role.UserName
  35996. }
  35997. baseParams := models.BaseParams{
  35998. SecretKey: miConfig.SecretKey,
  35999. FixmedinsCode: miConfig.Code,
  36000. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36001. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36002. OrgName: miConfig.OrgName,
  36003. Doctor: user_name,
  36004. }
  36005. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  36006. var dat map[string]interface{}
  36007. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36008. fmt.Println(dat)
  36009. } else {
  36010. fmt.Println(err)
  36011. }
  36012. userJSONBytes, _ := json.Marshal(dat)
  36013. var res ResultNine
  36014. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36015. utils.ErrorLog("解析失败:%v", err)
  36016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36017. return
  36018. }
  36019. if res.Infcode == 0 {
  36020. fileNo := res.Output.FileQuryNo
  36021. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  36022. "file_qury_no=" + fileNo +
  36023. "&setl_optins=" + "定点医保中心" +
  36024. "&stmt_begndate=" + start_time +
  36025. "&stm_enddate=" + end_time +
  36026. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  36027. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  36028. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  36029. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  36030. "&fixmedins_code=" + miConfig.Code +
  36031. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  36032. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  36033. "&secret_key=" + miConfig.SecretKey +
  36034. "&org_name=" + miConfig.OrgName +
  36035. "&doctor=" + user_name
  36036. resp, requestErr := http.Get(api)
  36037. if requestErr != nil {
  36038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36039. return
  36040. }
  36041. body, ioErr := ioutil.ReadAll(resp.Body)
  36042. if ioErr != nil {
  36043. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36045. return
  36046. }
  36047. var respJSON map[string]interface{}
  36048. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36049. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36051. return
  36052. }
  36053. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36054. userJSONBytes, _ := json.Marshal(respJSON)
  36055. var res ResultTen
  36056. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36057. utils.ErrorLog("解析失败:%v", err)
  36058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36059. return
  36060. }
  36061. if res.Infcode == 0 {
  36062. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  36063. micc := &models.MedicalInsuranceCostCompare{
  36064. StartTime: startime.Unix(),
  36065. EndTime: endtime.Unix(),
  36066. Insutype: "0",
  36067. CheckType: 2,
  36068. Num: fixmedins_setl_cnt,
  36069. Mtime: time.Now().Unix(),
  36070. Status: 1,
  36071. UserOrgId: adminUser.CurrentOrgId,
  36072. CostTotal: medfee_sumamt,
  36073. FuncTotal: fund_pay_sumamt,
  36074. PsnPay: psn_cash_pay,
  36075. Creator: admin_user_id,
  36076. Ctime: time.Now().Unix(),
  36077. }
  36078. service.CreateMedicalInsuranceCostCompareRecord(micc)
  36079. c.ServeSuccessJSON(map[string]interface{}{
  36080. "msg": "明细对账成功",
  36081. })
  36082. }
  36083. } else {
  36084. }
  36085. }
  36086. }
  36087. type CustomOrderInfo struct {
  36088. Name string
  36089. Spec string
  36090. Unit string
  36091. Count float64
  36092. Price float64
  36093. Total float64
  36094. }
  36095. func (c *HisApiController) GetBatchSettleAccounts() {
  36096. admin_user_id, _ := c.GetInt64("admin_user_id")
  36097. order_ids := c.GetString("order_ids")
  36098. order_ids_arr := strings.Split(order_ids, ",")
  36099. data3 := []map[string]interface{}{}
  36100. for _, item := range order_ids_arr {
  36101. id, _ := strconv.ParseInt(item, 10, 64)
  36102. order_id := id
  36103. adminUser := c.GetAdminUserInfo()
  36104. order, _ := service.GetHisOrderByID(order_id)
  36105. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  36106. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  36107. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  36108. orderInfos = append(orderInfos, orderInfos_two...)
  36109. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  36110. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  36111. var diagnosis_ids []string
  36112. if his.ID > 0 {
  36113. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  36114. } else {
  36115. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  36116. }
  36117. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  36118. var dia_config []*models.HisXtDiagnoseConfig
  36119. var name string
  36120. for _, item := range diagnosis_ids {
  36121. id, _ := strconv.ParseInt(item, 10, 64)
  36122. diagnosisConfig, _ := service.FindDiagnoseById(id)
  36123. dia_config = append(dia_config, &diagnosisConfig)
  36124. if len(name) == 0 {
  36125. name = diagnosisConfig.ClassName
  36126. }
  36127. //} else {
  36128. // name = name + "," + diagnosisConfig.ClassName
  36129. //}
  36130. }
  36131. var bedCostTotal float64 = 0 //床位总费
  36132. var bedCostSelfTotal float64 = 0 //床位自费
  36133. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  36134. var bedSelfTotal float64 = 0 //床位部分项目自费
  36135. var bedInscpTotal float64 = 0 //床位部分项目自费
  36136. var operationCostTotal float64 = 0 //手术费
  36137. var operationCostSelfTotal float64 = 0 //手术费
  36138. var operationCostPartSelfTotal float64 = 0 //手术费
  36139. var operationSelfTotal float64 = 0 //床位部分项目自费
  36140. var operationInscpTotal float64 = 0 //床位部分项目自费
  36141. var otherCostTotal float64 = 0 //其他费用
  36142. var otherCostSelfTotal float64 = 0 //其他费用
  36143. var otherCostPartSelfTotal float64 = 0 //其他费用
  36144. var otherSelfTotal float64 = 0 //床位部分项目自费
  36145. var otherInscpTotal float64 = 0 //床位部分项目自费
  36146. var materialCostTotal float64 = 0 //材料费
  36147. var materialCostSelfTotal float64 = 0 //材料费
  36148. var materialCostPartSelfTotal float64 = 0 //材料费
  36149. var materialSelfTotal float64 = 0 //床位部分项目自费
  36150. var materialInscpTotal float64 = 0 //床位部分项目自费
  36151. var westernMedicineCostTotal float64 = 0 //西药费
  36152. var westernMedicineCostSelfTotal float64 = 0 //西药费
  36153. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  36154. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  36155. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  36156. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  36157. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  36158. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  36159. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  36160. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  36161. var checkCostTotal float64 = 0 //检查费
  36162. var checkCostSelfTotal float64 = 0 //检查费
  36163. var checkCostPartSelfTotal float64 = 0 //检查费
  36164. var checkSelfTotal float64 = 0 //床位部分项目自费
  36165. var checkInscpTotal float64 = 0 //床位部分项目自费
  36166. var laboratoryCostTotal float64 = 0 //化验费
  36167. var laboratoryCostSelfTotal float64 = 0 //化验费
  36168. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  36169. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  36170. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  36171. var treatCostTotal float64 = 0 //治疗费用
  36172. var treatCostSelfTotal float64 = 0 //治疗费用
  36173. var treatCostPartSelfTotal float64 = 0 //治疗费用
  36174. var treatSelfTotal float64 = 0 //床位部分项目自费
  36175. var treatInscpTotal float64 = 0 //床位部分项目自费
  36176. decimal.DivisionPrecision = 2
  36177. for _, item := range orderInfos {
  36178. if item.MedChrgitmType == "01" { //床位费
  36179. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36180. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36181. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36182. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36183. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36184. }
  36185. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  36186. if item.MedChrgitmType == "03" { //检查费
  36187. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36188. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36189. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36190. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36191. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36192. }
  36193. } else {
  36194. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  36195. fmt.Println("------------")
  36196. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36197. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36198. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36199. }
  36200. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  36201. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36202. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36203. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36204. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36205. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36206. }
  36207. }
  36208. if item.MedChrgitmType == "04" { //化验费
  36209. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36210. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36211. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36212. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36213. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36214. }
  36215. if item.MedChrgitmType == "05" { //治疗费
  36216. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36217. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36218. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36219. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36220. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36221. }
  36222. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  36223. fmt.Println("------------")
  36224. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36225. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36226. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36227. }
  36228. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  36229. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36230. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36231. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36232. }
  36233. //if item.MedChrgitmType == "06" { //手术费
  36234. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36235. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36236. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36237. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36238. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36239. //
  36240. //}
  36241. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  36242. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36243. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36244. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36245. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36246. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36247. }
  36248. if item.MedChrgitmType == "09" { //西药费
  36249. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36250. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36251. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36252. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36253. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36254. }
  36255. if item.MedChrgitmType == "11" { //中成费
  36256. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36257. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36258. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36259. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36260. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36261. }
  36262. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  36263. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36264. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36265. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36266. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36267. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36268. }
  36269. }
  36270. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36271. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36272. var user_name string
  36273. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36274. if role.ID == 0 {
  36275. user_name = "管理员"
  36276. } else {
  36277. user_name = role.UserName
  36278. }
  36279. baseParams := models.BaseParams{
  36280. SecretKey: miConfig.SecretKey,
  36281. FixmedinsCode: miConfig.Code,
  36282. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36283. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36284. OrgName: miConfig.OrgName,
  36285. Doctor: user_name,
  36286. RequestUrl: miConfig.Url,
  36287. AccessKey: miConfig.AccessKey,
  36288. }
  36289. businessParams := models.BusinessParams{
  36290. PsnNo: order.PsnNo,
  36291. MdtrtId: order.MdtrtId,
  36292. SetlId: order.SetlId,
  36293. }
  36294. var res ResultEleven
  36295. var resEleven10265 ResultEleven10265
  36296. if config.IsOpen == 1 {
  36297. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36298. result := service.Gdyb5203(baseParams, businessParams)
  36299. service.Gdyb5204(baseParams, businessParams)
  36300. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  36301. var dat map[string]interface{}
  36302. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36303. fmt.Println(dat)
  36304. } else {
  36305. fmt.Println(err)
  36306. }
  36307. userJSONBytes, _ := json.Marshal(dat)
  36308. if miConfig.Code == "H15049901371" {
  36309. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  36310. utils.ErrorLog("解析失败:%v", err)
  36311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36312. return
  36313. }
  36314. res.InfRefmsgid = resEleven10265.InfRefmsgid
  36315. res.Output = resEleven10265.Output
  36316. res.ErrMsg = resEleven10265.ErrMsg
  36317. res.Cainfo = resEleven10265.Cainfo
  36318. res.WarnMsg = resEleven10265.WarnMsg
  36319. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  36320. res.Infcode = infocode
  36321. } else {
  36322. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36323. utils.ErrorLog("解析失败:%v", err)
  36324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36325. return
  36326. }
  36327. }
  36328. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36329. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  36330. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  36331. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  36332. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  36333. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36334. var doctor_name string
  36335. if roles.ID == 0 {
  36336. doctor_name = "管理员"
  36337. } else {
  36338. doctor_name = roles.UserName
  36339. }
  36340. yiliao_leibie := ""
  36341. switch order.MedType {
  36342. case "11":
  36343. yiliao_leibie = "普通门诊"
  36344. break
  36345. case "12":
  36346. yiliao_leibie = "门诊挂号"
  36347. break
  36348. case "13":
  36349. yiliao_leibie = "急诊"
  36350. break
  36351. case "14":
  36352. yiliao_leibie = "门诊特殊病"
  36353. break
  36354. case "15":
  36355. yiliao_leibie = "门诊统筹"
  36356. break
  36357. case "16":
  36358. yiliao_leibie = "门诊慢性病"
  36359. break
  36360. case "21":
  36361. yiliao_leibie = "普通住院"
  36362. break
  36363. }
  36364. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  36365. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  36366. if res.Infcode == 0 {
  36367. data2 := map[string]interface{}{
  36368. "diagnosis": name,
  36369. "order_infos": orderInfos,
  36370. "number": order.MdtrtId,
  36371. "date": order.SettleAccountsDate,
  36372. "charge_admin": charge_admin,
  36373. "printor_admin": printor_admin,
  36374. "info": res.Output.Setlinfo,
  36375. "order": order,
  36376. "bedCostTotal": bedCostTotal,
  36377. "bedCostSelfTotal": bedCostSelfTotal,
  36378. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  36379. "bedSelfTotal": bedSelfTotal,
  36380. "bedInscpTotal": bedInscpTotal,
  36381. "operationCostTotal": operationCostTotal,
  36382. "operationCostSelfTotal": operationCostSelfTotal,
  36383. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  36384. "operationSelfTotal": operationSelfTotal,
  36385. "operationInscpTotal": operationInscpTotal,
  36386. "otherCostTotal": otherCostTotal,
  36387. "otherCostSelfTotal": otherCostSelfTotal,
  36388. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  36389. "otherSelfTotal": otherSelfTotal,
  36390. "otherInscpTotal": otherInscpTotal,
  36391. "materialCostTotal": materialCostTotal,
  36392. "materialCostSelfTotal": materialCostSelfTotal,
  36393. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  36394. "materialSelfTotal": materialSelfTotal,
  36395. "materialInscpTotal": materialInscpTotal,
  36396. "westernMedicineCostTotal": westernMedicineCostTotal,
  36397. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  36398. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  36399. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  36400. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  36401. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  36402. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  36403. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  36404. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  36405. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  36406. "checkCostTotal": checkCostTotal,
  36407. "checkCostSelfTotal": checkCostSelfTotal,
  36408. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  36409. "checkSelfTotal": checkSelfTotal,
  36410. "checkInscpTotal": checkInscpTotal,
  36411. "laboratoryCostTotal": laboratoryCostTotal,
  36412. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  36413. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  36414. "laboratorySelfTotal": laboratorySelfTotal,
  36415. "laboratoryInscpTotal": laboratoryInscpTotal,
  36416. "treatCostTotal": treatCostTotal,
  36417. "treatCostSelfTotal": treatCostSelfTotal,
  36418. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  36419. "treatSelfTotal": treatSelfTotal,
  36420. "treatInscpTotal": treatInscpTotal,
  36421. "doctor_info": doctor_info,
  36422. "doctor_code": adminRole_two.DoctorCode,
  36423. "doctor_name": doctor_name,
  36424. "health_card_no": order.PsnNo,
  36425. "department": departments.Name,
  36426. "yiliao_leibie": yiliao_leibie,
  36427. "after_money": order.AccountPrice,
  36428. "patient": patient,
  36429. "org_name": miConfig.OrgName,
  36430. "org_code": miConfig.Code,
  36431. "order_number": order.Number,
  36432. "his_hospital": his_hospital,
  36433. "his": his,
  36434. "dia_config": dia_config,
  36435. "psn_cash_pay": order.PsnCashPay,
  36436. //"check_order_info": cus_slice,
  36437. }
  36438. data3 = append(data3, data2)
  36439. }
  36440. }
  36441. }
  36442. c.ServeSuccessJSON(map[string]interface{}{
  36443. "infos": data3,
  36444. })
  36445. }
  36446. func (c *HisApiController) GetSettleAccounts() {
  36447. //id, _ := c.GetInt64("id")
  36448. //record_time := c.GetString("record_time")
  36449. order_id, _ := c.GetInt64("order_id")
  36450. admin_user_id, _ := c.GetInt64("admin_user_id")
  36451. //timeLayout := "2006-01-02"
  36452. //loc, _ := time.LoadLocation("Local")
  36453. //
  36454. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  36455. //if err != nil {
  36456. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  36457. // return
  36458. //}Hbyb5203
  36459. //recordDateTime := theTime.Unix()
  36460. adminUser := c.GetAdminUserInfo()
  36461. order, _ := service.GetHisOrderByID(order_id)
  36462. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  36463. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  36464. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  36465. orderInfos = append(orderInfos, orderInfos_two...)
  36466. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  36467. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  36468. var diagnosis_ids []string
  36469. if his.ID > 0 {
  36470. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  36471. } else {
  36472. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  36473. }
  36474. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  36475. var dia_config []*models.HisXtDiagnoseConfig
  36476. var name string
  36477. for _, item := range diagnosis_ids {
  36478. id, _ := strconv.ParseInt(item, 10, 64)
  36479. diagnosisConfig, _ := service.FindDiagnoseById(id)
  36480. dia_config = append(dia_config, &diagnosisConfig)
  36481. if len(name) == 0 {
  36482. name = diagnosisConfig.ClassName
  36483. } else {
  36484. name = name + "," + diagnosisConfig.ClassName
  36485. }
  36486. }
  36487. if patient.UserOrgId == 10215 {
  36488. name = "慢性肾功能不全(血透治疗)"
  36489. }
  36490. var bedCostTotal float64 = 0 //床位总费
  36491. var bedCostSelfTotal float64 = 0 //床位自费
  36492. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  36493. var bedSelfTotal float64 = 0 //床位部分项目自费
  36494. var bedInscpTotal float64 = 0 //床位部分项目自费
  36495. var operationCostTotal float64 = 0 //手术费
  36496. var operationCostSelfTotal float64 = 0 //手术费
  36497. var operationCostPartSelfTotal float64 = 0 //手术费
  36498. var operationSelfTotal float64 = 0 //床位部分项目自费
  36499. var operationInscpTotal float64 = 0 //床位部分项目自费
  36500. var otherCostTotal float64 = 0 //其他费用
  36501. var otherCostSelfTotal float64 = 0 //其他费用
  36502. var otherCostPartSelfTotal float64 = 0 //其他费用
  36503. var otherSelfTotal float64 = 0 //床位部分项目自费
  36504. var otherInscpTotal float64 = 0 //床位部分项目自费
  36505. var materialCostTotal float64 = 0 //材料费
  36506. var materialCostSelfTotal float64 = 0 //材料费
  36507. var materialCostPartSelfTotal float64 = 0 //材料费
  36508. var materialSelfTotal float64 = 0 //床位部分项目自费
  36509. var materialInscpTotal float64 = 0 //床位部分项目自费
  36510. var westernMedicineCostTotal float64 = 0 //西药费
  36511. var westernMedicineCostSelfTotal float64 = 0 //西药费
  36512. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  36513. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  36514. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  36515. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  36516. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  36517. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  36518. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  36519. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  36520. var checkCostTotal float64 = 0 //检查费
  36521. var checkCostSelfTotal float64 = 0 //检查费
  36522. var checkCostPartSelfTotal float64 = 0 //检查费
  36523. var checkSelfTotal float64 = 0 //床位部分项目自费
  36524. var checkInscpTotal float64 = 0 //床位部分项目自费
  36525. var laboratoryCostTotal float64 = 0 //化验费
  36526. var laboratoryCostSelfTotal float64 = 0 //化验费
  36527. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  36528. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  36529. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  36530. var treatCostTotal float64 = 0 //治疗费用
  36531. var treatCostSelfTotal float64 = 0 //治疗费用
  36532. var treatCostPartSelfTotal float64 = 0 //治疗费用
  36533. var treatSelfTotal float64 = 0 //床位部分项目自费
  36534. var treatInscpTotal float64 = 0 //床位部分项目自费
  36535. var zcCostTotal float64 = 0 //治疗费用
  36536. var zcCostSelfTotal float64 = 0 //治疗费用
  36537. var zcCostPartSelfTotal float64 = 0 //治疗费用
  36538. var zcSelfTotal float64 = 0 //床位部分项目自费
  36539. var zcInscpTotal float64 = 0 //床位部分项目自费
  36540. var huliCostTotal float64 = 0 //治疗费用
  36541. var huliCostSelfTotal float64 = 0 //治疗费用
  36542. var huliCostPartSelfTotal float64 = 0 //治疗费用
  36543. var huliSelfTotal float64 = 0 //床位部分项目自费
  36544. var huliInscpTotal float64 = 0 //床位部分项目自费
  36545. decimal.DivisionPrecision = 2
  36546. for _, item := range orderInfos {
  36547. if item.MedChrgitmType == "01" { //床位费
  36548. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36549. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36550. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36551. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36552. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36553. }
  36554. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  36555. if item.MedChrgitmType == "03" { //检查费
  36556. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36557. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36558. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36559. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36560. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36561. }
  36562. } else {
  36563. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  36564. fmt.Println("------------")
  36565. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36566. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36567. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36568. }
  36569. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  36570. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36571. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36572. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36573. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36574. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36575. }
  36576. }
  36577. if item.MedChrgitmType == "04" { //化验费
  36578. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36579. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36580. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36581. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36582. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36583. }
  36584. if item.MedChrgitmType == "05" { //治疗费
  36585. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36586. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36587. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36588. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36589. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36590. }
  36591. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  36592. fmt.Println("------------")
  36593. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36594. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36595. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36596. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36597. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36598. }
  36599. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  36600. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36601. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36602. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36603. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36604. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36605. }
  36606. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  36607. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36608. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36609. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36610. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36611. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36612. }
  36613. if item.MedChrgitmType == "09" { //西药费
  36614. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36615. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36616. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36617. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36618. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36619. }
  36620. if item.MedChrgitmType == "11" { //中成费
  36621. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36622. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36623. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36624. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36625. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36626. }
  36627. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  36628. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36629. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36630. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36631. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36632. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36633. }
  36634. if item.MedChrgitmType == "02" { //其他费
  36635. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36636. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36637. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36638. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36639. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36640. }
  36641. if item.MedChrgitmType == "07" { //其他费
  36642. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36643. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36644. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36645. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36646. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36647. }
  36648. }
  36649. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36650. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36651. var user_name string
  36652. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36653. if role.ID == 0 {
  36654. user_name = "管理员"
  36655. } else {
  36656. user_name = role.UserName
  36657. }
  36658. baseParams := models.BaseParams{
  36659. SecretKey: miConfig.SecretKey,
  36660. FixmedinsCode: miConfig.Code,
  36661. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36662. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36663. OrgName: miConfig.OrgName,
  36664. Doctor: user_name,
  36665. RequestUrl: miConfig.Url,
  36666. AccessKey: miConfig.AccessKey,
  36667. }
  36668. businessParams := models.BusinessParams{
  36669. PsnNo: order.PsnNo,
  36670. MdtrtId: order.MdtrtId,
  36671. SetlId: order.SetlId,
  36672. }
  36673. var res ResultEleven
  36674. var resah ResultElevenah
  36675. var resEleven10265 ResultEleven10265
  36676. if config.IsOpen == 1 {
  36677. if miConfig.MdtrtareaAdmvs == "421300" {
  36678. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36679. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36680. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36681. resp, requestErr := http.Get(api)
  36682. if requestErr != nil {
  36683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36684. return
  36685. }
  36686. body, ioErr := ioutil.ReadAll(resp.Body)
  36687. if ioErr != nil {
  36688. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36690. return
  36691. }
  36692. var respJSON map[string]interface{}
  36693. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36694. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36696. return
  36697. }
  36698. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36699. result, _ := json.Marshal(respJSON)
  36700. fmt.Println("log")
  36701. fmt.Println(string(result))
  36702. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36703. utils.ErrorLog("解析失败:%v", err)
  36704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36705. return
  36706. }
  36707. } else if miConfig.MdtrtareaAdmvs == "420200" {
  36708. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36709. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36710. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36711. resp, requestErr := http.Get(api)
  36712. if requestErr != nil {
  36713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36714. return
  36715. }
  36716. body, ioErr := ioutil.ReadAll(resp.Body)
  36717. if ioErr != nil {
  36718. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36720. return
  36721. }
  36722. var respJSON map[string]interface{}
  36723. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36724. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36726. return
  36727. }
  36728. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36729. result, _ := json.Marshal(respJSON)
  36730. fmt.Println("log")
  36731. fmt.Println(string(result))
  36732. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36733. utils.ErrorLog("解析失败:%v", err)
  36734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36735. return
  36736. }
  36737. } else if miConfig.MdtrtareaAdmvs == "420902" {
  36738. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36739. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36740. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36741. resp, requestErr := http.Get(api)
  36742. if requestErr != nil {
  36743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36744. return
  36745. }
  36746. body, ioErr := ioutil.ReadAll(resp.Body)
  36747. if ioErr != nil {
  36748. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36750. return
  36751. }
  36752. var respJSON map[string]interface{}
  36753. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36754. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36756. return
  36757. }
  36758. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36759. result, _ := json.Marshal(respJSON)
  36760. fmt.Println("log")
  36761. fmt.Println(string(result))
  36762. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36763. utils.ErrorLog("解析失败:%v", err)
  36764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36765. return
  36766. }
  36767. } else if miConfig.MdtrtareaAdmvs == "421182" {
  36768. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36769. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36770. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  36771. resp, requestErr := http.Get(api)
  36772. if requestErr != nil {
  36773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36774. return
  36775. }
  36776. body, ioErr := ioutil.ReadAll(resp.Body)
  36777. if ioErr != nil {
  36778. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36780. return
  36781. }
  36782. var respJSON map[string]interface{}
  36783. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36784. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36786. return
  36787. }
  36788. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36789. result, _ := json.Marshal(respJSON)
  36790. fmt.Println("log")
  36791. fmt.Println(string(result))
  36792. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36793. utils.ErrorLog("解析失败:%v", err)
  36794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36795. return
  36796. }
  36797. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  36798. var api string
  36799. if miConfig.MdtrtareaAdmvs == "320830" {
  36800. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36801. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36802. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  36803. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36804. } else if miConfig.MdtrtareaAdmvs == "320921" {
  36805. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36806. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36807. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  36808. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36809. } else {
  36810. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36811. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36812. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36813. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  36814. }
  36815. resp, requestErr := http.Get(api)
  36816. if requestErr != nil {
  36817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36818. return
  36819. }
  36820. body, ioErr := ioutil.ReadAll(resp.Body)
  36821. if ioErr != nil {
  36822. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36824. return
  36825. }
  36826. var respJSON map[string]interface{}
  36827. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36828. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36830. return
  36831. }
  36832. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36833. result, _ := json.Marshal(respJSON)
  36834. fmt.Println("log")
  36835. fmt.Println(string(result))
  36836. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  36837. utils.ErrorLog("解析失败:%v", err)
  36838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36839. return
  36840. }
  36841. res.InfRefmsgid = resEleven10265.InfRefmsgid
  36842. res.Output = resEleven10265.Output
  36843. res.ErrMsg = resEleven10265.ErrMsg
  36844. res.Cainfo = resEleven10265.Cainfo
  36845. res.WarnMsg = resEleven10265.WarnMsg
  36846. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  36847. res.Infcode = infocode
  36848. } else if miConfig.MdtrtareaAdmvs == "350500" {
  36849. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  36850. saveLog(result, requestLog, "5203", "结算单")
  36851. var dat map[string]interface{}
  36852. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36853. fmt.Println(dat)
  36854. } else {
  36855. fmt.Println(err)
  36856. }
  36857. userJSONBytes, _ := json.Marshal(dat)
  36858. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36859. utils.ErrorLog("解析失败:%v", err)
  36860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36861. return
  36862. }
  36863. } else if miConfig.MdtrtareaAdmvs == "360302" {
  36864. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36865. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  36866. saveLog(result, requestLog, "5203", "结算单")
  36867. var dat map[string]interface{}
  36868. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36869. fmt.Println(dat)
  36870. } else {
  36871. fmt.Println(err)
  36872. }
  36873. userJSONBytes, _ := json.Marshal(dat)
  36874. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36875. utils.ErrorLog("解析失败:%v", err)
  36876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36877. return
  36878. }
  36879. } else if miConfig.MdtrtareaAdmvs == "361025" {
  36880. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36881. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  36882. saveLog(result, requestLog, "5203", "结算单")
  36883. var dat map[string]interface{}
  36884. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36885. fmt.Println(dat)
  36886. } else {
  36887. fmt.Println(err)
  36888. }
  36889. userJSONBytes, _ := json.Marshal(dat)
  36890. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36891. utils.ErrorLog("解析失败:%v", err)
  36892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36893. return
  36894. }
  36895. } else if miConfig.MdtrtareaAdmvs == "360100" {
  36896. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36897. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  36898. saveLog(result, requestLog, "5203", "结算单")
  36899. var dat map[string]interface{}
  36900. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36901. fmt.Println(dat)
  36902. } else {
  36903. fmt.Println(err)
  36904. }
  36905. userJSONBytes, _ := json.Marshal(dat)
  36906. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36907. utils.ErrorLog("解析失败:%v", err)
  36908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36909. return
  36910. }
  36911. } else if miConfig.MdtrtareaAdmvs == "341203" {
  36912. var api string
  36913. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36914. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36915. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  36916. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36917. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36918. resp, requestErr := http.Get(api)
  36919. if requestErr != nil {
  36920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36921. return
  36922. }
  36923. body, ioErr := ioutil.ReadAll(resp.Body)
  36924. if ioErr != nil {
  36925. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36927. return
  36928. }
  36929. var respJSON map[string]interface{}
  36930. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36931. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36933. return
  36934. }
  36935. status := respJSON["data"].(map[string]interface{})["status"].(string)
  36936. if status == "0" {
  36937. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  36938. c.ServeSuccessJSON(map[string]interface{}{
  36939. "failed_code": -10,
  36940. "msg": err_msg,
  36941. })
  36942. return
  36943. }
  36944. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36945. result, _ := json.Marshal(respJSON)
  36946. fmt.Println("log")
  36947. fmt.Println(string(result))
  36948. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  36949. utils.ErrorLog("解析失败:%v", err)
  36950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36951. return
  36952. }
  36953. res.InfRefmsgid = resah.InfRefmsgid
  36954. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  36955. // 创建对应的Time类型
  36956. t := time.UnixMilli(timestamp)
  36957. // 格式化成指定的日期字符串
  36958. str := t.Format("2006-01-02 15:04:05")
  36959. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  36960. // 创建对应的Time类型
  36961. t3 := time.UnixMilli(timestamp2)
  36962. // 格式化成指定的日期字符串
  36963. str2 := t3.Format("2006-01-02 15:04:05")
  36964. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  36965. // 创建对应的Time类型
  36966. t4 := time.UnixMilli(timestamp3)
  36967. // 格式化成指定的日期字符串
  36968. str3 := t4.Format("2006-01-02 15:04:05")
  36969. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  36970. // 创建对应的Time类型
  36971. t5 := time.UnixMilli(timestamp4)
  36972. // 格式化成指定的日期字符串
  36973. str5 := t5.Format("2006-01-02 15:04:05")
  36974. res.Output.Setlinfo.Brdy = str2
  36975. res.Output.Setlinfo.SetlTime = str
  36976. res.Output.Setlinfo.Begndate = str3
  36977. res.Output.Setlinfo.Enddate = str5
  36978. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  36979. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  36980. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  36981. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  36982. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  36983. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  36984. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  36985. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  36986. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  36987. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  36988. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  36989. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  36990. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  36991. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  36992. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  36993. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  36994. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  36995. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  36996. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  36997. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  36998. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  36999. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  37000. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  37001. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  37002. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  37003. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  37004. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  37005. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  37006. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  37007. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  37008. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  37009. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  37010. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  37011. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  37012. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  37013. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  37014. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  37015. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  37016. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  37017. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  37018. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  37019. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  37020. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  37021. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  37022. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  37023. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  37024. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  37025. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  37026. //res.Output.Setldetail = resah.Output.Setldetail
  37027. res.ErrMsg = resah.ErrMsg
  37028. res.Cainfo = resah.Cainfo
  37029. res.WarnMsg = resah.WarnMsg
  37030. } else if miConfig.MdtrtareaAdmvs == "340699" {
  37031. var api string
  37032. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37033. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37034. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  37035. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37036. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37037. resp, requestErr := http.Get(api)
  37038. if requestErr != nil {
  37039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37040. return
  37041. }
  37042. body, ioErr := ioutil.ReadAll(resp.Body)
  37043. if ioErr != nil {
  37044. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37046. return
  37047. }
  37048. var respJSON map[string]interface{}
  37049. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37050. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37052. return
  37053. }
  37054. status := respJSON["data"].(map[string]interface{})["status"].(string)
  37055. if status == "0" {
  37056. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  37057. c.ServeSuccessJSON(map[string]interface{}{
  37058. "failed_code": -10,
  37059. "msg": err_msg,
  37060. })
  37061. return
  37062. }
  37063. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37064. result, _ := json.Marshal(respJSON)
  37065. fmt.Println("log")
  37066. fmt.Println(string(result))
  37067. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  37068. utils.ErrorLog("解析失败:%v", err)
  37069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37070. return
  37071. }
  37072. res.InfRefmsgid = resah.InfRefmsgid
  37073. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  37074. // 创建对应的Time类型
  37075. t := time.UnixMilli(timestamp)
  37076. // 格式化成指定的日期字符串
  37077. str := t.Format("2006-01-02 15:04:05")
  37078. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  37079. // 创建对应的Time类型
  37080. t3 := time.UnixMilli(timestamp2)
  37081. // 格式化成指定的日期字符串
  37082. str2 := t3.Format("2006-01-02 15:04:05")
  37083. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  37084. // 创建对应的Time类型
  37085. t4 := time.UnixMilli(timestamp3)
  37086. // 格式化成指定的日期字符串
  37087. str3 := t4.Format("2006-01-02 15:04:05")
  37088. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  37089. // 创建对应的Time类型
  37090. t5 := time.UnixMilli(timestamp4)
  37091. // 格式化成指定的日期字符串
  37092. str5 := t5.Format("2006-01-02 15:04:05")
  37093. res.Output.Setlinfo.Brdy = str2
  37094. res.Output.Setlinfo.SetlTime = str
  37095. res.Output.Setlinfo.Begndate = str3
  37096. res.Output.Setlinfo.Enddate = str5
  37097. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  37098. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  37099. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  37100. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  37101. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  37102. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  37103. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  37104. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  37105. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  37106. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  37107. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  37108. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  37109. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  37110. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  37111. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  37112. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  37113. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  37114. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  37115. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  37116. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  37117. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  37118. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  37119. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  37120. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  37121. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  37122. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  37123. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  37124. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  37125. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  37126. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  37127. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  37128. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  37129. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  37130. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  37131. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  37132. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  37133. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  37134. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  37135. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  37136. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  37137. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  37138. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  37139. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  37140. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  37141. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  37142. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  37143. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  37144. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  37145. //res.Output.Setldetail = resah.Output.Setldetail
  37146. res.ErrMsg = resah.ErrMsg
  37147. res.Cainfo = resah.Cainfo
  37148. res.WarnMsg = resah.WarnMsg
  37149. } else if miConfig.MdtrtareaAdmvs == "430800" {
  37150. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  37151. saveLog(result, requestLog, "5203", "结算单")
  37152. var dat map[string]interface{}
  37153. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37154. fmt.Println(dat)
  37155. } else {
  37156. fmt.Println(err)
  37157. }
  37158. userJSONBytes, _ := json.Marshal(dat)
  37159. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37160. utils.ErrorLog("解析失败:%v", err)
  37161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37162. return
  37163. }
  37164. } else if miConfig.MdtrtareaAdmvs == "150499" {
  37165. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37166. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37167. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  37168. resp, requestErr := http.Get(api)
  37169. if requestErr != nil {
  37170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37171. return
  37172. }
  37173. body, ioErr := ioutil.ReadAll(resp.Body)
  37174. if ioErr != nil {
  37175. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37177. return
  37178. }
  37179. var respJSON map[string]interface{}
  37180. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37181. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37183. return
  37184. }
  37185. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37186. result, _ := json.Marshal(respJSON)
  37187. fmt.Println("log")
  37188. fmt.Println(string(result))
  37189. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  37190. utils.ErrorLog("解析失败:%v", err)
  37191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37192. return
  37193. }
  37194. res.InfRefmsgid = resEleven10265.InfRefmsgid
  37195. res.Output = resEleven10265.Output
  37196. res.ErrMsg = resEleven10265.ErrMsg
  37197. res.Cainfo = resEleven10265.Cainfo
  37198. res.WarnMsg = resEleven10265.WarnMsg
  37199. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  37200. res.Infcode = infocode
  37201. } else if miConfig.MdtrtareaAdmvs == "441799" {
  37202. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37203. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37204. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  37205. resp, requestErr := http.Get(api)
  37206. if requestErr != nil {
  37207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37208. return
  37209. }
  37210. body, ioErr := ioutil.ReadAll(resp.Body)
  37211. if ioErr != nil {
  37212. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37214. return
  37215. }
  37216. var respJSON map[string]interface{}
  37217. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37218. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37220. return
  37221. }
  37222. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37223. result, _ := json.Marshal(respJSON)
  37224. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37225. utils.ErrorLog("解析失败:%v", err)
  37226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37227. return
  37228. }
  37229. } else if miConfig.MdtrtareaAdmvs == "450721" {
  37230. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  37231. //return
  37232. } else {
  37233. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  37234. if len(his.InsuplcAdmdvs) == 0 {
  37235. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  37236. } else {
  37237. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  37238. }
  37239. result := service.Gdyb5203(baseParams, businessParams)
  37240. //service.Gdyb5204(baseParams, businessParams)
  37241. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  37242. var dat map[string]interface{}
  37243. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37244. fmt.Println(dat)
  37245. } else {
  37246. fmt.Println(err)
  37247. }
  37248. userJSONBytes, _ := json.Marshal(dat)
  37249. if miConfig.Code == "H15049901371" {
  37250. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  37251. utils.ErrorLog("解析失败:%v", err)
  37252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37253. return
  37254. }
  37255. res.InfRefmsgid = resEleven10265.InfRefmsgid
  37256. res.Output = resEleven10265.Output
  37257. res.ErrMsg = resEleven10265.ErrMsg
  37258. res.Cainfo = resEleven10265.Cainfo
  37259. res.WarnMsg = resEleven10265.WarnMsg
  37260. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  37261. res.Infcode = infocode
  37262. } else {
  37263. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37264. utils.ErrorLog("解析失败:%v", err)
  37265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37266. return
  37267. }
  37268. }
  37269. }
  37270. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37271. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  37272. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  37273. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  37274. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  37275. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37276. var doctor_name string
  37277. if roles.ID == 0 {
  37278. doctor_name = "管理员"
  37279. } else {
  37280. doctor_name = roles.UserName
  37281. }
  37282. yiliao_leibie := ""
  37283. switch order.MedType {
  37284. case "11":
  37285. yiliao_leibie = "普通门诊"
  37286. break
  37287. case "12":
  37288. yiliao_leibie = "门诊挂号"
  37289. break
  37290. case "13":
  37291. yiliao_leibie = "急诊"
  37292. break
  37293. case "14":
  37294. yiliao_leibie = "门诊特殊病"
  37295. break
  37296. case "15":
  37297. yiliao_leibie = "门诊统筹"
  37298. break
  37299. case "16":
  37300. yiliao_leibie = "门诊慢性病"
  37301. break
  37302. case "21":
  37303. yiliao_leibie = "普通住院"
  37304. break
  37305. }
  37306. //var rf []CustomFundPay
  37307. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  37308. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  37309. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  37310. if res.Infcode == 0 {
  37311. 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 {
  37312. c.ServeSuccessJSON(map[string]interface{}{
  37313. "diagnosis": name,
  37314. "order_infos": orderInfos,
  37315. "number": order.MdtrtId,
  37316. "date": order.SettleAccountsDate,
  37317. "charge_admin": charge_admin,
  37318. "printor_admin": printor_admin,
  37319. "info": res.Output.Setlinfo,
  37320. "order": order,
  37321. "bedCostTotal": bedCostTotal,
  37322. "bedCostSelfTotal": bedCostSelfTotal,
  37323. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  37324. "bedSelfTotal": bedSelfTotal,
  37325. "bedInscpTotal": bedInscpTotal,
  37326. "operationCostTotal": operationCostTotal,
  37327. "operationCostSelfTotal": operationCostSelfTotal,
  37328. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  37329. "operationSelfTotal": operationSelfTotal,
  37330. "operationInscpTotal": operationInscpTotal,
  37331. "otherCostTotal": otherCostTotal,
  37332. "otherCostSelfTotal": otherCostSelfTotal,
  37333. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  37334. "otherSelfTotal": otherSelfTotal,
  37335. "otherInscpTotal": otherInscpTotal,
  37336. "materialCostTotal": materialCostTotal,
  37337. "materialCostSelfTotal": materialCostSelfTotal,
  37338. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  37339. "materialSelfTotal": materialSelfTotal,
  37340. "materialInscpTotal": materialInscpTotal,
  37341. "westernMedicineCostTotal": westernMedicineCostTotal,
  37342. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  37343. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  37344. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  37345. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  37346. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  37347. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  37348. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  37349. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  37350. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  37351. "checkCostTotal": checkCostTotal,
  37352. "checkCostSelfTotal": checkCostSelfTotal,
  37353. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  37354. "checkSelfTotal": checkSelfTotal,
  37355. "checkInscpTotal": checkInscpTotal,
  37356. "laboratoryCostTotal": laboratoryCostTotal,
  37357. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  37358. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  37359. "laboratorySelfTotal": laboratorySelfTotal,
  37360. "laboratoryInscpTotal": laboratoryInscpTotal,
  37361. "treatCostTotal": treatCostTotal,
  37362. "treatCostSelfTotal": treatCostSelfTotal,
  37363. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  37364. "treatSelfTotal": treatSelfTotal,
  37365. "treatInscpTotal": treatInscpTotal,
  37366. "doctor_info": doctor_info,
  37367. "doctor_code": adminRole_two.DoctorCode,
  37368. "doctor_name": doctor_name,
  37369. "health_card_no": order.PsnNo,
  37370. "department": departments.Name,
  37371. "yiliao_leibie": yiliao_leibie,
  37372. "after_money": order.AccountPrice,
  37373. "patient": patient,
  37374. "org_name": miConfig.OrgName,
  37375. "org_code": miConfig.Code,
  37376. "order_number": order.Number,
  37377. "his_hospital": his_hospital,
  37378. "his": his,
  37379. "dia_config": dia_config,
  37380. "psn_cash_pay": order.PsnCashPay,
  37381. "zcCostTotal": zcCostTotal,
  37382. "zcCostSelfTotal": zcCostSelfTotal,
  37383. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  37384. "zcSelfTotal": zcSelfTotal,
  37385. "zcInscpTotal": zcInscpTotal,
  37386. "huliCostTotal": huliCostTotal,
  37387. "huliCostSelfTotal": huliCostSelfTotal,
  37388. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  37389. "huliSelfTotal": huliSelfTotal,
  37390. "huliInscpTotal": huliInscpTotal,
  37391. //"funds": rf,
  37392. //"check_order_info": cus_slice,
  37393. })
  37394. } else {
  37395. c.ServeSuccessJSON(map[string]interface{}{
  37396. "diagnosis": name,
  37397. "order_infos": orderInfos,
  37398. "number": order.MdtrtId,
  37399. "date": order.SettleAccountsDate,
  37400. "charge_admin": charge_admin,
  37401. "printor_admin": printor_admin,
  37402. "info": order,
  37403. "order": order,
  37404. "bedCostTotal": bedCostTotal,
  37405. "bedCostSelfTotal": bedCostSelfTotal,
  37406. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  37407. "bedSelfTotal": bedSelfTotal,
  37408. "bedInscpTotal": bedInscpTotal,
  37409. "operationCostTotal": operationCostTotal,
  37410. "operationCostSelfTotal": operationCostSelfTotal,
  37411. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  37412. "operationSelfTotal": operationSelfTotal,
  37413. "operationInscpTotal": operationInscpTotal,
  37414. "otherCostTotal": otherCostTotal,
  37415. "otherCostSelfTotal": otherCostSelfTotal,
  37416. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  37417. "otherSelfTotal": otherSelfTotal,
  37418. "otherInscpTotal": otherInscpTotal,
  37419. "materialCostTotal": materialCostTotal,
  37420. "materialCostSelfTotal": materialCostSelfTotal,
  37421. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  37422. "materialSelfTotal": materialSelfTotal,
  37423. "materialInscpTotal": materialInscpTotal,
  37424. "westernMedicineCostTotal": westernMedicineCostTotal,
  37425. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  37426. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  37427. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  37428. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  37429. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  37430. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  37431. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  37432. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  37433. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  37434. "checkCostTotal": checkCostTotal,
  37435. "checkCostSelfTotal": checkCostSelfTotal,
  37436. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  37437. "checkSelfTotal": checkSelfTotal,
  37438. "checkInscpTotal": checkInscpTotal,
  37439. "laboratoryCostTotal": laboratoryCostTotal,
  37440. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  37441. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  37442. "laboratorySelfTotal": laboratorySelfTotal,
  37443. "laboratoryInscpTotal": laboratoryInscpTotal,
  37444. "treatCostTotal": treatCostTotal,
  37445. "treatCostSelfTotal": treatCostSelfTotal,
  37446. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  37447. "treatSelfTotal": treatSelfTotal,
  37448. "treatInscpTotal": treatInscpTotal,
  37449. "doctor_info": doctor_info,
  37450. "doctor_code": adminRole_two.DoctorCode,
  37451. "doctor_name": doctor_name,
  37452. "health_card_no": order.PsnNo,
  37453. "department": departments.Name,
  37454. "yiliao_leibie": yiliao_leibie,
  37455. "after_money": order.AccountPrice,
  37456. "patient": patient,
  37457. "org_name": miConfig.OrgName,
  37458. "org_code": miConfig.Code,
  37459. "order_number": order.Number,
  37460. "his_hospital": his_hospital,
  37461. "his": his,
  37462. "dia_config": dia_config,
  37463. "psn_cash_pay": order.PsnCashPay,
  37464. "zcCostTotal": zcCostTotal,
  37465. "zcCostSelfTotal": zcCostSelfTotal,
  37466. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  37467. "zcSelfTotal": zcSelfTotal,
  37468. "zcInscpTotal": zcInscpTotal,
  37469. "huliCostTotal": huliCostTotal,
  37470. "huliCostSelfTotal": huliCostSelfTotal,
  37471. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  37472. "huliSelfTotal": huliSelfTotal,
  37473. "huliInscpTotal": huliInscpTotal,
  37474. //"funds": rf,
  37475. //"check_order_info": cus_slice,
  37476. })
  37477. }
  37478. }
  37479. }
  37480. }
  37481. //func (c *HisApiController) CheckTreatment() {
  37482. // patient_id, _ := c.GetInt64("patient_id")
  37483. // id_card_no := c.GetString("id_card_no")
  37484. // insutype := c.GetString("insutype")
  37485. // med_type := c.GetString("med_type")
  37486. // admin_user_id, _ := c.GetInt64("admin_user_id")
  37487. //
  37488. // adminUser := c.GetAdminUserInfo()
  37489. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  37490. //
  37491. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37492. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37493. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37494. //
  37495. // if miConfig.MdtrtareaAdmvs == "421300" {
  37496. // var res ResultTwo
  37497. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  37498. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  37499. // "&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)
  37500. // resp, requestErr := http.Get(api)
  37501. // if requestErr != nil {
  37502. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37503. // return
  37504. // }
  37505. //
  37506. // body, ioErr := ioutil.ReadAll(resp.Body)
  37507. // if ioErr != nil {
  37508. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37509. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37510. // return
  37511. // }
  37512. // var respJSON map[string]interface{}
  37513. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37514. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37515. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37516. // return
  37517. // }
  37518. //
  37519. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37520. // result, _ := json.Marshal(respJSON)
  37521. //
  37522. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  37523. // utils.ErrorLog("解析失败:%v", err)
  37524. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37525. // return
  37526. // }
  37527. //
  37528. // if res.Infcode == 0 {
  37529. //
  37530. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  37531. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  37532. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  37533. // resp, requestErr := http.Get(api)
  37534. // if requestErr != nil {
  37535. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37536. // return
  37537. // }
  37538. //
  37539. // body, ioErr := ioutil.ReadAll(resp.Body)
  37540. // if ioErr != nil {
  37541. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37542. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37543. // return
  37544. // }
  37545. // var respJSON map[string]interface{}
  37546. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37547. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37548. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37549. // return
  37550. // }
  37551. // var res Result2001
  37552. //
  37553. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37554. // result2, _ := json.Marshal(respJSON)
  37555. //
  37556. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  37557. // utils.ErrorLog("解析失败:%v", err)
  37558. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37559. // return
  37560. // }
  37561. //
  37562. // if res.Infcode == 0 {
  37563. // c.ServeSuccessJSON(map[string]interface{}{
  37564. // "msg": res.Output.Trtinfo,
  37565. // })
  37566. // }
  37567. //
  37568. // } else {
  37569. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37570. // return
  37571. // }
  37572. //
  37573. // } else {
  37574. //
  37575. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  37576. // var dat map[string]interface{}
  37577. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37578. // fmt.Println(dat)
  37579. // } else {
  37580. // fmt.Println(err)
  37581. // }
  37582. // userJSONBytes, _ := json.Marshal(dat)
  37583. // var res ResultTwo
  37584. // var res10265 ResultTwo10265
  37585. // if miConfig.Code == "H15049901371" {
  37586. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  37587. // utils.ErrorLog("解析失败:%v", err)
  37588. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37589. // return
  37590. // }
  37591. // res.ErrMsg = res10265.ErrMsg
  37592. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37593. // res.Infcode = infocode
  37594. // res.Output = res10265.Output
  37595. // res.InfRefmsgid = res10265.InfRefmsgid
  37596. // } else {
  37597. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37598. // utils.ErrorLog("解析失败:%v", err)
  37599. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37600. // return
  37601. // }
  37602. // }
  37603. //
  37604. // var user_name string
  37605. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  37606. // if role.ID == 0 {
  37607. // user_name = "xxx"
  37608. // } else {
  37609. // user_name = role.UserName
  37610. // }
  37611. //
  37612. // baseParams := models.BaseParams{
  37613. // SecretKey: miConfig.SecretKey,
  37614. // FixmedinsCode: miConfig.Code,
  37615. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  37616. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  37617. // OrgName: miConfig.OrgName,
  37618. // Doctor: user_name,
  37619. // }
  37620. //
  37621. // if config.IsOpen == 1 {
  37622. // if miConfig.Code == "H15049901371" {
  37623. // if med_type == "14" {
  37624. // if insutype == "390" {
  37625. // med_type = "9933"
  37626. // } else if insutype == "310" {
  37627. // med_type = "990502"
  37628. // }
  37629. // } else if med_type == "11" {
  37630. // med_type = "11"
  37631. // }
  37632. // }
  37633. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  37634. // var dat map[string]interface{}
  37635. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37636. // fmt.Println(dat)
  37637. // } else {
  37638. // fmt.Println(err)
  37639. // }
  37640. // var res Result2001
  37641. // var res10265 Result2001Org10265
  37642. // if miConfig.Code == "H15049901371" {
  37643. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37644. // utils.ErrorLog("解析失败:%v", err)
  37645. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37646. // return
  37647. // }
  37648. // res.ErrMsg = res10265.ErrMsg
  37649. // res.Output = res10265.Output
  37650. // res.InfRefmsgid = res10265.InfRefmsgid
  37651. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37652. // res.Infcode = infocode
  37653. // } else {
  37654. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  37655. // utils.ErrorLog("解析失败:%v", err)
  37656. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37657. // return
  37658. // }
  37659. // }
  37660. // if res.Infcode == 0 {
  37661. // c.ServeSuccessJSON(map[string]interface{}{
  37662. // "msg": res.Output.Trtinfo,
  37663. // })
  37664. // }
  37665. // }
  37666. // }
  37667. //}
  37668. //func (c *HisApiController) PutRecord() {
  37669. // id, _ := c.GetInt64("id")
  37670. // record_time := c.GetString("record_time")
  37671. // timeLayout := "2006-01-02"
  37672. // loc, _ := time.LoadLocation("Local")
  37673. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  37674. // if err != nil {
  37675. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  37676. // return
  37677. // }
  37678. // recordDateTime := theTime.Unix()
  37679. //
  37680. // adminInfo := c.GetAdminUserInfo()
  37681. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  37682. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  37683. //
  37684. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  37685. //
  37686. // fmt.Println(miConfig.SecretKey)
  37687. //
  37688. // if patient == nil {
  37689. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  37690. // return
  37691. // }
  37692. // if len(patient.IdCardNo) == 0 {
  37693. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  37694. // return
  37695. // }
  37696. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  37697. // if config.IsOpen == 1 {
  37698. // 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
  37699. // resp, requestErr := http.Get(api)
  37700. // if requestErr != nil {
  37701. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37702. // return
  37703. // }
  37704. // defer resp.Body.Close()
  37705. // body, ioErr := ioutil.ReadAll(resp.Body)
  37706. // if ioErr != nil {
  37707. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37708. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37709. // return
  37710. // }
  37711. // var respJSON map[string]interface{}
  37712. //
  37713. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37714. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37715. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37716. // return
  37717. // }
  37718. //
  37719. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37720. // userJSONBytes, _ := json.Marshal(userJSON)
  37721. // var res ResultTwo
  37722. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37723. // utils.ErrorLog("解析失败:%v", err)
  37724. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37725. // return
  37726. // }
  37727. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37728. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37729. // infoStr := string(Iinfos)
  37730. // idetinfoStr := string(Idetinfos)
  37731. //
  37732. // if res.Infcode == 0 {
  37733. // his := models.VMHisPatient{
  37734. // Status: 1,
  37735. // Ctime: time.Now().Unix(),
  37736. // Mtime: time.Now().Unix(),
  37737. // PsnNo: res.Output.Baseinfo.PsnNo,
  37738. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  37739. // Certno: res.Output.Baseinfo.Certno,
  37740. // PsnName: res.Output.Baseinfo.PsnName,
  37741. // Gend: res.Output.Baseinfo.Gend,
  37742. // Naty: res.Output.Baseinfo.Naty,
  37743. // Brdy: res.Output.Baseinfo.Brdy,
  37744. // Age: res.Output.Baseinfo.Age,
  37745. // Iinfo: infoStr,
  37746. // Idetinfo: idetinfoStr,
  37747. // PatientId: patient.ID,
  37748. // RecordDate: theTime.Unix(),
  37749. // UserOrgId: adminInfo.CurrentOrgId,
  37750. // AdminUserId: adminInfo.AdminUser.Id,
  37751. // IsReturn: 1,
  37752. // }
  37753. //
  37754. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  37755. // //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")
  37756. // //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")
  37757. //
  37758. // //var dat map[string]interface{}
  37759. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37760. // // fmt.Println(dat)
  37761. // //} else {
  37762. // // fmt.Println(err)
  37763. // //}
  37764. //
  37765. // var dat2 map[string]interface{}
  37766. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37767. // fmt.Println(dat2)
  37768. // } else {
  37769. // fmt.Println(err)
  37770. // }
  37771. //
  37772. // } else {
  37773. // adminUser := c.GetAdminUserInfo()
  37774. // errlog := &models.HisOrderError{
  37775. // UserOrgId: adminUser.CurrentOrgId,
  37776. // Ctime: time.Now().Unix(),
  37777. // Mtime: time.Now().Unix(),
  37778. // ErrMsg: res.ErrMsg,
  37779. // Status: 1,
  37780. // PatientId: id,
  37781. // RecordTime: recordDateTime,
  37782. // Stage: 1,
  37783. // }
  37784. // service.CreateErrMsgLog(errlog)
  37785. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  37786. // return
  37787. // }
  37788. // }
  37789. //
  37790. //}
  37791. //func (c *HisApiController) GetUploadDiag() {
  37792. // id, _ := c.GetInt64("id")
  37793. // record_time := c.GetString("record_time")
  37794. //
  37795. // diagnosis_id, _ := c.GetInt64("diagnosis")
  37796. // sick_type, _ := c.GetInt64("sick_type")
  37797. // reg_type, _ := c.GetInt64("reg_type")
  37798. //
  37799. // timeLayout := "2006-01-02"
  37800. // loc, _ := time.LoadLocation("Local")
  37801. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  37802. // if err != nil {
  37803. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  37804. // return
  37805. // }
  37806. //
  37807. // var patientPrescription models.HisPrescriptionInfo
  37808. // recordDateTime := theTime.Unix()
  37809. // adminInfo := c.GetAdminUserInfo()
  37810. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  37811. //
  37812. // if patientPrescription.ID == 0 {
  37813. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  37814. // }
  37815. //
  37816. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  37817. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  37818. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  37819. // sickConfig, _ := service.FindSickById(sick_type)
  37820. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  37821. //
  37822. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  37823. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  37824. // "&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 +
  37825. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  37826. // resp2, requestErr2 := http.Get(api2)
  37827. // if requestErr2 != nil {
  37828. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37829. // return
  37830. // }
  37831. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  37832. // if ioErr2 != nil {
  37833. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  37834. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37835. // return
  37836. // }
  37837. // var respJSON2 map[string]interface{}
  37838. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  37839. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37840. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37841. // return
  37842. // }
  37843. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37844. // userJSONBytes2, _ := json.Marshal(respJSON2)
  37845. //
  37846. // var res2 ResultSix
  37847. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37848. // utils.ErrorLog("解析失败:%v", err)
  37849. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37850. // return
  37851. // }
  37852. // if res2.Infcode != 0 {
  37853. // adminUser := c.GetAdminUserInfo()
  37854. // errlog := &models.HisOrderError{
  37855. // UserOrgId: adminUser.CurrentOrgId,
  37856. // Ctime: time.Now().Unix(),
  37857. // Mtime: time.Now().Unix(),
  37858. // ErrMsg: res2.ErrMsg,
  37859. // Status: 1,
  37860. // PatientId: id,
  37861. // RecordTime: recordDateTime,
  37862. // Stage: 3,
  37863. // }
  37864. // service.CreateErrMsgLog(errlog)
  37865. //
  37866. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  37867. // return
  37868. // }
  37869. //
  37870. // c.ServeSuccessJSON(map[string]interface{}{
  37871. // "msg": "上传成功",
  37872. // })
  37873. //
  37874. //}
  37875. type QueryResult struct {
  37876. ID int64
  37877. Name string
  37878. Code string
  37879. List_type_code string
  37880. }
  37881. func (c *HisApiController) GetCheckCode() {
  37882. ids_str := c.GetString("ids")
  37883. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  37884. ids_arr := strings.Split(ids_str, ",")
  37885. var queryResult []QueryResult
  37886. ids := make([]int64, 0)
  37887. for _, item := range ids_arr {
  37888. id, _ := strconv.ParseInt(item, 10, 64)
  37889. ids = append(ids, id)
  37890. }
  37891. if record_type == 1 {
  37892. drugs, _ := service.GetBatchDrugList(ids)
  37893. for _, item := range drugs {
  37894. result := QueryResult{
  37895. ID: item.ID,
  37896. Name: item.DrugName,
  37897. Code: item.MedicalInsuranceNumber,
  37898. List_type_code: "101",
  37899. }
  37900. queryResult = append(queryResult, result)
  37901. }
  37902. } else if record_type == 2 {
  37903. goods, _ := service.GetBatchGoodInformationList(ids)
  37904. fmt.Println(goods)
  37905. for _, item := range goods {
  37906. result := QueryResult{
  37907. ID: item.ID,
  37908. Name: item.GoodName,
  37909. Code: item.SocialSecurityDirectoryCode,
  37910. List_type_code: "301",
  37911. }
  37912. queryResult = append(queryResult, result)
  37913. }
  37914. } else if record_type == 3 {
  37915. projects, _ := service.GetBathchMyPorjecgList(ids)
  37916. for _, item := range projects {
  37917. result := QueryResult{
  37918. ID: item.ID,
  37919. Name: item.ProjectName,
  37920. Code: item.MedicalCode,
  37921. List_type_code: "201",
  37922. }
  37923. queryResult = append(queryResult, result)
  37924. }
  37925. }
  37926. admin_user_id, _ := c.GetInt64("admin_user_id")
  37927. adminUser := c.GetAdminUserInfo()
  37928. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37929. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37930. var user_name string
  37931. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37932. if role.ID == 0 {
  37933. user_name = "管理员"
  37934. } else {
  37935. user_name = role.UserName
  37936. }
  37937. baseParams := models.BaseParams{
  37938. SecretKey: miConfig.SecretKey,
  37939. FixmedinsCode: miConfig.Code,
  37940. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  37941. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  37942. OrgName: miConfig.OrgName,
  37943. Doctor: user_name,
  37944. }
  37945. var result string
  37946. if miConfig.MdtrtareaAdmvs == "430800" {
  37947. for _, item := range queryResult {
  37948. if record_type == 1 {
  37949. 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)
  37950. } else if record_type == 2 {
  37951. fmt.Println(item.Code)
  37952. 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)
  37953. } else if record_type == 3 {
  37954. 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)
  37955. }
  37956. var dat map[string]interface{}
  37957. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37958. fmt.Println(dat)
  37959. } else {
  37960. fmt.Println(err)
  37961. }
  37962. userJSONBytes, _ := json.Marshal(dat)
  37963. var res ResultSix
  37964. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37965. utils.ErrorLog("解析失败:%v", err)
  37966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37967. return
  37968. }
  37969. if res.Infcode == 0 {
  37970. if record_type == 1 {
  37971. service.UpdateBaseDrugById(item.ID)
  37972. } else if record_type == 2 {
  37973. service.UpdateGoodInformaitonByDetail(item.ID)
  37974. } else if record_type == 3 {
  37975. service.UpdateProjectById(item.ID)
  37976. }
  37977. c.ServeSuccessJSON(map[string]interface{}{
  37978. "failed_code": 0,
  37979. "msg": "目录对照成功",
  37980. })
  37981. } else {
  37982. c.ServeSuccessJSON(map[string]interface{}{
  37983. "failed_code": -10,
  37984. "msg": res.ErrMsg,
  37985. })
  37986. }
  37987. }
  37988. } else {
  37989. for _, item := range queryResult {
  37990. var result string
  37991. if record_type == 1 {
  37992. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  37993. } else if record_type == 2 {
  37994. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  37995. } else if record_type == 3 {
  37996. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  37997. }
  37998. var dat map[string]interface{}
  37999. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38000. fmt.Println(dat)
  38001. } else {
  38002. fmt.Println(err)
  38003. }
  38004. userJSONBytes, _ := json.Marshal(dat)
  38005. var res ResultSix
  38006. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38007. utils.ErrorLog("解析失败:%v", err)
  38008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38009. return
  38010. }
  38011. if res.Infcode == 0 {
  38012. if record_type == 1 {
  38013. service.UpdateBaseDrugById(item.ID)
  38014. } else if record_type == 2 {
  38015. service.UpdateGoodInformaitonByDetail(item.ID)
  38016. } else if record_type == 3 {
  38017. service.UpdateProjectById(item.ID)
  38018. }
  38019. c.ServeSuccessJSON(map[string]interface{}{
  38020. "failed_code": 0,
  38021. "msg": "目录对照成功",
  38022. })
  38023. } else {
  38024. c.ServeSuccessJSON(map[string]interface{}{
  38025. "failed_code": -10,
  38026. "msg": res.ErrMsg,
  38027. })
  38028. }
  38029. }
  38030. }
  38031. }
  38032. func (c *HisApiController) UnCheckCode() {
  38033. ids_str := c.GetString("ids")
  38034. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  38035. admin_user_id, _ := c.GetInt64("admin_user_id")
  38036. ids_arr := strings.Split(ids_str, ",")
  38037. var queryResult []QueryResult
  38038. ids := make([]int64, 0)
  38039. for _, item := range ids_arr {
  38040. id, _ := strconv.ParseInt(item, 10, 64)
  38041. ids = append(ids, id)
  38042. }
  38043. if record_type == 1 {
  38044. drugs, _ := service.GetBatchDrugList(ids)
  38045. for _, item := range drugs {
  38046. result := QueryResult{
  38047. ID: item.ID,
  38048. Name: item.DrugName,
  38049. Code: item.MedicalInsuranceNumber,
  38050. List_type_code: "101",
  38051. }
  38052. queryResult = append(queryResult, result)
  38053. }
  38054. } else if record_type == 2 {
  38055. goods, _ := service.GetBatchGoodInformationList(ids)
  38056. for _, item := range goods {
  38057. result := QueryResult{
  38058. ID: item.ID,
  38059. Name: item.GoodName,
  38060. Code: item.SocialSecurityDirectoryCode,
  38061. List_type_code: "301",
  38062. }
  38063. queryResult = append(queryResult, result)
  38064. }
  38065. } else if record_type == 3 {
  38066. projects, _ := service.GetBathchMyPorjecgList(ids)
  38067. for _, item := range projects {
  38068. result := QueryResult{
  38069. ID: item.ID,
  38070. Name: item.ProjectName,
  38071. Code: item.MedicalCode,
  38072. List_type_code: "201",
  38073. }
  38074. queryResult = append(queryResult, result)
  38075. }
  38076. }
  38077. adminUser := c.GetAdminUserInfo()
  38078. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38079. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38080. var user_name string
  38081. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38082. if role.ID == 0 {
  38083. user_name = "xxx"
  38084. } else {
  38085. user_name = role.UserName
  38086. }
  38087. baseParams := &models.BaseParams{
  38088. SecretKey: miConfig.SecretKey,
  38089. FixmedinsCode: miConfig.Code,
  38090. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  38091. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  38092. OrgName: miConfig.OrgName,
  38093. Doctor: user_name,
  38094. }
  38095. if config.IsOpen == 1 {
  38096. if miConfig.MdtrtareaAdmvs == "430800" {
  38097. for _, item := range queryResult {
  38098. var result string
  38099. if record_type == 1 {
  38100. 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)
  38101. } else if record_type == 2 {
  38102. fmt.Println(item.Code)
  38103. 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)
  38104. } else if record_type == 3 {
  38105. 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)
  38106. }
  38107. var dat map[string]interface{}
  38108. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38109. fmt.Println(dat)
  38110. } else {
  38111. fmt.Println(err)
  38112. }
  38113. userJSONBytes, _ := json.Marshal(dat)
  38114. var res ResultSix
  38115. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38116. utils.ErrorLog("解析失败:%v", err)
  38117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38118. return
  38119. }
  38120. if res.Infcode == 0 {
  38121. if record_type == 1 {
  38122. service.UpdateBaseDrugById(item.ID)
  38123. } else if record_type == 2 {
  38124. service.UpdateGoodInformaitonByDetail(item.ID)
  38125. } else if record_type == 3 {
  38126. service.UpdateProjectById(item.ID)
  38127. }
  38128. c.ServeSuccessJSON(map[string]interface{}{
  38129. "failed_code": 0,
  38130. "msg": "目录对照成功",
  38131. })
  38132. } else {
  38133. c.ServeSuccessJSON(map[string]interface{}{
  38134. "failed_code": -10,
  38135. "msg": res.ErrMsg,
  38136. })
  38137. }
  38138. }
  38139. } else {
  38140. for _, item := range queryResult {
  38141. var result string
  38142. if record_type == 1 {
  38143. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  38144. } else if record_type == 2 {
  38145. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  38146. } else if record_type == 3 {
  38147. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  38148. }
  38149. var dat2 map[string]interface{}
  38150. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  38151. fmt.Println(dat2)
  38152. } else {
  38153. fmt.Println(err)
  38154. }
  38155. userJSONBytes, _ := json.Marshal(dat2)
  38156. var res ResultSix
  38157. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38158. utils.ErrorLog("解析失败:%v", err)
  38159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38160. return
  38161. }
  38162. if res.Infcode == 0 {
  38163. if record_type == 1 {
  38164. service.UpdateDrugByIdDetail(item.ID)
  38165. } else if record_type == 2 {
  38166. service.UpdateGoodInfoById(item.ID)
  38167. } else if record_type == 3 {
  38168. service.UpdateMyProjectById(item.ID)
  38169. }
  38170. c.ServeSuccessJSON(map[string]interface{}{
  38171. "failed_code": 0,
  38172. "msg": "撤销目录对照成功",
  38173. })
  38174. } else {
  38175. c.ServeSuccessJSON(map[string]interface{}{
  38176. "failed_code": -10,
  38177. "msg": res.ErrMsg,
  38178. })
  38179. }
  38180. }
  38181. }
  38182. }
  38183. }
  38184. func (c *HisApiController) GetPatientInfo() {
  38185. id_card_no := c.GetString("id_card_no")
  38186. admin_user_id, _ := c.GetInt64("admin_user_id")
  38187. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  38188. if patient.ID == 0 {
  38189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  38190. return
  38191. }
  38192. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  38193. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38194. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  38195. var res ResultTwo
  38196. var res10265 ResultTwo10265
  38197. if config.IsOpen == 1 {
  38198. if miConfig.MdtrtareaAdmvs == "150499" {
  38199. //请求内网数据
  38200. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  38201. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  38202. "&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
  38203. resp, requestErr := http.Get(api)
  38204. if requestErr != nil {
  38205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38206. return
  38207. }
  38208. body, ioErr := ioutil.ReadAll(resp.Body)
  38209. if ioErr != nil {
  38210. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38212. return
  38213. }
  38214. var respJSON map[string]interface{}
  38215. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38216. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38218. return
  38219. }
  38220. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38221. result_byte, _ := json.Marshal(respJSON)
  38222. result := string(result_byte)
  38223. var dat map[string]interface{}
  38224. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38225. fmt.Println(dat)
  38226. } else {
  38227. fmt.Println(err)
  38228. }
  38229. userJSONBytes, _ := json.Marshal(dat)
  38230. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  38231. utils.ErrorLog("解析失败:%v", err)
  38232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38233. return
  38234. }
  38235. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38236. res.Infcode = Infcode
  38237. res.ErrMsg = res10265.ErrMsg
  38238. res.Output = res10265.Output
  38239. res.InfRefmsgid = res10265.InfRefmsgid
  38240. res.RespondTime = res10265.RespondTime
  38241. res.WarnInfo = res10265.WarnInfo
  38242. } else {
  38243. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  38244. var dat map[string]interface{}
  38245. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38246. fmt.Println(dat)
  38247. } else {
  38248. fmt.Println(err)
  38249. }
  38250. userJSONBytes, _ := json.Marshal(dat)
  38251. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38252. utils.ErrorLog("解析失败:%v", err)
  38253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38254. return
  38255. }
  38256. }
  38257. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38258. // utils.ErrorLog("解析失败:%v", err)
  38259. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38260. // return
  38261. //}
  38262. for index, item := range res.Output.Iinfo {
  38263. if item.PsnInsuStas == "2" {
  38264. fmt.Println("--------")
  38265. res.Output.Iinfo[index].Insutype = "300"
  38266. res.Output.Iinfo[index].PsnInsuStas = "1"
  38267. }
  38268. }
  38269. fmt.Println(res.Output.Iinfo)
  38270. if res.Infcode != 0 {
  38271. c.ServeSuccessJSON(map[string]interface{}{
  38272. "failed_code": -10,
  38273. "msg": res.ErrMsg,
  38274. })
  38275. } else {
  38276. c.ServeSuccessJSON(map[string]interface{}{
  38277. "failed_code": 0,
  38278. "info": res,
  38279. })
  38280. }
  38281. }
  38282. }
  38283. func (c *HisApiController) PsnPutOnRecord() {
  38284. record_type, _ := c.GetInt64("type")
  38285. patient_id, _ := c.GetInt64("patient_id")
  38286. admin_user_id, _ := c.GetInt64("admin_user_id")
  38287. start_time := c.GetString("start_time")
  38288. end_time := c.GetString("end_time")
  38289. adminUser := c.GetAdminUserInfo()
  38290. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38291. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38292. var patients []*models.Patients
  38293. if record_type == 1 { //全部备案
  38294. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  38295. patients = append(patients, patient...)
  38296. } else { //单个备案
  38297. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  38298. patients = append(patients, patient)
  38299. }
  38300. var user_name string
  38301. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38302. if role.ID == 0 {
  38303. user_name = "xxx"
  38304. } else {
  38305. user_name = role.UserName
  38306. }
  38307. if config.IsOpen == 1 {
  38308. for _, item := range patients {
  38309. 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
  38310. resp, requestErr := http.Get(api)
  38311. if requestErr != nil {
  38312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38313. return
  38314. }
  38315. defer resp.Body.Close()
  38316. body, ioErr := ioutil.ReadAll(resp.Body)
  38317. if ioErr != nil {
  38318. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38320. return
  38321. }
  38322. var respJSON map[string]interface{}
  38323. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38324. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38326. return
  38327. }
  38328. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38329. userJSONBytes, _ := json.Marshal(userJSON)
  38330. var res ResultTwo
  38331. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38332. utils.ErrorLog("解析失败:%v", err)
  38333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38334. return
  38335. }
  38336. if res.Infcode == 0 {
  38337. 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)
  38338. var dat map[string]interface{}
  38339. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38340. fmt.Println(dat)
  38341. } else {
  38342. fmt.Println(err)
  38343. }
  38344. userJSONBytes, _ := json.Marshal(dat)
  38345. var res2 ResultThirteen
  38346. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  38347. utils.ErrorLog("解析失败:%v", err)
  38348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38349. return
  38350. }
  38351. if res2.Infcode == 0 {
  38352. psnResult := &models.GdybPsnRecord{
  38353. UserOrgId: adminUser.CurrentOrgId,
  38354. PatientId: item.ID,
  38355. PsnNo: res.Output.Baseinfo.PsnNo,
  38356. Ctime: time.Now().Unix(),
  38357. Mtime: time.Now().Unix(),
  38358. Status: 1,
  38359. IsCancel: 1,
  38360. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  38361. }
  38362. service.CreatePsnRecord(psnResult)
  38363. } else {
  38364. c.ServeSuccessJSON(map[string]interface{}{
  38365. "failed_code": -10,
  38366. "msg": res2.ErrMsg,
  38367. })
  38368. return
  38369. }
  38370. }
  38371. }
  38372. }
  38373. }
  38374. func (c *HisApiController) PsnUnPutOnRecord() {
  38375. id, _ := c.GetInt64("id")
  38376. //record_type, _ := c.GetInt64("type")
  38377. admin_user_id, _ := c.GetInt64("admin_user_id")
  38378. adminUser := c.GetAdminUserInfo()
  38379. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38380. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38381. var user_name string
  38382. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38383. if role.ID == 0 {
  38384. user_name = "xxx"
  38385. } else {
  38386. user_name = role.UserName
  38387. }
  38388. psn_record, _ := service.GetPsnRecordById(id)
  38389. if psn_record.ID == 0 {
  38390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  38391. return
  38392. }
  38393. if config.IsOpen == 1 {
  38394. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  38395. var dat map[string]interface{}
  38396. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38397. fmt.Println(dat)
  38398. } else {
  38399. fmt.Println(err)
  38400. }
  38401. userJSONBytes, _ := json.Marshal(dat)
  38402. var res ResultFourteen
  38403. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38404. utils.ErrorLog("解析失败:%v", err)
  38405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38406. return
  38407. }
  38408. if res.Infcode == 0 {
  38409. psn_record.IsCancel = 2
  38410. service.CreatePsnRecord(&psn_record)
  38411. } else {
  38412. c.ServeSuccessJSON(map[string]interface{}{
  38413. "failed_code": -10,
  38414. "msg": res.ErrMsg,
  38415. })
  38416. return
  38417. }
  38418. }
  38419. }
  38420. func (c *HisApiController) PsnPutNCDSOnRecord() {
  38421. patient_id, _ := c.GetInt64("patient_id")
  38422. insutype_two := c.GetString("insutype")
  38423. psn_no := c.GetString("psn_no")
  38424. doctor_id, _ := c.GetInt64("doctor_id")
  38425. sick_id, _ := c.GetInt64("sick_id")
  38426. department_id, _ := c.GetInt64("department_id")
  38427. start_time := c.GetString("start_time")
  38428. end_time := c.GetString("end_time")
  38429. check_time := c.GetString("check_time")
  38430. hospital_code := c.GetString("hospital_code")
  38431. hospital_name := c.GetString("hospital_name")
  38432. adminUser := c.GetAdminUserInfo()
  38433. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  38434. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38435. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38436. sick, _ := service.FindSickById(sick_id)
  38437. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  38438. if len(hospital_code) == 0 {
  38439. hospital_code = miConfig.Code
  38440. }
  38441. if len(hospital_name) == 0 {
  38442. hospital_name = miConfig.OrgName
  38443. }
  38444. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  38445. var res ResultTwo
  38446. var res10265 ResultTwo10265
  38447. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  38448. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  38449. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  38450. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  38451. "&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
  38452. resp, requestErr := http.Get(api)
  38453. if requestErr != nil {
  38454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38455. return
  38456. }
  38457. body, ioErr := ioutil.ReadAll(resp.Body)
  38458. if ioErr != nil {
  38459. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38461. return
  38462. }
  38463. var respJSON map[string]interface{}
  38464. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38465. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38467. return
  38468. }
  38469. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38470. result, _ := json.Marshal(respJSON)
  38471. fmt.Println("log")
  38472. fmt.Println(string(result))
  38473. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38474. utils.ErrorLog("解析失败:%v", err)
  38475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38476. return
  38477. }
  38478. res.ErrMsg = res10265.ErrMsg
  38479. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38480. res.Infcode = infocode
  38481. res.Output = res10265.Output
  38482. res.InfRefmsgid = res10265.InfRefmsgid
  38483. } else {
  38484. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  38485. if miConfig.Code == "H15049901371" {
  38486. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38487. utils.ErrorLog("解析失败:%v", err)
  38488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38489. return
  38490. }
  38491. res.ErrMsg = res10265.ErrMsg
  38492. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38493. res.Infcode = infocode
  38494. res.Output = res10265.Output
  38495. res.InfRefmsgid = res10265.InfRefmsgid
  38496. } else {
  38497. if err := json.Unmarshal([]byte(result), &res); err != nil {
  38498. utils.ErrorLog("解析失败:%v", err)
  38499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38500. return
  38501. }
  38502. }
  38503. }
  38504. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  38505. infoStr := string(Iinfos)
  38506. var rf []*ResultFive
  38507. json.Unmarshal([]byte(infoStr), &rf)
  38508. var insuplc_admdvs string
  38509. var insutype string
  38510. var is390 int = 0
  38511. var is310 int = 0
  38512. var insutypes []*ResultFive
  38513. for _, item := range rf {
  38514. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  38515. insutypes = append(insutypes, item)
  38516. }
  38517. }
  38518. if len(insutypes) == 1 {
  38519. insutype = insutypes[0].Insutype
  38520. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  38521. } else {
  38522. for _, i := range insutypes {
  38523. if i.Insutype == "390" {
  38524. is390 = 1
  38525. }
  38526. if i.Insutype == "310" {
  38527. is310 = 1
  38528. }
  38529. }
  38530. }
  38531. if is390 == 1 {
  38532. insutype = "390"
  38533. }
  38534. if is310 == 1 {
  38535. insutype = "310"
  38536. }
  38537. if len(insutypes) == 2 {
  38538. insutype = insutype_two
  38539. }
  38540. if len(insutypes) == 0 {
  38541. insutype = "310"
  38542. }
  38543. insutype = insutype_two
  38544. fmt.Println(insutype)
  38545. for _, item := range rf {
  38546. fmt.Println(item.Insutype)
  38547. fmt.Println(insutype)
  38548. if item.Insutype == insutype {
  38549. fmt.Println(item.Insutype)
  38550. fmt.Println(insutype)
  38551. insuplc_admdvs = item.InsuplcAdmdvs
  38552. }
  38553. }
  38554. fmt.Println(insuplc_admdvs)
  38555. var res2 ResultThirteen
  38556. var res10265_2 ResultThirteen10265
  38557. if config.IsOpen == 1 {
  38558. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  38559. } else {
  38560. if miConfig.MdtrtareaAdmvs == "150499" {
  38561. //
  38562. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  38563. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  38564. // "&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
  38565. //resp, requestErr := http.Get(api)
  38566. //if requestErr != nil {
  38567. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38568. // return
  38569. //}
  38570. //
  38571. //body, ioErr := ioutil.ReadAll(resp.Body)
  38572. //if ioErr != nil {
  38573. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38574. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38575. // return
  38576. //}
  38577. //var respJSON map[string]interface{}
  38578. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38579. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38580. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38581. // return
  38582. //}
  38583. //
  38584. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38585. //result, _ := json.Marshal(respJSON)
  38586. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  38587. // utils.ErrorLog("解析失败:%v", err)
  38588. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38589. // return
  38590. //}
  38591. //infocode = resThree.Infcode
  38592. //result, _ := json.Marshal(respJSON)
  38593. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  38594. // utils.ErrorLog("解析失败:%v", err)
  38595. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38596. // return
  38597. //}
  38598. //
  38599. //resThree.ErrMsg = resThree10265.ErrMsg
  38600. //
  38601. //resThree.Output = resThree10265.Output
  38602. //
  38603. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  38604. //
  38605. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  38606. //
  38607. } else {
  38608. 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)
  38609. var dat map[string]interface{}
  38610. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38611. fmt.Println(dat)
  38612. } else {
  38613. fmt.Println(err)
  38614. }
  38615. userJSONBytes, _ := json.Marshal(dat)
  38616. if miConfig.Code == "H15049901371" {
  38617. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  38618. utils.ErrorLog("解析失败:%v", err)
  38619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38620. return
  38621. }
  38622. res2.ErrMsg = res10265_2.ErrMsg
  38623. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  38624. res2.Infcode = infocode
  38625. res2.Output = res10265_2.Output
  38626. res2.InfRefmsgid = res10265_2.InfRefmsgid
  38627. } else {
  38628. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  38629. utils.ErrorLog("解析失败:%v", err)
  38630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38631. return
  38632. }
  38633. }
  38634. }
  38635. }
  38636. if res2.Infcode == 0 {
  38637. psnResult := &models.GdybPsnNcdsRecord{
  38638. UserOrgId: adminUser.CurrentOrgId,
  38639. PatientId: patient.ID,
  38640. PsnNo: psn_no,
  38641. DoctorId: doctor.AdminUserId,
  38642. DepartmentId: department_id,
  38643. SickType: sick_id,
  38644. Insutype: insutype,
  38645. Ctime: time.Now().Unix(),
  38646. Mtime: time.Now().Unix(),
  38647. Status: 1,
  38648. IsCancel: 1,
  38649. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  38650. }
  38651. service.CreatePsnNCDSRecord(psnResult)
  38652. c.ServeSuccessJSON(map[string]interface{}{
  38653. "failed_code": 0,
  38654. "msg": "备案成功",
  38655. "result": psnResult,
  38656. })
  38657. } else {
  38658. c.ServeSuccessJSON(map[string]interface{}{
  38659. "failed_code": -10,
  38660. "msg": res2.ErrMsg,
  38661. })
  38662. return
  38663. }
  38664. }
  38665. }
  38666. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  38667. id, _ := c.GetInt64("id")
  38668. admin_user_id, _ := c.GetInt64("admin_user_id")
  38669. adminUser := c.GetAdminUserInfo()
  38670. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38671. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38672. //config, _ := service.Ge(adminUser.CurrentOrgId)
  38673. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  38674. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38675. //var user_name string
  38676. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38677. //if role.ID == 0 {
  38678. // user_name = "xxx"
  38679. //} else {
  38680. // user_name = role.UserName
  38681. //}
  38682. psn_record, _ := service.GetPsnNCDSRecordById(id)
  38683. if psn_record.ID == 0 {
  38684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  38685. return
  38686. }
  38687. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  38688. var res ResultTwo
  38689. var res10265 ResultTwo10265
  38690. if miConfig.Code == "H15049901371" {
  38691. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38692. utils.ErrorLog("解析失败:%v", err)
  38693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38694. return
  38695. }
  38696. res.ErrMsg = res10265.ErrMsg
  38697. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38698. res.Infcode = infocode
  38699. res.Output = res10265.Output
  38700. res.InfRefmsgid = res10265.InfRefmsgid
  38701. } else {
  38702. if err := json.Unmarshal([]byte(result), &res); err != nil {
  38703. utils.ErrorLog("解析失败:%v", err)
  38704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38705. return
  38706. }
  38707. }
  38708. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  38709. infoStr := string(Iinfos)
  38710. var rf []*ResultFive
  38711. json.Unmarshal([]byte(infoStr), &rf)
  38712. var insuplc_admdvs string
  38713. var insutype string
  38714. var is390 int = 0
  38715. var is310 int = 0
  38716. var insutypes []*ResultFive
  38717. for _, item := range rf {
  38718. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  38719. insutypes = append(insutypes, item)
  38720. }
  38721. }
  38722. if len(insutypes) == 1 {
  38723. insutype = insutypes[0].Insutype
  38724. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  38725. } else {
  38726. for _, i := range insutypes {
  38727. if i.Insutype == "390" {
  38728. is390 = 1
  38729. }
  38730. if i.Insutype == "310" {
  38731. is310 = 1
  38732. }
  38733. }
  38734. }
  38735. if is390 == 1 {
  38736. insutype = "390"
  38737. }
  38738. if is310 == 1 {
  38739. insutype = "310"
  38740. }
  38741. if len(insutypes) == 0 {
  38742. insutype = "310"
  38743. }
  38744. insutype = psn_record.Insutype
  38745. for _, item := range rf {
  38746. if item.Insutype == insutype {
  38747. insuplc_admdvs = item.InsuplcAdmdvs
  38748. }
  38749. }
  38750. if config.IsOpen == 1 {
  38751. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  38752. var dat map[string]interface{}
  38753. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38754. fmt.Println(dat)
  38755. } else {
  38756. fmt.Println(err)
  38757. }
  38758. userJSONBytes, _ := json.Marshal(dat)
  38759. var res ResultFourteen
  38760. var res10265 ResultFourteen10265
  38761. if miConfig.Code == "H15049901371" {
  38762. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  38763. utils.ErrorLog("解析失败:%v", err)
  38764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38765. return
  38766. }
  38767. res.ErrMsg = res10265.ErrMsg
  38768. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38769. res.Infcode = infocode
  38770. res.Output = res10265.Output
  38771. res.InfRefmsgid = res10265.InfRefmsgid
  38772. } else {
  38773. if err := json.Unmarshal([]byte(result), &res); err != nil {
  38774. utils.ErrorLog("解析失败:%v", err)
  38775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38776. return
  38777. }
  38778. }
  38779. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38780. // utils.ErrorLog("解析失败:%v", err)
  38781. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38782. // return
  38783. //}
  38784. if res.Infcode == 0 {
  38785. psn_record.IsCancel = 2
  38786. service.CreatePsnNCDSRecord(&psn_record)
  38787. c.ServeSuccessJSON(map[string]interface{}{
  38788. "failed_code": 0,
  38789. "msg": "撤销备案成功",
  38790. })
  38791. } else {
  38792. c.ServeSuccessJSON(map[string]interface{}{
  38793. "failed_code": -10,
  38794. "msg": res.ErrMsg,
  38795. })
  38796. return
  38797. }
  38798. }
  38799. }
  38800. func (c *HisApiController) TestTest() {
  38801. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  38802. fmt.Println(patient.Iinfo)
  38803. }
  38804. type CustomData struct {
  38805. MsgId string
  38806. PsnNo string
  38807. Info string
  38808. }
  38809. func (c *HisApiController) ReversalData() {
  38810. var customData []*CustomData
  38811. custom := &CustomData{
  38812. MsgId: "H44022900158202103301714472004",
  38813. PsnNo: "44020000001101329945",
  38814. Info: "2207",
  38815. }
  38816. customData = append(customData, custom)
  38817. custom1 := &CustomData{
  38818. MsgId: "H4402290015820210330172057803",
  38819. PsnNo: "44020000001101161813",
  38820. Info: "2207",
  38821. }
  38822. customData = append(customData, custom1)
  38823. custom2 := &CustomData{
  38824. MsgId: "H44022900158202103301705198813",
  38825. PsnNo: "44190000133097375417",
  38826. Info: "2207",
  38827. }
  38828. customData = append(customData, custom2)
  38829. custom3 := &CustomData{
  38830. MsgId: "H44022900158202103301715524756",
  38831. PsnNo: "44020000001100187221",
  38832. Info: "2207",
  38833. }
  38834. customData = append(customData, custom3)
  38835. custom4 := &CustomData{
  38836. MsgId: "H44022900158202103301730376224",
  38837. PsnNo: "44020000001101959155",
  38838. Info: "2207",
  38839. }
  38840. customData = append(customData, custom4)
  38841. custom5 := &CustomData{
  38842. MsgId: "H44022900158202103301748008725",
  38843. PsnNo: "44020000001104246641",
  38844. Info: "2207",
  38845. }
  38846. customData = append(customData, custom5)
  38847. custom6 := &CustomData{
  38848. MsgId: "H44022900158202103301718096755",
  38849. PsnNo: "44020000001102211860",
  38850. Info: "2207",
  38851. }
  38852. customData = append(customData, custom6)
  38853. custom7 := &CustomData{
  38854. MsgId: "H44022900158202103301736551640",
  38855. PsnNo: "44020000001102687718",
  38856. Info: "2207",
  38857. }
  38858. customData = append(customData, custom7)
  38859. custom8 := &CustomData{
  38860. MsgId: "H44022900158202103301743097676",
  38861. PsnNo: "44020000001102127785",
  38862. Info: "2207",
  38863. }
  38864. customData = append(customData, custom8)
  38865. custom9 := &CustomData{
  38866. MsgId: "H44022900158202103301712304203",
  38867. PsnNo: "44020000001101518097",
  38868. Info: "2207",
  38869. }
  38870. customData = append(customData, custom9)
  38871. custom10 := &CustomData{
  38872. MsgId: "H44022900158202103301738448785",
  38873. PsnNo: "44020000001100500813",
  38874. Info: "2207",
  38875. }
  38876. customData = append(customData, custom10)
  38877. custom11 := &CustomData{
  38878. MsgId: "H44022900158202103301732455843",
  38879. PsnNo: "44020000001102690557",
  38880. Info: "2207",
  38881. }
  38882. customData = append(customData, custom11)
  38883. custom12 := &CustomData{
  38884. MsgId: "H44022900158202103301745421708",
  38885. PsnNo: "44020000001102211928",
  38886. Info: "2207",
  38887. }
  38888. customData = append(customData, custom12)
  38889. custom1212 := &CustomData{
  38890. MsgId: "H440229001582021033017351627",
  38891. PsnNo: "44020000001102481733",
  38892. Info: "2207",
  38893. }
  38894. customData = append(customData, custom1212)
  38895. custom13 := &CustomData{
  38896. MsgId: "H44022900158202103301740327951",
  38897. PsnNo: "44020000001103174866",
  38898. Info: "2207",
  38899. }
  38900. customData = append(customData, custom13)
  38901. custom14 := &CustomData{
  38902. MsgId: "H4402290015820210330174922668",
  38903. PsnNo: "44020000001102927272",
  38904. Info: "2207",
  38905. }
  38906. customData = append(customData, custom14)
  38907. custom15 := &CustomData{
  38908. MsgId: "H44022900158202103301752362273",
  38909. PsnNo: "44020000001102942890",
  38910. Info: "2207",
  38911. }
  38912. customData = append(customData, custom15)
  38913. custom16 := &CustomData{
  38914. MsgId: "H44022900158202103301751082917",
  38915. PsnNo: "44020000001101662162",
  38916. Info: "2207",
  38917. }
  38918. customData = append(customData, custom16)
  38919. custom17 := &CustomData{
  38920. MsgId: "H44022900158202103301754147728",
  38921. PsnNo: "44020000000229014511",
  38922. Info: "2207",
  38923. }
  38924. customData = append(customData, custom17)
  38925. adminUser := c.GetAdminUserInfo()
  38926. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38927. for _, item := range customData {
  38928. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  38929. fmt.Println(result)
  38930. }
  38931. }
  38932. func (c *HisApiController) GetAllopatry() {
  38933. year := c.GetString("year")
  38934. month := c.GetString("month")
  38935. admin_user_id, _ := c.GetInt64("admin_user_id")
  38936. adminUser := c.GetAdminUserInfo()
  38937. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38938. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38939. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  38940. var dat map[string]interface{}
  38941. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38942. fmt.Println(dat)
  38943. } else {
  38944. fmt.Println(err)
  38945. }
  38946. userJSONBytes, _ := json.Marshal(dat)
  38947. var res models.Result9001
  38948. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38949. utils.ErrorLog("解析失败:%v", err)
  38950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38951. return
  38952. }
  38953. fmt.Println(res.Output.Signinoutb)
  38954. fmt.Println(res.Output.Signinoutb.SignNo)
  38955. fmt.Println(string(userJSONBytes))
  38956. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  38957. var dat3 map[string]interface{}
  38958. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  38959. fmt.Println(dat3)
  38960. } else {
  38961. fmt.Println(err)
  38962. }
  38963. userJSONBytes3, _ := json.Marshal(dat3)
  38964. var res3 models.Result3260
  38965. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  38966. utils.ErrorLog("解析失败:%v", err)
  38967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38968. return
  38969. }
  38970. var curpage int
  38971. var pagesize int = 100
  38972. var start int = 1
  38973. //var stop int
  38974. //pagecount := 10
  38975. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  38976. var res22 []models.Result3260
  38977. for curpage = 1; curpage <= pagecount; curpage++ {
  38978. if curpage == 1 {
  38979. start = 0
  38980. } else {
  38981. start = (curpage-1)*pagesize + 1
  38982. }
  38983. fmt.Println(start)
  38984. //stop = curpage * pagesize
  38985. //if stop > int(res3.Output.Totalrow) {
  38986. // stop =int(res3.Output.Totalrow)
  38987. //}
  38988. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  38989. var dat2 map[string]interface{}
  38990. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  38991. fmt.Println(dat)
  38992. } else {
  38993. fmt.Println(err)
  38994. }
  38995. userJSONBytes2, _ := json.Marshal(dat2)
  38996. var res2 models.Result3260
  38997. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  38998. utils.ErrorLog("解析失败:%v", err)
  38999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39000. return
  39001. }
  39002. if res2.Infcode == 0 {
  39003. res22 = append(res22, res2)
  39004. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  39005. //var dat2 map[string]interface{}
  39006. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  39007. // fmt.Println(dat)
  39008. //} else {
  39009. // fmt.Println(err)
  39010. //}
  39011. //c.ServeSuccessJSON(map[string]interface{}{
  39012. // "list": res2.Output.Data,
  39013. //})
  39014. //continue
  39015. }
  39016. }
  39017. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  39018. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  39019. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  39020. //var dat2 map[string]interface{}
  39021. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  39022. // fmt.Println(dat)
  39023. //} else {
  39024. // fmt.Println(err)
  39025. //}
  39026. //userJSONBytes2, _ := json.Marshal(dat2)
  39027. //var res2 models.Result3260
  39028. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  39029. // utils.ErrorLog("解析失败:%v", err)
  39030. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39031. // return
  39032. //}
  39033. //if res2.Infcode == 0 {
  39034. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  39035. // var dat2 map[string]interface{}
  39036. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  39037. // fmt.Println(dat)
  39038. // } else {
  39039. // fmt.Println(err)
  39040. // }
  39041. // c.ServeSuccessJSON(map[string]interface{}{
  39042. // "list": res2.Output.Data,
  39043. // })
  39044. //}
  39045. }
  39046. func (c *HisApiController) ComfirmAllopatry() {
  39047. year := c.GetString("year")
  39048. month := c.GetString("month")
  39049. admin_user_id, _ := c.GetInt64("admin_user_id")
  39050. adminUser := c.GetAdminUserInfo()
  39051. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39052. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39053. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  39054. var dat map[string]interface{}
  39055. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  39056. fmt.Println(dat)
  39057. } else {
  39058. fmt.Println(err)
  39059. }
  39060. userJSONBytes, _ := json.Marshal(dat)
  39061. var res models.Result9001
  39062. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39063. utils.ErrorLog("解析失败:%v", err)
  39064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39065. return
  39066. }
  39067. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  39068. var dat2 map[string]interface{}
  39069. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  39070. fmt.Println(dat)
  39071. } else {
  39072. fmt.Println(err)
  39073. }
  39074. userJSONBytes2, _ := json.Marshal(dat2)
  39075. var res2 models.Result3260
  39076. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  39077. utils.ErrorLog("解析失败:%v", err)
  39078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39079. return
  39080. }
  39081. //if res2.Infcode == 0 {
  39082. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  39083. // var dat map[string]interface{}
  39084. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  39085. // fmt.Println(dat)
  39086. // } else {
  39087. // fmt.Println(err)
  39088. // }
  39089. // userJSONBytes, _ := json.Marshal(dat)
  39090. // var res3 models.Result3261
  39091. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  39092. // utils.ErrorLog("解析失败:%v", err)
  39093. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39094. // return
  39095. // }
  39096. //
  39097. // if res3.Infcode == 0 {
  39098. // record := &models.HisYidiClearRecord{
  39099. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39100. // Ctime: time.Now().Unix(),
  39101. // Mtime: time.Now().Unix(),
  39102. // Status: 1,
  39103. // MsgId: msgId,
  39104. // }
  39105. // service.SaveClearRecord(record)
  39106. // c.ServeSuccessJSON(map[string]interface{}{
  39107. // "msg": "提取成功",
  39108. // })
  39109. // }
  39110. //}
  39111. }
  39112. func (c *HisApiController) RefundAllopatry() {
  39113. year := c.GetString("year")
  39114. month := c.GetString("month")
  39115. //id, _ := c.GetInt64("id")
  39116. admin_user_id, _ := c.GetInt64("admin_user_id")
  39117. adminUser := c.GetAdminUserInfo()
  39118. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39119. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39120. //record, _ := service.GetClearRecordById(id)
  39121. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  39122. var dat map[string]interface{}
  39123. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  39124. fmt.Println(dat)
  39125. } else {
  39126. fmt.Println(err)
  39127. }
  39128. userJSONBytes, _ := json.Marshal(dat)
  39129. var res models.Result9001
  39130. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39131. utils.ErrorLog("解析失败:%v", err)
  39132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39133. return
  39134. }
  39135. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  39136. var dat2 map[string]interface{}
  39137. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  39138. fmt.Println(dat)
  39139. } else {
  39140. fmt.Println(err)
  39141. }
  39142. userJSONBytes2, _ := json.Marshal(dat2)
  39143. var empty ResultFourteen
  39144. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  39145. utils.ErrorLog("解析失败:%v", err)
  39146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39147. return
  39148. }
  39149. if empty.Infcode == 0 {
  39150. c.ServeSuccessJSON(map[string]interface{}{
  39151. "msg": "撤销成功",
  39152. })
  39153. return
  39154. }
  39155. }
  39156. func (c *HisApiController) ReversalOtherData() {
  39157. var customData []*CustomData
  39158. custom := &CustomData{
  39159. MsgId: "H44022900158202103301714472004",
  39160. PsnNo: "44020000001101329945",
  39161. Info: "2208",
  39162. }
  39163. customData = append(customData, custom)
  39164. custom1 := &CustomData{
  39165. MsgId: "H4402290015820210330172057803",
  39166. PsnNo: "44020000001101161813",
  39167. Info: "2208",
  39168. }
  39169. customData = append(customData, custom1)
  39170. custom2 := &CustomData{
  39171. MsgId: "H44022900158202103301705198813",
  39172. PsnNo: "44190000133097375417",
  39173. Info: "2208",
  39174. }
  39175. customData = append(customData, custom2)
  39176. custom3 := &CustomData{
  39177. MsgId: "H44022900158202103301715524756",
  39178. PsnNo: "44020000001100187221",
  39179. Info: "2208",
  39180. }
  39181. customData = append(customData, custom3)
  39182. custom4 := &CustomData{
  39183. MsgId: "H44022900158202103301730376224",
  39184. PsnNo: "44020000001101959155",
  39185. Info: "2208",
  39186. }
  39187. customData = append(customData, custom4)
  39188. custom5 := &CustomData{
  39189. MsgId: "H44022900158202103301748008725",
  39190. PsnNo: "44020000001104246641",
  39191. Info: "2208",
  39192. }
  39193. customData = append(customData, custom5)
  39194. custom6 := &CustomData{
  39195. MsgId: "H44022900158202103301718096755",
  39196. PsnNo: "44020000001102211860",
  39197. Info: "2208",
  39198. }
  39199. customData = append(customData, custom6)
  39200. custom7 := &CustomData{
  39201. MsgId: "H44022900158202103301736551640",
  39202. PsnNo: "44020000001102687718",
  39203. Info: "2208",
  39204. }
  39205. customData = append(customData, custom7)
  39206. custom8 := &CustomData{
  39207. MsgId: "H44022900158202103301743097676",
  39208. PsnNo: "44020000001102127785",
  39209. Info: "2208",
  39210. }
  39211. customData = append(customData, custom8)
  39212. custom9 := &CustomData{
  39213. MsgId: "H44022900158202103301712304203",
  39214. PsnNo: "44020000001101518097",
  39215. Info: "2208",
  39216. }
  39217. customData = append(customData, custom9)
  39218. custom10 := &CustomData{
  39219. MsgId: "H44022900158202103301738448785",
  39220. PsnNo: "44020000001100500813",
  39221. Info: "2208",
  39222. }
  39223. customData = append(customData, custom10)
  39224. custom11 := &CustomData{
  39225. MsgId: "H44022900158202103301732455843",
  39226. PsnNo: "44020000001102690557",
  39227. Info: "2208",
  39228. }
  39229. customData = append(customData, custom11)
  39230. custom12 := &CustomData{
  39231. MsgId: "H44022900158202103301745421708",
  39232. PsnNo: "44020000001102211928",
  39233. Info: "2208",
  39234. }
  39235. customData = append(customData, custom12)
  39236. custom1212 := &CustomData{
  39237. MsgId: "H440229001582021033017351627",
  39238. PsnNo: "44020000001102481733",
  39239. Info: "2208",
  39240. }
  39241. customData = append(customData, custom1212)
  39242. custom13 := &CustomData{
  39243. MsgId: "H44022900158202103301740327951",
  39244. PsnNo: "44020000001103174866",
  39245. Info: "2208",
  39246. }
  39247. customData = append(customData, custom13)
  39248. custom14 := &CustomData{
  39249. MsgId: "H4402290015820210330174922668",
  39250. PsnNo: "44020000001102927272",
  39251. Info: "2208",
  39252. }
  39253. customData = append(customData, custom14)
  39254. custom15 := &CustomData{
  39255. MsgId: "H44022900158202103301752362273",
  39256. PsnNo: "44020000001102942890",
  39257. Info: "2208",
  39258. }
  39259. customData = append(customData, custom15)
  39260. custom16 := &CustomData{
  39261. MsgId: "H44022900158202103301751082917",
  39262. PsnNo: "44020000001101662162",
  39263. Info: "2208",
  39264. }
  39265. customData = append(customData, custom16)
  39266. custom17 := &CustomData{
  39267. MsgId: "H44022900158202103301754147728",
  39268. PsnNo: "44020000000229014511",
  39269. Info: "2208",
  39270. }
  39271. customData = append(customData, custom17)
  39272. adminUser := c.GetAdminUserInfo()
  39273. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39274. for _, item := range customData {
  39275. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  39276. fmt.Println(result)
  39277. }
  39278. }
  39279. func PathExists(path string) (bool, error) {
  39280. _, err := os.Stat(path)
  39281. if err == nil {
  39282. return true, nil
  39283. }
  39284. if os.IsNotExist(err) {
  39285. return false, nil
  39286. }
  39287. return false, err
  39288. }
  39289. // 创建文件夹
  39290. func Mkdir(dir string) {
  39291. // 创建文件夹
  39292. exist, err := PathExists(dir)
  39293. if err != nil {
  39294. fmt.Println(err.Error())
  39295. } else {
  39296. if exist {
  39297. fmt.Println(dir + "文件夹已存在!")
  39298. } else {
  39299. // 文件夹名称,权限
  39300. err := os.Mkdir(dir, os.ModePerm)
  39301. if err != nil {
  39302. fmt.Println(dir+"文件夹创建失败:", err.Error())
  39303. } else {
  39304. fmt.Println(dir + "文件夹创建成功!")
  39305. }
  39306. }
  39307. }
  39308. }
  39309. // 压缩文件
  39310. func Zip(srcFile string, destZip string) error {
  39311. zipfile, err := os.Create(destZip)
  39312. if err != nil {
  39313. return err
  39314. }
  39315. defer zipfile.Close()
  39316. archive := zip.NewWriter(zipfile)
  39317. defer archive.Close()
  39318. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  39319. if err != nil {
  39320. return err
  39321. }
  39322. header, err := zip.FileInfoHeader(info)
  39323. if err != nil {
  39324. return err
  39325. }
  39326. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  39327. // header.Name = path
  39328. if info.IsDir() {
  39329. header.Name += "/"
  39330. } else {
  39331. header.Method = zip.Deflate
  39332. }
  39333. writer, err := archive.CreateHeader(header)
  39334. if err != nil {
  39335. return err
  39336. }
  39337. if !info.IsDir() {
  39338. file, err := os.Open(path)
  39339. if err != nil {
  39340. return err
  39341. }
  39342. defer file.Close()
  39343. _, err = io.Copy(writer, file)
  39344. }
  39345. return err
  39346. })
  39347. return err
  39348. }
  39349. func ReadFile(filePath string) []byte {
  39350. f, err := os.Open(filePath)
  39351. if err != nil {
  39352. fmt.Println("read file fail", err)
  39353. return nil
  39354. }
  39355. defer f.Close()
  39356. fd, err := ioutil.ReadAll(f)
  39357. if err != nil {
  39358. fmt.Println("read to fd fail", err)
  39359. return nil
  39360. }
  39361. return fd
  39362. }
  39363. func saveLogq(result string, request string, infno string, desc string) {
  39364. dir := "日志"
  39365. utils.Mkdir(dir)
  39366. month := time.Unix(1557042972, 0).Format("1")
  39367. year := time.Now().Format("2006")
  39368. month = time.Now().Format("01")
  39369. day := time.Now().Format("02")
  39370. hour := time.Now().Format("15")
  39371. min := time.Now().Format("04")
  39372. sec := time.Now().Format("05")
  39373. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  39374. file := year + month + day + "_log"
  39375. file_name := file + ".txt"
  39376. file_path := "日志" + "/" + file_name
  39377. exist, _ := utils.PathExists(file_path)
  39378. if exist { //存在
  39379. fmt.Println("存在")
  39380. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  39381. if err != nil {
  39382. fmt.Println("read fail")
  39383. }
  39384. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  39385. n, _ := f.Seek(0, 2)
  39386. _, err = f.WriteAt([]byte(content), n)
  39387. } else { //不存在
  39388. fmt.Println("文件不存在,创建文件")
  39389. f, err := os.Create("日志" + "/" + file_name)
  39390. defer f.Close()
  39391. if err != nil {
  39392. } else {
  39393. _, err = f.Write([]byte("记录日志"))
  39394. }
  39395. }
  39396. }
  39397. func saveLog(result string, request string, infno string, desc string) {
  39398. org_id, _ := beego.AppConfig.Int64("org_id")
  39399. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39400. dir := miConfig.OrgName + "日志"
  39401. utils.Mkdir(dir)
  39402. month := time.Unix(1557042972, 0).Format("1")
  39403. year := time.Now().Format("2006")
  39404. month = time.Now().Format("01")
  39405. day := time.Now().Format("02")
  39406. hour := time.Now().Format("15")
  39407. min := time.Now().Format("04")
  39408. sec := time.Now().Format("05")
  39409. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  39410. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  39411. file_name := file + ".txt"
  39412. file_path := miConfig.OrgName + "日志" + "/" + file_name
  39413. exist, _ := utils.PathExists(file_path)
  39414. if exist { //存在
  39415. fmt.Println("存在")
  39416. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  39417. if err != nil {
  39418. fmt.Println("read fail")
  39419. }
  39420. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  39421. n, _ := f.Seek(0, 2)
  39422. _, err = f.WriteAt([]byte(content), n)
  39423. } else { //不存在
  39424. fmt.Println("文件不存在,创建文件")
  39425. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  39426. defer f.Close()
  39427. if err != nil {
  39428. } else {
  39429. _, err = f.Write([]byte("记录日志"))
  39430. }
  39431. }
  39432. }
  39433. type Charset string
  39434. const (
  39435. UTF8 = Charset("UTF-8")
  39436. GB18030 = Charset("GB18030")
  39437. )
  39438. func ConvertToString(src string, srcCode string, tagCode string) string {
  39439. srcCoder := mahonia.NewDecoder(srcCode)
  39440. srcResult := srcCoder.ConvertString(src)
  39441. tagCoder := mahonia.NewDecoder(tagCode)
  39442. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  39443. result := string(cdata)
  39444. return result
  39445. }
  39446. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  39447. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39448. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39449. var token string
  39450. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  39451. var api string
  39452. if miConfig.MdtrtareaAdmvs == "320830" {
  39453. api = miConfig.AppSecret + "jsyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  39454. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(4, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  39455. fmt.Println(api)
  39456. } else if miConfig.MdtrtareaAdmvs == "320921" {
  39457. 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 +
  39458. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(4, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  39459. fmt.Println(api)
  39460. } else {
  39461. 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 +
  39462. "&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
  39463. }
  39464. resp, requestErr := http.Get(api)
  39465. if requestErr != nil {
  39466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39467. return ""
  39468. }
  39469. body, ioErr := ioutil.ReadAll(resp.Body)
  39470. if ioErr != nil {
  39471. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39473. return ""
  39474. }
  39475. var respJSON map[string]interface{}
  39476. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  39477. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39479. return ""
  39480. }
  39481. var status string
  39482. status = respJSON["data"].(map[string]interface{})["status"].(string)
  39483. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  39484. var res ResultTwo //1101结果
  39485. var res10265 ResultTwo10265 //1101结果
  39486. if status == "0" { //读卡成功
  39487. var card_info string //卡信息
  39488. var busi_card_info string
  39489. token = respJSON["data"].(map[string]interface{})["token"].(string)
  39490. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  39491. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  39492. fmt.Println(card_info)
  39493. fmt.Println(busi_card_info)
  39494. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  39495. result, _ := json.Marshal(respJSON)
  39496. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  39497. utils.ErrorLog("解析失败:%v", err)
  39498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39499. return ""
  39500. }
  39501. res.ErrMsg = res10265.ErrMsg
  39502. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  39503. res.Infcode = infocode
  39504. res.Output = res10265.Output
  39505. res.InfRefmsgid = res10265.InfRefmsgid
  39506. if res.Infcode == 0 {
  39507. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  39508. if err == gorm.ErrRecordNotFound {
  39509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  39510. return ""
  39511. } else if err != nil {
  39512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  39513. return ""
  39514. } else {
  39515. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39516. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  39517. infoStr := string(Iinfos)
  39518. idetinfoStr := string(Idetinfos)
  39519. psn := &models.HisPsn{
  39520. PsnNo: res.Output.Baseinfo.PsnNo,
  39521. PatientId: patient.ID,
  39522. Certno: res.Output.Baseinfo.Certno,
  39523. Gend: res.Output.Baseinfo.Gend,
  39524. Naty: res.Output.Baseinfo.Naty,
  39525. PsnCertType: res.Output.Baseinfo.PsnCertType,
  39526. PsnName: res.Output.Baseinfo.PsnName,
  39527. Idetinfo: idetinfoStr,
  39528. Insuinfo: infoStr,
  39529. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39530. CardInfo: card_info,
  39531. VerifyNumber: token,
  39532. }
  39533. service.CreateHisPsn(psn)
  39534. return token
  39535. }
  39536. }
  39537. } else {
  39538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39539. return ""
  39540. }
  39541. } else { //读卡失败
  39542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39543. return ""
  39544. }
  39545. return token
  39546. }
  39547. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  39548. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39549. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39550. var token string
  39551. var api string
  39552. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  39553. "&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
  39554. fmt.Println(api)
  39555. resp, requestErr := http.Get(api)
  39556. if requestErr != nil {
  39557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39558. return ""
  39559. }
  39560. body, ioErr := ioutil.ReadAll(resp.Body)
  39561. if ioErr != nil {
  39562. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39564. return ""
  39565. }
  39566. var respJSON map[string]interface{}
  39567. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  39568. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39570. return ""
  39571. }
  39572. var status string
  39573. status = respJSON["data"].(map[string]interface{})["status"].(string)
  39574. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  39575. var res ResultTwo //1101结果
  39576. if status == "1" { //读卡成功
  39577. var card_info string //卡信息
  39578. var busi_card_info string
  39579. token = respJSON["data"].(map[string]interface{})["token"].(string)
  39580. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  39581. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  39582. fmt.Println(card_info)
  39583. fmt.Println(busi_card_info)
  39584. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  39585. result, _ := json.Marshal(respJSON)
  39586. if err := json.Unmarshal([]byte(result), &res); err != nil {
  39587. utils.ErrorLog("解析失败:%v", err)
  39588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39589. return ""
  39590. }
  39591. if res.Infcode == 0 {
  39592. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  39593. if err == gorm.ErrRecordNotFound {
  39594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  39595. return ""
  39596. } else if err != nil {
  39597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  39598. return ""
  39599. } else {
  39600. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39601. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  39602. infoStr := string(Iinfos)
  39603. idetinfoStr := string(Idetinfos)
  39604. psn := &models.HisPsn{
  39605. PsnNo: res.Output.Baseinfo.PsnNo,
  39606. PatientId: patient.ID,
  39607. Certno: res.Output.Baseinfo.Certno,
  39608. Gend: res.Output.Baseinfo.Gend,
  39609. Naty: res.Output.Baseinfo.Naty,
  39610. PsnCertType: res.Output.Baseinfo.PsnCertType,
  39611. PsnName: res.Output.Baseinfo.PsnName,
  39612. Idetinfo: idetinfoStr,
  39613. Insuinfo: infoStr,
  39614. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39615. CardInfo: card_info,
  39616. VerifyNumber: token,
  39617. }
  39618. service.CreateHisPsn(psn)
  39619. return token
  39620. }
  39621. }
  39622. } else {
  39623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39624. return ""
  39625. }
  39626. return token
  39627. }
  39628. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  39629. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39630. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39631. var token string
  39632. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  39633. var api string
  39634. if miConfig.MdtrtareaAdmvs == "320830" {
  39635. api = miConfig.AppSecret + "jsyb/readcardface?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  39636. "&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
  39637. fmt.Println(api)
  39638. } else if miConfig.MdtrtareaAdmvs == "320921" {
  39639. 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 +
  39640. "&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
  39641. fmt.Println(api)
  39642. } else {
  39643. 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 +
  39644. "&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
  39645. }
  39646. resp, requestErr := http.Get(api)
  39647. if requestErr != nil {
  39648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39649. return ""
  39650. }
  39651. body, ioErr := ioutil.ReadAll(resp.Body)
  39652. if ioErr != nil {
  39653. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39655. return ""
  39656. }
  39657. var respJSON map[string]interface{}
  39658. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  39659. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39661. return ""
  39662. }
  39663. var status string
  39664. status = respJSON["data"].(map[string]interface{})["status"].(string)
  39665. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  39666. var res ResultTwo //1101结果
  39667. var res10265 ResultTwo10265 //1101结果
  39668. if status == "0" { //读卡成功
  39669. var card_info string //卡信息
  39670. var busi_card_info string
  39671. token = respJSON["data"].(map[string]interface{})["token"].(string)
  39672. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  39673. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  39674. fmt.Println(card_info)
  39675. fmt.Println(busi_card_info)
  39676. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  39677. result, _ := json.Marshal(respJSON)
  39678. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  39679. utils.ErrorLog("解析失败:%v", err)
  39680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39681. return ""
  39682. }
  39683. res.ErrMsg = res10265.ErrMsg
  39684. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  39685. res.Infcode = infocode
  39686. res.Output = res10265.Output
  39687. res.InfRefmsgid = res10265.InfRefmsgid
  39688. if res.Infcode == 0 {
  39689. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  39690. if err == gorm.ErrRecordNotFound {
  39691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  39692. return ""
  39693. } else if err != nil {
  39694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  39695. return ""
  39696. } else {
  39697. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39698. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  39699. infoStr := string(Iinfos)
  39700. idetinfoStr := string(Idetinfos)
  39701. psn := &models.HisPsn{
  39702. PsnNo: res.Output.Baseinfo.PsnNo,
  39703. PatientId: patient.ID,
  39704. Certno: res.Output.Baseinfo.Certno,
  39705. Gend: res.Output.Baseinfo.Gend,
  39706. Naty: res.Output.Baseinfo.Naty,
  39707. PsnCertType: res.Output.Baseinfo.PsnCertType,
  39708. PsnName: res.Output.Baseinfo.PsnName,
  39709. Idetinfo: idetinfoStr,
  39710. Insuinfo: infoStr,
  39711. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39712. CardInfo: card_info,
  39713. VerifyNumber: token,
  39714. }
  39715. service.CreateHisPsn(psn)
  39716. return token
  39717. }
  39718. }
  39719. } else {
  39720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39721. return ""
  39722. }
  39723. } else { //读卡失败
  39724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39725. return ""
  39726. }
  39727. return token
  39728. }
  39729. func DeleteExtraSpaceTwo(s string) string {
  39730. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  39731. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  39732. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  39733. reg, _ := regexp.Compile(regstr) //编译正则表达式
  39734. s2 := make([]byte, len(s1)) //定义字符数组切片
  39735. copy(s2, s1) //将字符串复制到切片
  39736. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  39737. for len(spc_index) > 0 { //找到适配项
  39738. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  39739. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  39740. }
  39741. return string(s2)
  39742. }
  39743. func Remove0000(s string) string {
  39744. str := make([]rune, 0, len(s))
  39745. for _, v := range []rune(s) {
  39746. if v == 0 {
  39747. continue
  39748. }
  39749. str = append(str, v)
  39750. }
  39751. return string(str)
  39752. }
  39753. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  39754. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  39755. readCard := DllDef.MustFindProc("EcQuery")
  39756. pCardInfo := make([]byte, 8192)
  39757. pBusiCardInfo := make([]byte, 8192)
  39758. data := make(map[string]interface{})
  39759. //pData := make(map[string]interface{})
  39760. inputData := make(map[string]interface{})
  39761. inputData["orgId"] = code
  39762. inputData["businessType"] = "01101"
  39763. inputData["operatorId"] = operator_id
  39764. inputData["operatorName"] = operator_name
  39765. inputData["officeId"] = "001"
  39766. inputData["officeName"] = "血透室"
  39767. //
  39768. data["data"] = inputData
  39769. data["transType"] = "ec.query"
  39770. data["orgId"] = code
  39771. bytesData, _ := json.Marshal(data)
  39772. pCardInfo = bytesData
  39773. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  39774. fmt.Println(ret2)
  39775. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  39776. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  39777. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  39778. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  39779. if ret2 != 0 {
  39780. return "", ""
  39781. }
  39782. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  39783. }
  39784. func DeleteExtraSpace(s string) string {
  39785. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  39786. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  39787. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  39788. reg, _ := regexp.Compile(regstr) //编译正则表达式
  39789. s2 := make([]byte, len(s1)) //定义字符数组切片
  39790. copy(s2, s1) //将字符串复制到切片
  39791. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  39792. for len(spc_index) > 0 { //找到适配项
  39793. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  39794. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  39795. }
  39796. return string(s2)
  39797. }
  39798. // 对账
  39799. func (c *HisApiController) Post3202() {
  39800. start_time := c.GetString("start_time")
  39801. end_time := c.GetString("end_time")
  39802. //insutype := c.GetString("insutype")
  39803. clr_type := c.GetString("clr_type")
  39804. clr_org := c.GetString("clr_optins")
  39805. admin_user_id, _ := c.GetInt64("admin_user_id")
  39806. adminUser := c.GetAdminUserInfo()
  39807. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39808. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39809. if len(clr_org) == 0 {
  39810. clr_org = miConfig.MdtrtareaAdmvs
  39811. }
  39812. timeLayout := "2006-01-02"
  39813. loc, _ := time.LoadLocation("Local")
  39814. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  39815. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  39816. var orders []*models.HisOrder
  39817. if clr_org == "421300" {
  39818. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39819. } else if clr_org == "420902" {
  39820. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39821. } else {
  39822. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39823. }
  39824. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  39825. //fixmedins_setl_cnt := int64(len(orders))
  39826. var medfee_sumamt float64
  39827. var acct_pay float64
  39828. var fund_pay_sumamt float64
  39829. for _, item := range orders {
  39830. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  39831. acct_pay = acct_pay + item.AcctPay
  39832. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  39833. }
  39834. //var medfee_sumamt_two float64
  39835. //var acct_pay_two float64
  39836. //var fund_pay_sumamt_two float64
  39837. //for _, item := range orders_two {
  39838. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  39839. // acct_pay_two = acct_pay_two + item.AcctPay
  39840. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  39841. //}
  39842. //var user_name string
  39843. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39844. //if role.ID == 0 {
  39845. // user_name = "xxx"
  39846. //} else {
  39847. // user_name = role.UserName
  39848. //}
  39849. var res ResultSix
  39850. if config.IsOpen == 1 {
  39851. var bps []*models.BusinessParamsTwo
  39852. var bp models.BusinessParamsTwo
  39853. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  39854. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  39855. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  39856. bp.MedfeeSumamt = medfee_sumamt_str
  39857. bp.AcctPay = acct_pay_str
  39858. bp.FundPaySumamt = fund_pay_sumamt_str
  39859. bp.Insutype = ""
  39860. bp.StmtBegndate = start_time
  39861. bp.ClrType = clr_type
  39862. bp.SetlOptins = clr_org
  39863. bp.StmtEnddate = end_time
  39864. bps = append(bps, &bp)
  39865. data := make(map[string]interface{})
  39866. data["bps"] = bps
  39867. data["org_name"] = miConfig.OrgName
  39868. data["doctor"] = role.UserName
  39869. data["fixmedins_code"] = miConfig.Code
  39870. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39871. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39872. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39873. if miConfig.MdtrtareaAdmvs == "421300" {
  39874. client := &http.Client{}
  39875. bytesData, _ := json.Marshal(data)
  39876. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  39877. resp, _ := client.Do(req)
  39878. defer resp.Body.Close()
  39879. body, ioErr := ioutil.ReadAll(resp.Body)
  39880. if ioErr != nil {
  39881. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39883. return
  39884. }
  39885. var respJSON map[string]interface{}
  39886. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39887. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39889. return
  39890. }
  39891. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39892. userJSONBytes, _ := json.Marshal(respJSON)
  39893. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39894. utils.ErrorLog("解析失败:%v", err)
  39895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39896. return
  39897. }
  39898. }
  39899. if miConfig.MdtrtareaAdmvs == "420200" {
  39900. client := &http.Client{}
  39901. bytesData, _ := json.Marshal(data)
  39902. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  39903. resp, _ := client.Do(req)
  39904. defer resp.Body.Close()
  39905. body, ioErr := ioutil.ReadAll(resp.Body)
  39906. if ioErr != nil {
  39907. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39909. return
  39910. }
  39911. var respJSON map[string]interface{}
  39912. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39913. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39915. return
  39916. }
  39917. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39918. userJSONBytes, _ := json.Marshal(respJSON)
  39919. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39920. utils.ErrorLog("解析失败:%v", err)
  39921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39922. return
  39923. }
  39924. }
  39925. if miConfig.MdtrtareaAdmvs == "421182" {
  39926. client := &http.Client{}
  39927. bytesData, _ := json.Marshal(data)
  39928. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  39929. resp, _ := client.Do(req)
  39930. defer resp.Body.Close()
  39931. body, ioErr := ioutil.ReadAll(resp.Body)
  39932. if ioErr != nil {
  39933. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39935. return
  39936. }
  39937. var respJSON map[string]interface{}
  39938. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39939. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39941. return
  39942. }
  39943. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39944. userJSONBytes, _ := json.Marshal(respJSON)
  39945. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39946. utils.ErrorLog("解析失败:%v", err)
  39947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39948. return
  39949. }
  39950. }
  39951. if miConfig.MdtrtareaAdmvs == "420902" {
  39952. client := &http.Client{}
  39953. bytesData, _ := json.Marshal(data)
  39954. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  39955. resp, _ := client.Do(req)
  39956. defer resp.Body.Close()
  39957. body, ioErr := ioutil.ReadAll(resp.Body)
  39958. if ioErr != nil {
  39959. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39961. return
  39962. }
  39963. var respJSON map[string]interface{}
  39964. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39965. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39967. return
  39968. }
  39969. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39970. userJSONBytes, _ := json.Marshal(respJSON)
  39971. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39972. utils.ErrorLog("解析失败:%v", err)
  39973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39974. return
  39975. }
  39976. }
  39977. if res.Infcode == 0 {
  39978. c.ServeSuccessJSON(map[string]interface{}{
  39979. "msg": "发起成功",
  39980. })
  39981. } else {
  39982. c.ServeSuccessJSON(map[string]interface{}{
  39983. "failed_code": -10,
  39984. "msg": res.ErrMsg,
  39985. })
  39986. }
  39987. }
  39988. }
  39989. func (c *HisApiController) Post3204a() {
  39990. start_time := c.GetString("start_time")
  39991. end_time := c.GetString("end_time")
  39992. //insutype := c.GetString("insutype")
  39993. clr_type := c.GetString("clr_type")
  39994. clr_org := c.GetString("clr_optins")
  39995. admin_user_id, _ := c.GetInt64("admin_user_id")
  39996. adminUser := c.GetAdminUserInfo()
  39997. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39998. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39999. if len(clr_org) == 0 {
  40000. clr_org = miConfig.MdtrtareaAdmvs
  40001. }
  40002. timeLayout := "2006-01-02"
  40003. loc, _ := time.LoadLocation("Local")
  40004. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  40005. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  40006. var orders []*models.HisOrder
  40007. if clr_org == "421300" {
  40008. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40009. } else if clr_org == "420902" {
  40010. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40011. } else {
  40012. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40013. }
  40014. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  40015. //fixmedins_setl_cnt := int64(len(orders))
  40016. var medfee_sumamt float64
  40017. var acct_pay float64
  40018. var fund_pay_sumamt float64
  40019. for _, item := range orders {
  40020. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  40021. acct_pay = acct_pay + item.AcctPay
  40022. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  40023. }
  40024. //var medfee_sumamt_two float64
  40025. //var acct_pay_two float64
  40026. //var fund_pay_sumamt_two float64
  40027. //for _, item := range orders_two {
  40028. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  40029. // acct_pay_two = acct_pay_two + item.AcctPay
  40030. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  40031. //}
  40032. //var user_name string
  40033. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40034. //if role.ID == 0 {
  40035. // user_name = "xxx"
  40036. //} else {
  40037. // user_name = role.UserName
  40038. //}
  40039. var res ResultSix
  40040. if config.IsOpen == 1 {
  40041. var bps []*models.BusinessParamsTwo
  40042. var bp models.BusinessParamsTwo
  40043. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  40044. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  40045. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  40046. bp.MedfeeSumamt = medfee_sumamt_str
  40047. bp.AcctPay = acct_pay_str
  40048. bp.FundPaySumamt = fund_pay_sumamt_str
  40049. bp.Insutype = ""
  40050. bp.StmtBegndate = start_time
  40051. bp.ClrType = clr_type
  40052. bp.SetlOptins = clr_org
  40053. bp.StmtEnddate = end_time
  40054. bps = append(bps, &bp)
  40055. data := make(map[string]interface{})
  40056. data["bps"] = bps
  40057. data["org_name"] = miConfig.OrgName
  40058. data["doctor"] = role.UserName
  40059. data["fixmedins_code"] = miConfig.Code
  40060. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40061. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40062. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40063. if miConfig.MdtrtareaAdmvs == "421300" {
  40064. client := &http.Client{}
  40065. bytesData, _ := json.Marshal(data)
  40066. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  40067. resp, _ := client.Do(req)
  40068. defer resp.Body.Close()
  40069. body, ioErr := ioutil.ReadAll(resp.Body)
  40070. if ioErr != nil {
  40071. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40073. return
  40074. }
  40075. var respJSON map[string]interface{}
  40076. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40077. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40079. return
  40080. }
  40081. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40082. userJSONBytes, _ := json.Marshal(respJSON)
  40083. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40084. utils.ErrorLog("解析失败:%v", err)
  40085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40086. return
  40087. }
  40088. }
  40089. if miConfig.MdtrtareaAdmvs == "420200" {
  40090. client := &http.Client{}
  40091. bytesData, _ := json.Marshal(data)
  40092. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  40093. resp, _ := client.Do(req)
  40094. defer resp.Body.Close()
  40095. body, ioErr := ioutil.ReadAll(resp.Body)
  40096. if ioErr != nil {
  40097. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40099. return
  40100. }
  40101. var respJSON map[string]interface{}
  40102. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40103. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40105. return
  40106. }
  40107. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40108. userJSONBytes, _ := json.Marshal(respJSON)
  40109. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40110. utils.ErrorLog("解析失败:%v", err)
  40111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40112. return
  40113. }
  40114. }
  40115. if miConfig.MdtrtareaAdmvs == "421182" {
  40116. client := &http.Client{}
  40117. bytesData, _ := json.Marshal(data)
  40118. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  40119. resp, _ := client.Do(req)
  40120. defer resp.Body.Close()
  40121. body, ioErr := ioutil.ReadAll(resp.Body)
  40122. if ioErr != nil {
  40123. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40125. return
  40126. }
  40127. var respJSON map[string]interface{}
  40128. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40129. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40131. return
  40132. }
  40133. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40134. userJSONBytes, _ := json.Marshal(respJSON)
  40135. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40136. utils.ErrorLog("解析失败:%v", err)
  40137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40138. return
  40139. }
  40140. }
  40141. if miConfig.MdtrtareaAdmvs == "420902" {
  40142. client := &http.Client{}
  40143. bytesData, _ := json.Marshal(data)
  40144. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  40145. resp, _ := client.Do(req)
  40146. defer resp.Body.Close()
  40147. body, ioErr := ioutil.ReadAll(resp.Body)
  40148. if ioErr != nil {
  40149. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40151. return
  40152. }
  40153. var respJSON map[string]interface{}
  40154. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40155. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40157. return
  40158. }
  40159. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40160. userJSONBytes, _ := json.Marshal(respJSON)
  40161. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40162. utils.ErrorLog("解析失败:%v", err)
  40163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40164. return
  40165. }
  40166. }
  40167. if res.Infcode == 0 {
  40168. c.ServeSuccessJSON(map[string]interface{}{
  40169. "msg": "撤销成功",
  40170. })
  40171. } else {
  40172. c.ServeSuccessJSON(map[string]interface{}{
  40173. "failed_code": -10,
  40174. "msg": res.ErrMsg,
  40175. })
  40176. }
  40177. }
  40178. }
  40179. func (c *HisApiController) Post3204() {
  40180. admin_user_id, _ := c.GetInt64("admin_user_id")
  40181. id := c.GetString("id")
  40182. adminUser := c.GetAdminUserInfo()
  40183. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40184. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40185. //clr_org := miConfig.MdtrtareaAdmvs
  40186. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40187. var res ResultSix
  40188. if config.IsOpen == 1 {
  40189. data := make(map[string]interface{})
  40190. data["id"] = id
  40191. data["org_name"] = miConfig.OrgName
  40192. data["doctor"] = role.UserName
  40193. data["fixmedins_code"] = miConfig.Code
  40194. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40195. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40196. client := &http.Client{}
  40197. bytesData, _ := json.Marshal(data)
  40198. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  40199. resp, _ := client.Do(req)
  40200. defer resp.Body.Close()
  40201. body, ioErr := ioutil.ReadAll(resp.Body)
  40202. if ioErr != nil {
  40203. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40205. return
  40206. }
  40207. var respJSON map[string]interface{}
  40208. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40209. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40211. return
  40212. }
  40213. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40214. userJSONBytes, _ := json.Marshal(respJSON)
  40215. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40216. utils.ErrorLog("解析失败:%v", err)
  40217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40218. return
  40219. }
  40220. if res.Infcode == 0 {
  40221. c.ServeSuccessJSON(map[string]interface{}{
  40222. "msg": "发起成功",
  40223. })
  40224. } else {
  40225. c.ServeSuccessJSON(map[string]interface{}{
  40226. "failed_code": -10,
  40227. "msg": res.ErrMsg,
  40228. })
  40229. }
  40230. }
  40231. }
  40232. func (c *HisApiController) Post8404() {
  40233. admin_user_id, _ := c.GetInt64("admin_user_id")
  40234. month := c.GetString("month")
  40235. adminUser := c.GetAdminUserInfo()
  40236. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40237. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40238. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40239. var res ResultSix
  40240. if config.IsOpen == 1 {
  40241. data := make(map[string]interface{})
  40242. data["month"] = month
  40243. data["org_name"] = miConfig.OrgName
  40244. data["doctor"] = role.UserName
  40245. data["fixmedins_code"] = miConfig.Code
  40246. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40247. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40248. client := &http.Client{}
  40249. bytesData, _ := json.Marshal(data)
  40250. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  40251. resp, _ := client.Do(req)
  40252. defer resp.Body.Close()
  40253. body, ioErr := ioutil.ReadAll(resp.Body)
  40254. if ioErr != nil {
  40255. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40257. return
  40258. }
  40259. var respJSON map[string]interface{}
  40260. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40261. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40263. return
  40264. }
  40265. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40266. userJSONBytes, _ := json.Marshal(respJSON)
  40267. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40268. utils.ErrorLog("解析失败:%v", err)
  40269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40270. return
  40271. }
  40272. if res.Infcode == 0 {
  40273. c.ServeSuccessJSON(map[string]interface{}{
  40274. "msg": "查询成功",
  40275. })
  40276. } else {
  40277. c.ServeSuccessJSON(map[string]interface{}{
  40278. "failed_code": -10,
  40279. "msg": res.ErrMsg,
  40280. })
  40281. }
  40282. }
  40283. }
  40284. func (c *HisApiController) Post3202b() {
  40285. start_time := c.GetString("start_time")
  40286. end_time := c.GetString("end_time")
  40287. //insutype := c.GetString("insutype")
  40288. clr_type := c.GetString("clr_type")
  40289. clr_org := c.GetString("clr_optins")
  40290. admin_user_id, _ := c.GetInt64("admin_user_id")
  40291. adminUser := c.GetAdminUserInfo()
  40292. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40293. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40294. if len(clr_org) == 0 {
  40295. clr_org = miConfig.MdtrtareaAdmvs
  40296. }
  40297. timeLayout := "2006-01-02"
  40298. loc, _ := time.LoadLocation("Local")
  40299. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  40300. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  40301. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40302. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  40303. //fixmedins_setl_cnt := int64(len(orders))
  40304. var medfee_sumamt float64
  40305. var acct_pay float64
  40306. var fund_pay_sumamt float64
  40307. for _, item := range orders {
  40308. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  40309. acct_pay = acct_pay + item.AcctPay
  40310. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  40311. }
  40312. //var medfee_sumamt_two float64
  40313. //var acct_pay_two float64
  40314. //var fund_pay_sumamt_two float64
  40315. //for _, item := range orders_two {
  40316. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  40317. // acct_pay_two = acct_pay_two + item.AcctPay
  40318. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  40319. //}
  40320. //var user_name string
  40321. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40322. //if role.ID == 0 {
  40323. // user_name = "xxx"
  40324. //} else {
  40325. // user_name = role.UserName
  40326. //}
  40327. var res ResultSix
  40328. if config.IsOpen == 1 {
  40329. var bps []*models.BusinessParamsTwo
  40330. var bp models.BusinessParamsTwo
  40331. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  40332. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  40333. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  40334. bp.MedfeeSumamt = medfee_sumamt_str
  40335. bp.AcctPay = acct_pay_str
  40336. bp.FundPaySumamt = fund_pay_sumamt_str
  40337. bp.Insutype = "390"
  40338. bp.StmtBegndate = start_time
  40339. bp.ClrType = clr_type
  40340. bp.SetlOptins = clr_org
  40341. bp.StmtEnddate = end_time
  40342. bps = append(bps, &bp)
  40343. data := make(map[string]interface{})
  40344. data["bps"] = bps
  40345. data["org_name"] = miConfig.OrgName
  40346. data["doctor"] = role.UserName
  40347. data["fixmedins_code"] = miConfig.Code
  40348. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40349. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40350. if miConfig.MdtrtareaAdmvs == "421300" {
  40351. client := &http.Client{}
  40352. bytesData, _ := json.Marshal(data)
  40353. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  40354. resp, _ := client.Do(req)
  40355. defer resp.Body.Close()
  40356. body, ioErr := ioutil.ReadAll(resp.Body)
  40357. if ioErr != nil {
  40358. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40360. return
  40361. }
  40362. var respJSON map[string]interface{}
  40363. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40364. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40366. return
  40367. }
  40368. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40369. userJSONBytes, _ := json.Marshal(respJSON)
  40370. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40371. utils.ErrorLog("解析失败:%v", err)
  40372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40373. return
  40374. }
  40375. }
  40376. if miConfig.MdtrtareaAdmvs == "420200" {
  40377. client := &http.Client{}
  40378. bytesData, _ := json.Marshal(data)
  40379. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  40380. resp, _ := client.Do(req)
  40381. defer resp.Body.Close()
  40382. body, ioErr := ioutil.ReadAll(resp.Body)
  40383. if ioErr != nil {
  40384. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40386. return
  40387. }
  40388. var respJSON map[string]interface{}
  40389. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40390. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40392. return
  40393. }
  40394. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40395. userJSONBytes, _ := json.Marshal(respJSON)
  40396. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40397. utils.ErrorLog("解析失败:%v", err)
  40398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40399. return
  40400. }
  40401. }
  40402. if miConfig.MdtrtareaAdmvs == "421182" {
  40403. client := &http.Client{}
  40404. bytesData, _ := json.Marshal(data)
  40405. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  40406. resp, _ := client.Do(req)
  40407. defer resp.Body.Close()
  40408. body, ioErr := ioutil.ReadAll(resp.Body)
  40409. if ioErr != nil {
  40410. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40412. return
  40413. }
  40414. var respJSON map[string]interface{}
  40415. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40416. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40418. return
  40419. }
  40420. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40421. userJSONBytes, _ := json.Marshal(respJSON)
  40422. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40423. utils.ErrorLog("解析失败:%v", err)
  40424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40425. return
  40426. }
  40427. }
  40428. if res.Infcode == 0 {
  40429. c.ServeSuccessJSON(map[string]interface{}{
  40430. "msg": "发起成功",
  40431. })
  40432. } else {
  40433. c.ServeSuccessJSON(map[string]interface{}{
  40434. "failed_code": -10,
  40435. "msg": res.ErrMsg,
  40436. })
  40437. }
  40438. }
  40439. }
  40440. func (c *HisApiController) Post1608() {
  40441. start_time := c.GetString("start_time")
  40442. end_time := c.GetString("end_time")
  40443. admin_user_id, _ := c.GetInt64("admin_user_id")
  40444. adminUser := c.GetAdminUserInfo()
  40445. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40446. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40447. timeLayout := "2006-01-02"
  40448. loc, _ := time.LoadLocation("Local")
  40449. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  40450. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  40451. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40452. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  40453. fixmedins_setl_cnt := int64(len(orders))
  40454. var medfee_sumamt float64
  40455. var func_smamt float64
  40456. for _, item := range orders {
  40457. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  40458. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  40459. }
  40460. times := strings.Split(start_time, "-")
  40461. time_tows := strings.Split(end_time, "-")
  40462. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40463. var res ResultSix
  40464. if config.IsOpen == 1 {
  40465. //var bps []*models.BusinessParamsTwo
  40466. //var bp models.BusinessParamsTwo
  40467. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  40468. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  40469. data := make(map[string]interface{})
  40470. data["org_name"] = miConfig.OrgName
  40471. data["doctor"] = role.UserName
  40472. data["func_smamt"] = func_smamt_str
  40473. data["fixmedins_code"] = miConfig.Code
  40474. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40475. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40476. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  40477. data["medfee_sumamt"] = medfee_sumamt_str
  40478. data["start_time"] = times[0] + times[1] + times[2]
  40479. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  40480. if miConfig.MdtrtareaAdmvs == "421300" {
  40481. client := &http.Client{}
  40482. bytesData, _ := json.Marshal(data)
  40483. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  40484. resp, _ := client.Do(req)
  40485. defer resp.Body.Close()
  40486. body, ioErr := ioutil.ReadAll(resp.Body)
  40487. if ioErr != nil {
  40488. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40490. return
  40491. }
  40492. var respJSON map[string]interface{}
  40493. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40494. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40496. return
  40497. }
  40498. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40499. userJSONBytes, _ := json.Marshal(respJSON)
  40500. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40501. utils.ErrorLog("解析失败:%v", err)
  40502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40503. return
  40504. }
  40505. }
  40506. if miConfig.MdtrtareaAdmvs == "420200" {
  40507. client := &http.Client{}
  40508. bytesData, _ := json.Marshal(data)
  40509. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  40510. resp, _ := client.Do(req)
  40511. defer resp.Body.Close()
  40512. body, ioErr := ioutil.ReadAll(resp.Body)
  40513. if ioErr != nil {
  40514. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40516. return
  40517. }
  40518. var respJSON map[string]interface{}
  40519. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40520. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40522. return
  40523. }
  40524. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40525. userJSONBytes, _ := json.Marshal(respJSON)
  40526. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40527. utils.ErrorLog("解析失败:%v", err)
  40528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40529. return
  40530. }
  40531. }
  40532. if miConfig.MdtrtareaAdmvs == "421182" {
  40533. client := &http.Client{}
  40534. bytesData, _ := json.Marshal(data)
  40535. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  40536. resp, _ := client.Do(req)
  40537. defer resp.Body.Close()
  40538. body, ioErr := ioutil.ReadAll(resp.Body)
  40539. if ioErr != nil {
  40540. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40542. return
  40543. }
  40544. var respJSON map[string]interface{}
  40545. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40546. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40548. return
  40549. }
  40550. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40551. userJSONBytes, _ := json.Marshal(respJSON)
  40552. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40553. utils.ErrorLog("解析失败:%v", err)
  40554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40555. return
  40556. }
  40557. }
  40558. if res.Infcode == 0 {
  40559. c.ServeSuccessJSON(map[string]interface{}{
  40560. "msg": "发起成功",
  40561. })
  40562. } else {
  40563. c.ServeSuccessJSON(map[string]interface{}{
  40564. "failed_code": -10,
  40565. "msg": res.ErrMsg,
  40566. })
  40567. }
  40568. }
  40569. }
  40570. // 5.11.1.1【5262】结算信息按时间段查询
  40571. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  40572. admin_user_id, _ := c.GetInt64("admin_user_id")
  40573. adminUser := c.GetAdminUserInfo()
  40574. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40575. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40576. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40577. var res Result5262
  40578. if config.IsOpen == 1 {
  40579. if miConfig.MdtrtareaAdmvs == "421300" {
  40580. data := make(map[string]interface{})
  40581. data["bps"] = bp
  40582. data["org_name"] = miConfig.OrgName
  40583. data["doctor"] = role.UserName
  40584. data["fixmedins_code"] = miConfig.Code
  40585. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40586. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40587. data["page"] = strconv.FormatInt(page, 10)
  40588. data["limit"] = strconv.FormatInt(limit, 10)
  40589. fmt.Println(data)
  40590. client := &http.Client{}
  40591. bytesData, _ := json.Marshal(data)
  40592. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  40593. resp, _ := client.Do(req)
  40594. defer resp.Body.Close()
  40595. body, ioErr := ioutil.ReadAll(resp.Body)
  40596. if ioErr != nil {
  40597. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40599. return
  40600. }
  40601. var respJSON map[string]interface{}
  40602. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40603. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40605. return
  40606. }
  40607. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40608. userJSONBytes, _ := json.Marshal(respJSON)
  40609. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40610. utils.ErrorLog("解析失败:%v", err)
  40611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40612. return
  40613. }
  40614. }
  40615. if miConfig.MdtrtareaAdmvs == "420200" {
  40616. data := make(map[string]interface{})
  40617. data["bps"] = bp
  40618. data["org_name"] = miConfig.OrgName
  40619. data["doctor"] = role.UserName
  40620. data["fixmedins_code"] = miConfig.Code
  40621. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40622. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40623. data["page"] = strconv.FormatInt(page, 10)
  40624. data["limit"] = strconv.FormatInt(limit, 10)
  40625. fmt.Println(data)
  40626. client := &http.Client{}
  40627. bytesData, _ := json.Marshal(data)
  40628. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  40629. resp, _ := client.Do(req)
  40630. defer resp.Body.Close()
  40631. body, ioErr := ioutil.ReadAll(resp.Body)
  40632. if ioErr != nil {
  40633. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40635. return
  40636. }
  40637. var respJSON map[string]interface{}
  40638. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40639. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40641. return
  40642. }
  40643. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40644. userJSONBytes, _ := json.Marshal(respJSON)
  40645. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40646. utils.ErrorLog("解析失败:%v", err)
  40647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40648. return
  40649. }
  40650. }
  40651. if miConfig.MdtrtareaAdmvs == "421182" {
  40652. data := make(map[string]interface{})
  40653. data["bps"] = bp
  40654. data["org_name"] = miConfig.OrgName
  40655. data["doctor"] = role.UserName
  40656. data["fixmedins_code"] = miConfig.Code
  40657. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40658. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40659. data["page"] = strconv.FormatInt(page, 10)
  40660. data["limit"] = strconv.FormatInt(limit, 10)
  40661. fmt.Println(data)
  40662. client := &http.Client{}
  40663. bytesData, _ := json.Marshal(data)
  40664. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  40665. resp, _ := client.Do(req)
  40666. defer resp.Body.Close()
  40667. body, ioErr := ioutil.ReadAll(resp.Body)
  40668. if ioErr != nil {
  40669. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40671. return
  40672. }
  40673. var respJSON map[string]interface{}
  40674. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40675. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40677. return
  40678. }
  40679. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40680. userJSONBytes, _ := json.Marshal(respJSON)
  40681. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40682. utils.ErrorLog("解析失败:%v", err)
  40683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40684. return
  40685. }
  40686. }
  40687. if miConfig.MdtrtareaAdmvs == "420902" {
  40688. data := make(map[string]interface{})
  40689. data["bps"] = bp
  40690. data["org_name"] = miConfig.OrgName
  40691. data["doctor"] = role.UserName
  40692. data["fixmedins_code"] = miConfig.Code
  40693. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40694. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40695. data["page"] = strconv.FormatInt(page, 10)
  40696. data["limit"] = strconv.FormatInt(limit, 10)
  40697. fmt.Println(data)
  40698. client := &http.Client{}
  40699. bytesData, _ := json.Marshal(data)
  40700. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  40701. resp, _ := client.Do(req)
  40702. defer resp.Body.Close()
  40703. body, ioErr := ioutil.ReadAll(resp.Body)
  40704. if ioErr != nil {
  40705. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40707. return
  40708. }
  40709. var respJSON map[string]interface{}
  40710. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40711. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40713. return
  40714. }
  40715. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40716. userJSONBytes, _ := json.Marshal(respJSON)
  40717. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40718. utils.ErrorLog("解析失败:%v", err)
  40719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40720. return
  40721. }
  40722. }
  40723. if res.Infcode == 0 {
  40724. c.ServeSuccessJSON(map[string]interface{}{
  40725. "order": res.Output.Result,
  40726. "total": res.Output.PageInfo.RecordCounts,
  40727. })
  40728. } else {
  40729. c.ServeSuccessJSON(map[string]interface{}{
  40730. "failed_code": -10,
  40731. "msg": res.ErrMsg,
  40732. })
  40733. }
  40734. }
  40735. }
  40736. // 5.11.1.2【5267】异地结算信息时间段查询
  40737. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  40738. admin_user_id, _ := c.GetInt64("admin_user_id")
  40739. adminUser := c.GetAdminUserInfo()
  40740. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40741. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40742. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40743. var res Result5267
  40744. if config.IsOpen == 1 {
  40745. if miConfig.MdtrtareaAdmvs == "421300" {
  40746. data := make(map[string]interface{})
  40747. data["bps"] = bp
  40748. data["org_name"] = miConfig.OrgName
  40749. data["doctor"] = role.UserName
  40750. data["fixmedins_code"] = miConfig.Code
  40751. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40752. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40753. data["page"] = page
  40754. data["limit"] = limit
  40755. fmt.Println(data)
  40756. client := &http.Client{}
  40757. bytesData, _ := json.Marshal(data)
  40758. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  40759. resp, _ := client.Do(req)
  40760. defer resp.Body.Close()
  40761. body, ioErr := ioutil.ReadAll(resp.Body)
  40762. if ioErr != nil {
  40763. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40765. return
  40766. }
  40767. var respJSON map[string]interface{}
  40768. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40769. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40771. return
  40772. }
  40773. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40774. userJSONBytes, _ := json.Marshal(respJSON)
  40775. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40776. utils.ErrorLog("解析失败:%v", err)
  40777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40778. return
  40779. }
  40780. }
  40781. if miConfig.MdtrtareaAdmvs == "420200" {
  40782. data := make(map[string]interface{})
  40783. data["bps"] = bp
  40784. data["org_name"] = miConfig.OrgName
  40785. data["doctor"] = role.UserName
  40786. data["fixmedins_code"] = miConfig.Code
  40787. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40788. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40789. data["page"] = page
  40790. data["limit"] = limit
  40791. fmt.Println(data)
  40792. client := &http.Client{}
  40793. bytesData, _ := json.Marshal(data)
  40794. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  40795. resp, _ := client.Do(req)
  40796. defer resp.Body.Close()
  40797. body, ioErr := ioutil.ReadAll(resp.Body)
  40798. if ioErr != nil {
  40799. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40801. return
  40802. }
  40803. var respJSON map[string]interface{}
  40804. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40805. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40807. return
  40808. }
  40809. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40810. userJSONBytes, _ := json.Marshal(respJSON)
  40811. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40812. utils.ErrorLog("解析失败:%v", err)
  40813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40814. return
  40815. }
  40816. }
  40817. if miConfig.MdtrtareaAdmvs == "421182" {
  40818. data := make(map[string]interface{})
  40819. data["bps"] = bp
  40820. data["org_name"] = miConfig.OrgName
  40821. data["doctor"] = role.UserName
  40822. data["fixmedins_code"] = miConfig.Code
  40823. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40824. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40825. data["page"] = page
  40826. data["limit"] = limit
  40827. fmt.Println(data)
  40828. client := &http.Client{}
  40829. bytesData, _ := json.Marshal(data)
  40830. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  40831. resp, _ := client.Do(req)
  40832. defer resp.Body.Close()
  40833. body, ioErr := ioutil.ReadAll(resp.Body)
  40834. if ioErr != nil {
  40835. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40837. return
  40838. }
  40839. var respJSON map[string]interface{}
  40840. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40841. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40843. return
  40844. }
  40845. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40846. userJSONBytes, _ := json.Marshal(respJSON)
  40847. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40848. utils.ErrorLog("解析失败:%v", err)
  40849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40850. return
  40851. }
  40852. }
  40853. if res.Infcode == 0 {
  40854. c.ServeSuccessJSON(map[string]interface{}{
  40855. "order": res.Output.Result,
  40856. "total": res.Output.PageInfo.RecordCounts,
  40857. })
  40858. } else {
  40859. c.ServeSuccessJSON(map[string]interface{}{
  40860. "failed_code": -10,
  40861. "msg": res.ErrMsg,
  40862. })
  40863. }
  40864. }
  40865. }
  40866. func (c *HisApiController) Post3501() {
  40867. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  40868. data := make(map[string]interface{})
  40869. var struct3501s []models.Struct3501
  40870. var struct3501 models.Struct3501
  40871. struct3501.OrgName = miConfig.OrgName
  40872. struct3501.AccessKey = miConfig.AccessKey
  40873. struct3501.RequestUrl = miConfig.Url
  40874. struct3501.SecretKey = miConfig.SecretKey
  40875. struct3501.ManuDate = "2022-08-17"
  40876. struct3501.FixmedinsBchno = ""
  40877. struct3501.ManuLotnum = ""
  40878. struct3501.RxFlag = "0"
  40879. struct3501.ExpyEnd = "2022-08-17"
  40880. struct3501.Invdate = "2022-08-17"
  40881. struct3501.InvCnt = "20.25"
  40882. struct3501.Memo = ""
  40883. struct3501.MedListCodg = "XB01ABD056B002020200517"
  40884. struct3501.FixmedinsHilistId = miConfig.Code
  40885. struct3501.FixmedinsHilistName = miConfig.OrgName
  40886. struct3501s = append(struct3501s, struct3501)
  40887. data["struct_3501s"] = struct3501s
  40888. client := &http.Client{}
  40889. bytesData, _ := json.Marshal(data)
  40890. var req *http.Request
  40891. if miConfig.MdtrtareaAdmvs == "320830" {
  40892. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3501", bytes.NewReader(bytesData))
  40893. } else if miConfig.MdtrtareaAdmvs == "320921" {
  40894. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40895. } else {
  40896. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40897. }
  40898. resp, _ := client.Do(req)
  40899. defer resp.Body.Close()
  40900. body, ioErr := ioutil.ReadAll(resp.Body)
  40901. if ioErr != nil {
  40902. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40904. return
  40905. }
  40906. var respJSON map[string]interface{}
  40907. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40908. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40910. return
  40911. }
  40912. var res ResultSix
  40913. var resSix10265 ResultSix10265 //1101结果
  40914. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  40915. result, _ := json.Marshal(respJSON)
  40916. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  40917. utils.ErrorLog("解析失败:%v", err)
  40918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40919. return
  40920. }
  40921. res.InfRefmsgid = resSix10265.InfRefmsgid
  40922. res.Output = resSix10265.Output
  40923. res.ErrMsg = resSix10265.ErrMsg
  40924. res.Cainfo = resSix10265.Cainfo
  40925. res.WarnMsg = resSix10265.WarnMsg
  40926. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  40927. res.Infcode = infocode
  40928. if infocode == 0 {
  40929. c.ServeSuccessJSON(map[string]interface{}{
  40930. "msg": "上传成功",
  40931. })
  40932. return
  40933. } else {
  40934. c.ServeSuccessJSON(map[string]interface{}{
  40935. "failed_code": -10,
  40936. "msg": res.ErrMsg,
  40937. })
  40938. return
  40939. }
  40940. }
  40941. func (c *HisApiController) Post3502() {
  40942. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  40943. data := make(map[string]interface{})
  40944. var struct3502s []models.Struct3502
  40945. var struct3502 models.Struct3502
  40946. struct3502.OrgName = miConfig.OrgName
  40947. struct3502.AccessKey = miConfig.AccessKey
  40948. struct3502.RequestUrl = miConfig.Url
  40949. struct3502.SecretKey = miConfig.SecretKey
  40950. struct3502.ManuDate = "2022-08-15"
  40951. struct3502.FixmedinsBchno = ""
  40952. struct3502.ManuLotnum = ""
  40953. struct3502.RxFlag = "0"
  40954. struct3502.ExpyEnd = "2022-08-15"
  40955. struct3502.Invdate = "2022-08-15"
  40956. struct3502.InvCnt = "20.25"
  40957. struct3502.Memo = ""
  40958. struct3502.MedListCodg = "XB01ABD056B002020200517"
  40959. struct3502.FixmedinsHilistId = miConfig.Code
  40960. struct3502.FixmedinsHilistName = miConfig.OrgName
  40961. struct3502s = append(struct3502s, struct3502)
  40962. data["struct_3502s"] = struct3502s
  40963. client := &http.Client{}
  40964. bytesData, _ := json.Marshal(data)
  40965. var req *http.Request
  40966. if miConfig.MdtrtareaAdmvs == "320830" {
  40967. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3501", bytes.NewReader(bytesData))
  40968. } else if miConfig.MdtrtareaAdmvs == "320921" {
  40969. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40970. } else {
  40971. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40972. }
  40973. resp, _ := client.Do(req)
  40974. defer resp.Body.Close()
  40975. body, ioErr := ioutil.ReadAll(resp.Body)
  40976. if ioErr != nil {
  40977. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40979. return
  40980. }
  40981. var respJSON map[string]interface{}
  40982. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40983. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40985. return
  40986. }
  40987. var res ResultSix
  40988. var resSix10265 ResultSix10265 //1101结果
  40989. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  40990. result, _ := json.Marshal(respJSON)
  40991. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  40992. utils.ErrorLog("解析失败:%v", err)
  40993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40994. return
  40995. }
  40996. res.InfRefmsgid = resSix10265.InfRefmsgid
  40997. res.Output = resSix10265.Output
  40998. res.ErrMsg = resSix10265.ErrMsg
  40999. res.Cainfo = resSix10265.Cainfo
  41000. res.WarnMsg = resSix10265.WarnMsg
  41001. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41002. res.Infcode = infocode
  41003. if infocode == 0 {
  41004. c.ServeSuccessJSON(map[string]interface{}{
  41005. "msg": "上传成功",
  41006. })
  41007. return
  41008. } else {
  41009. c.ServeSuccessJSON(map[string]interface{}{
  41010. "failed_code": -10,
  41011. "msg": res.ErrMsg,
  41012. })
  41013. return
  41014. }
  41015. }
  41016. func (c *HisApiController) Post3503() {
  41017. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41018. data := make(map[string]interface{})
  41019. var struct3501s []models.Struct3501
  41020. var struct3501 models.Struct3501
  41021. struct3501.OrgName = miConfig.OrgName
  41022. struct3501.AccessKey = miConfig.AccessKey
  41023. struct3501.RequestUrl = miConfig.Url
  41024. struct3501.SecretKey = miConfig.SecretKey
  41025. struct3501.ManuDate = "2022-08-15"
  41026. struct3501.FixmedinsBchno = ""
  41027. struct3501.ManuLotnum = ""
  41028. struct3501.RxFlag = "0"
  41029. struct3501.ExpyEnd = "2022-08-15"
  41030. struct3501.Invdate = "2022-08-15"
  41031. struct3501.InvCnt = "20.25"
  41032. struct3501.Memo = ""
  41033. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41034. struct3501.FixmedinsHilistId = miConfig.Code
  41035. struct3501.FixmedinsHilistName = miConfig.OrgName
  41036. struct3501s = append(struct3501s, struct3501)
  41037. data["struct_3501s"] = struct3501s
  41038. client := &http.Client{}
  41039. bytesData, _ := json.Marshal(data)
  41040. var req *http.Request
  41041. if miConfig.MdtrtareaAdmvs == "320921" {
  41042. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41043. } else {
  41044. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41045. }
  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. var res ResultSix
  41061. var resSix10265 ResultSix10265 //1101结果
  41062. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41063. result, _ := json.Marshal(respJSON)
  41064. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41065. utils.ErrorLog("解析失败:%v", err)
  41066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41067. return
  41068. }
  41069. res.InfRefmsgid = resSix10265.InfRefmsgid
  41070. res.Output = resSix10265.Output
  41071. res.ErrMsg = resSix10265.ErrMsg
  41072. res.Cainfo = resSix10265.Cainfo
  41073. res.WarnMsg = resSix10265.WarnMsg
  41074. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41075. res.Infcode = infocode
  41076. if infocode == 0 {
  41077. c.ServeSuccessJSON(map[string]interface{}{
  41078. "msg": "上传成功",
  41079. })
  41080. return
  41081. } else {
  41082. c.ServeSuccessJSON(map[string]interface{}{
  41083. "failed_code": -10,
  41084. "msg": res.ErrMsg,
  41085. })
  41086. return
  41087. }
  41088. }
  41089. func (c *HisApiController) Post3504() {
  41090. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41091. data := make(map[string]interface{})
  41092. var struct3501s []models.Struct3501
  41093. var struct3501 models.Struct3501
  41094. struct3501.OrgName = miConfig.OrgName
  41095. struct3501.AccessKey = miConfig.AccessKey
  41096. struct3501.RequestUrl = miConfig.Url
  41097. struct3501.SecretKey = miConfig.SecretKey
  41098. struct3501.ManuDate = "2022-08-15"
  41099. struct3501.FixmedinsBchno = ""
  41100. struct3501.ManuLotnum = ""
  41101. struct3501.RxFlag = "0"
  41102. struct3501.ExpyEnd = "2022-08-15"
  41103. struct3501.Invdate = "2022-08-15"
  41104. struct3501.InvCnt = "20.25"
  41105. struct3501.Memo = ""
  41106. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41107. struct3501.FixmedinsHilistId = miConfig.Code
  41108. struct3501.FixmedinsHilistName = miConfig.OrgName
  41109. struct3501s = append(struct3501s, struct3501)
  41110. data["struct_3501s"] = struct3501s
  41111. client := &http.Client{}
  41112. bytesData, _ := json.Marshal(data)
  41113. var req *http.Request
  41114. if miConfig.MdtrtareaAdmvs == "320921" {
  41115. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41116. } else {
  41117. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41118. }
  41119. resp, _ := client.Do(req)
  41120. defer resp.Body.Close()
  41121. body, ioErr := ioutil.ReadAll(resp.Body)
  41122. if ioErr != nil {
  41123. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41125. return
  41126. }
  41127. var respJSON map[string]interface{}
  41128. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41129. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41131. return
  41132. }
  41133. var res ResultSix
  41134. var resSix10265 ResultSix10265 //1101结果
  41135. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41136. result, _ := json.Marshal(respJSON)
  41137. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41138. utils.ErrorLog("解析失败:%v", err)
  41139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41140. return
  41141. }
  41142. res.InfRefmsgid = resSix10265.InfRefmsgid
  41143. res.Output = resSix10265.Output
  41144. res.ErrMsg = resSix10265.ErrMsg
  41145. res.Cainfo = resSix10265.Cainfo
  41146. res.WarnMsg = resSix10265.WarnMsg
  41147. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41148. res.Infcode = infocode
  41149. if infocode == 0 {
  41150. c.ServeSuccessJSON(map[string]interface{}{
  41151. "msg": "上传成功",
  41152. })
  41153. return
  41154. } else {
  41155. c.ServeSuccessJSON(map[string]interface{}{
  41156. "failed_code": -10,
  41157. "msg": res.ErrMsg,
  41158. })
  41159. return
  41160. }
  41161. }
  41162. func (c *HisApiController) Post3505() {
  41163. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41164. data := make(map[string]interface{})
  41165. var struct3501s []models.Struct3501
  41166. var struct3501 models.Struct3501
  41167. struct3501.OrgName = miConfig.OrgName
  41168. struct3501.AccessKey = miConfig.AccessKey
  41169. struct3501.RequestUrl = miConfig.Url
  41170. struct3501.SecretKey = miConfig.SecretKey
  41171. struct3501.ManuDate = "2022-08-15"
  41172. struct3501.FixmedinsBchno = ""
  41173. struct3501.ManuLotnum = ""
  41174. struct3501.RxFlag = "0"
  41175. struct3501.ExpyEnd = "2022-08-15"
  41176. struct3501.Invdate = "2022-08-15"
  41177. struct3501.InvCnt = "20.25"
  41178. struct3501.Memo = ""
  41179. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41180. struct3501.FixmedinsHilistId = miConfig.Code
  41181. struct3501.FixmedinsHilistName = miConfig.OrgName
  41182. struct3501s = append(struct3501s, struct3501)
  41183. data["struct_3501s"] = struct3501s
  41184. client := &http.Client{}
  41185. bytesData, _ := json.Marshal(data)
  41186. var req *http.Request
  41187. if miConfig.MdtrtareaAdmvs == "320921" {
  41188. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41189. } else {
  41190. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41191. }
  41192. resp, _ := client.Do(req)
  41193. defer resp.Body.Close()
  41194. body, ioErr := ioutil.ReadAll(resp.Body)
  41195. if ioErr != nil {
  41196. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41198. return
  41199. }
  41200. var respJSON map[string]interface{}
  41201. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41202. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41204. return
  41205. }
  41206. var res ResultSix
  41207. var resSix10265 ResultSix10265 //1101结果
  41208. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41209. result, _ := json.Marshal(respJSON)
  41210. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41211. utils.ErrorLog("解析失败:%v", err)
  41212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41213. return
  41214. }
  41215. res.InfRefmsgid = resSix10265.InfRefmsgid
  41216. res.Output = resSix10265.Output
  41217. res.ErrMsg = resSix10265.ErrMsg
  41218. res.Cainfo = resSix10265.Cainfo
  41219. res.WarnMsg = resSix10265.WarnMsg
  41220. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41221. res.Infcode = infocode
  41222. if infocode == 0 {
  41223. c.ServeSuccessJSON(map[string]interface{}{
  41224. "msg": "上传成功",
  41225. })
  41226. return
  41227. } else {
  41228. c.ServeSuccessJSON(map[string]interface{}{
  41229. "failed_code": -10,
  41230. "msg": res.ErrMsg,
  41231. })
  41232. return
  41233. }
  41234. }
  41235. func (c *HisApiController) Post3506() {
  41236. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41237. data := make(map[string]interface{})
  41238. var struct3501s []models.Struct3501
  41239. var struct3501 models.Struct3501
  41240. struct3501.OrgName = miConfig.OrgName
  41241. struct3501.AccessKey = miConfig.AccessKey
  41242. struct3501.RequestUrl = miConfig.Url
  41243. struct3501.SecretKey = miConfig.SecretKey
  41244. struct3501.ManuDate = "2022-08-15"
  41245. struct3501.FixmedinsBchno = ""
  41246. struct3501.ManuLotnum = ""
  41247. struct3501.RxFlag = "0"
  41248. struct3501.ExpyEnd = "2022-08-15"
  41249. struct3501.Invdate = "2022-08-15"
  41250. struct3501.InvCnt = "20.25"
  41251. struct3501.Memo = ""
  41252. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41253. struct3501.FixmedinsHilistId = miConfig.Code
  41254. struct3501.FixmedinsHilistName = miConfig.OrgName
  41255. struct3501s = append(struct3501s, struct3501)
  41256. data["struct_3501s"] = struct3501s
  41257. client := &http.Client{}
  41258. bytesData, _ := json.Marshal(data)
  41259. var req *http.Request
  41260. if miConfig.MdtrtareaAdmvs == "320921" {
  41261. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41262. } else {
  41263. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41264. }
  41265. resp, _ := client.Do(req)
  41266. defer resp.Body.Close()
  41267. body, ioErr := ioutil.ReadAll(resp.Body)
  41268. if ioErr != nil {
  41269. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41271. return
  41272. }
  41273. var respJSON map[string]interface{}
  41274. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41275. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41277. return
  41278. }
  41279. var res ResultSix
  41280. var resSix10265 ResultSix10265 //1101结果
  41281. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41282. result, _ := json.Marshal(respJSON)
  41283. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41284. utils.ErrorLog("解析失败:%v", err)
  41285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41286. return
  41287. }
  41288. res.InfRefmsgid = resSix10265.InfRefmsgid
  41289. res.Output = resSix10265.Output
  41290. res.ErrMsg = resSix10265.ErrMsg
  41291. res.Cainfo = resSix10265.Cainfo
  41292. res.WarnMsg = resSix10265.WarnMsg
  41293. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41294. res.Infcode = infocode
  41295. if infocode == 0 {
  41296. c.ServeSuccessJSON(map[string]interface{}{
  41297. "msg": "上传成功",
  41298. })
  41299. return
  41300. } else {
  41301. c.ServeSuccessJSON(map[string]interface{}{
  41302. "failed_code": -10,
  41303. "msg": res.ErrMsg,
  41304. })
  41305. return
  41306. }
  41307. }
  41308. func (c *HisApiController) Post3507() {
  41309. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41310. data := make(map[string]interface{})
  41311. var struct3501s []models.Struct3501
  41312. var struct3501 models.Struct3501
  41313. struct3501.OrgName = miConfig.OrgName
  41314. struct3501.AccessKey = miConfig.AccessKey
  41315. struct3501.RequestUrl = miConfig.Url
  41316. struct3501.SecretKey = miConfig.SecretKey
  41317. struct3501.ManuDate = "2022-08-15"
  41318. struct3501.FixmedinsBchno = ""
  41319. struct3501.ManuLotnum = ""
  41320. struct3501.RxFlag = "0"
  41321. struct3501.ExpyEnd = "2022-08-15"
  41322. struct3501.Invdate = "2022-08-15"
  41323. struct3501.InvCnt = "20.25"
  41324. struct3501.Memo = ""
  41325. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41326. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  41327. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  41328. struct3501s = append(struct3501s, struct3501)
  41329. data["struct_3501s"] = struct3501s
  41330. client := &http.Client{}
  41331. bytesData, _ := json.Marshal(data)
  41332. var req *http.Request
  41333. if miConfig.MdtrtareaAdmvs == "320921" {
  41334. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41335. } else {
  41336. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41337. }
  41338. resp, _ := client.Do(req)
  41339. defer resp.Body.Close()
  41340. body, ioErr := ioutil.ReadAll(resp.Body)
  41341. if ioErr != nil {
  41342. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41344. return
  41345. }
  41346. var respJSON map[string]interface{}
  41347. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41348. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41350. return
  41351. }
  41352. var res ResultSix
  41353. var resSix10265 ResultSix10265 //1101结果
  41354. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41355. result, _ := json.Marshal(respJSON)
  41356. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41357. utils.ErrorLog("解析失败:%v", err)
  41358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41359. return
  41360. }
  41361. res.InfRefmsgid = resSix10265.InfRefmsgid
  41362. res.Output = resSix10265.Output
  41363. res.ErrMsg = resSix10265.ErrMsg
  41364. res.Cainfo = resSix10265.Cainfo
  41365. res.WarnMsg = resSix10265.WarnMsg
  41366. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41367. res.Infcode = infocode
  41368. if infocode == 0 {
  41369. c.ServeSuccessJSON(map[string]interface{}{
  41370. "msg": "上传成功",
  41371. })
  41372. return
  41373. } else {
  41374. c.ServeSuccessJSON(map[string]interface{}{
  41375. "failed_code": -10,
  41376. "msg": res.ErrMsg,
  41377. })
  41378. return
  41379. }
  41380. }
  41381. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  41382. // WebSocket服务器地址
  41383. serverURL := "ws://127.0.0.1:8899"
  41384. // 解析WebSocket服务器地址
  41385. u, err := url.Parse(serverURL)
  41386. if err != nil {
  41387. }
  41388. // 建立WebSocket连接
  41389. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41390. if err != nil {
  41391. }
  41392. defer conn.Close()
  41393. input2 := make(map[string]interface{})
  41394. input := make(map[string]interface{})
  41395. inputData := make(map[string]interface{})
  41396. inputData["orgId"] = code
  41397. inputData["businessType"] = "01101"
  41398. inputData["operatorId"] = operator_id
  41399. inputData["operatorName"] = operator_name
  41400. inputData["officeId"] = "001"
  41401. inputData["officeName"] = "血透室"
  41402. inputData["deviceType"] = ""
  41403. input["data"] = inputData
  41404. input["orgId"] = code
  41405. input["transType"] = "ec.query"
  41406. //if md == ""
  41407. if md[:4] == "4403" {
  41408. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41409. } else if md[:4] == "4401" {
  41410. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41411. } else {
  41412. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41413. }
  41414. input2["indata"] = input
  41415. fmt.Println(input2)
  41416. bytesData, _ := json.Marshal(input2)
  41417. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41418. if err != nil {
  41419. fmt.Println(err)
  41420. }
  41421. // 接收消息
  41422. _, receivedMessage, err := conn.ReadMessage()
  41423. if err != nil {
  41424. fmt.Println(err)
  41425. }
  41426. return "", string(receivedMessage)
  41427. }
  41428. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  41429. // WebSocket服务器地址
  41430. serverURL := "ws://127.0.0.1:8899"
  41431. // 解析WebSocket服务器地址
  41432. u, err := url.Parse(serverURL)
  41433. if err != nil {
  41434. }
  41435. // 建立WebSocket连接
  41436. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41437. if err != nil {
  41438. }
  41439. defer conn.Close()
  41440. input2 := make(map[string]interface{})
  41441. input := make(map[string]interface{})
  41442. inputData := make(map[string]interface{})
  41443. inputData["orgId"] = code
  41444. inputData["businessType"] = "01101"
  41445. inputData["operatorId"] = operator_id
  41446. inputData["operatorName"] = operator_name
  41447. inputData["officeId"] = "001"
  41448. inputData["officeName"] = "血透室"
  41449. inputData["deviceType"] = ""
  41450. input["data"] = inputData
  41451. input["orgId"] = code
  41452. input["transType"] = "ec.query"
  41453. //if md == ""
  41454. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  41455. input2["indata"] = input
  41456. fmt.Println(input2)
  41457. bytesData, _ := json.Marshal(input2)
  41458. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41459. if err != nil {
  41460. fmt.Println(err)
  41461. }
  41462. // 接收消息
  41463. _, receivedMessage, err := conn.ReadMessage()
  41464. if err != nil {
  41465. fmt.Println(err)
  41466. }
  41467. return "", string(receivedMessage)
  41468. }
  41469. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  41470. // WebSocket服务器地址
  41471. serverURL := "ws://127.0.0.1:8899"
  41472. // 解析WebSocket服务器地址
  41473. u, err := url.Parse(serverURL)
  41474. if err != nil {
  41475. }
  41476. // 建立WebSocket连接
  41477. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41478. if err != nil {
  41479. }
  41480. defer conn.Close()
  41481. input2 := make(map[string]interface{})
  41482. input := make(map[string]interface{})
  41483. inputData := make(map[string]interface{})
  41484. inputData["orgId"] = code
  41485. inputData["businessType"] = "01301"
  41486. inputData["operatorId"] = operator_id
  41487. inputData["operatorName"] = operator_name
  41488. inputData["officeId"] = "001"
  41489. inputData["officeName"] = "血透室"
  41490. inputData["deviceType"] = ""
  41491. input["data"] = inputData
  41492. input["orgId"] = code
  41493. input["transType"] = "ec.query"
  41494. //if md == ""
  41495. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  41496. input2["indata"] = input
  41497. fmt.Println(input2)
  41498. bytesData, _ := json.Marshal(input2)
  41499. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41500. if err != nil {
  41501. fmt.Println(err)
  41502. }
  41503. // 接收消息
  41504. _, receivedMessage, err := conn.ReadMessage()
  41505. if err != nil {
  41506. fmt.Println(err)
  41507. }
  41508. return "", string(receivedMessage)
  41509. }
  41510. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  41511. // WebSocket服务器地址
  41512. serverURL := "ws://127.0.0.1:8899"
  41513. // 解析WebSocket服务器地址
  41514. u, err := url.Parse(serverURL)
  41515. if err != nil {
  41516. }
  41517. // 建立WebSocket连接
  41518. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41519. if err != nil {
  41520. }
  41521. defer conn.Close()
  41522. input2 := make(map[string]interface{})
  41523. input := make(map[string]interface{})
  41524. inputData := make(map[string]interface{})
  41525. inputData["orgId"] = code
  41526. inputData["businessType"] = "01103"
  41527. inputData["operatorId"] = operator_id
  41528. inputData["operatorName"] = operator_name
  41529. inputData["officeId"] = "001"
  41530. inputData["officeName"] = "血透室"
  41531. inputData["deviceType"] = ""
  41532. input["data"] = inputData
  41533. input["orgId"] = code
  41534. input["transType"] = "ec.query"
  41535. //if md ==
  41536. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  41537. input2["indata"] = input
  41538. fmt.Println(input2)
  41539. bytesData, _ := json.Marshal(input2)
  41540. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41541. if err != nil {
  41542. fmt.Println(err)
  41543. }
  41544. // 接收消息
  41545. _, receivedMessage, err := conn.ReadMessage()
  41546. if err != nil {
  41547. fmt.Println(err)
  41548. }
  41549. return "", string(receivedMessage)
  41550. }
  41551. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  41552. // WebSocket服务器地址
  41553. serverURL := "ws://127.0.0.1:8899"
  41554. // 解析WebSocket服务器地址
  41555. u, err := url.Parse(serverURL)
  41556. if err != nil {
  41557. }
  41558. // 建立WebSocket连接
  41559. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41560. if err != nil {
  41561. }
  41562. defer conn.Close()
  41563. input2 := make(map[string]interface{})
  41564. input := make(map[string]interface{})
  41565. inputData := make(map[string]interface{})
  41566. inputData["orgId"] = code
  41567. inputData["businessType"] = "01101"
  41568. inputData["operatorId"] = operator_id
  41569. inputData["operatorName"] = operator_name
  41570. inputData["officeId"] = "001"
  41571. inputData["officeName"] = "血透室"
  41572. inputData["deviceType"] = ""
  41573. input["data"] = inputData
  41574. input["orgId"] = code
  41575. input["transType"] = "ec.query"
  41576. //if md == ""
  41577. if md[:4] == "4403" {
  41578. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41579. } else if md[:4] == "4401" {
  41580. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41581. } else {
  41582. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41583. }
  41584. input2["indata"] = input
  41585. fmt.Println(input2)
  41586. bytesData, _ := json.Marshal(input2)
  41587. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41588. if err != nil {
  41589. fmt.Println(err)
  41590. }
  41591. // 接收消息
  41592. _, receivedMessage, err := conn.ReadMessage()
  41593. if err != nil {
  41594. fmt.Println(err)
  41595. }
  41596. return "", string(receivedMessage)
  41597. }
  41598. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  41599. // WebSocket服务器地址
  41600. serverURL := "ws://127.0.0.1:8899"
  41601. // 解析WebSocket服务器地址
  41602. u, err := url.Parse(serverURL)
  41603. if err != nil {
  41604. }
  41605. // 建立WebSocket连接
  41606. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41607. if err != nil {
  41608. }
  41609. defer conn.Close()
  41610. input2 := make(map[string]interface{})
  41611. input := make(map[string]interface{})
  41612. inputData := make(map[string]interface{})
  41613. inputData["orgId"] = code
  41614. inputData["businessType"] = "01301"
  41615. inputData["operatorId"] = operator_id
  41616. inputData["operatorName"] = operator_name
  41617. inputData["officeId"] = "001"
  41618. inputData["officeName"] = "血透室"
  41619. inputData["deviceType"] = ""
  41620. input["data"] = inputData
  41621. input["orgId"] = code
  41622. input["transType"] = "ec.query"
  41623. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41624. input2["indata"] = input
  41625. bytesData, _ := json.Marshal(input2)
  41626. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41627. if err != nil {
  41628. fmt.Println(err)
  41629. }
  41630. // 接收消息
  41631. _, receivedMessage, err := conn.ReadMessage()
  41632. if err != nil {
  41633. fmt.Println(err)
  41634. }
  41635. return "", string(receivedMessage)
  41636. }
  41637. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  41638. newArr = make([]string, 0)
  41639. for i := 0; i < len(arr); i++ {
  41640. repeat := false
  41641. for j := i + 1; j < len(arr); j++ {
  41642. if arr[i] == arr[j] {
  41643. repeat = true
  41644. break
  41645. }
  41646. }
  41647. if !repeat {
  41648. newArr = append(newArr, arr[i])
  41649. }
  41650. }
  41651. return
  41652. }
  41653. func getBirthdateAndAge(idNumber string) (string, int, error) {
  41654. if len(idNumber) != 18 {
  41655. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  41656. }
  41657. // 提取出生日期
  41658. year, err := strconv.Atoi(idNumber[6:10])
  41659. if err != nil {
  41660. return "", 0, err
  41661. }
  41662. month, err := strconv.Atoi(idNumber[10:12])
  41663. if err != nil {
  41664. return "", 0, err
  41665. }
  41666. day, err := strconv.Atoi(idNumber[12:14])
  41667. if err != nil {
  41668. return "", 0, err
  41669. }
  41670. // 格式化生日字符串
  41671. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  41672. birthdateFormatted := birthdate.Format("2006-01-02")
  41673. // 计算年龄
  41674. today := time.Now()
  41675. age := today.Year() - birthdate.Year()
  41676. if today.YearDay() < birthdate.YearDay() {
  41677. age--
  41678. }
  41679. return birthdateFormatted, age, nil
  41680. }
  41681. // 从身份证号码中提取出生年月日
  41682. func getBirthDateFromIDCard(idCard string) (string, error) {
  41683. // 身份证号码长度应为18位
  41684. if len(idCard) != 18 {
  41685. return "", fmt.Errorf("身份证号码长度应为18位")
  41686. }
  41687. // 提取出生日期部分 (YYYYMMDD)
  41688. birthDateStr := idCard[6:14]
  41689. // 解析出生日期
  41690. birthDate, err := time.Parse("20060102", birthDateStr)
  41691. if err != nil {
  41692. return "", fmt.Errorf("解析出生日期失败: %v", err)
  41693. }
  41694. // 格式化出生日期为 YYYY-MM-DD
  41695. formattedDate := birthDate.Format("2006-01-02")
  41696. return formattedDate, nil
  41697. }