his_api_controller.go 1.7MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/base64"
  6. //"github.com/jung-kurt/gofpdf"
  7. "encoding/json"
  8. "fmt"
  9. "gdyb/controllers"
  10. "gdyb/enums"
  11. "gdyb/models"
  12. "gdyb/service"
  13. "gdyb/utils"
  14. "github.com/astaxie/beego"
  15. "github.com/axgle/mahonia"
  16. "github.com/go-ole/go-ole/oleutil"
  17. "github.com/gorilla/websocket"
  18. "github.com/jinzhu/gorm"
  19. "github.com/shopspring/decimal"
  20. "io"
  21. "io/ioutil"
  22. "math"
  23. "math/rand"
  24. "net/http"
  25. "net/url"
  26. "os"
  27. "path/filepath"
  28. "regexp"
  29. "strconv"
  30. "strings"
  31. "syscall"
  32. "time"
  33. "unsafe"
  34. "github.com/go-ole/go-ole"
  35. )
  36. type HisApiController struct {
  37. controllers.BaseAuthAPIController
  38. }
  39. func HisManagerApiRegistRouters() {
  40. //挂号
  41. beego.Router("/test/net", &HisApiController{}, "get:TestNet")
  42. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  43. //上传就诊信息-上传明细-结算
  44. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  45. //查询
  46. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  47. //对总账
  48. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  49. //对明细
  50. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  51. //退费,退明细
  52. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  53. //退号
  54. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  55. //退明细
  56. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  57. //上传就诊信息-上传明细-预结算
  58. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  59. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  60. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  61. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  62. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  63. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  64. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  65. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  66. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  67. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  68. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  69. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  70. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  71. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  72. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  73. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  74. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  75. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  76. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  77. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  78. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  79. beego.Router("/api/check", &HisApiController{}, "get:Check")
  80. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  81. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  82. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  83. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  84. beego.Router("/api/3204a", &HisApiController{}, "get:Post3204a")
  85. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  86. beego.Router("/api/8404", &HisApiController{}, "get:Post8404")
  87. beego.Router("/api/3204", &HisApiController{}, "get:Post3204")
  88. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  89. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  90. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  91. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  92. //beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  93. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  94. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  95. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  96. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  97. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  98. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  99. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  100. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  101. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  102. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  103. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  104. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  105. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  106. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  107. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  108. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  109. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  110. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  111. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  112. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  113. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  114. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  115. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  116. beego.Router("/api/CFYLJG012", &HisApiController{}, "get:GetCFYLJG12")
  117. beego.Router("/api/CFYLJG013", &HisApiController{}, "get:GetCFYLJG13")
  118. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  119. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  120. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  121. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  122. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  123. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  124. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  125. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  126. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  127. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  128. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  129. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  130. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  131. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  132. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  133. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  134. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  135. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  136. beego.Router("/api/3103", &HisApiController{}, "get:Get3103")
  137. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  138. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  139. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  140. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  141. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  142. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  143. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  144. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  145. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  146. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  147. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  148. //beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  149. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  150. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  151. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  152. //库盘和变更
  153. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  154. //删除库盘和变更
  155. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  156. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  157. //药品变更
  158. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  159. beego.Router("/api/changedrug/two", &HisApiController{}, "get:ChangeDrugtwo")
  160. beego.Router("/api/changedrug/three", &HisApiController{}, "get:ChangeDrugthree")
  161. beego.Router("/api/changedrug/ten", &HisApiController{}, "get:ChangeDrugTen")
  162. beego.Router("/api/3508", &HisApiController{}, "get:Get3508")
  163. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  164. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  165. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  166. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  167. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  168. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  169. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  170. beego.Router("/api/changedrug/four", &HisApiController{}, "get:ChangeDrugfour")
  171. beego.Router("/api/changedrug/five", &HisApiController{}, "get:ChangeDrugFive")
  172. beego.Router("/api/delete_xs_bg_two", &HisApiController{}, "get:DeleteXSandBGTwo")
  173. beego.Router("/api/delete_xs_bg_three", &HisApiController{}, "get:DeleteXSandBGThree")
  174. beego.Router("/api/3201", &HisApiController{}, "get:Get3201")
  175. beego.Router("/api/5101", &HisApiController{}, "get:Get5101")
  176. beego.Router("/api/5102", &HisApiController{}, "get:Get5102")
  177. }
  178. func (c *HisApiController) Get5101() {
  179. adminUser := c.GetAdminUserInfo()
  180. admin_user_id, _ := c.GetInt64("admin_user_id")
  181. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  182. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  183. if miConfig.MdtrtareaAdmvs == "341203" {
  184. fmt.Println(miConfig.SecretKey)
  185. var res models.Result9001Two
  186. api := miConfig.SecretKey + "ahyb/5101?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  187. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  188. resp, requestErr := http.Get(api)
  189. if requestErr != nil {
  190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  191. return
  192. }
  193. body, ioErr := ioutil.ReadAll(resp.Body)
  194. if ioErr != nil {
  195. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  197. return
  198. }
  199. var respJSON map[string]interface{}
  200. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  201. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  203. return
  204. }
  205. status := respJSON["data"].(map[string]interface{})["status"].(string)
  206. if status == "0" {
  207. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  208. c.ServeSuccessJSON(map[string]interface{}{
  209. "failed_code": -10,
  210. "msg": err_msg,
  211. })
  212. return
  213. }
  214. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  215. result, _ := json.Marshal(respJSON)
  216. fmt.Println("log")
  217. fmt.Println(string(result))
  218. if err := json.Unmarshal([]byte(result), &res); err != nil {
  219. utils.ErrorLog("解析失败:%v", err)
  220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  221. return
  222. }
  223. if res.Infcode == 0 {
  224. sign := models.HisSignIn{
  225. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  226. SignNo: res.Output.Signinoutb.SignNo,
  227. SignTime: "",
  228. Ctime: time.Now().Unix(),
  229. Mtime: time.Now().Unix(),
  230. Status: 1,
  231. InputLog: "",
  232. OutputLog: "",
  233. FixmedinsCode: miConfig.Code,
  234. }
  235. err := service.CreateSignIn(&sign)
  236. if err == nil {
  237. c.ServeSuccessJSON(map[string]interface{}{
  238. "msg": "签到成功",
  239. })
  240. }
  241. } else {
  242. c.ServeSuccessJSON(map[string]interface{}{
  243. "failed_code": -10,
  244. "msg": res.ErrMsg,
  245. })
  246. return
  247. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  248. //return
  249. }
  250. } else if miConfig.MdtrtareaAdmvs == "340699" {
  251. fmt.Println(miConfig.SecretKey)
  252. var res models.Result9001Two
  253. api := miConfig.SecretKey + "ahyb/5101?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  254. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  255. resp, requestErr := http.Get(api)
  256. if requestErr != nil {
  257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  258. return
  259. }
  260. body, ioErr := ioutil.ReadAll(resp.Body)
  261. if ioErr != nil {
  262. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  264. return
  265. }
  266. var respJSON map[string]interface{}
  267. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  270. return
  271. }
  272. status := respJSON["data"].(map[string]interface{})["status"].(string)
  273. if status == "0" {
  274. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  275. c.ServeSuccessJSON(map[string]interface{}{
  276. "failed_code": -10,
  277. "msg": err_msg,
  278. })
  279. return
  280. }
  281. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  282. result, _ := json.Marshal(respJSON)
  283. fmt.Println("log")
  284. fmt.Println(string(result))
  285. if err := json.Unmarshal([]byte(result), &res); err != nil {
  286. utils.ErrorLog("解析失败:%v", err)
  287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  288. return
  289. }
  290. if res.Infcode == 0 {
  291. sign := models.HisSignIn{
  292. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  293. SignNo: res.Output.Signinoutb.SignNo,
  294. SignTime: "",
  295. Ctime: time.Now().Unix(),
  296. Mtime: time.Now().Unix(),
  297. Status: 1,
  298. InputLog: "",
  299. OutputLog: "",
  300. FixmedinsCode: miConfig.Code,
  301. }
  302. err := service.CreateSignIn(&sign)
  303. if err == nil {
  304. c.ServeSuccessJSON(map[string]interface{}{
  305. "msg": "查询成功",
  306. })
  307. }
  308. } else {
  309. c.ServeSuccessJSON(map[string]interface{}{
  310. "failed_code": -10,
  311. "msg": res.ErrMsg,
  312. })
  313. return
  314. }
  315. }
  316. }
  317. func (c *HisApiController) Get5102() {
  318. adminUser := c.GetAdminUserInfo()
  319. admin_user_id, _ := c.GetInt64("admin_user_id")
  320. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  321. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  322. if miConfig.MdtrtareaAdmvs == "341203" {
  323. fmt.Println(miConfig.SecretKey)
  324. var res models.Result9001Two
  325. api := miConfig.SecretKey + "ahyb/5102?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  326. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  327. resp, requestErr := http.Get(api)
  328. if requestErr != nil {
  329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  330. return
  331. }
  332. body, ioErr := ioutil.ReadAll(resp.Body)
  333. if ioErr != nil {
  334. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  336. return
  337. }
  338. var respJSON map[string]interface{}
  339. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  340. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  342. return
  343. }
  344. status := respJSON["data"].(map[string]interface{})["status"].(string)
  345. if status == "0" {
  346. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  347. c.ServeSuccessJSON(map[string]interface{}{
  348. "failed_code": -10,
  349. "msg": err_msg,
  350. })
  351. return
  352. }
  353. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  354. result, _ := json.Marshal(respJSON)
  355. fmt.Println("log")
  356. fmt.Println(string(result))
  357. if err := json.Unmarshal([]byte(result), &res); err != nil {
  358. utils.ErrorLog("解析失败:%v", err)
  359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  360. return
  361. }
  362. if res.Infcode == 0 {
  363. sign := models.HisSignIn{
  364. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  365. SignNo: res.Output.Signinoutb.SignNo,
  366. SignTime: "",
  367. Ctime: time.Now().Unix(),
  368. Mtime: time.Now().Unix(),
  369. Status: 1,
  370. InputLog: "",
  371. OutputLog: "",
  372. FixmedinsCode: miConfig.Code,
  373. }
  374. err := service.CreateSignIn(&sign)
  375. if err == nil {
  376. c.ServeSuccessJSON(map[string]interface{}{
  377. "msg": "签到成功",
  378. })
  379. }
  380. } else {
  381. c.ServeSuccessJSON(map[string]interface{}{
  382. "failed_code": -10,
  383. "msg": res.ErrMsg,
  384. })
  385. return
  386. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  387. //return
  388. }
  389. } else if miConfig.MdtrtareaAdmvs == "340699" {
  390. fmt.Println(miConfig.SecretKey)
  391. var res models.Result9001Two
  392. api := miConfig.SecretKey + "ahyb/5102?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName + "&opera_id=" + strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  393. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  394. resp, requestErr := http.Get(api)
  395. if requestErr != nil {
  396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  397. return
  398. }
  399. body, ioErr := ioutil.ReadAll(resp.Body)
  400. if ioErr != nil {
  401. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  403. return
  404. }
  405. var respJSON map[string]interface{}
  406. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  407. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  409. return
  410. }
  411. status := respJSON["data"].(map[string]interface{})["status"].(string)
  412. if status == "0" {
  413. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  414. c.ServeSuccessJSON(map[string]interface{}{
  415. "failed_code": -10,
  416. "msg": err_msg,
  417. })
  418. return
  419. }
  420. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  421. result, _ := json.Marshal(respJSON)
  422. fmt.Println("log")
  423. fmt.Println(string(result))
  424. if err := json.Unmarshal([]byte(result), &res); err != nil {
  425. utils.ErrorLog("解析失败:%v", err)
  426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  427. return
  428. }
  429. if res.Infcode == 0 {
  430. sign := models.HisSignIn{
  431. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  432. SignNo: res.Output.Signinoutb.SignNo,
  433. SignTime: "",
  434. Ctime: time.Now().Unix(),
  435. Mtime: time.Now().Unix(),
  436. Status: 1,
  437. InputLog: "",
  438. OutputLog: "",
  439. FixmedinsCode: miConfig.Code,
  440. }
  441. err := service.CreateSignIn(&sign)
  442. if err == nil {
  443. c.ServeSuccessJSON(map[string]interface{}{
  444. "msg": "查询成功",
  445. })
  446. }
  447. } else {
  448. c.ServeSuccessJSON(map[string]interface{}{
  449. "failed_code": -10,
  450. "msg": res.ErrMsg,
  451. })
  452. return
  453. }
  454. }
  455. }
  456. func (c *HisApiController) Get3201() {
  457. adminUser := c.GetAdminUserInfo()
  458. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  459. result, _ := service.AHyb3201(932, 0, 571536.19, 543283.9, "2024-10-01", "2024-10-31", "340699", "11", "390", miConfig.OrgName, "王幸子", miConfig.Code, "340399", "340399", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey, miConfig.Cainfo)
  460. var response Response
  461. if err := json.Unmarshal([]byte(result), &response); err != nil {
  462. fmt.Println("Error decoding JSON:", err)
  463. return
  464. }
  465. }
  466. func (c *HisApiController) TestNet() {
  467. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  468. //return
  469. c.ServeSuccessJSON(map[string]interface{}{
  470. "msg": "成功",
  471. })
  472. }
  473. func (c *HisApiController) Get3508() {
  474. admin_user_id, _ := c.GetInt64("admin_user_id")
  475. drug_id, _ := c.GetInt64("id")
  476. start_time := c.GetString("start_time")
  477. end_time := c.GetString("end_time")
  478. adminUser := c.GetAdminUserInfo()
  479. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  480. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  481. drug, _ := service.GetDrugByID(drug_id)
  482. var struct3508 models.Struct3508
  483. struct3508.OrgName = miConfig.OrgName
  484. struct3508.FixmedinsCode = miConfig.Code
  485. struct3508.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  486. struct3508.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  487. struct3508.AccessKey = miConfig.AccessKey
  488. struct3508.Opter = curRoles.UserName
  489. struct3508.RequestUrl = miConfig.Url
  490. struct3508.Url = miConfig.Url
  491. struct3508.AppId = miConfig.Cainfo
  492. struct3508.AppSecret = miConfig.AppSecret
  493. struct3508.Enckey = miConfig.EncKey
  494. struct3508.SignKey = miConfig.SignKey
  495. struct3508.SecretKey = miConfig.SecretKey
  496. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  497. struct3508.Begndate = start_time
  498. struct3508.Enddate = end_time
  499. struct3508.Enddate = end_time
  500. struct3508.Enddate = end_time
  501. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  502. result1, result2 := service.Gdyb3508(struct3508, struct3508.SecretKey)
  503. saveLog(result1, result2, "3508", "3508")
  504. var res models.Result3508
  505. var respJSON2 map[string]interface{}
  506. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  507. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  509. return
  510. }
  511. userJSONBytes2, _ := json.Marshal(respJSON2)
  512. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  513. utils.ErrorLog("解析失败:%v", err)
  514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  515. return
  516. }
  517. if res.Infcode == -1 {
  518. c.ServeSuccessJSON(map[string]interface{}{
  519. "failed_code": -10,
  520. "msg": res.ErrMsg,
  521. })
  522. } else {
  523. c.ServeSuccessJSON(map[string]interface{}{
  524. "info": res.Output,
  525. })
  526. }
  527. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  528. result1, result2, _ := service.FJyb3508(struct3508)
  529. saveLog(result1, result2, "3508", "3508")
  530. var res models.Result3508
  531. var respJSON2 map[string]interface{}
  532. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  533. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  535. return
  536. }
  537. userJSONBytes2, _ := json.Marshal(respJSON2)
  538. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  539. utils.ErrorLog("解析失败:%v", err)
  540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  541. return
  542. }
  543. if res.Infcode == -1 {
  544. c.ServeSuccessJSON(map[string]interface{}{
  545. "failed_code": -10,
  546. "msg": res.ErrMsg,
  547. })
  548. } else {
  549. c.ServeSuccessJSON(map[string]interface{}{
  550. "info": res.Output,
  551. })
  552. }
  553. }
  554. }
  555. func (c *HisApiController) Get3509() {
  556. admin_user_id, _ := c.GetInt64("admin_user_id")
  557. drug_id, _ := c.GetInt64("id")
  558. start_time := c.GetString("start_time")
  559. end_time := c.GetString("end_time")
  560. adminUser := c.GetAdminUserInfo()
  561. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  562. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  563. drug, _ := service.GetDrugByID(drug_id)
  564. var struct3508 models.Struct3509
  565. struct3508.OrgName = miConfig.OrgName
  566. struct3508.FixmedinsCode = miConfig.Code
  567. struct3508.AccessKey = miConfig.AccessKey
  568. struct3508.Opter = curRoles.UserName
  569. struct3508.RequestUrl = miConfig.Url
  570. struct3508.Url = miConfig.Url
  571. struct3508.AppId = miConfig.Cainfo
  572. struct3508.AppSecret = miConfig.AppSecret
  573. struct3508.Enckey = miConfig.EncKey
  574. struct3508.SignKey = miConfig.SignKey
  575. struct3508.SecretKey = miConfig.SecretKey
  576. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  577. struct3508.Begndate = start_time
  578. struct3508.Enddate = end_time
  579. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  580. result1, result2 := service.Gdyb3509(struct3508, struct3508.SecretKey)
  581. saveLog(result1, result2, "3509", "3509")
  582. var res models.Result3508
  583. var respJSON2 map[string]interface{}
  584. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  585. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  587. return
  588. }
  589. userJSONBytes2, _ := json.Marshal(respJSON2)
  590. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  591. utils.ErrorLog("解析失败:%v", err)
  592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  593. return
  594. }
  595. if res.Infcode == -1 {
  596. c.ServeSuccessJSON(map[string]interface{}{
  597. "failed_code": -10,
  598. "msg": res.ErrMsg,
  599. })
  600. } else {
  601. c.ServeSuccessJSON(map[string]interface{}{
  602. "info": res.Output,
  603. })
  604. }
  605. } else {
  606. result1, result2, _ := service.FJyb3509(struct3508)
  607. saveLog(result1, result2, "3509", "3509")
  608. var res models.Result3509
  609. var respJSON2 map[string]interface{}
  610. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  611. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  613. return
  614. }
  615. userJSONBytes2, _ := json.Marshal(respJSON2)
  616. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  617. utils.ErrorLog("解析失败:%v", err)
  618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  619. return
  620. }
  621. if res.Infcode == -1 {
  622. c.ServeSuccessJSON(map[string]interface{}{
  623. "failed_code": -10,
  624. "msg": res.ErrMsg,
  625. })
  626. } else {
  627. c.ServeSuccessJSON(map[string]interface{}{
  628. "info": res.Output,
  629. })
  630. }
  631. }
  632. }
  633. func (c *HisApiController) Get3510() {
  634. admin_user_id, _ := c.GetInt64("admin_user_id")
  635. drug_id, _ := c.GetInt64("id")
  636. start_time := c.GetString("start_time")
  637. end_time := c.GetString("end_time")
  638. adminUser := c.GetAdminUserInfo()
  639. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  640. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  641. drug, _ := service.GetDrugByID(drug_id)
  642. var struct3508 models.Struct3510
  643. struct3508.FixmedinsCode = miConfig.Code
  644. struct3508.OrgName = miConfig.OrgName
  645. struct3508.AccessKey = miConfig.AccessKey
  646. struct3508.Opter = curRoles.UserName
  647. struct3508.RequestUrl = miConfig.Url
  648. struct3508.Url = miConfig.Url
  649. struct3508.AppId = miConfig.Cainfo
  650. struct3508.AppSecret = miConfig.AppSecret
  651. struct3508.Enckey = miConfig.EncKey
  652. struct3508.SignKey = miConfig.SignKey
  653. struct3508.SecretKey = miConfig.SecretKey
  654. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  655. struct3508.Begndate = start_time
  656. struct3508.Enddate = end_time
  657. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  658. result1, result2 := service.Gdyb3510(struct3508, struct3508.SecretKey)
  659. saveLog(result1, result2, "3510", "3510")
  660. var res models.Result3510
  661. var respJSON2 map[string]interface{}
  662. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  663. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  665. return
  666. }
  667. userJSONBytes2, _ := json.Marshal(respJSON2)
  668. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  669. utils.ErrorLog("解析失败:%v", err)
  670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  671. return
  672. }
  673. if res.Infcode == -1 {
  674. c.ServeSuccessJSON(map[string]interface{}{
  675. "failed_code": -10,
  676. "msg": res.ErrMsg,
  677. })
  678. } else {
  679. c.ServeSuccessJSON(map[string]interface{}{
  680. "info": res.Output,
  681. })
  682. }
  683. } else {
  684. result1, result2, _ := service.FJyb3510(struct3508)
  685. saveLog(result1, result2, "3510", "3510")
  686. var res models.Result3510
  687. var respJSON2 map[string]interface{}
  688. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  689. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  691. return
  692. }
  693. userJSONBytes2, _ := json.Marshal(respJSON2)
  694. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  695. utils.ErrorLog("解析失败:%v", err)
  696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  697. return
  698. }
  699. if res.Infcode == -1 {
  700. c.ServeSuccessJSON(map[string]interface{}{
  701. "failed_code": -10,
  702. "msg": res.ErrMsg,
  703. })
  704. } else {
  705. c.ServeSuccessJSON(map[string]interface{}{
  706. "info": res.Output,
  707. })
  708. }
  709. }
  710. }
  711. func (c *HisApiController) Get3511() {
  712. admin_user_id, _ := c.GetInt64("admin_user_id")
  713. drug_id, _ := c.GetInt64("id")
  714. start_time := c.GetString("start_time")
  715. end_time := c.GetString("end_time")
  716. adminUser := c.GetAdminUserInfo()
  717. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  718. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  719. drug, _ := service.GetDrugByID(drug_id)
  720. var struct3508 models.Struct3511
  721. struct3508.FixmedinsCode = miConfig.Code
  722. struct3508.OrgName = miConfig.OrgName
  723. struct3508.AccessKey = miConfig.AccessKey
  724. struct3508.Opter = curRoles.UserName
  725. struct3508.RequestUrl = miConfig.Url
  726. struct3508.Url = miConfig.Url
  727. struct3508.AppId = miConfig.Cainfo
  728. struct3508.AppSecret = miConfig.AppSecret
  729. struct3508.Enckey = miConfig.EncKey
  730. struct3508.SignKey = miConfig.SignKey
  731. struct3508.SecretKey = miConfig.SecretKey
  732. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  733. struct3508.Begndate = start_time
  734. struct3508.Enddate = end_time
  735. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  736. result1, result2 := service.Gdyb3511(struct3508, struct3508.SecretKey)
  737. saveLog(result1, result2, "3511", "3511")
  738. var res models.Result3511
  739. var respJSON2 map[string]interface{}
  740. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  741. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  743. return
  744. }
  745. userJSONBytes2, _ := json.Marshal(respJSON2)
  746. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  747. utils.ErrorLog("解析失败:%v", err)
  748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  749. return
  750. }
  751. if res.Infcode == -1 {
  752. c.ServeSuccessJSON(map[string]interface{}{
  753. "failed_code": -10,
  754. "msg": res.ErrMsg,
  755. })
  756. } else {
  757. c.ServeSuccessJSON(map[string]interface{}{
  758. "info": res.Output,
  759. })
  760. }
  761. } else {
  762. result1, result2, _ := service.FJyb3511(struct3508)
  763. saveLog(result1, result2, "3511", "3511")
  764. var res models.Result3511
  765. var respJSON2 map[string]interface{}
  766. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  767. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  769. return
  770. }
  771. userJSONBytes2, _ := json.Marshal(respJSON2)
  772. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  773. utils.ErrorLog("解析失败:%v", err)
  774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  775. return
  776. }
  777. if res.Infcode == -1 {
  778. c.ServeSuccessJSON(map[string]interface{}{
  779. "failed_code": -10,
  780. "msg": res.ErrMsg,
  781. })
  782. } else {
  783. c.ServeSuccessJSON(map[string]interface{}{
  784. "info": res.Output,
  785. })
  786. }
  787. }
  788. }
  789. func (c *HisApiController) Get3512() {
  790. admin_user_id, _ := c.GetInt64("admin_user_id")
  791. drug_id, _ := c.GetInt64("id")
  792. start_time := c.GetString("start_time")
  793. end_time := c.GetString("end_time")
  794. adminUser := c.GetAdminUserInfo()
  795. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  796. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  797. drug, _ := service.GetDrugByID(drug_id)
  798. var struct3508 models.Struct3512
  799. struct3508.FixmedinsCode = miConfig.Code
  800. struct3508.OrgName = miConfig.OrgName
  801. struct3508.AccessKey = miConfig.AccessKey
  802. struct3508.Opter = curRoles.UserName
  803. struct3508.RequestUrl = miConfig.Url
  804. struct3508.Url = miConfig.Url
  805. struct3508.AppId = miConfig.Cainfo
  806. struct3508.AppSecret = miConfig.AppSecret
  807. struct3508.Enckey = miConfig.EncKey
  808. struct3508.SignKey = miConfig.SignKey
  809. struct3508.SecretKey = miConfig.SecretKey
  810. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  811. struct3508.Begndate = start_time
  812. struct3508.Enddate = end_time
  813. struct3508.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  814. struct3508.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  815. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  816. result1, result2 := service.Gdyb3512(struct3508, struct3508.SecretKey)
  817. saveLog(result1, result2, "3512", "3512")
  818. var res models.Result3512
  819. var respJSON2 map[string]interface{}
  820. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  821. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  823. return
  824. }
  825. userJSONBytes2, _ := json.Marshal(respJSON2)
  826. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  827. utils.ErrorLog("解析失败:%v", err)
  828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  829. return
  830. }
  831. if res.Infcode == -1 {
  832. c.ServeSuccessJSON(map[string]interface{}{
  833. "failed_code": -10,
  834. "msg": res.ErrMsg,
  835. })
  836. } else {
  837. c.ServeSuccessJSON(map[string]interface{}{
  838. "info": res.Output,
  839. })
  840. }
  841. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  842. result1, result2, _ := service.FJyb3512(struct3508)
  843. saveLog(result1, result2, "3512", "3512")
  844. var res models.Result3512
  845. var respJSON2 map[string]interface{}
  846. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  847. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  849. return
  850. }
  851. userJSONBytes2, _ := json.Marshal(respJSON2)
  852. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  853. utils.ErrorLog("解析失败:%v", err)
  854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  855. return
  856. }
  857. if res.Infcode == -1 {
  858. c.ServeSuccessJSON(map[string]interface{}{
  859. "failed_code": -10,
  860. "msg": res.ErrMsg,
  861. })
  862. } else {
  863. c.ServeSuccessJSON(map[string]interface{}{
  864. "info": res.Output,
  865. })
  866. }
  867. }
  868. }
  869. func (c *HisApiController) Get3513() {
  870. admin_user_id, _ := c.GetInt64("admin_user_id")
  871. drug_id, _ := c.GetInt64("id")
  872. start_time := c.GetString("start_time")
  873. end_time := c.GetString("end_time")
  874. adminUser := c.GetAdminUserInfo()
  875. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  876. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  877. drug, _ := service.GetDrugByID(drug_id)
  878. var struct3508 models.Struct3513
  879. struct3508.FixmedinsCode = miConfig.Code
  880. struct3508.OrgName = miConfig.OrgName
  881. struct3508.AccessKey = miConfig.AccessKey
  882. struct3508.Opter = curRoles.UserName
  883. struct3508.RequestUrl = miConfig.Url
  884. struct3508.Url = miConfig.Url
  885. struct3508.AppId = miConfig.Cainfo
  886. struct3508.AppSecret = miConfig.AppSecret
  887. struct3508.Enckey = miConfig.EncKey
  888. struct3508.SignKey = miConfig.SignKey
  889. struct3508.SecretKey = miConfig.SecretKey
  890. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  891. struct3508.Begndate = start_time
  892. struct3508.Enddate = end_time
  893. struct3508.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  894. struct3508.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  895. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  896. result1, result2 := service.Gdyb3513(struct3508, struct3508.SecretKey)
  897. saveLog(result1, result2, "3513", "3513")
  898. var res models.Result3513
  899. var respJSON2 map[string]interface{}
  900. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  901. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  903. return
  904. }
  905. userJSONBytes2, _ := json.Marshal(respJSON2)
  906. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  907. utils.ErrorLog("解析失败:%v", err)
  908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  909. return
  910. }
  911. if res.Infcode == -1 {
  912. c.ServeSuccessJSON(map[string]interface{}{
  913. "failed_code": -10,
  914. "msg": res.ErrMsg,
  915. })
  916. } else {
  917. c.ServeSuccessJSON(map[string]interface{}{
  918. "info": res.Output,
  919. })
  920. }
  921. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  922. result1, result2, _ := service.FJyb3513(struct3508)
  923. saveLog(result1, result2, "3513", "3513")
  924. var res models.Result3513
  925. var respJSON2 map[string]interface{}
  926. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  927. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  929. return
  930. }
  931. userJSONBytes2, _ := json.Marshal(respJSON2)
  932. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  933. utils.ErrorLog("解析失败:%v", err)
  934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  935. return
  936. }
  937. if res.Infcode == -1 {
  938. c.ServeSuccessJSON(map[string]interface{}{
  939. "failed_code": -10,
  940. "msg": res.ErrMsg,
  941. })
  942. } else {
  943. c.ServeSuccessJSON(map[string]interface{}{
  944. "info": res.Output,
  945. })
  946. }
  947. }
  948. }
  949. func (c *HisApiController) Get35081() {
  950. admin_user_id, _ := c.GetInt64("admin_user_id")
  951. drug_id, _ := c.GetInt64("id")
  952. //start_time := c.GetString("start_time")
  953. //end_time := c.GetString("end_time")
  954. page, _ := c.GetInt("page")
  955. adminUser := c.GetAdminUserInfo()
  956. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  957. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  958. drug, _ := service.GetDrugByID(drug_id)
  959. var struct3508 models.Struct35081
  960. struct3508.FixmedinsCode = miConfig.Code
  961. struct3508.OrgName = miConfig.OrgName
  962. struct3508.AccessKey = miConfig.AccessKey
  963. struct3508.Opter = curRoles.UserName
  964. struct3508.RequestUrl = miConfig.Url
  965. struct3508.Url = miConfig.Url
  966. struct3508.AppId = miConfig.Cainfo
  967. struct3508.AppSecret = miConfig.AppSecret
  968. struct3508.Enckey = miConfig.EncKey
  969. struct3508.SignKey = miConfig.SignKey
  970. struct3508.SecretKey = miConfig.SecretKey
  971. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  972. struct3508.PageNum = page
  973. struct3508.PageSize = 10
  974. result1, result2, _ := service.FJyb35081(struct3508)
  975. saveLog(result1, result2, "35081", "35081")
  976. var res models.Result35081
  977. var respJSON2 map[string]interface{}
  978. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  979. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  981. return
  982. }
  983. userJSONBytes2, _ := json.Marshal(respJSON2)
  984. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  985. utils.ErrorLog("解析失败:%v", err)
  986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  987. return
  988. }
  989. if res.Infcode == -1 {
  990. c.ServeSuccessJSON(map[string]interface{}{
  991. "failed_code": -10,
  992. "msg": res.ErrMsg,
  993. })
  994. } else {
  995. c.ServeSuccessJSON(map[string]interface{}{
  996. "info": res.Output,
  997. })
  998. }
  999. }
  1000. func (c *HisApiController) Get35082() {
  1001. admin_user_id, _ := c.GetInt64("admin_user_id")
  1002. drug_id, _ := c.GetInt64("id")
  1003. //start_time := c.GetString("start_time")
  1004. //end_time := c.GetString("end_time")
  1005. page, _ := c.GetInt("page")
  1006. adminUser := c.GetAdminUserInfo()
  1007. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1008. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1009. drug, _ := service.GetDrugByID(drug_id)
  1010. var struct3508 models.Struct35082
  1011. struct3508.FixmedinsCode = miConfig.Code
  1012. struct3508.OrgName = miConfig.OrgName
  1013. struct3508.AccessKey = miConfig.AccessKey
  1014. struct3508.Opter = curRoles.UserName
  1015. struct3508.RequestUrl = miConfig.Url
  1016. struct3508.Url = miConfig.Url
  1017. struct3508.AppId = miConfig.Cainfo
  1018. struct3508.AppSecret = miConfig.AppSecret
  1019. struct3508.Enckey = miConfig.EncKey
  1020. struct3508.SignKey = miConfig.SignKey
  1021. struct3508.SecretKey = miConfig.SecretKey
  1022. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  1023. struct3508.PageNum = page
  1024. struct3508.PageSize = 10
  1025. result1, result2, _ := service.FJyb35082(struct3508)
  1026. saveLog(result1, result2, "35082", "35082")
  1027. var res models.Result35082
  1028. var respJSON2 map[string]interface{}
  1029. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1030. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1032. return
  1033. }
  1034. userJSONBytes2, _ := json.Marshal(respJSON2)
  1035. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1036. utils.ErrorLog("解析失败:%v", err)
  1037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1038. return
  1039. }
  1040. if res.Infcode == -1 {
  1041. c.ServeSuccessJSON(map[string]interface{}{
  1042. "failed_code": -10,
  1043. "msg": res.ErrMsg,
  1044. })
  1045. } else {
  1046. c.ServeSuccessJSON(map[string]interface{}{
  1047. "info": res.Output,
  1048. })
  1049. }
  1050. }
  1051. func IsDigit(s string) bool {
  1052. re := regexp.MustCompile("^[0-9]+$")
  1053. return re.MatchString(s)
  1054. }
  1055. func (c *HisApiController) FJ3501AND3502() {
  1056. ids := c.GetString("ids")
  1057. admin_user_id, _ := c.GetInt64("admin_user_id")
  1058. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1059. id_arr := strings.Split(ids, ",")
  1060. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1061. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1062. //规则判断
  1063. var errs []string
  1064. for _, drug := range drugs {
  1065. if drug.IsPc == 0 {
  1066. if len(drug.DrugCode) > 0 {
  1067. codes := strings.Split(drug.DrugCode, ",")
  1068. for _, code := range codes {
  1069. if len(code) > 0 {
  1070. if len(code) != 20 {
  1071. errs = append(errs, drug.BaseDrugLib.DrugName+" 溯源码"+code+"位数不是20位")
  1072. }
  1073. if IsDigit(code) == false {
  1074. errs = append(errs, drug.BaseDrugLib.DrugName+" 溯源码"+code+"不是纯数字")
  1075. }
  1076. }
  1077. }
  1078. }
  1079. }
  1080. }
  1081. if len(errs) > 0 {
  1082. c.ServeSuccessJSON(map[string]interface{}{
  1083. "failed_code": -10,
  1084. "msg": errs,
  1085. })
  1086. return
  1087. }
  1088. //库盘
  1089. for _, drug := range drugs {
  1090. if drug.IsPc == 0 {
  1091. var res2 ResultSix
  1092. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  1093. var struct3501 models.Struct3501
  1094. struct3501.Code = miConfig.Code
  1095. struct3501.OrgName = miConfig.OrgName
  1096. struct3501.AccessKey = miConfig.AccessKey
  1097. struct3501.Opter = roles.UserName
  1098. struct3501.RequestUrl = miConfig.Url
  1099. struct3501.Url = miConfig.Url
  1100. struct3501.AppId = miConfig.Cainfo
  1101. struct3501.AppSecret = miConfig.AppSecret
  1102. struct3501.Enckey = miConfig.EncKey
  1103. struct3501.SignKey = miConfig.SignKey
  1104. struct3501.SecretKey = miConfig.SecretKey
  1105. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  1106. struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  1107. struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  1108. struct3501.RxFlag = "1"
  1109. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  1110. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  1111. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1112. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1113. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  1114. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  1115. struct3501.FixmedinsBchno = number
  1116. struct3501.DrugTracCodg = drug.DrugCode
  1117. memo := make(map[string]interface{})
  1118. memo["pric"] = drug.Price
  1119. bytesData, _ := json.Marshal(memo)
  1120. struct3501.Memo = string(bytesData)
  1121. if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  1122. result1, result2, _ := service.FJyb3501(struct3501)
  1123. saveLog(result1, result2, "3501", "3501")
  1124. //saveLog(result, requestLog, "2201", "挂号")
  1125. var respJSON2 map[string]interface{}
  1126. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1127. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1129. return
  1130. }
  1131. userJSONBytes2, _ := json.Marshal(respJSON2)
  1132. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1133. utils.ErrorLog("解析失败:%v", err)
  1134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1135. return
  1136. }
  1137. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  1138. data := make(map[string]interface{})
  1139. data["struct_3501s"] = struct3501
  1140. client := &http.Client{}
  1141. bytesData, _ := json.Marshal(data)
  1142. var req *http.Request
  1143. if miConfig.MdtrtareaAdmvs == "320830" {
  1144. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3501", bytes.NewReader(bytesData))
  1145. } else {
  1146. if miConfig.MdtrtareaAdmvs == "320921" {
  1147. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  1148. } else {
  1149. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  1150. }
  1151. }
  1152. resp, _ := client.Do(req)
  1153. defer resp.Body.Close()
  1154. body, ioErr := ioutil.ReadAll(resp.Body)
  1155. if ioErr != nil {
  1156. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1157. }
  1158. var respJSON map[string]interface{}
  1159. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1160. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1162. return
  1163. }
  1164. var resSix10265 ResultSix10265 //1101结果
  1165. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1166. result, _ := json.Marshal(respJSON)
  1167. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1168. utils.ErrorLog("解析失败:%v", err)
  1169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1170. return
  1171. }
  1172. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1173. res2.Output = resSix10265.Output
  1174. res2.ErrMsg = resSix10265.ErrMsg
  1175. res2.Cainfo = resSix10265.Cainfo
  1176. res2.WarnMsg = resSix10265.WarnMsg
  1177. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1178. res2.Infcode = infocode
  1179. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  1180. data := make(map[string]interface{})
  1181. data["struct_3501s"] = struct3501
  1182. client := &http.Client{}
  1183. bytesData, _ := json.Marshal(data)
  1184. var req *http.Request
  1185. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  1186. resp, _ := client.Do(req)
  1187. defer resp.Body.Close()
  1188. body, ioErr := ioutil.ReadAll(resp.Body)
  1189. if ioErr != nil {
  1190. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1191. }
  1192. var respJSON map[string]interface{}
  1193. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1194. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1196. return
  1197. }
  1198. var resSix10265 ResultSix10265 //1101结果
  1199. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1200. result, _ := json.Marshal(respJSON)
  1201. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1202. utils.ErrorLog("解析失败:%v", err)
  1203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1204. return
  1205. }
  1206. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1207. res2.Output = resSix10265.Output
  1208. res2.ErrMsg = resSix10265.ErrMsg
  1209. res2.Cainfo = resSix10265.Cainfo
  1210. res2.WarnMsg = resSix10265.WarnMsg
  1211. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1212. res2.Infcode = infocode
  1213. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  1214. data := make(map[string]interface{})
  1215. data["struct_3501s"] = struct3501
  1216. client := &http.Client{}
  1217. bytesData, _ := json.Marshal(data)
  1218. var req *http.Request
  1219. req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  1220. resp, _ := client.Do(req)
  1221. defer resp.Body.Close()
  1222. body, ioErr := ioutil.ReadAll(resp.Body)
  1223. if ioErr != nil {
  1224. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1225. }
  1226. var respJSON map[string]interface{}
  1227. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1228. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1230. return
  1231. }
  1232. var resSix10265 ResultSix10265 //1101结果
  1233. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1234. result, _ := json.Marshal(respJSON)
  1235. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1236. utils.ErrorLog("解析失败:%v", err)
  1237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1238. return
  1239. }
  1240. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1241. res2.Output = resSix10265.Output
  1242. res2.ErrMsg = resSix10265.ErrMsg
  1243. res2.Cainfo = resSix10265.Cainfo
  1244. res2.WarnMsg = resSix10265.WarnMsg
  1245. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1246. res2.Infcode = infocode
  1247. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  1248. result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  1249. saveLog(result1, result2, "3501", "3501")
  1250. //saveLog(result, requestLog, "2201", "挂号")
  1251. var respJSON2 map[string]interface{}
  1252. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1255. return
  1256. }
  1257. userJSONBytes2, _ := json.Marshal(respJSON2)
  1258. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1259. utils.ErrorLog("解析失败:%v", err)
  1260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1261. return
  1262. }
  1263. }
  1264. utils.ErrorLog("解析失败:%v", res2.Infcode)
  1265. if res2.Infcode != -1 {
  1266. drug.IsPc = 1
  1267. drug.Bchno = number
  1268. drug.PcDate = time.Now().Unix()
  1269. service.SaveW(drug)
  1270. //if err == nil {
  1271. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  1272. // var struct3502 models.Struct3502
  1273. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  1274. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  1275. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  1276. // struct3502.FixmedinsCode = miConfig.Code
  1277. // struct3502.Code = miConfig.Code
  1278. //
  1279. // struct3502.RxFlag = "0"
  1280. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  1281. // struct3502.OrgName = miConfig.OrgName
  1282. // struct3502.Opter = roles.UserName
  1283. // struct3502.AccessKey = miConfig.AccessKey
  1284. // struct3502.RequestUrl = miConfig.Url
  1285. // struct3502.SecretKey = miConfig.SecretKey
  1286. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1287. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1288. // struct3502.Url = miConfig.Url
  1289. // struct3502.AppId = miConfig.Cainfo
  1290. // struct3502.AppSecret = miConfig.AppSecret
  1291. // struct3502.Enckey = miConfig.EncKey
  1292. // struct3502.SignKey = miConfig.SignKey
  1293. // struct3502.SecretKey = miConfig.SecretKey
  1294. // struct3502.DrugTracCodg = drug.DrugCode
  1295. //
  1296. // struct3502.Memo = ""
  1297. // struct3502.InvChgType = "108"
  1298. // struct3502.FixmedinsBchno = bg_number
  1299. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  1300. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  1301. //
  1302. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  1303. // result11, result22, _ := service.FJyb3502(struct3502)
  1304. // saveLog(result11, result22, "3502", "3502")
  1305. //
  1306. // var respJSON3 map[string]interface{}
  1307. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1308. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1309. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1310. // return
  1311. // }
  1312. // userJSONBytes3, _ := json.Marshal(respJSON3)
  1313. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1314. // utils.ErrorLog("解析失败:%v", err)
  1315. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1316. // return
  1317. // }
  1318. //
  1319. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  1320. // data := make(map[string]interface{})
  1321. // data["struct_3502s"] = struct3502
  1322. // client := &http.Client{}
  1323. // bytesData, _ := json.Marshal(data)
  1324. // var req *http.Request
  1325. // if miConfig.MdtrtareaAdmvs == "320830" {
  1326. // req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3502", bytes.NewReader(bytesData))
  1327. // } else if miConfig.MdtrtareaAdmvs == "320921" {
  1328. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1329. // } else {
  1330. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  1331. // }
  1332. //
  1333. // resp, _ := client.Do(req)
  1334. // defer resp.Body.Close()
  1335. // body, ioErr := ioutil.ReadAll(resp.Body)
  1336. // if ioErr != nil {
  1337. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1338. // }
  1339. // var respJSON map[string]interface{}
  1340. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1341. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1342. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1343. // return
  1344. // }
  1345. // var resSix10265 ResultSix10265 //1101结果
  1346. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1347. // result, _ := json.Marshal(respJSON)
  1348. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1349. // utils.ErrorLog("解析失败:%v", err)
  1350. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1351. // return
  1352. // }
  1353. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  1354. // res3.Output = resSix10265.Output
  1355. // res3.ErrMsg = resSix10265.ErrMsg
  1356. // res3.Cainfo = resSix10265.Cainfo
  1357. // res3.WarnMsg = resSix10265.WarnMsg
  1358. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1359. // res3.Infcode = infocode
  1360. //
  1361. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  1362. //
  1363. // data := make(map[string]interface{})
  1364. // data["struct_3502s"] = struct3502
  1365. // client := &http.Client{}
  1366. // bytesData, _ := json.Marshal(data)
  1367. // var req *http.Request
  1368. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  1369. // resp, _ := client.Do(req)
  1370. // defer resp.Body.Close()
  1371. // body, ioErr := ioutil.ReadAll(resp.Body)
  1372. // if ioErr != nil {
  1373. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1374. // }
  1375. // var respJSON map[string]interface{}
  1376. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1377. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1378. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1379. // return
  1380. // }
  1381. // var resSix10265 ResultSix10265 //1101结果
  1382. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1383. // result, _ := json.Marshal(respJSON)
  1384. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1385. // utils.ErrorLog("解析失败:%v", err)
  1386. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1387. // return
  1388. // }
  1389. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  1390. // res3.Output = resSix10265.Output
  1391. // res3.ErrMsg = resSix10265.ErrMsg
  1392. // res3.Cainfo = resSix10265.Cainfo
  1393. // res3.WarnMsg = resSix10265.WarnMsg
  1394. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1395. // res3.Infcode = infocode
  1396. //
  1397. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  1398. //
  1399. // data := make(map[string]interface{})
  1400. // data["struct_3501s"] = struct3501
  1401. // client := &http.Client{}
  1402. // bytesData, _ := json.Marshal(data)
  1403. // var req *http.Request
  1404. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  1405. // resp, _ := client.Do(req)
  1406. // defer resp.Body.Close()
  1407. // body, ioErr := ioutil.ReadAll(resp.Body)
  1408. // if ioErr != nil {
  1409. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1410. // }
  1411. // var respJSON map[string]interface{}
  1412. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1413. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1414. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1415. // return
  1416. // }
  1417. // var resSix10265 ResultSix10265 //1101结果
  1418. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1419. // result, _ := json.Marshal(respJSON)
  1420. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1421. // utils.ErrorLog("解析失败:%v", err)
  1422. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1423. // return
  1424. // }
  1425. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  1426. // res2.Output = resSix10265.Output
  1427. // res2.ErrMsg = resSix10265.ErrMsg
  1428. // res2.Cainfo = resSix10265.Cainfo
  1429. // res2.WarnMsg = resSix10265.WarnMsg
  1430. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1431. // res2.Infcode = infocode
  1432. //
  1433. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  1434. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  1435. // saveLog(result11, result22, "3502", "3502")
  1436. //
  1437. // var respJSON3 map[string]interface{}
  1438. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1439. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1440. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1441. // return
  1442. // }
  1443. // userJSONBytes3, _ := json.Marshal(respJSON3)
  1444. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1445. // utils.ErrorLog("解析失败:%v", err)
  1446. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1447. // return
  1448. // }
  1449. // }
  1450. // if res3.Infcode == -1 {
  1451. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  1452. // c.ServeSuccessJSON(map[string]interface{}{
  1453. // "failed_code": -10,
  1454. // "msg": res3.ErrMsg,
  1455. // })
  1456. // } else {
  1457. // drug.IsBg = 1
  1458. // drug.BgBchno = bg_number
  1459. // service.SaveW(drug)
  1460. // }
  1461. //}
  1462. //} else {
  1463. } else {
  1464. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  1465. }
  1466. }
  1467. //变更
  1468. }
  1469. if len(errs) == 0 {
  1470. c.ServeSuccessJSON(map[string]interface{}{
  1471. "msg": "盘存变更成功",
  1472. })
  1473. } else {
  1474. c.ServeSuccessJSON(map[string]interface{}{
  1475. "failed_code": -10,
  1476. "msg": errs,
  1477. })
  1478. }
  1479. }
  1480. func (c *HisApiController) DeletePCandBG() {
  1481. ids := c.GetString("ids")
  1482. id_arr := strings.Split(ids, ",")
  1483. admin_user_id, _ := c.GetInt64("admin_user_id")
  1484. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1485. drugs, _ := service.GetNewDrugWarehouseInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1486. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1487. var err []string
  1488. for _, item := range drugs {
  1489. if item.IsPc == 1 {
  1490. var res FJ3507Result
  1491. var struct3507 models.Struct3507
  1492. struct3507.FixmedinsBchno = item.Bchno
  1493. struct3507.InvDataType = "1"
  1494. struct3507.Opter = roles.UserName
  1495. struct3507.OrgName = miConfig.OrgName
  1496. struct3507.AccessKey = miConfig.AccessKey
  1497. struct3507.RequestUrl = miConfig.Url
  1498. struct3507.FixmedinsCode = miConfig.Code
  1499. struct3507.Code = miConfig.Code
  1500. struct3507.SecretKey = miConfig.SecretKey
  1501. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1502. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1503. struct3507.Url = miConfig.Url
  1504. struct3507.AppId = miConfig.Cainfo
  1505. struct3507.AppSecret = miConfig.AppSecret
  1506. struct3507.Enckey = miConfig.EncKey
  1507. struct3507.SignKey = miConfig.SignKey
  1508. struct3507.SecretKey = miConfig.SecretKey
  1509. if miConfig.MdtrtareaAdmvs == "350500" {
  1510. result, result1, _ := service.FJyb3507(struct3507)
  1511. saveLog(result, result1, "3507", "3507")
  1512. var respJSON2 map[string]interface{}
  1513. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1514. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1516. return
  1517. }
  1518. userJSONBytes2, _ := json.Marshal(respJSON2)
  1519. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1520. utils.ErrorLog("解析失败:%v", err)
  1521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1522. return
  1523. }
  1524. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  1525. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  1526. saveLog(result2, result1, "3507", "3507")
  1527. var respJSON2 map[string]interface{}
  1528. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  1529. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1531. return
  1532. }
  1533. userJSONBytes2, _ := json.Marshal(respJSON2)
  1534. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1535. utils.ErrorLog("解析失败:%v", err)
  1536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1537. return
  1538. }
  1539. } else {
  1540. data := make(map[string]interface{})
  1541. data["struct_3507s"] = struct3507
  1542. client := &http.Client{}
  1543. bytesData, _ := json.Marshal(data)
  1544. var req *http.Request
  1545. if miConfig.MdtrtareaAdmvs == "320830" {
  1546. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1547. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1548. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1549. } else {
  1550. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1551. }
  1552. resp, _ := client.Do(req)
  1553. defer resp.Body.Close()
  1554. body, ioErr := ioutil.ReadAll(resp.Body)
  1555. if ioErr != nil {
  1556. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1557. }
  1558. var respJSON map[string]interface{}
  1559. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1560. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1562. return
  1563. }
  1564. var resSix10265 ResultSix10265 //1101结果
  1565. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1566. result, _ := json.Marshal(respJSON)
  1567. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1568. utils.ErrorLog("解析失败:%v", err)
  1569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1570. return
  1571. }
  1572. res.InfRefmsgid = resSix10265.InfRefmsgid
  1573. //res.Output = resSix10265.Output
  1574. res.ErrMsg = resSix10265.ErrMsg
  1575. res.Cainfo = resSix10265.Cainfo
  1576. res.WarnMsg = resSix10265.WarnMsg
  1577. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1578. res.Infcode = infocode
  1579. }
  1580. if res.Infcode == 0 {
  1581. item.IsPc = 0
  1582. service.SaveW(item)
  1583. } else {
  1584. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1585. }
  1586. }
  1587. }
  1588. if len(err) == 0 {
  1589. c.ServeSuccessJSON(map[string]interface{}{
  1590. "msg": "删除盘存变更成功",
  1591. })
  1592. } else {
  1593. c.ServeSuccessJSON(map[string]interface{}{
  1594. "failed_code": -10,
  1595. "msg": err,
  1596. })
  1597. }
  1598. }
  1599. func (c *HisApiController) DeleteXSandBG() {
  1600. ids := c.GetString("ids")
  1601. id_arr := strings.Split(ids, ",")
  1602. admin_user_id, _ := c.GetInt64("admin_user_id")
  1603. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  1604. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1605. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1606. var err []string
  1607. for _, item := range flows {
  1608. if item.IsSale == 1 && item.IsChange == 1 {
  1609. var res FJ3507Result
  1610. var res2 FJ3507Result
  1611. var struct3507 models.Struct3507
  1612. struct3507.FixmedinsBchno = item.Bchno
  1613. struct3507.InvDataType = "4"
  1614. struct3507.Opter = roles.UserName
  1615. struct3507.OrgName = miConfig.OrgName
  1616. struct3507.AccessKey = miConfig.AccessKey
  1617. struct3507.RequestUrl = miConfig.Url
  1618. struct3507.FixmedinsCode = miConfig.Code
  1619. struct3507.SecretKey = miConfig.SecretKey
  1620. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1621. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1622. struct3507.Url = miConfig.Url
  1623. struct3507.AppId = miConfig.Cainfo
  1624. struct3507.AppSecret = miConfig.AppSecret
  1625. struct3507.Enckey = miConfig.EncKey
  1626. struct3507.SignKey = miConfig.SignKey
  1627. struct3507.SecretKey = miConfig.SecretKey
  1628. //result, result1, _ := service.FJyb3507(struct3507)
  1629. //saveLog(result, result1, "3507", "3507")
  1630. if miConfig.MdtrtareaAdmvs == "350500" {
  1631. result, result1, _ := service.FJyb3507(struct3507)
  1632. saveLog(result, result1, "3507", "3507")
  1633. var respJSON2 map[string]interface{}
  1634. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1635. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1637. return
  1638. }
  1639. userJSONBytes2, _ := json.Marshal(respJSON2)
  1640. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1641. utils.ErrorLog("解析失败:%v", err)
  1642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1643. return
  1644. }
  1645. } else {
  1646. data := make(map[string]interface{})
  1647. data["struct_3507s"] = struct3507
  1648. client := &http.Client{}
  1649. bytesData, _ := json.Marshal(data)
  1650. var req *http.Request
  1651. if miConfig.MdtrtareaAdmvs == "320830" {
  1652. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1653. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1654. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1655. } else {
  1656. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1657. }
  1658. resp, _ := client.Do(req)
  1659. defer resp.Body.Close()
  1660. body, ioErr := ioutil.ReadAll(resp.Body)
  1661. if ioErr != nil {
  1662. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1663. }
  1664. var respJSON map[string]interface{}
  1665. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1666. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1668. return
  1669. }
  1670. var resSix10265 ResultSix10265 //1101结果
  1671. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1672. result, _ := json.Marshal(respJSON)
  1673. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1674. utils.ErrorLog("解析失败:%v", err)
  1675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1676. return
  1677. }
  1678. res.InfRefmsgid = resSix10265.InfRefmsgid
  1679. //res.Output = resSix10265.Output
  1680. res.ErrMsg = resSix10265.ErrMsg
  1681. res.Cainfo = resSix10265.Cainfo
  1682. res.WarnMsg = resSix10265.WarnMsg
  1683. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1684. res.Infcode = infocode
  1685. }
  1686. if res.Infcode == 0 {
  1687. item.IsSale = 0
  1688. item.SaleDate = ""
  1689. item.Bchno = ""
  1690. err2 := service.SaveDF(item)
  1691. if err2 == nil {
  1692. var struct3507_2 models.Struct3507
  1693. struct3507_2.OrgName = miConfig.OrgName
  1694. struct3507_2.AccessKey = miConfig.AccessKey
  1695. struct3507_2.RequestUrl = miConfig.Url
  1696. struct3507_2.Opter = roles.UserName
  1697. struct3507_2.FixmedinsCode = miConfig.Code
  1698. struct3507_2.Code = miConfig.Code
  1699. struct3507_2.SecretKey = miConfig.SecretKey
  1700. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1701. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1702. struct3507_2.Url = miConfig.Url
  1703. struct3507_2.AppId = miConfig.Cainfo
  1704. struct3507_2.AppSecret = miConfig.AppSecret
  1705. struct3507_2.Enckey = miConfig.EncKey
  1706. struct3507_2.SignKey = miConfig.SignKey
  1707. struct3507_2.SecretKey = miConfig.SecretKey
  1708. struct3507_2.FixmedinsBchno = item.BgBchno
  1709. struct3507_2.InvDataType = "2"
  1710. if miConfig.MdtrtareaAdmvs == "350500" {
  1711. result11, result22, _ := service.FJyb3507(struct3507_2)
  1712. saveLog(result11, result22, "3507", "3507")
  1713. var respJSON3 map[string]interface{}
  1714. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1715. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1717. return
  1718. }
  1719. userJSONBytes3, _ := json.Marshal(respJSON3)
  1720. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1721. utils.ErrorLog("解析失败:%v", err)
  1722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1723. return
  1724. }
  1725. } else {
  1726. data := make(map[string]interface{})
  1727. data["struct_3507s"] = struct3507_2
  1728. client := &http.Client{}
  1729. bytesData, _ := json.Marshal(data)
  1730. var req *http.Request
  1731. if miConfig.MdtrtareaAdmvs == "320830" {
  1732. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1733. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1734. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1735. } else {
  1736. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1737. }
  1738. resp, _ := client.Do(req)
  1739. defer resp.Body.Close()
  1740. body, ioErr := ioutil.ReadAll(resp.Body)
  1741. if ioErr != nil {
  1742. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1743. }
  1744. var respJSON map[string]interface{}
  1745. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1746. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1748. return
  1749. }
  1750. var resSix10265 ResultSix10265 //1101结果
  1751. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1752. result, _ := json.Marshal(respJSON)
  1753. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1754. utils.ErrorLog("解析失败:%v", err)
  1755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1756. return
  1757. }
  1758. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1759. //res.Output = resSix10265.Output
  1760. res2.ErrMsg = resSix10265.ErrMsg
  1761. res2.Cainfo = resSix10265.Cainfo
  1762. res2.WarnMsg = resSix10265.WarnMsg
  1763. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1764. res2.Infcode = infocode
  1765. }
  1766. if res2.Infcode == 0 {
  1767. item.IsChange = 0
  1768. item.BgBchno = ""
  1769. service.SaveDF2(item)
  1770. } else {
  1771. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1772. }
  1773. }
  1774. } else {
  1775. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1776. }
  1777. }
  1778. if item.IsSale == 2 && item.IsChange == 1 {
  1779. var res FJ3507Result
  1780. var res2 FJ3507Result
  1781. var struct3507 models.Struct3507
  1782. struct3507.FixmedinsBchno = item.Bchno
  1783. struct3507.InvDataType = "4"
  1784. struct3507.Opter = roles.UserName
  1785. struct3507.OrgName = miConfig.OrgName
  1786. struct3507.AccessKey = miConfig.AccessKey
  1787. struct3507.RequestUrl = miConfig.Url
  1788. struct3507.FixmedinsCode = miConfig.Code
  1789. struct3507.Code = miConfig.Code
  1790. struct3507.SecretKey = miConfig.SecretKey
  1791. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1792. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1793. struct3507.Url = miConfig.Url
  1794. struct3507.AppId = miConfig.Cainfo
  1795. struct3507.AppSecret = miConfig.AppSecret
  1796. struct3507.Enckey = miConfig.EncKey
  1797. struct3507.SignKey = miConfig.SignKey
  1798. struct3507.SecretKey = miConfig.SecretKey
  1799. //result, result1, _ := service.FJyb3507(struct3507)
  1800. //saveLog(result, result1, "3507", "3507")
  1801. //
  1802. //var respJSON2 map[string]interface{}
  1803. //if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1804. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1805. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1806. // return
  1807. //}
  1808. //userJSONBytes2, _ := json.Marshal(respJSON2)
  1809. //if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1810. // utils.ErrorLog("解析失败:%v", err)
  1811. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1812. // return
  1813. //}
  1814. if miConfig.MdtrtareaAdmvs == "350500" {
  1815. result, result1, _ := service.FJyb3507(struct3507)
  1816. saveLog(result, result1, "3507", "3507")
  1817. var respJSON2 map[string]interface{}
  1818. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1819. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1821. return
  1822. }
  1823. userJSONBytes2, _ := json.Marshal(respJSON2)
  1824. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1825. utils.ErrorLog("解析失败:%v", err)
  1826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1827. return
  1828. }
  1829. } else {
  1830. data := make(map[string]interface{})
  1831. data["struct_3507s"] = struct3507
  1832. client := &http.Client{}
  1833. bytesData, _ := json.Marshal(data)
  1834. var req *http.Request
  1835. if miConfig.MdtrtareaAdmvs == "320830" {
  1836. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1837. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1838. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1839. } else {
  1840. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1841. }
  1842. resp, _ := client.Do(req)
  1843. defer resp.Body.Close()
  1844. body, ioErr := ioutil.ReadAll(resp.Body)
  1845. if ioErr != nil {
  1846. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1847. }
  1848. var respJSON map[string]interface{}
  1849. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1850. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1852. return
  1853. }
  1854. var resSix10265 ResultSix10265 //1101结果
  1855. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1856. result, _ := json.Marshal(respJSON)
  1857. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1858. utils.ErrorLog("解析失败:%v", err)
  1859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1860. return
  1861. }
  1862. res.InfRefmsgid = resSix10265.InfRefmsgid
  1863. //res.Output = resSix10265.Output
  1864. res.ErrMsg = resSix10265.ErrMsg
  1865. res.Cainfo = resSix10265.Cainfo
  1866. res.WarnMsg = resSix10265.WarnMsg
  1867. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1868. res.Infcode = infocode
  1869. }
  1870. if res.Infcode == 0 {
  1871. item.IsSale = 0
  1872. item.SaleDate = ""
  1873. item.Bchno = ""
  1874. err2 := service.SaveDF(item)
  1875. if err2 == nil {
  1876. var struct3507_2 models.Struct3507
  1877. struct3507_2.OrgName = miConfig.OrgName
  1878. struct3507_2.AccessKey = miConfig.AccessKey
  1879. struct3507_2.RequestUrl = miConfig.Url
  1880. struct3507_2.Opter = roles.UserName
  1881. struct3507_2.FixmedinsCode = miConfig.Code
  1882. struct3507_2.Code = miConfig.Code
  1883. struct3507_2.SecretKey = miConfig.SecretKey
  1884. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1885. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1886. struct3507_2.Url = miConfig.Url
  1887. struct3507_2.AppId = miConfig.Cainfo
  1888. struct3507_2.AppSecret = miConfig.AppSecret
  1889. struct3507_2.Enckey = miConfig.EncKey
  1890. struct3507_2.SignKey = miConfig.SignKey
  1891. struct3507_2.SecretKey = miConfig.SecretKey
  1892. struct3507_2.FixmedinsBchno = item.BgBchno
  1893. struct3507_2.InvDataType = "2"
  1894. //result11, result22, _ := service.FJyb3507(struct3507_2)
  1895. //saveLog(result11, result22, "3507", "3507")
  1896. //var respJSON3 map[string]interface{}
  1897. //if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1898. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1899. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1900. // return
  1901. //}
  1902. //userJSONBytes3, _ := json.Marshal(respJSON3)
  1903. //if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1904. // utils.ErrorLog("解析失败:%v", err)
  1905. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1906. // return
  1907. //}
  1908. if miConfig.MdtrtareaAdmvs == "350500" {
  1909. result11, result22, _ := service.FJyb3507(struct3507_2)
  1910. saveLog(result11, result22, "3507", "3507")
  1911. var respJSON3 map[string]interface{}
  1912. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1913. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1915. return
  1916. }
  1917. userJSONBytes3, _ := json.Marshal(respJSON3)
  1918. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1919. utils.ErrorLog("解析失败:%v", err)
  1920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1921. return
  1922. }
  1923. } else {
  1924. data := make(map[string]interface{})
  1925. data["struct_3507s"] = struct3507_2
  1926. client := &http.Client{}
  1927. bytesData, _ := json.Marshal(data)
  1928. var req *http.Request
  1929. if miConfig.MdtrtareaAdmvs == "320830" {
  1930. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  1931. } else if miConfig.MdtrtareaAdmvs == "320921" {
  1932. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1933. } else {
  1934. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  1935. }
  1936. resp, _ := client.Do(req)
  1937. defer resp.Body.Close()
  1938. body, ioErr := ioutil.ReadAll(resp.Body)
  1939. if ioErr != nil {
  1940. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1941. }
  1942. var respJSON map[string]interface{}
  1943. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1944. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1946. return
  1947. }
  1948. var resSix10265 ResultSix10265 //1101结果
  1949. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1950. result, _ := json.Marshal(respJSON)
  1951. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  1952. utils.ErrorLog("解析失败:%v", err)
  1953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1954. return
  1955. }
  1956. res2.InfRefmsgid = resSix10265.InfRefmsgid
  1957. //res.Output = resSix10265.Output
  1958. res2.ErrMsg = resSix10265.ErrMsg
  1959. res2.Cainfo = resSix10265.Cainfo
  1960. res2.WarnMsg = resSix10265.WarnMsg
  1961. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  1962. res2.Infcode = infocode
  1963. }
  1964. if res2.Infcode == 0 {
  1965. item.IsChange = 0
  1966. item.BgBchno = ""
  1967. service.SaveDF2(item)
  1968. } else {
  1969. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1970. }
  1971. }
  1972. } else {
  1973. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1974. }
  1975. }
  1976. if item.IsSale == 1 && item.IsChange == 0 {
  1977. var res FJ3507Result
  1978. var struct3507 models.Struct3507
  1979. struct3507.FixmedinsBchno = item.Bchno
  1980. struct3507.InvDataType = "4"
  1981. struct3507.Opter = roles.UserName
  1982. struct3507.FixmedinsCode = miConfig.Code
  1983. struct3507.Code = miConfig.Code
  1984. struct3507.OrgName = miConfig.OrgName
  1985. struct3507.AccessKey = miConfig.AccessKey
  1986. struct3507.RequestUrl = miConfig.Url
  1987. struct3507.SecretKey = miConfig.SecretKey
  1988. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1989. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1990. struct3507.Url = miConfig.Url
  1991. struct3507.AppId = miConfig.Cainfo
  1992. struct3507.AppSecret = miConfig.AppSecret
  1993. struct3507.Enckey = miConfig.EncKey
  1994. struct3507.SignKey = miConfig.SignKey
  1995. struct3507.SecretKey = miConfig.SecretKey
  1996. //result, result1, _ := service.FJyb3507(struct3507)
  1997. //saveLog(result, result1, "3507", "3507")
  1998. //
  1999. //var respJSON3 map[string]interface{}
  2000. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2001. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2002. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2003. // return
  2004. //}
  2005. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2006. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2007. // utils.ErrorLog("解析失败:%v", err)
  2008. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2009. // return
  2010. //}
  2011. if miConfig.MdtrtareaAdmvs == "350500" {
  2012. result, result1, _ := service.FJyb3507(struct3507)
  2013. saveLog(result, result1, "3507", "3507")
  2014. var respJSON2 map[string]interface{}
  2015. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2016. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2018. return
  2019. }
  2020. userJSONBytes2, _ := json.Marshal(respJSON2)
  2021. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2022. utils.ErrorLog("解析失败:%v", err)
  2023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2024. return
  2025. }
  2026. } else {
  2027. data := make(map[string]interface{})
  2028. data["struct_3507s"] = struct3507
  2029. client := &http.Client{}
  2030. bytesData, _ := json.Marshal(data)
  2031. var req *http.Request
  2032. if miConfig.MdtrtareaAdmvs == "320830" {
  2033. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2034. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2035. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2036. } else {
  2037. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2038. }
  2039. resp, _ := client.Do(req)
  2040. defer resp.Body.Close()
  2041. body, ioErr := ioutil.ReadAll(resp.Body)
  2042. if ioErr != nil {
  2043. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2044. }
  2045. var respJSON map[string]interface{}
  2046. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2047. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2049. return
  2050. }
  2051. var resSix10265 ResultSix10265 //1101结果
  2052. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2053. result, _ := json.Marshal(respJSON)
  2054. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2055. utils.ErrorLog("解析失败:%v", err)
  2056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2057. return
  2058. }
  2059. res.InfRefmsgid = resSix10265.InfRefmsgid
  2060. //res.Output = resSix10265.Output
  2061. res.ErrMsg = resSix10265.ErrMsg
  2062. res.Cainfo = resSix10265.Cainfo
  2063. res.WarnMsg = resSix10265.WarnMsg
  2064. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2065. res.Infcode = infocode
  2066. }
  2067. if res.Infcode == 0 {
  2068. item.IsSale = 0
  2069. item.SaleDate = ""
  2070. service.SaveDF(item)
  2071. } else {
  2072. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2073. }
  2074. }
  2075. if item.IsSale == 2 && item.IsChange == 0 {
  2076. var res FJ3507Result
  2077. var struct3507 models.Struct3507
  2078. struct3507.FixmedinsBchno = item.Bchno
  2079. struct3507.InvDataType = "4"
  2080. struct3507.Opter = roles.UserName
  2081. struct3507.FixmedinsCode = miConfig.Code
  2082. struct3507.Code = miConfig.Code
  2083. struct3507.OrgName = miConfig.OrgName
  2084. struct3507.AccessKey = miConfig.AccessKey
  2085. struct3507.RequestUrl = miConfig.Url
  2086. struct3507.SecretKey = miConfig.SecretKey
  2087. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2088. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2089. struct3507.Url = miConfig.Url
  2090. struct3507.AppId = miConfig.Cainfo
  2091. struct3507.AppSecret = miConfig.AppSecret
  2092. struct3507.Enckey = miConfig.EncKey
  2093. struct3507.SignKey = miConfig.SignKey
  2094. struct3507.SecretKey = miConfig.SecretKey
  2095. //result, result1, _ := service.FJyb3507(struct3507)
  2096. //saveLog(result, result1, "3507", "3507")
  2097. //
  2098. //var respJSON3 map[string]interface{}
  2099. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2100. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2101. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2102. // return
  2103. //}
  2104. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2105. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2106. // utils.ErrorLog("解析失败:%v", err)
  2107. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2108. // return
  2109. //}
  2110. if miConfig.MdtrtareaAdmvs == "350500" {
  2111. result, result1, _ := service.FJyb3507(struct3507)
  2112. saveLog(result, result1, "3507", "3507")
  2113. var respJSON2 map[string]interface{}
  2114. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2115. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2117. return
  2118. }
  2119. userJSONBytes2, _ := json.Marshal(respJSON2)
  2120. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2121. utils.ErrorLog("解析失败:%v", err)
  2122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2123. return
  2124. }
  2125. } else {
  2126. data := make(map[string]interface{})
  2127. data["struct_3507s"] = struct3507
  2128. client := &http.Client{}
  2129. bytesData, _ := json.Marshal(data)
  2130. var req *http.Request
  2131. if miConfig.MdtrtareaAdmvs == "320830" {
  2132. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2133. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2134. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2135. } else {
  2136. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2137. }
  2138. resp, _ := client.Do(req)
  2139. defer resp.Body.Close()
  2140. body, ioErr := ioutil.ReadAll(resp.Body)
  2141. if ioErr != nil {
  2142. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2143. }
  2144. var respJSON map[string]interface{}
  2145. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2146. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2148. return
  2149. }
  2150. var resSix10265 ResultSix10265 //1101结果
  2151. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2152. result, _ := json.Marshal(respJSON)
  2153. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2154. utils.ErrorLog("解析失败:%v", err)
  2155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2156. return
  2157. }
  2158. res.InfRefmsgid = resSix10265.InfRefmsgid
  2159. //res.Output = resSix10265.Output
  2160. res.ErrMsg = resSix10265.ErrMsg
  2161. res.Cainfo = resSix10265.Cainfo
  2162. res.WarnMsg = resSix10265.WarnMsg
  2163. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2164. res.Infcode = infocode
  2165. }
  2166. if res.Infcode == 0 {
  2167. item.IsSale = 0
  2168. item.SaleDate = ""
  2169. item.Bchno = ""
  2170. service.SaveDF(item)
  2171. } else {
  2172. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2173. }
  2174. }
  2175. if item.IsSale == 0 && item.IsChange == 1 {
  2176. var res FJ3507Result
  2177. var struct3507 models.Struct3507
  2178. struct3507.FixmedinsBchno = item.BgBchno
  2179. struct3507.InvDataType = "2"
  2180. struct3507.Opter = roles.UserName
  2181. struct3507.FixmedinsCode = miConfig.Code
  2182. struct3507.Code = miConfig.Code
  2183. struct3507.OrgName = miConfig.OrgName
  2184. struct3507.AccessKey = miConfig.AccessKey
  2185. struct3507.RequestUrl = miConfig.Url
  2186. struct3507.SecretKey = miConfig.SecretKey
  2187. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2188. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2189. struct3507.Url = miConfig.Url
  2190. struct3507.AppId = miConfig.Cainfo
  2191. struct3507.AppSecret = miConfig.AppSecret
  2192. struct3507.Enckey = miConfig.EncKey
  2193. struct3507.SignKey = miConfig.SignKey
  2194. struct3507.SecretKey = miConfig.SecretKey
  2195. //result, result1, _ := service.FJyb3507(struct3507)
  2196. //saveLog(result, result1, "3507", "3507")
  2197. //
  2198. //var respJSON3 map[string]interface{}
  2199. //if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  2200. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2201. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2202. // return
  2203. //}
  2204. //userJSONBytes3, _ := json.Marshal(respJSON3)
  2205. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  2206. // utils.ErrorLog("解析失败:%v", err)
  2207. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2208. // return
  2209. //}
  2210. if miConfig.MdtrtareaAdmvs == "350500" {
  2211. result, result1, _ := service.FJyb3507(struct3507)
  2212. saveLog(result, result1, "3507", "3507")
  2213. var respJSON2 map[string]interface{}
  2214. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2215. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2217. return
  2218. }
  2219. userJSONBytes2, _ := json.Marshal(respJSON2)
  2220. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2221. utils.ErrorLog("解析失败:%v", err)
  2222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2223. return
  2224. }
  2225. } else {
  2226. data := make(map[string]interface{})
  2227. data["struct_3507s"] = struct3507
  2228. client := &http.Client{}
  2229. bytesData, _ := json.Marshal(data)
  2230. var req *http.Request
  2231. if miConfig.MdtrtareaAdmvs == "320830" {
  2232. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2233. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2234. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2235. } else {
  2236. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2237. }
  2238. resp, _ := client.Do(req)
  2239. defer resp.Body.Close()
  2240. body, ioErr := ioutil.ReadAll(resp.Body)
  2241. if ioErr != nil {
  2242. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2243. }
  2244. var respJSON map[string]interface{}
  2245. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2246. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2248. return
  2249. }
  2250. var resSix10265 ResultSix10265 //1101结果
  2251. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2252. result, _ := json.Marshal(respJSON)
  2253. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2254. utils.ErrorLog("解析失败:%v", err)
  2255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2256. return
  2257. }
  2258. res.InfRefmsgid = resSix10265.InfRefmsgid
  2259. //res.Output = resSix10265.Output
  2260. res.ErrMsg = resSix10265.ErrMsg
  2261. res.Cainfo = resSix10265.Cainfo
  2262. res.WarnMsg = resSix10265.WarnMsg
  2263. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2264. res.Infcode = infocode
  2265. }
  2266. if res.Infcode == 0 {
  2267. item.IsChange = 0
  2268. item.BgBchno = ""
  2269. service.SaveDF2(item)
  2270. } else {
  2271. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  2272. }
  2273. }
  2274. }
  2275. if len(err) == 0 {
  2276. c.ServeSuccessJSON(map[string]interface{}{
  2277. "msg": "删除销售变更成功",
  2278. })
  2279. } else {
  2280. c.ServeSuccessJSON(map[string]interface{}{
  2281. "failed_code": -10,
  2282. "msg": err,
  2283. })
  2284. }
  2285. }
  2286. //func (c *HisApiController) BatchFJ3501AND3502() {
  2287. // //ids := c.GetString("ids")
  2288. // start_time := c.GetString("start_time")
  2289. // end_time := c.GetString("end_time")
  2290. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2291. //
  2292. //
  2293. // timeLayout := "2006-01-02"
  2294. // loc, _ := time.LoadLocation("Local")
  2295. // startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  2296. // endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  2297. //
  2298. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2299. // //id_arr := strings.Split(ids, ",")
  2300. // drugs, _ := service.GetNewDrugWarehouseInfobytime(c.GetAdminUserInfo().CurrentOrgId, startime,endtime)
  2301. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2302. // //库盘
  2303. // var errs []string
  2304. // for _, drug := range drugs {
  2305. // if drug.IsPc == 0 && drug.IsBg == 0 {
  2306. // var res2 ResultSix
  2307. // var res3 ResultSix
  2308. //
  2309. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  2310. // var struct3501 models.Struct3501
  2311. // struct3501.Code = miConfig.Code
  2312. // struct3501.OrgName = miConfig.OrgName
  2313. // struct3501.AccessKey = miConfig.AccessKey
  2314. // struct3501.Opter = roles.UserName
  2315. // struct3501.RequestUrl = miConfig.Url
  2316. // struct3501.Url = miConfig.Url
  2317. // struct3501.AppId = miConfig.Cainfo
  2318. // struct3501.AppSecret = miConfig.AppSecret
  2319. // struct3501.Enckey = miConfig.EncKey
  2320. // struct3501.SignKey = miConfig.SignKey
  2321. // struct3501.SecretKey = miConfig.SecretKey
  2322. // struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2323. // struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2324. // struct3501.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2325. // struct3501.RxFlag = "1"
  2326. // struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  2327. // struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  2328. //
  2329. // struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2330. // struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2331. // struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  2332. // struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  2333. // struct3501.FixmedinsBchno = number
  2334. // struct3501.DrugTracCodg = drug.DrugCode
  2335. // memo := make(map[string]interface{})
  2336. // memo["pric"] = drug.Price
  2337. // bytesData, _ := json.Marshal(memo)
  2338. // struct3501.Memo = string(bytesData)
  2339. //
  2340. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") { //福建
  2341. //
  2342. // result1, result2, _ := service.FJyb3501(struct3501)
  2343. // saveLog(result1, result2, "3501", "3501")
  2344. // //saveLog(result, requestLog, "2201", "挂号")
  2345. //
  2346. // var respJSON2 map[string]interface{}
  2347. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2348. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2349. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2350. // return
  2351. // }
  2352. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2353. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2354. // utils.ErrorLog("解析失败:%v", err)
  2355. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2356. // return
  2357. // }
  2358. //
  2359. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") { //江苏
  2360. // data := make(map[string]interface{})
  2361. // data["struct_3501s"] = struct3501
  2362. // client := &http.Client{}
  2363. // bytesData, _ := json.Marshal(data)
  2364. // var req *http.Request
  2365. // if miConfig.MdtrtareaAdmvs == "320921" {
  2366. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2367. // } else {
  2368. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  2369. // }
  2370. //
  2371. // resp, _ := client.Do(req)
  2372. // defer resp.Body.Close()
  2373. // body, ioErr := ioutil.ReadAll(resp.Body)
  2374. // if ioErr != nil {
  2375. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2376. // }
  2377. // var respJSON map[string]interface{}
  2378. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2379. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2380. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2381. // return
  2382. // }
  2383. // var resSix10265 ResultSix10265 //1101结果
  2384. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2385. // result, _ := json.Marshal(respJSON)
  2386. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2387. // utils.ErrorLog("解析失败:%v", err)
  2388. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2389. // return
  2390. // }
  2391. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2392. // res2.Output = resSix10265.Output
  2393. // res2.ErrMsg = resSix10265.ErrMsg
  2394. // res2.Cainfo = resSix10265.Cainfo
  2395. // res2.WarnMsg = resSix10265.WarnMsg
  2396. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2397. // res2.Infcode = infocode
  2398. //
  2399. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") { //安徽
  2400. // data := make(map[string]interface{})
  2401. // data["struct_3501s"] = struct3501
  2402. // client := &http.Client{}
  2403. // bytesData, _ := json.Marshal(data)
  2404. // var req *http.Request
  2405. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2406. // resp, _ := client.Do(req)
  2407. // defer resp.Body.Close()
  2408. // body, ioErr := ioutil.ReadAll(resp.Body)
  2409. // if ioErr != nil {
  2410. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2411. // }
  2412. // var respJSON map[string]interface{}
  2413. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2414. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2415. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2416. // return
  2417. // }
  2418. // var resSix10265 ResultSix10265 //1101结果
  2419. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2420. // result, _ := json.Marshal(respJSON)
  2421. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2422. // utils.ErrorLog("解析失败:%v", err)
  2423. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2424. // return
  2425. // }
  2426. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2427. // res2.Output = resSix10265.Output
  2428. // res2.ErrMsg = resSix10265.ErrMsg
  2429. // res2.Cainfo = resSix10265.Cainfo
  2430. // res2.WarnMsg = resSix10265.WarnMsg
  2431. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2432. // res2.Infcode = infocode
  2433. //
  2434. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") { //内蒙
  2435. // data := make(map[string]interface{})
  2436. // data["struct_3501s"] = struct3501
  2437. // client := &http.Client{}
  2438. // bytesData, _ := json.Marshal(data)
  2439. // var req *http.Request
  2440. // req, _ = http.NewRequest("POST", miConfig.Url+"nmyb/3501", bytes.NewReader(bytesData))
  2441. // resp, _ := client.Do(req)
  2442. // defer resp.Body.Close()
  2443. // body, ioErr := ioutil.ReadAll(resp.Body)
  2444. // if ioErr != nil {
  2445. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2446. // }
  2447. // var respJSON map[string]interface{}
  2448. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2449. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2450. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2451. // return
  2452. // }
  2453. // var resSix10265 ResultSix10265 //1101结果
  2454. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2455. // result, _ := json.Marshal(respJSON)
  2456. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2457. // utils.ErrorLog("解析失败:%v", err)
  2458. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2459. // return
  2460. // }
  2461. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2462. // res2.Output = resSix10265.Output
  2463. // res2.ErrMsg = resSix10265.ErrMsg
  2464. // res2.Cainfo = resSix10265.Cainfo
  2465. // res2.WarnMsg = resSix10265.WarnMsg
  2466. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2467. // res2.Infcode = infocode
  2468. //
  2469. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") { //广东
  2470. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2471. // saveLog(result1, result2, "3501", "3501")
  2472. // //saveLog(result, requestLog, "2201", "挂号")
  2473. //
  2474. // var respJSON2 map[string]interface{}
  2475. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2476. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2477. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2478. // return
  2479. // }
  2480. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2481. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2482. // utils.ErrorLog("解析失败:%v", err)
  2483. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2484. // return
  2485. // }
  2486. //
  2487. // }
  2488. //
  2489. // if res2.Infcode != -1 {
  2490. // drug.IsPc = 1
  2491. // drug.Bchno = number
  2492. // drug.PcDate = time.Now().Unix()
  2493. // err := service.SaveW(drug)
  2494. // if err == nil {
  2495. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2496. // var struct3502 models.Struct3502
  2497. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2498. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2499. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2500. // struct3502.FixmedinsCode = miConfig.Code
  2501. // struct3502.Code = miConfig.Code
  2502. //
  2503. // struct3502.RxFlag = "0"
  2504. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2505. // struct3502.OrgName = miConfig.OrgName
  2506. // struct3502.Opter = roles.UserName
  2507. // struct3502.AccessKey = miConfig.AccessKey
  2508. // struct3502.RequestUrl = miConfig.Url
  2509. // struct3502.SecretKey = miConfig.SecretKey
  2510. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2511. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2512. // struct3502.Url = miConfig.Url
  2513. // struct3502.AppId = miConfig.Cainfo
  2514. // struct3502.AppSecret = miConfig.AppSecret
  2515. // struct3502.Enckey = miConfig.EncKey
  2516. // struct3502.SignKey = miConfig.SignKey
  2517. // struct3502.SecretKey = miConfig.SecretKey
  2518. // struct3502.DrugTracCodg = drug.DrugCode
  2519. //
  2520. // struct3502.Memo = ""
  2521. // struct3502.InvChgType = "108"
  2522. // struct3502.FixmedinsBchno = bg_number
  2523. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2524. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2525. //
  2526. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2527. // result11, result22, _ := service.FJyb3502(struct3502)
  2528. // saveLog(result11, result22, "3502", "3502")
  2529. //
  2530. // var respJSON3 map[string]interface{}
  2531. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2532. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2533. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2534. // return
  2535. // }
  2536. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2537. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2538. // utils.ErrorLog("解析失败:%v", err)
  2539. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2540. // return
  2541. // }
  2542. //
  2543. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2544. // data := make(map[string]interface{})
  2545. // data["struct_3502s"] = struct3502
  2546. // client := &http.Client{}
  2547. // bytesData, _ := json.Marshal(data)
  2548. // var req *http.Request
  2549. // if miConfig.MdtrtareaAdmvs == "320921" {
  2550. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2551. // } else {
  2552. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2553. // }
  2554. //
  2555. // resp, _ := client.Do(req)
  2556. // defer resp.Body.Close()
  2557. // body, ioErr := ioutil.ReadAll(resp.Body)
  2558. // if ioErr != nil {
  2559. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2560. // }
  2561. // var respJSON map[string]interface{}
  2562. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2563. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2564. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2565. // return
  2566. // }
  2567. // var resSix10265 ResultSix10265 //1101结果
  2568. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2569. // result, _ := json.Marshal(respJSON)
  2570. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2571. // utils.ErrorLog("解析失败:%v", err)
  2572. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2573. // return
  2574. // }
  2575. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2576. // res3.Output = resSix10265.Output
  2577. // res3.ErrMsg = resSix10265.ErrMsg
  2578. // res3.Cainfo = resSix10265.Cainfo
  2579. // res3.WarnMsg = resSix10265.WarnMsg
  2580. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2581. // res3.Infcode = infocode
  2582. //
  2583. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2584. //
  2585. // data := make(map[string]interface{})
  2586. // data["struct_3502s"] = struct3502
  2587. // client := &http.Client{}
  2588. // bytesData, _ := json.Marshal(data)
  2589. // var req *http.Request
  2590. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"nmyb/3502", bytes.NewReader(bytesData))
  2591. // resp, _ := client.Do(req)
  2592. // defer resp.Body.Close()
  2593. // body, ioErr := ioutil.ReadAll(resp.Body)
  2594. // if ioErr != nil {
  2595. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2596. // }
  2597. // var respJSON map[string]interface{}
  2598. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2599. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2600. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2601. // return
  2602. // }
  2603. // var resSix10265 ResultSix10265 //1101结果
  2604. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2605. // result, _ := json.Marshal(respJSON)
  2606. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2607. // utils.ErrorLog("解析失败:%v", err)
  2608. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2609. // return
  2610. // }
  2611. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2612. // res3.Output = resSix10265.Output
  2613. // res3.ErrMsg = resSix10265.ErrMsg
  2614. // res3.Cainfo = resSix10265.Cainfo
  2615. // res3.WarnMsg = resSix10265.WarnMsg
  2616. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2617. // res3.Infcode = infocode
  2618. //
  2619. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2620. //
  2621. // data := make(map[string]interface{})
  2622. // data["struct_3501s"] = struct3501
  2623. // client := &http.Client{}
  2624. // bytesData, _ := json.Marshal(data)
  2625. // var req *http.Request
  2626. // req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/3501", bytes.NewReader(bytesData))
  2627. // resp, _ := client.Do(req)
  2628. // defer resp.Body.Close()
  2629. // body, ioErr := ioutil.ReadAll(resp.Body)
  2630. // if ioErr != nil {
  2631. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2632. // }
  2633. // var respJSON map[string]interface{}
  2634. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2635. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2636. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2637. // return
  2638. // }
  2639. // var resSix10265 ResultSix10265 //1101结果
  2640. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2641. // result, _ := json.Marshal(respJSON)
  2642. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2643. // utils.ErrorLog("解析失败:%v", err)
  2644. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2645. // return
  2646. // }
  2647. // res2.InfRefmsgid = resSix10265.InfRefmsgid
  2648. // res2.Output = resSix10265.Output
  2649. // res2.ErrMsg = resSix10265.ErrMsg
  2650. // res2.Cainfo = resSix10265.Cainfo
  2651. // res2.WarnMsg = resSix10265.WarnMsg
  2652. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2653. // res2.Infcode = infocode
  2654. //
  2655. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2656. // result11, result22 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  2657. // saveLog(result11, result22, "3502", "3502")
  2658. //
  2659. // var respJSON3 map[string]interface{}
  2660. // if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  2661. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2662. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2663. // return
  2664. // }
  2665. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2666. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2667. // utils.ErrorLog("解析失败:%v", err)
  2668. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2669. // return
  2670. // }
  2671. // }
  2672. // if res3.Infcode == -1 {
  2673. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2674. // c.ServeSuccessJSON(map[string]interface{}{
  2675. // "failed_code": -10,
  2676. // "msg": res3.ErrMsg,
  2677. // })
  2678. // } else {
  2679. // drug.IsBg = 1
  2680. // drug.BgBchno = bg_number
  2681. // service.SaveW(drug)
  2682. // }
  2683. // }
  2684. // } else {
  2685. // errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  2686. // }
  2687. // }
  2688. // //变更
  2689. // if drug.IsPc == 1 && drug.IsBg == 0 {
  2690. // var res3 ResultSix
  2691. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  2692. //
  2693. // var struct3502 models.Struct3502
  2694. // struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  2695. // struct3502.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  2696. // struct3502.FixmedinsHilistName = drug.BaseDrugLib.DrugName
  2697. // struct3502.FixmedinsCode = miConfig.Code
  2698. // struct3502.Code = miConfig.Code
  2699. //
  2700. // struct3502.Opter = roles.UserName
  2701. // struct3502.RxFlag = "0"
  2702. // struct3502.InvChgTime = time.Now().Format("2006-01-02")
  2703. // struct3502.OrgName = miConfig.OrgName
  2704. // struct3502.AccessKey = miConfig.AccessKey
  2705. // struct3502.RequestUrl = miConfig.Url
  2706. // struct3502.SecretKey = miConfig.SecretKey
  2707. // struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2708. // struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2709. // struct3502.InvChgType = "108"
  2710. // struct3502.DrugTracCodg = drug.DrugCode
  2711. //
  2712. // struct3502.Url = miConfig.Url
  2713. // struct3502.AppId = miConfig.Cainfo
  2714. // struct3502.AppSecret = miConfig.AppSecret
  2715. // struct3502.Enckey = miConfig.EncKey
  2716. // struct3502.SignKey = miConfig.SignKey
  2717. // struct3502.SecretKey = miConfig.SecretKey
  2718. //
  2719. // struct3502.FixmedinsBchno = bg_number
  2720. // struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  2721. // struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  2722. //
  2723. // if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "350") {
  2724. // result1, result2, _ := service.FJyb3502(struct3502)
  2725. // saveLog(result1, result2, "3502", "3502")
  2726. // var respJSON3 map[string]interface{}
  2727. // if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  2728. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2729. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2730. // return
  2731. // }
  2732. // userJSONBytes3, _ := json.Marshal(respJSON3)
  2733. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  2734. // utils.ErrorLog("解析失败:%v", err)
  2735. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2736. // return
  2737. // }
  2738. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "320") {
  2739. // data := make(map[string]interface{})
  2740. // data["struct_3502s"] = struct3502
  2741. // client := &http.Client{}
  2742. // bytesData, _ := json.Marshal(data)
  2743. // var req *http.Request
  2744. // if miConfig.MdtrtareaAdmvs == "320921" {
  2745. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2746. // } else {
  2747. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  2748. // }
  2749. // resp, _ := client.Do(req)
  2750. // defer resp.Body.Close()
  2751. // body, ioErr := ioutil.ReadAll(resp.Body)
  2752. // if ioErr != nil {
  2753. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2754. // }
  2755. // var respJSON map[string]interface{}
  2756. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2757. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2758. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2759. // return
  2760. // }
  2761. // var resSix10265 ResultSix10265 //1101结果
  2762. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2763. // result, _ := json.Marshal(respJSON)
  2764. // if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2765. // utils.ErrorLog("解析失败:%v", err)
  2766. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2767. // return
  2768. // }
  2769. // res3.InfRefmsgid = resSix10265.InfRefmsgid
  2770. // res3.Output = resSix10265.Output
  2771. // res3.ErrMsg = resSix10265.ErrMsg
  2772. // res3.Cainfo = resSix10265.Cainfo
  2773. // res3.WarnMsg = resSix10265.WarnMsg
  2774. // infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2775. // res3.Infcode = infocode
  2776. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "150") {
  2777. //
  2778. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "340") {
  2779. //
  2780. // } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "420") {
  2781. //
  2782. // }else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2783. //
  2784. // result1, result2 := service.Gdyb3501(struct3501, struct3501.SecretKey)
  2785. // saveLog(result1, result2, "3501", "3501")
  2786. // //saveLog(result, requestLog, "2201", "挂号")
  2787. //
  2788. // var respJSON2 map[string]interface{}
  2789. // if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2790. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2791. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2792. // return
  2793. // }
  2794. // userJSONBytes2, _ := json.Marshal(respJSON2)
  2795. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2796. // utils.ErrorLog("解析失败:%v", err)
  2797. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2798. // return
  2799. // }
  2800. //
  2801. // }
  2802. // if res3.Infcode == -1 {
  2803. // errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  2804. // } else {
  2805. // drug.IsBg = 1
  2806. // drug.BgBchno = bg_number
  2807. // service.SaveW(drug)
  2808. // }
  2809. // }
  2810. // }
  2811. //
  2812. // if len(errs) == 0 {
  2813. // c.ServeSuccessJSON(map[string]interface{}{
  2814. // "msg": "盘存变更成功",
  2815. // })
  2816. // } else {
  2817. // c.ServeSuccessJSON(map[string]interface{}{
  2818. // "failed_code": -10,
  2819. // "msg": errs,
  2820. // })
  2821. // }
  2822. //}
  2823. func (c *HisApiController) DeleteXSandBGTwo() {
  2824. patient_id, _ := c.GetInt64("patient_id")
  2825. admin_user_id, _ := c.GetInt64("admin_user_id")
  2826. times := c.GetString("time", "")
  2827. timeLayout := "2006-01-02"
  2828. loc, _ := time.LoadLocation("Local")
  2829. var stime, etime int64
  2830. if times == "" {
  2831. stime, etime = GetNowTime()
  2832. } else {
  2833. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  2834. stime = stmp.Unix()
  2835. etime = stime + 86399
  2836. }
  2837. advicelist, _ := service.FindUploadHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  2838. var flows []*models.DrugFlow
  2839. for _, item := range advicelist {
  2840. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  2841. flows = append(flows, flow...)
  2842. }
  2843. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  2844. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2845. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2846. var err []string
  2847. for _, item := range flows {
  2848. if item.IsSale == 1 {
  2849. var res FJ3507Result
  2850. var struct3507 models.Struct3507
  2851. struct3507.FixmedinsBchno = item.Bchno
  2852. struct3507.InvDataType = "4"
  2853. struct3507.Opter = roles.UserName
  2854. struct3507.OrgName = miConfig.OrgName
  2855. struct3507.AccessKey = miConfig.AccessKey
  2856. struct3507.RequestUrl = miConfig.Url
  2857. struct3507.FixmedinsCode = miConfig.Code
  2858. struct3507.SecretKey = miConfig.SecretKey
  2859. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2860. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2861. struct3507.Url = miConfig.Url
  2862. struct3507.AppId = miConfig.Cainfo
  2863. struct3507.AppSecret = miConfig.AppSecret
  2864. struct3507.Enckey = miConfig.EncKey
  2865. struct3507.SignKey = miConfig.SignKey
  2866. struct3507.SecretKey = miConfig.SecretKey
  2867. if miConfig.MdtrtareaAdmvs == "350500" {
  2868. result, result1, _ := service.FJyb3507(struct3507)
  2869. saveLog(result, result1, "3507", "3507")
  2870. var respJSON2 map[string]interface{}
  2871. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2872. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2874. return
  2875. }
  2876. userJSONBytes2, _ := json.Marshal(respJSON2)
  2877. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2878. utils.ErrorLog("解析失败:%v", err)
  2879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2880. return
  2881. }
  2882. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  2883. data := make(map[string]interface{})
  2884. data["struct_3507s"] = struct3507
  2885. client := &http.Client{}
  2886. bytesData, _ := json.Marshal(data)
  2887. var req *http.Request
  2888. if miConfig.MdtrtareaAdmvs == "320830" {
  2889. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  2890. } else if miConfig.MdtrtareaAdmvs == "320921" {
  2891. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2892. } else {
  2893. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  2894. }
  2895. resp, _ := client.Do(req)
  2896. defer resp.Body.Close()
  2897. body, ioErr := ioutil.ReadAll(resp.Body)
  2898. if ioErr != nil {
  2899. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2900. }
  2901. var respJSON map[string]interface{}
  2902. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2903. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2905. return
  2906. }
  2907. var resSix10265 ResultSix10265 //1101结果
  2908. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2909. result, _ := json.Marshal(respJSON)
  2910. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  2911. utils.ErrorLog("解析失败:%v", err)
  2912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2913. return
  2914. }
  2915. res.InfRefmsgid = resSix10265.InfRefmsgid
  2916. //res.Output = resSix10265.Output
  2917. res.ErrMsg = resSix10265.ErrMsg
  2918. res.Cainfo = resSix10265.Cainfo
  2919. res.WarnMsg = resSix10265.WarnMsg
  2920. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  2921. res.Infcode = infocode
  2922. } else if miConfig.MdtrtareaAdmvs == "440100" {
  2923. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  2924. saveLog(result2, result1, "3507", "3507")
  2925. var respJSON2 map[string]interface{}
  2926. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2927. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2929. return
  2930. }
  2931. userJSONBytes2, _ := json.Marshal(respJSON2)
  2932. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2933. utils.ErrorLog("解析失败:%v", err)
  2934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2935. return
  2936. }
  2937. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  2938. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  2939. saveLog(result2, result1, "3507", "3507")
  2940. var respJSON2 map[string]interface{}
  2941. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2942. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2944. return
  2945. }
  2946. userJSONBytes2, _ := json.Marshal(respJSON2)
  2947. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2948. utils.ErrorLog("解析失败:%v", err)
  2949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2950. return
  2951. }
  2952. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  2953. result1, result2 := service.Jxyb3507(struct3507)
  2954. saveLog(result2, result1, "3507", "3507")
  2955. var respJSON2 map[string]interface{}
  2956. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2957. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2959. return
  2960. }
  2961. userJSONBytes2, _ := json.Marshal(respJSON2)
  2962. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2963. utils.ErrorLog("解析失败:%v", err)
  2964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2965. return
  2966. }
  2967. } else if miConfig.MdtrtareaAdmvs == "340699" {
  2968. result1, result2 := service.AHyb3507(struct3507)
  2969. saveLog(result2, result1, "3507", "3507")
  2970. var respJSON2 map[string]interface{}
  2971. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  2972. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2974. return
  2975. }
  2976. userJSONBytes2, _ := json.Marshal(respJSON2)
  2977. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2978. utils.ErrorLog("解析失败:%v", err)
  2979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2980. return
  2981. }
  2982. } else if miConfig.MdtrtareaAdmvs == "150499" {
  2983. data := make(map[string]interface{})
  2984. data["struct_3507s"] = struct3507
  2985. client := &http.Client{}
  2986. bytesData, _ := json.Marshal(data)
  2987. var req *http.Request
  2988. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  2989. resp, _ := client.Do(req)
  2990. defer resp.Body.Close()
  2991. body, ioErr := ioutil.ReadAll(resp.Body)
  2992. if ioErr != nil {
  2993. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2994. }
  2995. var respJSON map[string]interface{}
  2996. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2997. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2998. }
  2999. var resSix10265 ResultSix10265 //1101结果
  3000. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3001. result, _ := json.Marshal(respJSON)
  3002. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3003. utils.ErrorLog("解析失败:%v", err)
  3004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3005. return
  3006. }
  3007. res.InfRefmsgid = resSix10265.InfRefmsgid
  3008. res.ErrMsg = resSix10265.ErrMsg
  3009. res.Cainfo = resSix10265.Cainfo
  3010. res.WarnMsg = resSix10265.WarnMsg
  3011. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3012. res.Infcode = infocode
  3013. }
  3014. if res.Infcode == 0 {
  3015. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  3016. item.IsSale = 0
  3017. item.SaleDate = ""
  3018. item.Bchno = ""
  3019. service.SaveDF(item)
  3020. } else {
  3021. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  3022. }
  3023. }
  3024. }
  3025. c.ServeSuccessJSON(map[string]interface{}{
  3026. "msg": "删除销售数据成功",
  3027. })
  3028. }
  3029. // 删除
  3030. func (c *HisApiController) DeleteXSandBGThree() {
  3031. id, _ := c.GetInt64("id")
  3032. admin_user_id, _ := c.GetInt64("admin_user_id")
  3033. advicelist, _ := service.FinddelHisAdviceDocAdvice(id)
  3034. var flows []*models.DrugFlow
  3035. for _, item := range advicelist {
  3036. flow, _ := service.GetNewUploadDrugFlowInfoByPatientTwo(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3037. flows = append(flows, flow...)
  3038. }
  3039. //flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3040. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3041. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3042. var err []string
  3043. for _, item := range flows {
  3044. if item.IsSale == 1 {
  3045. var res FJ3507Result
  3046. var struct3507 models.Struct3507
  3047. struct3507.FixmedinsBchno = item.Bchno
  3048. struct3507.InvDataType = "4"
  3049. struct3507.Opter = roles.UserName
  3050. struct3507.OrgName = miConfig.OrgName
  3051. struct3507.AccessKey = miConfig.AccessKey
  3052. struct3507.RequestUrl = miConfig.Url
  3053. struct3507.FixmedinsCode = miConfig.Code
  3054. struct3507.SecretKey = miConfig.SecretKey
  3055. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  3056. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  3057. struct3507.Url = miConfig.Url
  3058. struct3507.AppId = miConfig.Cainfo
  3059. struct3507.AppSecret = miConfig.AppSecret
  3060. struct3507.Enckey = miConfig.EncKey
  3061. struct3507.SignKey = miConfig.SignKey
  3062. struct3507.SecretKey = miConfig.SecretKey
  3063. if miConfig.MdtrtareaAdmvs == "350500" {
  3064. result, result1, _ := service.FJyb3507(struct3507)
  3065. saveLog(result, result1, "3507", "3507")
  3066. var respJSON2 map[string]interface{}
  3067. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3068. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3070. return
  3071. }
  3072. userJSONBytes2, _ := json.Marshal(respJSON2)
  3073. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3074. utils.ErrorLog("解析失败:%v", err)
  3075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3076. return
  3077. }
  3078. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  3079. data := make(map[string]interface{})
  3080. data["struct_3507s"] = struct3507
  3081. client := &http.Client{}
  3082. bytesData, _ := json.Marshal(data)
  3083. var req *http.Request
  3084. if miConfig.MdtrtareaAdmvs == "320830" {
  3085. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3507", bytes.NewReader(bytesData))
  3086. } else if miConfig.MdtrtareaAdmvs == "320921" {
  3087. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3088. } else {
  3089. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3507", bytes.NewReader(bytesData))
  3090. }
  3091. resp, _ := client.Do(req)
  3092. defer resp.Body.Close()
  3093. body, ioErr := ioutil.ReadAll(resp.Body)
  3094. if ioErr != nil {
  3095. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3096. }
  3097. var respJSON map[string]interface{}
  3098. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3099. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3101. return
  3102. }
  3103. var resSix10265 ResultSix10265 //1101结果
  3104. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3105. result, _ := json.Marshal(respJSON)
  3106. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3107. utils.ErrorLog("解析失败:%v", err)
  3108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3109. return
  3110. }
  3111. res.InfRefmsgid = resSix10265.InfRefmsgid
  3112. //res.Output = resSix10265.Output
  3113. res.ErrMsg = resSix10265.ErrMsg
  3114. res.Cainfo = resSix10265.Cainfo
  3115. res.WarnMsg = resSix10265.WarnMsg
  3116. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3117. res.Infcode = infocode
  3118. } else if miConfig.MdtrtareaAdmvs == "440100" {
  3119. result1, result2 := service.Gzyb3507(struct3507, struct3507.SecretKey)
  3120. saveLog(result2, result1, "3507", "3507")
  3121. var respJSON2 map[string]interface{}
  3122. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3123. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3125. return
  3126. }
  3127. userJSONBytes2, _ := json.Marshal(respJSON2)
  3128. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3129. utils.ErrorLog("解析失败:%v", err)
  3130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3131. return
  3132. }
  3133. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  3134. result1, result2 := service.Gdyb3507(struct3507, struct3507.SecretKey)
  3135. saveLog(result2, result1, "3507", "3507")
  3136. var respJSON2 map[string]interface{}
  3137. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3138. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3140. return
  3141. }
  3142. userJSONBytes2, _ := json.Marshal(respJSON2)
  3143. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3144. utils.ErrorLog("解析失败:%v", err)
  3145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3146. return
  3147. }
  3148. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  3149. result1, result2 := service.Jxyb3507(struct3507)
  3150. saveLog(result2, result1, "3507", "3507")
  3151. var respJSON2 map[string]interface{}
  3152. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3153. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3155. return
  3156. }
  3157. userJSONBytes2, _ := json.Marshal(respJSON2)
  3158. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3159. utils.ErrorLog("解析失败:%v", err)
  3160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3161. return
  3162. }
  3163. } else if miConfig.MdtrtareaAdmvs == "340699" {
  3164. result1, result2 := service.AHyb3507(struct3507)
  3165. saveLog(result2, result1, "3507", "3507")
  3166. var respJSON2 map[string]interface{}
  3167. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  3168. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3170. return
  3171. }
  3172. userJSONBytes2, _ := json.Marshal(respJSON2)
  3173. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3174. utils.ErrorLog("解析失败:%v", err)
  3175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3176. return
  3177. }
  3178. } else if miConfig.MdtrtareaAdmvs == "150499" {
  3179. data := make(map[string]interface{})
  3180. data["struct_3507s"] = struct3507
  3181. client := &http.Client{}
  3182. bytesData, _ := json.Marshal(data)
  3183. var req *http.Request
  3184. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3507", bytes.NewReader(bytesData))
  3185. resp, _ := client.Do(req)
  3186. defer resp.Body.Close()
  3187. body, ioErr := ioutil.ReadAll(resp.Body)
  3188. if ioErr != nil {
  3189. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3190. }
  3191. var respJSON map[string]interface{}
  3192. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3193. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3194. }
  3195. var resSix10265 ResultSix10265 //1101结果
  3196. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3197. result, _ := json.Marshal(respJSON)
  3198. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  3199. utils.ErrorLog("解析失败:%v", err)
  3200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3201. return
  3202. }
  3203. res.InfRefmsgid = resSix10265.InfRefmsgid
  3204. res.ErrMsg = resSix10265.ErrMsg
  3205. res.Cainfo = resSix10265.Cainfo
  3206. res.WarnMsg = resSix10265.WarnMsg
  3207. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  3208. res.Infcode = infocode
  3209. }
  3210. if res.Infcode == 0 {
  3211. service.SaveDoctoradviceStatusTwo(item.HisDoctorAdviceInfo.ID)
  3212. item.IsSale = 0
  3213. item.SaleDate = ""
  3214. item.Bchno = ""
  3215. service.SaveDF(item)
  3216. } else {
  3217. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  3218. }
  3219. }
  3220. }
  3221. c.ServeSuccessJSON(map[string]interface{}{
  3222. "msg": "删除销售数据成功",
  3223. })
  3224. }
  3225. // 获取当天起止时间戳
  3226. func GetNowTime() (int64, int64) {
  3227. t := time.Now()
  3228. addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
  3229. timesamp := addTime.Unix()
  3230. return timesamp, timesamp + 86399
  3231. }
  3232. func (c *HisApiController) ChangeDrugfour() {
  3233. patient_id, _ := c.GetInt64("patient_id")
  3234. admin_user_id, _ := c.GetInt64("admin_user_id")
  3235. times := c.GetString("time", "")
  3236. timeLayout := "2006-01-02"
  3237. loc, _ := time.LoadLocation("Local")
  3238. var stime, etime int64
  3239. if times == "" {
  3240. stime, etime = GetNowTime()
  3241. } else {
  3242. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3243. stime = stmp.Unix()
  3244. etime = stime + 86399
  3245. }
  3246. advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3247. var flows []*models.DrugFlow
  3248. for _, item := range advicelist {
  3249. flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, stime, c.GetAdminUserInfo().CurrentOrgId)
  3250. flows = append(flows, flow...)
  3251. }
  3252. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3253. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3254. var err []string
  3255. for _, item := range flows {
  3256. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3257. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3258. if prescription.OrderStatus == 2 {
  3259. if item.IsSale == 0 {
  3260. var res FJ3507Result
  3261. var res3507for10188 FJ3507ResultFor10188
  3262. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3263. //进行商品销售接口
  3264. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3265. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3266. var respJSON3 map[string]interface{}
  3267. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3270. return
  3271. }
  3272. userJSONBytes3, _ := json.Marshal(respJSON3)
  3273. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3274. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3275. utils.ErrorLog("解析失败:%v", err)
  3276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3277. return
  3278. }
  3279. //if res3507for10188.Infcode
  3280. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3281. //res.Output = resSix10265.Output
  3282. res.ErrMsg = res3507for10188.ErrMsg
  3283. res.Cainfo = res3507for10188.Cainfo
  3284. res.WarnMsg = res3507for10188.WarnMsg
  3285. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3286. res.Infcode = infocode
  3287. } else {
  3288. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3289. utils.ErrorLog("解析失败:%v", err)
  3290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3291. return
  3292. }
  3293. }
  3294. if res.Infcode == 0 {
  3295. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3296. item.IsSale = 1
  3297. item.Bchno = number
  3298. item.SaleDate = time.Now().Format("2006-01-02")
  3299. service.SaveDF(item)
  3300. } else {
  3301. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3302. }
  3303. }
  3304. } else { //还没结,提示用户去结算,并药品追溯上传
  3305. err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3306. }
  3307. }
  3308. }
  3309. str := strings.Join(err, " ")
  3310. saveLog(str, str, "3505", "3505自动上传日志")
  3311. c.ServeSuccessJSON(map[string]interface{}{
  3312. "status": "1",
  3313. "msg": err,
  3314. })
  3315. }
  3316. func (c *HisApiController) ChangeDrugFive() {
  3317. id := c.GetString("id")
  3318. ids := strings.Split(id, ",")
  3319. admin_user_id, _ := c.GetInt64("admin_user_id")
  3320. var errs []string
  3321. //校验gui'ge
  3322. for _, value := range ids {
  3323. intValue, _ := strconv.ParseInt(value, 10, 64)
  3324. //file := strconv.FormatInt(int64(num), 10)
  3325. advicelist, _ := service.FindHisAdviceDocAdvice(intValue)
  3326. var flows []*models.DrugFlow
  3327. for _, item := range advicelist {
  3328. flow, _ := service.GetNewDrugFlowInfoByPatient(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3329. flows = append(flows, flow...)
  3330. }
  3331. //roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3332. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3333. for _, item := range flows {
  3334. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3335. if prescription.OrderStatus != 2 {
  3336. // 将时间戳转换为time.Time类型
  3337. t := time.Unix(item.HisDoctorAdviceInfo.RecordDate, 0) // 注意第二个参数是纳秒,这里是0
  3338. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, item.HisDoctorAdviceInfo.PatientId)
  3339. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"医嘱没结算无法上传")
  3340. }
  3341. if len(item.HisDoctorAdviceInfo.DrugCode) > 0 {
  3342. t := time.Unix(item.HisDoctorAdviceInfo.RecordDate, 0) // 注意第二个参数是纳秒,这里是0
  3343. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, item.HisDoctorAdviceInfo.PatientId)
  3344. codes := strings.Split(item.HisDoctorAdviceInfo.DrugCode, ",")
  3345. for _, code := range codes {
  3346. if len(code) > 0 {
  3347. if len(code) != 20 {
  3348. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+" 溯源码"+code+"位数不是20位")
  3349. }
  3350. if IsDigit(code) == false {
  3351. errs = append(errs, patient.Name+"的"+t.Format("2006-01-02")+" 的"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+" 溯源码"+code+"不是纯数字")
  3352. }
  3353. }
  3354. }
  3355. }
  3356. }
  3357. }
  3358. utils.ErrorLog("接口返回数据解析JSON失败: %v", errs)
  3359. if len(errs) > 0 {
  3360. c.ServeSuccessJSON(map[string]interface{}{
  3361. "failed_code": -10,
  3362. "msg": errs,
  3363. })
  3364. return
  3365. }
  3366. for _, value := range ids {
  3367. intValue, _ := strconv.ParseInt(value, 10, 64)
  3368. //file := strconv.FormatInt(int64(num), 10)
  3369. advicelist, _ := service.FindHisAdviceDocAdvice(intValue)
  3370. var flows []*models.DrugFlow
  3371. for _, item := range advicelist {
  3372. flow, _ := service.GetNewDrugFlowInfoByPatient(item.PatientId, item.DrugId, item.RecordDate, c.GetAdminUserInfo().CurrentOrgId)
  3373. flows = append(flows, flow...)
  3374. }
  3375. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3376. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3377. for _, item := range flows {
  3378. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3379. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3380. if prescription.OrderStatus == 2 {
  3381. if item.IsSale == 0 {
  3382. var res FJ3507Result
  3383. var res3507for10188 FJ3507ResultFor10188
  3384. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3385. //进行商品销售接口
  3386. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3387. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3388. var respJSON3 map[string]interface{}
  3389. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3390. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3392. return
  3393. }
  3394. userJSONBytes3, _ := json.Marshal(respJSON3)
  3395. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3396. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3397. utils.ErrorLog("解析失败:%v", err)
  3398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3399. return
  3400. }
  3401. //if res3507for10188.Infcode
  3402. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3403. //res.Output = resSix10265.Output
  3404. res.ErrMsg = res3507for10188.ErrMsg
  3405. res.Cainfo = res3507for10188.Cainfo
  3406. res.WarnMsg = res3507for10188.WarnMsg
  3407. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3408. res.Infcode = infocode
  3409. } else {
  3410. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3411. utils.ErrorLog("解析失败:%v", err)
  3412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3413. return
  3414. }
  3415. }
  3416. if res.Infcode == 0 {
  3417. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  3418. item.IsSale = 1
  3419. item.Bchno = number
  3420. item.SaleDate = time.Now().Format("2006-01-02")
  3421. service.SaveDF(item)
  3422. } else {
  3423. errs = append(errs, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3424. }
  3425. }
  3426. } else { //还没结,提示用户去结算,并药品追溯上传
  3427. errs = append(errs, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3428. }
  3429. }
  3430. }
  3431. str := strings.Join(errs, " ")
  3432. saveLog(str, str, "3505", "3505自动上传日志")
  3433. }
  3434. c.ServeSuccessJSON(map[string]interface{}{
  3435. "status": "1",
  3436. "msg": errs,
  3437. })
  3438. }
  3439. //func (c *HisApiController) ChangeDrugfour() {
  3440. // patient_id, _ := c.GetInt64("patient_id")
  3441. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3442. // //id_arr := strings.Split(ids, ",")
  3443. // times := c.GetString("time", "")
  3444. // timeLayout := "2006-01-02"
  3445. // loc, _ := time.LoadLocation("Local")
  3446. // var stime, etime int64
  3447. // if times == "" {
  3448. // stime, etime = GetNowTime()
  3449. // } else {
  3450. // stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  3451. // stime = stmp.Unix()
  3452. // etime = stime + 86399
  3453. // }
  3454. // advicelist, _ := service.FindeHisAdviceDocAdvice(c.GetAdminUserInfo().CurrentOrgId, patient_id, stime, etime)
  3455. // var flows []*models.DrugFlow
  3456. // for _, item := range advicelist {
  3457. // flow, _ := service.GetNewDrugFlowInfoByPatient(patient_id, item.DrugId, times, c.GetAdminUserInfo().CurrentOrgId)
  3458. // flows = append(flows, flow...)
  3459. // }
  3460. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3461. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3462. // var err []string
  3463. //
  3464. // for _, item := range flows {
  3465. // var res3 ResultSix
  3466. // if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3467. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3468. // if prescription.OrderStatus == 2 {
  3469. // //已经结算
  3470. // //判断是否已经销售
  3471. // if item.IsSale == 1 { //是否已经销售,1是 0否
  3472. // //是否已经变更 1是 0否
  3473. // if item.IsChange == 0 { //没变更,进行变更操作
  3474. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3475. //
  3476. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3477. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3478. // var respJSON3 map[string]interface{}
  3479. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3480. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3481. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3482. // return
  3483. // }
  3484. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3485. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3486. // utils.ErrorLog("解析失败:%v", err)
  3487. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3488. // return
  3489. // }
  3490. // if res3.Infcode == 0 {
  3491. // item.IsChange = 1
  3492. // item.BgBchno = bg_number
  3493. // service.SaveDF2(item)
  3494. // } else {
  3495. //
  3496. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3497. // }
  3498. // }
  3499. // } else { //没销售,
  3500. // var res FJ3507Result
  3501. // var res3507for10188 FJ3507ResultFor10188
  3502. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3503. //
  3504. // //进行商品销售接口
  3505. // result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3506. // saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3507. // var respJSON3 map[string]interface{}
  3508. // if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3509. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3510. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3511. // return
  3512. // }
  3513. // userJSONBytes3, _ := json.Marshal(respJSON3)
  3514. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3515. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3516. // utils.ErrorLog("解析失败:%v", err)
  3517. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3518. // return
  3519. // }
  3520. // //if res3507for10188.Infcode
  3521. // res.InfRefmsgid = res3507for10188.InfRefmsgid
  3522. // //res.Output = resSix10265.Output
  3523. // res.ErrMsg = res3507for10188.ErrMsg
  3524. // res.Cainfo = res3507for10188.Cainfo
  3525. // res.WarnMsg = res3507for10188.WarnMsg
  3526. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3527. // res.Infcode = infocode
  3528. // } else {
  3529. // if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3530. // utils.ErrorLog("解析失败:%v", err)
  3531. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3532. // return
  3533. // }
  3534. //
  3535. // }
  3536. // if res.Infcode == 0 {
  3537. // item.IsSale = 1
  3538. // item.Bchno = number
  3539. // item.SaleDate = time.Now().Format("2006-01-02")
  3540. //
  3541. // err5 := service.SaveDF(item)
  3542. // if err5 == nil {
  3543. // if item.IsChange == 0 { //没变更,进行变更操作
  3544. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3545. //
  3546. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3547. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3548. //
  3549. // var respJSON3 map[string]interface{}
  3550. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3551. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3552. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3553. // return
  3554. // }
  3555. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3556. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3557. // utils.ErrorLog("解析失败:%v", err)
  3558. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3559. // return
  3560. // }
  3561. // //if res3507for10188.Infcode
  3562. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3563. // //res.Output = resSix10265.Output
  3564. // res3.ErrMsg = res3507for10188.ErrMsg
  3565. // res3.Cainfo = res3507for10188.Cainfo
  3566. // res3.WarnMsg = res3507for10188.WarnMsg
  3567. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3568. // res3.Infcode = infocode
  3569. // } else {
  3570. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3571. // utils.ErrorLog("解析失败:%v", err)
  3572. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3573. // return
  3574. // }
  3575. // }
  3576. // if res3.Infcode == 0 {
  3577. // item.IsChange = 1
  3578. // item.BgBchno = bg_number
  3579. // service.SaveDF2(item)
  3580. // } else {
  3581. //
  3582. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3583. // }
  3584. // }
  3585. // }
  3586. // } else {
  3587. //
  3588. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3589. // }
  3590. // }
  3591. //
  3592. // } else { //还没结,提示用户去结算,并药品追溯上传
  3593. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+"还没结算,请结算后,在药品追溯页面上传")
  3594. // }
  3595. // }
  3596. // }
  3597. // if len(err) == 0 {
  3598. // c.ServeSuccessJSON(map[string]interface{}{
  3599. // "msg": "销售变更成功",
  3600. // })
  3601. // } else {
  3602. // c.ServeSuccessJSON(map[string]interface{}{
  3603. // "failed_code": -10,
  3604. // "msg": err,
  3605. // })
  3606. // }
  3607. //}
  3608. func (c *HisApiController) ChangeDrug() {
  3609. ids := c.GetString("ids")
  3610. id_arr := strings.Split(ids, ",")
  3611. flows, _ := service.GetNewDrugFlowInfo(c.GetAdminUserInfo().CurrentOrgId, id_arr)
  3612. admin_user_id, _ := c.GetInt64("admin_user_id")
  3613. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3614. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3615. var err []string
  3616. for _, item := range flows {
  3617. var res3 ResultSix
  3618. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3619. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3620. if prescription.OrderStatus == 2 {
  3621. //已经结算
  3622. //判断是否已经销售
  3623. if item.IsSale == 1 { //是否已经销售,1是 0否
  3624. //是否已经变更 1是 0否
  3625. if item.IsChange == 0 { //没变更,进行变更操作
  3626. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3627. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3628. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  3629. var respJSON3 map[string]interface{}
  3630. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3631. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3633. return
  3634. }
  3635. userJSONBytes3, _ := json.Marshal(respJSON3)
  3636. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3637. utils.ErrorLog("解析失败:%v", err)
  3638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3639. return
  3640. }
  3641. if res3.Infcode == 0 {
  3642. item.IsChange = 1
  3643. item.BgBchno = bg_number
  3644. service.SaveDF2(item)
  3645. } else {
  3646. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3647. }
  3648. }
  3649. } else { //没销售,
  3650. var res FJ3507Result
  3651. var res3507for10188 FJ3507ResultFor10188
  3652. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  3653. //进行商品销售接口
  3654. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3655. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  3656. var respJSON3 map[string]interface{}
  3657. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  3658. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3660. return
  3661. }
  3662. userJSONBytes3, _ := json.Marshal(respJSON3)
  3663. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3664. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3665. utils.ErrorLog("解析失败:%v", err)
  3666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3667. return
  3668. }
  3669. //if res3507for10188.Infcode
  3670. res.InfRefmsgid = res3507for10188.InfRefmsgid
  3671. //res.Output = resSix10265.Output
  3672. res.ErrMsg = res3507for10188.ErrMsg
  3673. res.Cainfo = res3507for10188.Cainfo
  3674. res.WarnMsg = res3507for10188.WarnMsg
  3675. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3676. res.Infcode = infocode
  3677. } else {
  3678. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  3679. utils.ErrorLog("解析失败:%v", err)
  3680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3681. return
  3682. }
  3683. }
  3684. if res.Infcode == 0 {
  3685. item.IsSale = 1
  3686. item.Bchno = number
  3687. item.SaleDate = time.Now().Format("2006-01-02")
  3688. err5 := service.SaveDF(item)
  3689. if err5 == nil {
  3690. if item.IsChange == 0 { //没变更,进行变更操作
  3691. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3692. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3693. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  3694. var respJSON3 map[string]interface{}
  3695. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3696. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3698. return
  3699. }
  3700. userJSONBytes3, _ := json.Marshal(respJSON3)
  3701. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3702. utils.ErrorLog("解析失败:%v", err)
  3703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3704. return
  3705. }
  3706. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3707. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3708. utils.ErrorLog("解析失败:%v", err)
  3709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3710. return
  3711. }
  3712. //if res3507for10188.Infcode
  3713. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3714. //res.Output = resSix10265.Output
  3715. res3.ErrMsg = res3507for10188.ErrMsg
  3716. res3.Cainfo = res3507for10188.Cainfo
  3717. res3.WarnMsg = res3507for10188.WarnMsg
  3718. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3719. res3.Infcode = infocode
  3720. } else {
  3721. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3722. utils.ErrorLog("解析失败:%v", err)
  3723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3724. return
  3725. }
  3726. }
  3727. if res3.Infcode == 0 {
  3728. item.IsChange = 1
  3729. item.BgBchno = bg_number
  3730. service.SaveDF2(item)
  3731. } else {
  3732. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3733. }
  3734. }
  3735. }
  3736. } else {
  3737. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  3738. }
  3739. }
  3740. } else { //还没结算
  3741. var res3507for10188 FJ3507ResultFor10188
  3742. if item.IsChange == 0 { //没变更,进行变更操作
  3743. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3744. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  3745. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3746. var respJSON3 map[string]interface{}
  3747. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3748. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3750. return
  3751. }
  3752. userJSONBytes3, _ := json.Marshal(respJSON3)
  3753. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3754. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3755. utils.ErrorLog("解析失败:%v", err)
  3756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3757. return
  3758. }
  3759. //if res3507for10188.Infcode
  3760. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3761. //res.Output = resSix10265.Output
  3762. res3.ErrMsg = res3507for10188.ErrMsg
  3763. res3.Cainfo = res3507for10188.Cainfo
  3764. res3.WarnMsg = res3507for10188.WarnMsg
  3765. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3766. res3.Infcode = infocode
  3767. } else {
  3768. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3769. utils.ErrorLog("解析失败:%v", err)
  3770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3771. return
  3772. }
  3773. }
  3774. if res3.Infcode == 0 {
  3775. item.IsChange = 1
  3776. item.BgBchno = bg_number
  3777. service.SaveDF2(item)
  3778. } else {
  3779. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3780. }
  3781. }
  3782. }
  3783. } else if item.ConsumableType == 7 {
  3784. var res3507for10188 FJ3507ResultFor10188
  3785. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3786. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  3787. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  3788. //判断是否已经销售
  3789. if item.IsSale == 2 { //是否已经销售,1是 0否
  3790. //是否已经变更 1是 0否
  3791. if item.IsChange == 0 { //没变更,进行变更操作
  3792. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3793. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3794. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3795. var respJSON3 map[string]interface{}
  3796. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3797. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3799. return
  3800. }
  3801. userJSONBytes3, _ := json.Marshal(respJSON3)
  3802. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3803. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3804. utils.ErrorLog("解析失败:%v", err)
  3805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3806. return
  3807. }
  3808. //if res3507for10188.Infcode
  3809. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3810. //res.Output = resSix10265.Output
  3811. res3.ErrMsg = res3507for10188.ErrMsg
  3812. res3.Cainfo = res3507for10188.Cainfo
  3813. res3.WarnMsg = res3507for10188.WarnMsg
  3814. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3815. res3.Infcode = infocode
  3816. } else {
  3817. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3818. utils.ErrorLog("解析失败:%v", err)
  3819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3820. return
  3821. }
  3822. }
  3823. if res3.Infcode == 0 {
  3824. item.IsChange = 1
  3825. item.BgBchno = bg_number
  3826. service.SaveDF2(item)
  3827. } else {
  3828. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3829. }
  3830. }
  3831. } else { //没销售,
  3832. //进行商品销售退货接口
  3833. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  3834. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  3835. saveLog(result111, result222, "3506", "销售退货")
  3836. var res7 FJ3507Result
  3837. //进行商品销售接口
  3838. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  3839. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  3840. var respJSON3 map[string]interface{}
  3841. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  3842. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3844. return
  3845. }
  3846. userJSONBytes3, _ := json.Marshal(respJSON3)
  3847. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3848. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3849. utils.ErrorLog("解析失败:%v", err)
  3850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3851. return
  3852. }
  3853. //if res3507for10188.Infcode
  3854. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  3855. //res.Output = resSix10265.Output
  3856. res7.ErrMsg = res3507for10188.ErrMsg
  3857. res7.Cainfo = res3507for10188.Cainfo
  3858. res7.WarnMsg = res3507for10188.WarnMsg
  3859. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3860. res7.Infcode = infocode
  3861. } else {
  3862. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  3863. utils.ErrorLog("解析失败:%v", err)
  3864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3865. return
  3866. }
  3867. }
  3868. if res7.Infcode == 0 {
  3869. item.IsSale = 2
  3870. item.SaleDate = item.SaleDate
  3871. item.Bchno = number
  3872. service.SaveDF(item)
  3873. if item.IsChange == 0 { //没变更,进行变更操作
  3874. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3875. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3876. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3877. var respJSON3 map[string]interface{}
  3878. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3879. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3881. return
  3882. }
  3883. userJSONBytes3, _ := json.Marshal(respJSON3)
  3884. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3885. // utils.ErrorLog("解析失败:%v", err)
  3886. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3887. // return
  3888. //}
  3889. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3890. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3891. utils.ErrorLog("解析失败:%v", err)
  3892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3893. return
  3894. }
  3895. //if res3507for10188.Infcode
  3896. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3897. //res.Output = resSix10265.Output
  3898. res3.ErrMsg = res3507for10188.ErrMsg
  3899. res3.Cainfo = res3507for10188.Cainfo
  3900. res3.WarnMsg = res3507for10188.WarnMsg
  3901. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3902. res3.Infcode = infocode
  3903. } else {
  3904. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3905. utils.ErrorLog("解析失败:%v", err)
  3906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3907. return
  3908. }
  3909. }
  3910. if res3.Infcode == 0 {
  3911. item.IsChange = 1
  3912. item.BgBchno = bg_number
  3913. service.SaveDF2(item)
  3914. } else {
  3915. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3916. }
  3917. }
  3918. } else {
  3919. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  3920. }
  3921. }
  3922. } else { //还没结算
  3923. if item.IsChange == 0 { //没变更,进行变更操作
  3924. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  3925. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  3926. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  3927. var respJSON3 map[string]interface{}
  3928. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  3929. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3931. return
  3932. }
  3933. userJSONBytes3, _ := json.Marshal(respJSON3)
  3934. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3935. // utils.ErrorLog("解析失败:%v", err)
  3936. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3937. // return
  3938. //}
  3939. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  3940. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  3941. utils.ErrorLog("解析失败:%v", err)
  3942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3943. return
  3944. }
  3945. //if res3507for10188.Infcode
  3946. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  3947. //res.Output = resSix10265.Output
  3948. res3.ErrMsg = res3507for10188.ErrMsg
  3949. res3.Cainfo = res3507for10188.Cainfo
  3950. res3.WarnMsg = res3507for10188.WarnMsg
  3951. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  3952. res3.Infcode = infocode
  3953. } else {
  3954. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  3955. utils.ErrorLog("解析失败:%v", err)
  3956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3957. return
  3958. }
  3959. }
  3960. if res3.Infcode == 0 {
  3961. item.IsChange = 1
  3962. item.BgBchno = bg_number
  3963. service.SaveDF2(item)
  3964. } else {
  3965. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  3966. }
  3967. }
  3968. }
  3969. }
  3970. }
  3971. if len(err) == 0 {
  3972. c.ServeSuccessJSON(map[string]interface{}{
  3973. "msg": "销售变更成功",
  3974. })
  3975. } else {
  3976. c.ServeSuccessJSON(map[string]interface{}{
  3977. "failed_code": -10,
  3978. "msg": err,
  3979. })
  3980. }
  3981. }
  3982. func (c *HisApiController) ChangeDrugtwo() {
  3983. //ids := c.GetString("ids")
  3984. //id_arr := strings.Split(ids, ",")
  3985. flows, _ := service.GetNewDrugFlowInfothree123()
  3986. admin_user_id, _ := c.GetInt64("admin_user_id")
  3987. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3988. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3989. var err []string
  3990. for _, item := range flows {
  3991. var res3 ResultSix
  3992. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  3993. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  3994. if prescription.OrderStatus == 2 {
  3995. //已经结算
  3996. //判断是否已经销售
  3997. //if item.IsSale == 1 { //是否已经销售,1是 0否
  3998. // //是否已经变更 1是 0否
  3999. // if item.IsChange == 0 { //没变更,进行变更操作
  4000. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4001. //
  4002. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4003. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4004. // var respJSON3 map[string]interface{}
  4005. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4006. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4007. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4008. // return
  4009. // }
  4010. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4011. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4012. // utils.ErrorLog("解析失败:%v", err)
  4013. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4014. // return
  4015. // }
  4016. // if res3.Infcode == 0 {
  4017. // item.IsChange = 1
  4018. // item.BgBchno = bg_number
  4019. // service.SaveDF2(item)
  4020. // } else {
  4021. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4022. // }
  4023. // }
  4024. //}
  4025. //else
  4026. { //没销售,
  4027. var res FJ3507Result
  4028. var res3507for10188 FJ3507ResultFor10188
  4029. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4030. //进行商品销售接口
  4031. result3, result4 := SaleStock10217(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4032. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4033. var respJSON3 map[string]interface{}
  4034. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4035. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4037. return
  4038. }
  4039. userJSONBytes3, _ := json.Marshal(respJSON3)
  4040. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4041. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4042. utils.ErrorLog("解析失败:%v", err)
  4043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4044. return
  4045. }
  4046. //if res3507for10188.Infcode
  4047. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4048. //res.Output = resSix10265.Output
  4049. res.ErrMsg = res3507for10188.ErrMsg
  4050. res.Cainfo = res3507for10188.Cainfo
  4051. res.WarnMsg = res3507for10188.WarnMsg
  4052. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4053. res.Infcode = infocode
  4054. } else {
  4055. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4056. utils.ErrorLog("解析失败:%v", err)
  4057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4058. return
  4059. }
  4060. }
  4061. if res.Infcode == 0 {
  4062. item.IsSale = 1
  4063. item.Bchno = number
  4064. item.SaleDate = time.Now().Format("2006-01-02")
  4065. service.SaveDF(item)
  4066. //if err5 == nil {
  4067. // if item.IsChange == 0 { //没变更,进行变更操作
  4068. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4069. //
  4070. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4071. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4072. //
  4073. // var respJSON3 map[string]interface{}
  4074. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4075. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4076. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4077. // return
  4078. // }
  4079. //
  4080. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4081. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4082. // utils.ErrorLog("解析失败:%v", err)
  4083. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4084. // return
  4085. // }
  4086. // //if res3507for10188.Infcode
  4087. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4088. // //res.Output = resSix10265.Output
  4089. // res3.ErrMsg = res3507for10188.ErrMsg
  4090. // res3.Cainfo = res3507for10188.Cainfo
  4091. // res3.WarnMsg = res3507for10188.WarnMsg
  4092. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4093. // res3.Infcode = infocode
  4094. // } else {
  4095. //
  4096. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4097. // utils.ErrorLog("解析失败:%v", err)
  4098. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4099. // return
  4100. // }
  4101. //
  4102. // }
  4103. //
  4104. // if res3.Infcode == 0 {
  4105. // item.IsChange = 1
  4106. // item.BgBchno = bg_number
  4107. // service.SaveDF2(item)
  4108. // } else {
  4109. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4110. // }
  4111. // }
  4112. //}
  4113. } else {
  4114. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4115. }
  4116. }
  4117. } else { //还没结算
  4118. var res3507for10188 FJ3507ResultFor10188
  4119. if item.IsChange == 0 { //没变更,进行变更操作
  4120. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4121. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4122. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4123. var respJSON3 map[string]interface{}
  4124. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4125. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4127. return
  4128. }
  4129. userJSONBytes3, _ := json.Marshal(respJSON3)
  4130. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4131. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4132. utils.ErrorLog("解析失败:%v", err)
  4133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4134. return
  4135. }
  4136. //if res3507for10188.Infcode
  4137. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4138. //res.Output = resSix10265.Output
  4139. res3.ErrMsg = res3507for10188.ErrMsg
  4140. res3.Cainfo = res3507for10188.Cainfo
  4141. res3.WarnMsg = res3507for10188.WarnMsg
  4142. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4143. res3.Infcode = infocode
  4144. } else {
  4145. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4146. utils.ErrorLog("解析失败:%v", err)
  4147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4148. return
  4149. }
  4150. }
  4151. if res3.Infcode == 0 {
  4152. item.IsChange = 1
  4153. item.BgBchno = bg_number
  4154. service.SaveDF2(item)
  4155. } else {
  4156. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4157. }
  4158. }
  4159. }
  4160. }
  4161. //if item.ConsumableType == 7 {
  4162. // var res3507for10188 FJ3507ResultFor10188
  4163. //
  4164. // prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4165. // order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4166. // if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4167. // //判断是否已经销售
  4168. // if item.IsSale == 2 { //是否已经销售,1是 0否
  4169. // //是否已经变更 1是 0否
  4170. // if item.IsChange == 0 { //没变更,进行变更操作
  4171. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4172. //
  4173. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4174. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4175. //
  4176. // var respJSON3 map[string]interface{}
  4177. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4178. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4179. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4180. // return
  4181. // }
  4182. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4183. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4184. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4185. // utils.ErrorLog("解析失败:%v", err)
  4186. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4187. // return
  4188. // }
  4189. // //if res3507for10188.Infcode
  4190. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4191. // //res.Output = resSix10265.Output
  4192. // res3.ErrMsg = res3507for10188.ErrMsg
  4193. // res3.Cainfo = res3507for10188.Cainfo
  4194. // res3.WarnMsg = res3507for10188.WarnMsg
  4195. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4196. // res3.Infcode = infocode
  4197. // } else {
  4198. //
  4199. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4200. // utils.ErrorLog("解析失败:%v", err)
  4201. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4202. // return
  4203. // }
  4204. //
  4205. // }
  4206. // if res3.Infcode == 0 {
  4207. // item.IsChange = 1
  4208. // item.BgBchno = bg_number
  4209. // service.SaveDF2(item)
  4210. // } else {
  4211. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4212. // }
  4213. // }
  4214. // } else { //没销售,
  4215. // //进行商品销售退货接口
  4216. // number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4217. //
  4218. // result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4219. // saveLog(result111, result222, "3506", "销售退货")
  4220. // var res7 FJ3507Result
  4221. //
  4222. // //进行商品销售接口
  4223. // //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4224. // //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4225. // var respJSON3 map[string]interface{}
  4226. // if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4227. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4228. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4229. // return
  4230. // }
  4231. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4232. //
  4233. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4234. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4235. // utils.ErrorLog("解析失败:%v", err)
  4236. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4237. // return
  4238. // }
  4239. // //if res3507for10188.Infcode
  4240. // res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4241. // //res.Output = resSix10265.Output
  4242. // res7.ErrMsg = res3507for10188.ErrMsg
  4243. // res7.Cainfo = res3507for10188.Cainfo
  4244. // res7.WarnMsg = res3507for10188.WarnMsg
  4245. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4246. // res7.Infcode = infocode
  4247. // } else {
  4248. //
  4249. // if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4250. // utils.ErrorLog("解析失败:%v", err)
  4251. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4252. // return
  4253. // }
  4254. //
  4255. // }
  4256. // if res7.Infcode == 0 {
  4257. // item.IsSale = 2
  4258. // item.SaleDate = item.SaleDate
  4259. // item.Bchno = number
  4260. // service.SaveDF(item)
  4261. // if item.IsChange == 0 { //没变更,进行变更操作
  4262. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4263. //
  4264. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4265. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4266. //
  4267. // var respJSON3 map[string]interface{}
  4268. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4269. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4270. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4271. // return
  4272. // }
  4273. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4274. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4275. // // utils.ErrorLog("解析失败:%v", err)
  4276. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4277. // // return
  4278. // //}
  4279. //
  4280. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4281. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4282. // utils.ErrorLog("解析失败:%v", err)
  4283. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4284. // return
  4285. // }
  4286. // //if res3507for10188.Infcode
  4287. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4288. // //res.Output = resSix10265.Output
  4289. // res3.ErrMsg = res3507for10188.ErrMsg
  4290. // res3.Cainfo = res3507for10188.Cainfo
  4291. // res3.WarnMsg = res3507for10188.WarnMsg
  4292. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4293. // res3.Infcode = infocode
  4294. // } else {
  4295. //
  4296. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4297. // utils.ErrorLog("解析失败:%v", err)
  4298. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4299. // return
  4300. // }
  4301. //
  4302. // }
  4303. // if res3.Infcode == 0 {
  4304. // item.IsChange = 1
  4305. // item.BgBchno = bg_number
  4306. // service.SaveDF2(item)
  4307. // } else {
  4308. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4309. // }
  4310. // }
  4311. // } else {
  4312. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4313. // }
  4314. // }
  4315. // } else { //还没结算
  4316. // if item.IsChange == 0 { //没变更,进行变更操作
  4317. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4318. //
  4319. // result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4320. // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4321. //
  4322. // var respJSON3 map[string]interface{}
  4323. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4324. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4325. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4326. // return
  4327. // }
  4328. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4329. // //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4330. // // utils.ErrorLog("解析失败:%v", err)
  4331. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4332. // // return
  4333. // //}
  4334. //
  4335. // if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4336. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4337. // utils.ErrorLog("解析失败:%v", err)
  4338. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4339. // return
  4340. // }
  4341. // //if res3507for10188.Infcode
  4342. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4343. // //res.Output = resSix10265.Output
  4344. // res3.ErrMsg = res3507for10188.ErrMsg
  4345. // res3.Cainfo = res3507for10188.Cainfo
  4346. // res3.WarnMsg = res3507for10188.WarnMsg
  4347. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4348. // res3.Infcode = infocode
  4349. // } else {
  4350. //
  4351. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4352. // utils.ErrorLog("解析失败:%v", err)
  4353. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4354. // return
  4355. // }
  4356. //
  4357. // }
  4358. // if res3.Infcode == 0 {
  4359. // item.IsChange = 1
  4360. // item.BgBchno = bg_number
  4361. // service.SaveDF2(item)
  4362. // } else {
  4363. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4364. // }
  4365. // }
  4366. // }
  4367. //}
  4368. }
  4369. if len(err) == 0 {
  4370. c.ServeSuccessJSON(map[string]interface{}{
  4371. "msg": "销售变更成功",
  4372. })
  4373. } else {
  4374. c.ServeSuccessJSON(map[string]interface{}{
  4375. "failed_code": -10,
  4376. "msg": err,
  4377. })
  4378. }
  4379. }
  4380. func (c *HisApiController) ChangeDrugthree() {
  4381. //ids := c.GetString("ids")
  4382. //id_arr := strings.Split(ids, ",")
  4383. flows, _ := service.GetNewDrugFlowInfothree()
  4384. admin_user_id, _ := c.GetInt64("admin_user_id")
  4385. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4386. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4387. var err []string
  4388. for _, item := range flows {
  4389. var res3 ResultSix
  4390. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4391. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4392. if prescription.OrderStatus == 2 {
  4393. //已经结算
  4394. //判断是否已经销售
  4395. if item.IsSale == 1 { //是否已经销售,1是 0否
  4396. //是否已经变更 1是 0否
  4397. if item.IsChange == 0 { //没变更,进行变更操作
  4398. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4399. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4400. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4401. var respJSON3 map[string]interface{}
  4402. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4403. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4405. return
  4406. }
  4407. userJSONBytes3, _ := json.Marshal(respJSON3)
  4408. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4409. utils.ErrorLog("解析失败:%v", err)
  4410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4411. return
  4412. }
  4413. if res3.Infcode == 0 {
  4414. item.IsChange = 1
  4415. item.BgBchno = bg_number
  4416. service.SaveDF2(item)
  4417. } else {
  4418. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4419. }
  4420. }
  4421. } else { //没销售,
  4422. var res FJ3507Result
  4423. var res3507for10188 FJ3507ResultFor10188
  4424. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4425. //进行商品销售接口
  4426. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4427. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4428. var respJSON3 map[string]interface{}
  4429. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4430. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4432. return
  4433. }
  4434. userJSONBytes3, _ := json.Marshal(respJSON3)
  4435. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4436. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4437. utils.ErrorLog("解析失败:%v", err)
  4438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4439. return
  4440. }
  4441. //if res3507for10188.Infcode
  4442. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4443. //res.Output = resSix10265.Output
  4444. res.ErrMsg = res3507for10188.ErrMsg
  4445. res.Cainfo = res3507for10188.Cainfo
  4446. res.WarnMsg = res3507for10188.WarnMsg
  4447. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4448. res.Infcode = infocode
  4449. } else {
  4450. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4451. utils.ErrorLog("解析失败:%v", err)
  4452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4453. return
  4454. }
  4455. }
  4456. if res.Infcode == 0 {
  4457. item.IsSale = 1
  4458. item.Bchno = number
  4459. item.SaleDate = time.Now().Format("2006-01-02")
  4460. err5 := service.SaveDF(item)
  4461. if err5 == nil {
  4462. if item.IsChange == 0 { //没变更,进行变更操作
  4463. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4464. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4465. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4466. var respJSON3 map[string]interface{}
  4467. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4468. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4470. return
  4471. }
  4472. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4473. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4474. utils.ErrorLog("解析失败:%v", err)
  4475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4476. return
  4477. }
  4478. //if res3507for10188.Infcode
  4479. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4480. //res.Output = resSix10265.Output
  4481. res3.ErrMsg = res3507for10188.ErrMsg
  4482. res3.Cainfo = res3507for10188.Cainfo
  4483. res3.WarnMsg = res3507for10188.WarnMsg
  4484. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4485. res3.Infcode = infocode
  4486. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4487. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4488. utils.ErrorLog("解析失败:%v", err)
  4489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4490. return
  4491. }
  4492. //if res3507for10188.Infcode
  4493. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4494. //res.Output = resSix10265.Output
  4495. res3.ErrMsg = res3507for10188.ErrMsg
  4496. res3.Cainfo = res3507for10188.Cainfo
  4497. res3.WarnMsg = res3507for10188.WarnMsg
  4498. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4499. res3.Infcode = infocode
  4500. } else {
  4501. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4502. utils.ErrorLog("解析失败:%v", err)
  4503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4504. return
  4505. }
  4506. }
  4507. if res3.Infcode == 0 {
  4508. item.IsChange = 1
  4509. item.BgBchno = bg_number
  4510. service.SaveDF2(item)
  4511. } else {
  4512. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4513. }
  4514. }
  4515. }
  4516. } else {
  4517. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4518. }
  4519. }
  4520. } else { //还没结算
  4521. var res3507for10188 FJ3507ResultFor10188
  4522. if item.IsChange == 0 { //没变更,进行变更操作
  4523. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4524. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4525. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4526. var respJSON3 map[string]interface{}
  4527. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4528. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4530. return
  4531. }
  4532. userJSONBytes3, _ := json.Marshal(respJSON3)
  4533. if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4534. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4535. utils.ErrorLog("解析失败:%v", err)
  4536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4537. return
  4538. }
  4539. //if res3507for10188.Infcode
  4540. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4541. //res.Output = resSix10265.Output
  4542. res3.ErrMsg = res3507for10188.ErrMsg
  4543. res3.Cainfo = res3507for10188.Cainfo
  4544. res3.WarnMsg = res3507for10188.WarnMsg
  4545. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4546. res3.Infcode = infocode
  4547. } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4548. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4549. utils.ErrorLog("解析失败:%v", err)
  4550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4551. return
  4552. }
  4553. //if res3507for10188.Infcode
  4554. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4555. //res.Output = resSix10265.Output
  4556. res3.ErrMsg = res3507for10188.ErrMsg
  4557. res3.Cainfo = res3507for10188.Cainfo
  4558. res3.WarnMsg = res3507for10188.WarnMsg
  4559. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4560. res3.Infcode = infocode
  4561. } else {
  4562. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4563. utils.ErrorLog("解析失败:%v", err)
  4564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4565. return
  4566. }
  4567. }
  4568. if res3.Infcode == 0 {
  4569. item.IsChange = 1
  4570. item.BgBchno = bg_number
  4571. service.SaveDF2(item)
  4572. } else {
  4573. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4574. }
  4575. }
  4576. }
  4577. } else if item.ConsumableType == 7 {
  4578. var res3507for10188 FJ3507ResultFor10188
  4579. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4580. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4581. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4582. //判断是否已经销售
  4583. if item.IsSale == 2 { //是否已经销售,1是 0否
  4584. //是否已经变更 1是 0否
  4585. if item.IsChange == 0 { //没变更,进行变更操作
  4586. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4587. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4588. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4589. var respJSON3 map[string]interface{}
  4590. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4591. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4593. return
  4594. }
  4595. userJSONBytes3, _ := json.Marshal(respJSON3)
  4596. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4597. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4598. utils.ErrorLog("解析失败:%v", err)
  4599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4600. return
  4601. }
  4602. //if res3507for10188.Infcode
  4603. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4604. //res.Output = resSix10265.Output
  4605. res3.ErrMsg = res3507for10188.ErrMsg
  4606. res3.Cainfo = res3507for10188.Cainfo
  4607. res3.WarnMsg = res3507for10188.WarnMsg
  4608. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4609. res3.Infcode = infocode
  4610. } else {
  4611. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4612. utils.ErrorLog("解析失败:%v", err)
  4613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4614. return
  4615. }
  4616. }
  4617. if res3.Infcode == 0 {
  4618. item.IsChange = 1
  4619. item.BgBchno = bg_number
  4620. service.SaveDF2(item)
  4621. } else {
  4622. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4623. }
  4624. }
  4625. } else { //没销售,
  4626. //进行商品销售退货接口
  4627. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4628. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4629. saveLog(result111, result222, "3506", "销售退货")
  4630. var res7 FJ3507Result
  4631. //进行商品销售接口
  4632. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  4633. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  4634. var respJSON3 map[string]interface{}
  4635. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  4636. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4638. return
  4639. }
  4640. userJSONBytes3, _ := json.Marshal(respJSON3)
  4641. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4642. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4643. utils.ErrorLog("解析失败:%v", err)
  4644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4645. return
  4646. }
  4647. //if res3507for10188.Infcode
  4648. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  4649. //res.Output = resSix10265.Output
  4650. res7.ErrMsg = res3507for10188.ErrMsg
  4651. res7.Cainfo = res3507for10188.Cainfo
  4652. res7.WarnMsg = res3507for10188.WarnMsg
  4653. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4654. res7.Infcode = infocode
  4655. } else {
  4656. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  4657. utils.ErrorLog("解析失败:%v", err)
  4658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4659. return
  4660. }
  4661. }
  4662. if res7.Infcode == 0 {
  4663. item.IsSale = 2
  4664. item.SaleDate = item.SaleDate
  4665. item.Bchno = number
  4666. service.SaveDF(item)
  4667. if item.IsChange == 0 { //没变更,进行变更操作
  4668. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4669. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4670. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4671. var respJSON3 map[string]interface{}
  4672. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4673. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4675. return
  4676. }
  4677. userJSONBytes3, _ := json.Marshal(respJSON3)
  4678. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4679. // utils.ErrorLog("解析失败:%v", err)
  4680. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4681. // return
  4682. //}
  4683. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4684. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4685. utils.ErrorLog("解析失败:%v", err)
  4686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4687. return
  4688. }
  4689. //if res3507for10188.Infcode
  4690. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4691. //res.Output = resSix10265.Output
  4692. res3.ErrMsg = res3507for10188.ErrMsg
  4693. res3.Cainfo = res3507for10188.Cainfo
  4694. res3.WarnMsg = res3507for10188.WarnMsg
  4695. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4696. res3.Infcode = infocode
  4697. } else {
  4698. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4699. utils.ErrorLog("解析失败:%v", err)
  4700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4701. return
  4702. }
  4703. }
  4704. if res3.Infcode == 0 {
  4705. item.IsChange = 1
  4706. item.BgBchno = bg_number
  4707. service.SaveDF2(item)
  4708. } else {
  4709. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4710. }
  4711. }
  4712. } else {
  4713. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  4714. }
  4715. }
  4716. } else { //还没结算
  4717. if item.IsChange == 0 { //没变更,进行变更操作
  4718. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4719. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4720. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4721. var respJSON3 map[string]interface{}
  4722. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4723. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4725. return
  4726. }
  4727. userJSONBytes3, _ := json.Marshal(respJSON3)
  4728. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4729. // utils.ErrorLog("解析失败:%v", err)
  4730. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4731. // return
  4732. //}
  4733. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4734. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4735. utils.ErrorLog("解析失败:%v", err)
  4736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4737. return
  4738. }
  4739. //if res3507for10188.Infcode
  4740. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4741. //res.Output = resSix10265.Output
  4742. res3.ErrMsg = res3507for10188.ErrMsg
  4743. res3.Cainfo = res3507for10188.Cainfo
  4744. res3.WarnMsg = res3507for10188.WarnMsg
  4745. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4746. res3.Infcode = infocode
  4747. } else {
  4748. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4749. utils.ErrorLog("解析失败:%v", err)
  4750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4751. return
  4752. }
  4753. }
  4754. if res3.Infcode == 0 {
  4755. item.IsChange = 1
  4756. item.BgBchno = bg_number
  4757. service.SaveDF2(item)
  4758. } else {
  4759. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4760. }
  4761. }
  4762. }
  4763. }
  4764. }
  4765. if len(err) == 0 {
  4766. c.ServeSuccessJSON(map[string]interface{}{
  4767. "msg": "销售变更成功",
  4768. })
  4769. } else {
  4770. c.ServeSuccessJSON(map[string]interface{}{
  4771. "failed_code": -10,
  4772. "msg": err,
  4773. })
  4774. }
  4775. }
  4776. func (c *HisApiController) ChangeDrugTen() {
  4777. start_time_str := c.GetString("start_time")
  4778. end_time_str := c.GetString("end_time")
  4779. //ids := c.GetString("ids")
  4780. //id_arr := strings.Split(ids, ",")
  4781. timeLayout := "2006-01-02"
  4782. loc, _ := time.LoadLocation("Local")
  4783. theStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4784. recordStartTime := theStartTime.Unix()
  4785. theEndTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4786. recordEndTime := theEndTime.Unix()
  4787. //timestamp := int64(1729612800)
  4788. flows, _ := service.GetNewDrugFlowInforTenone(recordStartTime, recordEndTime, c.GetAdminUserInfo().CurrentOrgId)
  4789. admin_user_id, _ := c.GetInt64("admin_user_id")
  4790. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4791. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4792. var err []string
  4793. for _, item := range flows {
  4794. var res3 ResultSix
  4795. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  4796. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4797. continue
  4798. }
  4799. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  4800. continue
  4801. }
  4802. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4803. if prescription.OrderStatus == 2 {
  4804. //已经结算
  4805. //判断 是否已经销售
  4806. //if item.IsSale == 1 { //是否已经销售,1是 0否
  4807. ////是否已经变更 1是 0否
  4808. //if item.IsChange == 0 { //没变更,进行变更操作
  4809. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4810. //
  4811. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4812. // saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  4813. // var respJSON3 map[string]interface{}
  4814. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4815. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4816. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4817. // return
  4818. // }
  4819. // userJSONBytes3, _ := json.Marshal(respJSON3)
  4820. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4821. // utils.ErrorLog("解析失败:%v", err)
  4822. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4823. // return
  4824. // }
  4825. // if res3.Infcode == 0 {
  4826. // item.IsChange = 1
  4827. // item.BgBchno = bg_number
  4828. // service.SaveDF2(item)
  4829. // } else {
  4830. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4831. // }
  4832. //}
  4833. //} else
  4834. if item.IsSale == 0 { //没销售,
  4835. var res FJ3507Result
  4836. var res3507for10188 FJ3507ResultFor10188
  4837. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  4838. //进行商品销售接口
  4839. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4840. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  4841. var respJSON3 map[string]interface{}
  4842. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  4843. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4845. return
  4846. }
  4847. userJSONBytes3, _ := json.Marshal(respJSON3)
  4848. if c.GetAdminUserInfo().CurrentOrgId == 10265 || c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4849. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4850. utils.ErrorLog("解析失败:%v", err)
  4851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4852. return
  4853. }
  4854. //if res3507for10188.Infcode
  4855. res.InfRefmsgid = res3507for10188.InfRefmsgid
  4856. //res.Output = resSix10265.Output
  4857. res.ErrMsg = res3507for10188.ErrMsg
  4858. res.Cainfo = res3507for10188.Cainfo
  4859. res.WarnMsg = res3507for10188.WarnMsg
  4860. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4861. res.Infcode = infocode
  4862. } else if c.GetAdminUserInfo().CurrentOrgId == 10480 {
  4863. } else {
  4864. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4865. utils.ErrorLog("解析失败:%v", err)
  4866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4867. return
  4868. }
  4869. }
  4870. if res.Infcode == 0 {
  4871. item.IsSale = 1
  4872. item.Bchno = number
  4873. item.SaleDate = time.Now().Format("2006-01-02")
  4874. service.SaveDoctoradviceStatus(item.HisDoctorAdviceInfo.ID)
  4875. err5 := service.SaveDF(item)
  4876. utils.ErrorLog("接口返回数据解析JSON失败: %v", err5)
  4877. //if err5 == nil {
  4878. //
  4879. // if item.IsChange == 1 { //没变更,进行变更操作
  4880. // bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4881. //
  4882. // result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  4883. // saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  4884. //
  4885. // var respJSON3 map[string]interface{}
  4886. // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4887. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4888. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4889. // return
  4890. // }
  4891. //
  4892. // if c.GetAdminUserInfo().CurrentOrgId == 10188 {
  4893. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4894. // utils.ErrorLog("解析失败:%v", err)
  4895. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4896. // return
  4897. // }
  4898. // //if res3507for10188.Infcode
  4899. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4900. // //res.Output = resSix10265.Output
  4901. // res3.ErrMsg = res3507for10188.ErrMsg
  4902. // res3.Cainfo = res3507for10188.Cainfo
  4903. // res3.WarnMsg = res3507for10188.WarnMsg
  4904. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4905. // res3.Infcode = infocode
  4906. // } else if c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4907. // if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4908. // utils.ErrorLog("解析失败:%v", err)
  4909. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4910. // return
  4911. // }
  4912. // //if res3507for10188.Infcode
  4913. // res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4914. // //res.Output = resSix10265.Output
  4915. // res3.ErrMsg = res3507for10188.ErrMsg
  4916. // res3.Cainfo = res3507for10188.Cainfo
  4917. // res3.WarnMsg = res3507for10188.WarnMsg
  4918. // infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4919. // res3.Infcode = infocode
  4920. //
  4921. // } else {
  4922. //
  4923. // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4924. // utils.ErrorLog("解析失败:%v", err)
  4925. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4926. // return
  4927. // }
  4928. //
  4929. // }
  4930. //
  4931. // if res3.Infcode == 0 {
  4932. // item.IsChange = 1
  4933. // item.BgBchno = bg_number
  4934. // service.SaveDF2(item)
  4935. // return
  4936. // } else {
  4937. // err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4938. // }
  4939. // }
  4940. //}
  4941. } else {
  4942. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  4943. }
  4944. }
  4945. }
  4946. } else if item.ConsumableType == 7 {
  4947. var res3507for10188 FJ3507ResultFor10188
  4948. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  4949. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  4950. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  4951. //判断是否已经销售
  4952. if item.IsSale == 2 { //是否已经销售,1是 0否
  4953. //是否已经变更 1是 0否
  4954. if item.IsChange == 0 { //没变更,进行变更操作
  4955. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  4956. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  4957. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  4958. var respJSON3 map[string]interface{}
  4959. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  4960. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4962. return
  4963. }
  4964. userJSONBytes3, _ := json.Marshal(respJSON3)
  4965. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  4966. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  4967. utils.ErrorLog("解析失败:%v", err)
  4968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4969. return
  4970. }
  4971. //if res3507for10188.Infcode
  4972. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  4973. //res.Output = resSix10265.Output
  4974. res3.ErrMsg = res3507for10188.ErrMsg
  4975. res3.Cainfo = res3507for10188.Cainfo
  4976. res3.WarnMsg = res3507for10188.WarnMsg
  4977. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  4978. res3.Infcode = infocode
  4979. } else {
  4980. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  4981. utils.ErrorLog("解析失败:%v", err)
  4982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4983. return
  4984. }
  4985. }
  4986. if res3.Infcode == 0 {
  4987. item.IsChange = 1
  4988. item.BgBchno = bg_number
  4989. service.SaveDF2(item)
  4990. } else {
  4991. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  4992. }
  4993. }
  4994. } else { //没销售,
  4995. //进行商品销售退货接口
  4996. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3506"
  4997. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles, number)
  4998. saveLog(result111, result222, "3506", "销售退货")
  4999. var res7 FJ3507Result
  5000. //进行商品销售接口
  5001. //result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles,number)
  5002. //saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  5003. var respJSON3 map[string]interface{}
  5004. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  5005. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5007. return
  5008. }
  5009. userJSONBytes3, _ := json.Marshal(respJSON3)
  5010. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5011. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5012. utils.ErrorLog("解析失败:%v", err)
  5013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5014. return
  5015. }
  5016. //if res3507for10188.Infcode
  5017. res7.InfRefmsgid = res3507for10188.InfRefmsgid
  5018. //res.Output = resSix10265.Output
  5019. res7.ErrMsg = res3507for10188.ErrMsg
  5020. res7.Cainfo = res3507for10188.Cainfo
  5021. res7.WarnMsg = res3507for10188.WarnMsg
  5022. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5023. res7.Infcode = infocode
  5024. } else {
  5025. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  5026. utils.ErrorLog("解析失败:%v", err)
  5027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5028. return
  5029. }
  5030. }
  5031. if res7.Infcode == 0 {
  5032. item.IsSale = 2
  5033. item.SaleDate = item.SaleDate
  5034. item.Bchno = number
  5035. service.SaveDF(item)
  5036. if item.IsChange == 0 { //没变更,进行变更操作
  5037. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5038. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  5039. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  5040. var respJSON3 map[string]interface{}
  5041. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5042. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5044. return
  5045. }
  5046. userJSONBytes3, _ := json.Marshal(respJSON3)
  5047. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5048. // utils.ErrorLog("解析失败:%v", err)
  5049. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5050. // return
  5051. //}
  5052. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5053. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5054. utils.ErrorLog("解析失败:%v", err)
  5055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5056. return
  5057. }
  5058. //if res3507for10188.Infcode
  5059. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5060. //res.Output = resSix10265.Output
  5061. res3.ErrMsg = res3507for10188.ErrMsg
  5062. res3.Cainfo = res3507for10188.Cainfo
  5063. res3.WarnMsg = res3507for10188.WarnMsg
  5064. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5065. res3.Infcode = infocode
  5066. } else {
  5067. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5068. utils.ErrorLog("解析失败:%v", err)
  5069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5070. return
  5071. }
  5072. }
  5073. if res3.Infcode == 0 {
  5074. item.IsChange = 1
  5075. item.BgBchno = bg_number
  5076. service.SaveDF2(item)
  5077. } else {
  5078. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5079. }
  5080. }
  5081. } else {
  5082. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  5083. }
  5084. }
  5085. } else { //还没结算
  5086. if item.IsChange == 0 { //没变更,进行变更操作
  5087. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5088. result, result2 := ChangeStock(item.Count, item, miConfig, "101", roles, bg_number)
  5089. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  5090. var respJSON3 map[string]interface{}
  5091. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5092. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5094. return
  5095. }
  5096. userJSONBytes3, _ := json.Marshal(respJSON3)
  5097. //if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5098. // utils.ErrorLog("解析失败:%v", err)
  5099. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5100. // return
  5101. //}
  5102. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  5103. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5104. utils.ErrorLog("解析失败:%v", err)
  5105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5106. return
  5107. }
  5108. //if res3507for10188.Infcode
  5109. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5110. //res.Output = resSix10265.Output
  5111. res3.ErrMsg = res3507for10188.ErrMsg
  5112. res3.Cainfo = res3507for10188.Cainfo
  5113. res3.WarnMsg = res3507for10188.WarnMsg
  5114. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5115. res3.Infcode = infocode
  5116. } else {
  5117. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5118. utils.ErrorLog("解析失败:%v", err)
  5119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5120. return
  5121. }
  5122. }
  5123. if res3.Infcode == 0 {
  5124. item.IsChange = 1
  5125. item.BgBchno = bg_number
  5126. service.SaveDF2(item)
  5127. } else {
  5128. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5129. }
  5130. }
  5131. }
  5132. }
  5133. }
  5134. if len(err) == 0 {
  5135. c.ServeSuccessJSON(map[string]interface{}{
  5136. "msg": "销售变更成功",
  5137. })
  5138. } else {
  5139. c.ServeSuccessJSON(map[string]interface{}{
  5140. "failed_code": -10,
  5141. "msg": err,
  5142. })
  5143. }
  5144. }
  5145. func ChangeDrugTenone() {
  5146. //ids := c.GetString("ids")
  5147. //id_arr := strings.Split(ids, ",")
  5148. now := time.Now()
  5149. timestamp := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
  5150. //timestamp := int64(1729612800)
  5151. flows, _ := service.GetNewDrugFlowInforTen(timestamp, 10188)
  5152. admin_user_id := int64(2463)
  5153. roles, _ := service.GetAdminUserInfoByID(10188, admin_user_id)
  5154. miConfig, _ := service.FindMedicalInsuranceInfo(10188)
  5155. var err []string
  5156. for _, item := range flows {
  5157. var res3 ResultSix
  5158. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  5159. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  5160. continue
  5161. }
  5162. if item.HisDoctorAdviceInfo.PrescriptionId == 0 {
  5163. continue
  5164. }
  5165. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  5166. if prescription.OrderStatus == 2 {
  5167. //已经结算
  5168. //判断是否已经销售
  5169. if item.IsSale == 1 { //是否已经销售,1是 0否
  5170. //是否已经变更 1是 0否
  5171. if item.IsChange == 0 { //没变更,进行变更操作
  5172. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5173. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  5174. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  5175. var respJSON3 map[string]interface{}
  5176. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5177. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5178. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5179. return
  5180. }
  5181. userJSONBytes3, _ := json.Marshal(respJSON3)
  5182. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  5183. utils.ErrorLog("解析失败:%v", err)
  5184. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5185. return
  5186. }
  5187. if res3.Infcode == 0 {
  5188. item.IsChange = 1
  5189. item.BgBchno = bg_number
  5190. service.SaveDF2(item)
  5191. } else {
  5192. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5193. }
  5194. }
  5195. } else { //没销售,
  5196. var res FJ3507Result
  5197. var res3507for10188 FJ3507ResultFor10188
  5198. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3505"
  5199. //进行商品销售接口
  5200. result3, result4 := SaleStock(10188, prescription, item, miConfig, "", roles, number)
  5201. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  5202. var respJSON3 map[string]interface{}
  5203. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  5204. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5205. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5206. return
  5207. }
  5208. userJSONBytes3, _ := json.Marshal(respJSON3)
  5209. {
  5210. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5211. utils.ErrorLog("解析失败:%v", err)
  5212. return
  5213. }
  5214. //if res3507for10188.Infcode
  5215. res.InfRefmsgid = res3507for10188.InfRefmsgid
  5216. //res.Output = resSix10265.Output
  5217. res.ErrMsg = res3507for10188.ErrMsg
  5218. res.Cainfo = res3507for10188.Cainfo
  5219. res.WarnMsg = res3507for10188.WarnMsg
  5220. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5221. res.Infcode = infocode
  5222. }
  5223. if res.Infcode == 0 {
  5224. item.IsSale = 1
  5225. item.Bchno = number
  5226. item.SaleDate = time.Now().Format("2006-01-02")
  5227. err5 := service.SaveDF(item)
  5228. if err5 == nil {
  5229. if item.IsChange == 1 { //没变更,进行变更操作
  5230. bg_number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3502"
  5231. result, result2 := ChangeStock(item.Count, item, miConfig, "102", roles, bg_number)
  5232. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  5233. var respJSON3 map[string]interface{}
  5234. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  5235. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5236. return
  5237. }
  5238. {
  5239. if err := json.Unmarshal(userJSONBytes3, &res3507for10188); err != nil {
  5240. utils.ErrorLog("解析失败:%v", err)
  5241. return
  5242. }
  5243. //if res3507for10188.Infcode
  5244. res3.InfRefmsgid = res3507for10188.InfRefmsgid
  5245. //res.Output = resSix10265.Output
  5246. res3.ErrMsg = res3507for10188.ErrMsg
  5247. res3.Cainfo = res3507for10188.Cainfo
  5248. res3.WarnMsg = res3507for10188.WarnMsg
  5249. infocode, _ := strconv.ParseInt(res3507for10188.Infcode, 10, 64)
  5250. res3.Infcode = infocode
  5251. }
  5252. if res3.Infcode == 0 {
  5253. item.IsChange = 1
  5254. item.BgBchno = bg_number
  5255. service.SaveDF2(item)
  5256. } else {
  5257. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  5258. }
  5259. }
  5260. }
  5261. } else {
  5262. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  5263. }
  5264. }
  5265. }
  5266. }
  5267. }
  5268. }
  5269. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5270. var struct3502 models.Struct3502
  5271. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5272. struct3502.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5273. struct3502.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5274. struct3502.FixmedinsCode = miConfig.Code
  5275. struct3502.Code = miConfig.Code
  5276. struct3502.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5277. struct3502.Opter = role.UserName
  5278. struct3502.RxFlag = "1"
  5279. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  5280. struct3502.OrgName = miConfig.OrgName
  5281. struct3502.AccessKey = miConfig.AccessKey
  5282. struct3502.RequestUrl = miConfig.Url
  5283. struct3502.SecretKey = miConfig.SecretKey
  5284. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5285. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5286. struct3502.Url = miConfig.Url
  5287. struct3502.AppId = miConfig.Cainfo
  5288. struct3502.AppSecret = miConfig.AppSecret
  5289. struct3502.Enckey = miConfig.EncKey
  5290. struct3502.SignKey = miConfig.SignKey
  5291. struct3502.SecretKey = miConfig.SecretKey
  5292. struct3502.InvChgType = chgType
  5293. struct3502.FixmedinsBchno = number
  5294. struct3502.Cnt = strconv.FormatInt(count, 10)
  5295. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  5296. //result1, result2, _ := service.FJyb3502(struct3502)
  5297. if miConfig.MdtrtareaAdmvs == "350500" {
  5298. result1, result2, _ := service.FJyb3502(struct3502)
  5299. //saveLog(result1, result2, "3502", "3502")
  5300. return result1, result2
  5301. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5302. result1, result2 := service.Gzyb3502(struct3502, struct3502.SecretKey)
  5303. return result1, result2
  5304. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5305. result1, result2 := service.Gdyb3502(struct3502, struct3502.SecretKey)
  5306. return result1, result2
  5307. } else {
  5308. data := make(map[string]interface{})
  5309. data["struct_3502s"] = struct3502
  5310. client := &http.Client{}
  5311. bytesData, _ := json.Marshal(data)
  5312. var req *http.Request
  5313. if miConfig.MdtrtareaAdmvs == "320830" {
  5314. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3502", bytes.NewReader(bytesData))
  5315. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5316. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  5317. } else {
  5318. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData))
  5319. }
  5320. resp, _ := client.Do(req)
  5321. defer resp.Body.Close()
  5322. body, ioErr := ioutil.ReadAll(resp.Body)
  5323. if ioErr != nil {
  5324. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5325. }
  5326. var respJSON map[string]interface{}
  5327. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5328. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5329. }
  5330. //var resSix10265 ResultSix10265 //1101结果
  5331. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5332. result, _ := json.Marshal(respJSON)
  5333. return string(result), ""
  5334. }
  5335. }
  5336. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5337. var struct3505 models.Struct3505
  5338. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5339. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5340. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5341. struct3505.FixmedinsBchno = number
  5342. struct3505.Opter = role.UserName
  5343. struct3505.Bchno = "---"
  5344. struct3505.FixmedinsCode = miConfig.Code
  5345. struct3505.Code = miConfig.Code
  5346. struct3505.FinlTrnsPric = strconv.FormatFloat(drug.HisDoctorAdviceInfo.Price, 'f', -1, 64)
  5347. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5348. struct3505.PrscDrName = roles.UserName
  5349. if org_id == 10191 {
  5350. struct3505.PharName = "刘水山"
  5351. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5352. }
  5353. if org_id == 10188 {
  5354. struct3505.PharName = "李汉清"
  5355. struct3505.PharPracCertNo = "30220200932022010034"
  5356. }
  5357. if org_id == 10217 {
  5358. struct3505.PharName = "张敏"
  5359. struct3505.PharPracCertNo = "30220230432090100108"
  5360. }
  5361. if org_id == 10318 {
  5362. struct3505.PharName = "邹刘阳"
  5363. struct3505.PharPracCertNo = "210441200001378"
  5364. }
  5365. if org_id == 10402 {
  5366. struct3505.PharName = "刘韶健"
  5367. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5368. }
  5369. if org_id == 9919 {
  5370. struct3505.PharName = "周君权"
  5371. struct3505.PharPracCertNo = "089644396094401375"
  5372. }
  5373. if org_id == 10644 {
  5374. struct3505.PharName = "陈金娣"
  5375. struct3505.PharPracCertNo = "20181441500320100066"
  5376. }
  5377. if org_id == 10567 {
  5378. struct3505.PharName = "范小兰"
  5379. struct3505.PharPracCertNo = "0200102079485"
  5380. }
  5381. if org_id == 10721 {
  5382. struct3505.PharName = "孙莉侠"
  5383. struct3505.PharPracCertNo = "060399"
  5384. }
  5385. if org_id == 10726 {
  5386. struct3505.PharName = "彭建福"
  5387. struct3505.PharPracCertNo = "D445281006261"
  5388. }
  5389. if org_id == 10697 {
  5390. struct3505.PharName = "陶海兰"
  5391. struct3505.PharPracCertNo = "0010933"
  5392. }
  5393. if org_id == 10265 {
  5394. struct3505.PharName = "李彩星"
  5395. struct3505.PharPracCertNo = "20171110600110100019"
  5396. }
  5397. if org_id == 10028 {
  5398. struct3505.PharName = "曾细平"
  5399. struct3505.PharPracCertNo = "D440307022134"
  5400. }
  5401. if org_id == 10138 {
  5402. struct3505.PharName = "彭斯遥"
  5403. struct3505.PharPracCertNo = "30220200943042010052"
  5404. }
  5405. if org_id == 10278 {
  5406. struct3505.PharName = "彭斯遥"
  5407. struct3505.PharPracCertNo = "30220200943042010052"
  5408. }
  5409. if org_id == 10610 {
  5410. struct3505.PharName = "彭斯遥"
  5411. struct3505.PharPracCertNo = "30220200943042010052"
  5412. }
  5413. if org_id == 10537 {
  5414. struct3505.PharName = "彭斯遥"
  5415. struct3505.PharPracCertNo = "30220200943042010052"
  5416. }
  5417. if org_id == 9504 {
  5418. struct3505.PharName = "资美红"
  5419. struct3505.PharPracCertNo = "D440904006635"
  5420. }
  5421. if org_id == 10480 {
  5422. struct3505.PharName = "陈思"
  5423. struct3505.PharPracCertNo = "30220240434110010470"
  5424. }
  5425. if org_id == 10653 {
  5426. struct3505.PharName = "邓树英"
  5427. struct3505.PharPracCertNo = "201910026440004734"
  5428. }
  5429. if org_id == 10571 {
  5430. struct3505.PharName = "廖志平"
  5431. struct3505.PharPracCertNo = "0136425"
  5432. }
  5433. if org_id == 10387 {
  5434. struct3505.PharName = "易圣"
  5435. struct3505.PharPracCertNo = "D430726002209"
  5436. }
  5437. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5438. struct3505.SetlId = order.SetlId
  5439. struct3505.MdtrtSn = order.MdtrtId
  5440. struct3505.ManuLotnum = drug.BatchNumber
  5441. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5442. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5443. struct3505.RxFlag = "1"
  5444. if drug.HisDoctorAdviceInfo.PrescribingNumberUnit != drug.HisDoctorAdviceInfo.BaseDrugLib.MinUnit {
  5445. struct3505.TrdnFlag = "0"
  5446. } else {
  5447. struct3505.TrdnFlag = "1"
  5448. }
  5449. if drug.HisDoctorAdviceInfo.ZeroFlag == 1 {
  5450. struct3505.TrdnFlag = "1"
  5451. }
  5452. if drug.HisDoctorAdviceInfo.ZeroFlag == 2 {
  5453. struct3505.TrdnFlag = "0"
  5454. }
  5455. if org_id == 10610 || org_id == 10278 || org_id == 10138 || org_id == 10537 || org_id == 10028 || org_id == 10191 {
  5456. if drug.HisDoctorAdviceInfo.BaseDrugLib.IsZeroFlag == 1 {
  5457. struct3505.TrdnFlag = "1"
  5458. }
  5459. if drug.HisDoctorAdviceInfo.BaseDrugLib.IsZeroFlag == 2 {
  5460. struct3505.TrdnFlag = "0"
  5461. }
  5462. }
  5463. struct3505.RtalDocno = order.Number
  5464. struct3505.PsnCertType = "01"
  5465. struct3505.CertNo = order.Certno
  5466. struct3505.PsnNo = order.PsnNo
  5467. struct3505.PsnName = order.PsnName
  5468. struct3505.Url = miConfig.Url
  5469. struct3505.AppId = miConfig.Cainfo
  5470. struct3505.AppSecret = miConfig.AppSecret
  5471. struct3505.Enckey = miConfig.EncKey
  5472. struct3505.SignKey = miConfig.SignKey
  5473. struct3505.SecretKey = miConfig.SecretKey
  5474. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5475. struct3505.SelRetnCnt = strValue
  5476. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5477. struct3505.SelRetnOpterName = role.UserName
  5478. if order.IsMedicineInsurance == 1 {
  5479. struct3505.MdtrtSetlType = "1"
  5480. } else {
  5481. struct3505.MdtrtSetlType = "2"
  5482. }
  5483. struct3505.OrgName = miConfig.OrgName
  5484. struct3505.AccessKey = miConfig.AccessKey
  5485. struct3505.RequestUrl = miConfig.Url
  5486. struct3505.SecretKey = miConfig.SecretKey
  5487. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5488. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5489. struct3505.Cainfo = miConfig.Cainfo
  5490. struct3505.DrugTracCodg = drug.HisDoctorAdviceInfo.DrugCode
  5491. if miConfig.MdtrtareaAdmvs == "350500" {
  5492. result1, result2, _ := service.FJyb3505(struct3505)
  5493. return result1, result2
  5494. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5495. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5496. return result1, result2
  5497. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5498. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5499. return result1, result2
  5500. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5501. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5502. return result1, result2
  5503. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "360") {
  5504. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5505. return result1, result2
  5506. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5507. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5508. return result1, result2
  5509. } else if miConfig.MdtrtareaAdmvs == "150499" {
  5510. data := make(map[string]interface{})
  5511. data["struct_3505s"] = struct3505
  5512. client := &http.Client{}
  5513. bytesData, _ := json.Marshal(data)
  5514. var req *http.Request
  5515. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532"+"/nmyb/3505", bytes.NewReader(bytesData))
  5516. resp, _ := client.Do(req)
  5517. defer resp.Body.Close()
  5518. body, ioErr := ioutil.ReadAll(resp.Body)
  5519. if ioErr != nil {
  5520. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5521. }
  5522. var respJSON map[string]interface{}
  5523. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5524. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5525. }
  5526. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5527. result, _ := json.Marshal(respJSON)
  5528. return string(result), ""
  5529. } else if miConfig.MdtrtareaAdmvs == "341203" {
  5530. data := make(map[string]interface{})
  5531. data["struct_3505s"] = struct3505
  5532. client := &http.Client{}
  5533. bytesData, _ := json.Marshal(data)
  5534. var req *http.Request
  5535. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/3505", bytes.NewReader(bytesData))
  5536. resp, _ := client.Do(req)
  5537. defer resp.Body.Close()
  5538. body, ioErr := ioutil.ReadAll(resp.Body)
  5539. if ioErr != nil {
  5540. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5541. }
  5542. var respJSON map[string]interface{}
  5543. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5544. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5545. }
  5546. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5547. if status == "0" {
  5548. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5549. utils.ErrorLog("接口返回数据读取失败: %v", err_msg)
  5550. }
  5551. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5552. result, _ := json.Marshal(respJSON)
  5553. return string(result), ""
  5554. } else if miConfig.MdtrtareaAdmvs == "430800" {
  5555. result1, result2 := service.Hnyb3505(struct3505)
  5556. return result1, result2
  5557. } else {
  5558. data := make(map[string]interface{})
  5559. data["struct_3505s"] = struct3505
  5560. client := &http.Client{}
  5561. bytesData, _ := json.Marshal(data)
  5562. var req *http.Request
  5563. if miConfig.MdtrtareaAdmvs == "320830" {
  5564. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3505", bytes.NewReader(bytesData))
  5565. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5566. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5567. } else {
  5568. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5569. }
  5570. resp, _ := client.Do(req)
  5571. defer resp.Body.Close()
  5572. body, ioErr := ioutil.ReadAll(resp.Body)
  5573. if ioErr != nil {
  5574. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5575. }
  5576. var respJSON map[string]interface{}
  5577. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5578. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5579. }
  5580. //var resSix10265 ResultSix10265 //1101结果
  5581. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5582. result, _ := json.Marshal(respJSON)
  5583. return string(result), ""
  5584. }
  5585. }
  5586. func SaleStock10217(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5587. var struct3505 models.Struct3505
  5588. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5589. struct3505.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5590. struct3505.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5591. struct3505.FixmedinsBchno = number
  5592. struct3505.Opter = role.UserName
  5593. struct3505.FixmedinsCode = miConfig.Code
  5594. struct3505.Code = miConfig.Code
  5595. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  5596. struct3505.PrscDrName = roles.UserName
  5597. if org_id == 10191 {
  5598. struct3505.PharName = "刘水山"
  5599. struct3505.PharPracCertNo = "2015026350260000002611351127"
  5600. }
  5601. if org_id == 10188 {
  5602. struct3505.PharName = "李汉清"
  5603. struct3505.PharPracCertNo = "30220200932022010034"
  5604. }
  5605. if org_id == 10217 {
  5606. struct3505.PharName = "张敏"
  5607. struct3505.PharPracCertNo = "30220230432090100108"
  5608. }
  5609. if org_id == 10318 {
  5610. struct3505.PharName = "邹刘阳"
  5611. struct3505.PharPracCertNo = "210441200001378"
  5612. }
  5613. if org_id == 10402 {
  5614. struct3505.PharName = "刘韶健"
  5615. struct3505.PharPracCertNo = "2015026440262015440501001198"
  5616. }
  5617. if org_id == 9919 {
  5618. struct3505.PharName = "周君权"
  5619. struct3505.PharPracCertNo = "089644396094401375"
  5620. }
  5621. if org_id == 10644 {
  5622. struct3505.PharName = "陈金娣"
  5623. struct3505.PharPracCertNo = "20181441500320100066"
  5624. }
  5625. if org_id == 10567 {
  5626. struct3505.PharName = "范小兰"
  5627. struct3505.PharPracCertNo = "0200102079485"
  5628. }
  5629. if org_id == 10721 {
  5630. struct3505.PharName = "孙莉侠"
  5631. struct3505.PharPracCertNo = "060399"
  5632. }
  5633. if org_id == 10726 {
  5634. struct3505.PharName = "彭建福"
  5635. struct3505.PharPracCertNo = "D445281006261"
  5636. }
  5637. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5638. struct3505.SetlId = order.SetlId
  5639. struct3505.MdtrtSn = order.MdtrtId
  5640. struct3505.ManuLotnum = drug.Number
  5641. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5642. struct3505.ExpyEnd = time.Unix(drug.ExpireDate, 0).Format("2006-01-02")
  5643. struct3505.RxFlag = "1"
  5644. struct3505.TrdnFlag = "0"
  5645. struct3505.RtalDocno = order.Number
  5646. struct3505.PsnCertType = "01"
  5647. struct3505.CertNo = order.Certno
  5648. struct3505.PsnNo = order.PsnNo
  5649. struct3505.PsnName = order.PsnName
  5650. struct3505.Url = miConfig.Url
  5651. struct3505.AppId = miConfig.Cainfo
  5652. struct3505.AppSecret = miConfig.AppSecret
  5653. struct3505.Enckey = miConfig.EncKey
  5654. struct3505.SignKey = miConfig.SignKey
  5655. struct3505.SecretKey = miConfig.SecretKey
  5656. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5657. struct3505.SelRetnCnt = strValue
  5658. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5659. struct3505.SelRetnOpterName = role.UserName
  5660. if order.IsMedicineInsurance == 1 {
  5661. struct3505.MdtrtSetlType = "1"
  5662. } else {
  5663. struct3505.MdtrtSetlType = "2"
  5664. }
  5665. struct3505.OrgName = miConfig.OrgName
  5666. struct3505.AccessKey = miConfig.AccessKey
  5667. struct3505.RequestUrl = miConfig.Url
  5668. struct3505.SecretKey = miConfig.SecretKey
  5669. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5670. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5671. struct3505.Cainfo = miConfig.Cainfo
  5672. struct3505.DrugTracCodg = drug.DrugCode
  5673. if miConfig.MdtrtareaAdmvs == "350500" {
  5674. result1, result2, _ := service.FJyb3505(struct3505)
  5675. return result1, result2
  5676. } else if miConfig.MdtrtareaAdmvs == "440100" {
  5677. result1, result2 := service.Gzyb3505(struct3505, struct3505.SecretKey)
  5678. return result1, result2
  5679. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "440") {
  5680. result1, result2 := service.Gdyb3505(struct3505, struct3505.SecretKey)
  5681. return result1, result2
  5682. } else if strings.HasPrefix(miConfig.MdtrtareaAdmvs[0:3], "361") {
  5683. result1, result2 := service.JXyb3505(struct3505, struct3505.SecretKey, struct3505.AccessKey, struct3505.RequestUrl)
  5684. return result1, result2
  5685. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5686. result1, result2 := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  5687. return result1, result2
  5688. } else {
  5689. data := make(map[string]interface{})
  5690. data["struct_3505s"] = struct3505
  5691. client := &http.Client{}
  5692. bytesData, _ := json.Marshal(data)
  5693. var req *http.Request
  5694. if miConfig.MdtrtareaAdmvs == "320830" {
  5695. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3505", bytes.NewReader(bytesData))
  5696. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5697. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5698. } else {
  5699. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData))
  5700. }
  5701. resp, _ := client.Do(req)
  5702. defer resp.Body.Close()
  5703. body, ioErr := ioutil.ReadAll(resp.Body)
  5704. if ioErr != nil {
  5705. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5706. }
  5707. var respJSON map[string]interface{}
  5708. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5709. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5710. }
  5711. //var resSix10265 ResultSix10265 //1101结果
  5712. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5713. result, _ := json.Marshal(respJSON)
  5714. return string(result), ""
  5715. }
  5716. }
  5717. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole, number string) (string, string) {
  5718. var struct3506 models.Struct3506
  5719. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5720. struct3506.FixmedinsHilistId = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5721. struct3506.FixmedinsHilistName = drug.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5722. struct3506.FixmedinsCode = miConfig.Code
  5723. struct3506.Code = miConfig.Code
  5724. struct3506.FixmedinsBchno = number
  5725. struct3506.Opter = role.UserName
  5726. order := service.GetHisOrderByNumber(pre.BatchNumber)
  5727. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  5728. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  5729. struct3506.MdtrtSn = order.MdtrtId
  5730. struct3506.ExpyEnd = ""
  5731. struct3506.RxFlag = "0"
  5732. struct3506.TrdnFlag = "1"
  5733. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  5734. struct3506.SelRetnCnt = strValue
  5735. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5736. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  5737. struct3506.SelRetnOpterName = role.UserName
  5738. struct3506.OrgName = miConfig.OrgName
  5739. struct3506.AccessKey = miConfig.AccessKey
  5740. struct3506.RequestUrl = miConfig.Url
  5741. struct3506.SecretKey = miConfig.SecretKey
  5742. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5743. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5744. struct3506.Url = miConfig.Url
  5745. struct3506.AppId = miConfig.Cainfo
  5746. struct3506.AppSecret = miConfig.AppSecret
  5747. struct3506.Enckey = miConfig.EncKey
  5748. struct3506.SignKey = miConfig.SignKey
  5749. struct3506.SecretKey = miConfig.SecretKey
  5750. struct3506.DrugTracCodg = drug.DrugCode
  5751. if miConfig.MdtrtareaAdmvs == "350500" {
  5752. result1, result2, _ := service.FJyb3506(struct3506)
  5753. return result1, result2
  5754. } else {
  5755. data := make(map[string]interface{})
  5756. data["struct_3506s"] = struct3506
  5757. client := &http.Client{}
  5758. bytesData, _ := json.Marshal(data)
  5759. var req *http.Request
  5760. if miConfig.MdtrtareaAdmvs == "320830" {
  5761. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3506", bytes.NewReader(bytesData))
  5762. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5763. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5764. } else {
  5765. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData))
  5766. }
  5767. resp, _ := client.Do(req)
  5768. defer resp.Body.Close()
  5769. body, ioErr := ioutil.ReadAll(resp.Body)
  5770. if ioErr != nil {
  5771. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5772. }
  5773. var respJSON map[string]interface{}
  5774. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5775. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5776. }
  5777. //var resSix10265 ResultSix10265 //1101结果
  5778. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5779. result, _ := json.Marshal(respJSON)
  5780. return string(result), ""
  5781. }
  5782. }
  5783. func (c *HisApiController) Get1318() {
  5784. adminUser := c.GetAdminUserInfo()
  5785. admin_user_id, _ := c.GetInt64("admin_user_id")
  5786. code := c.GetString("code")
  5787. code = ""
  5788. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5789. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5790. api := ""
  5791. if miConfig.MdtrtareaAdmvs == "320830" {
  5792. api = miConfig.AppSecret + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5793. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5794. } else if miConfig.MdtrtareaAdmvs == "320921" {
  5795. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5796. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5797. } else {
  5798. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  5799. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  5800. }
  5801. resp, requestErr := http.Get(api)
  5802. if requestErr != nil {
  5803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5804. return
  5805. }
  5806. body, ioErr := ioutil.ReadAll(resp.Body)
  5807. if ioErr != nil {
  5808. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5810. return
  5811. }
  5812. var respJSON map[string]interface{}
  5813. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5814. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5816. return
  5817. }
  5818. //var res Result2406
  5819. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5820. result, _ := json.Marshal(respJSON)
  5821. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5822. utils.ErrorLog("解析失败:%v", err)
  5823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5824. return
  5825. }
  5826. if res.Infcode == "0" {
  5827. c.ServeSuccessJSON(map[string]interface{}{
  5828. "result": "",
  5829. })
  5830. } else {
  5831. c.ServeSuccessJSON(map[string]interface{}{
  5832. "failed_code": -10,
  5833. "msg": res.ErrMsg,
  5834. })
  5835. */return
  5836. //}
  5837. }
  5838. func (c *HisApiController) Get2503() {
  5839. adminUser := c.GetAdminUserInfo()
  5840. admin_user_id, _ := c.GetInt64("admin_user_id")
  5841. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5842. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5843. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  5844. }
  5845. func (c *HisApiController) Get2406() {
  5846. id, _ := c.GetInt64("id")
  5847. record_time := c.GetString("record_time")
  5848. his_patient_id, _ := c.GetInt64("his_patient_id")
  5849. admin_user_id, _ := c.GetInt64("admin_user_id")
  5850. diagnosis_id := c.GetString("diagnosis")
  5851. timeLayout := "2006-01-02"
  5852. loc, _ := time.LoadLocation("Local")
  5853. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5854. if err != nil {
  5855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5856. return
  5857. }
  5858. recordDateTime := theTime.Unix()
  5859. adminUser := c.GetAdminUserInfo()
  5860. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5861. var config []*models.HisXtDiagnoseConfig
  5862. for _, item := range diagnosis_ids {
  5863. id, _ := strconv.ParseInt(item, 10, 64)
  5864. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5865. config = append(config, &diagnosisConfig)
  5866. }
  5867. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5868. fmt.Println(his_patient_id)
  5869. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5870. //timestamp := time.Now().Unix()
  5871. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5872. var patientPrescription models.HisPrescriptionInfo
  5873. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5874. if patientPrescription.ID == 0 {
  5875. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5876. }
  5877. var res2 Result2406
  5878. if miConfig.MdtrtareaAdmvs == "341203" {
  5879. data := make(map[string]interface{})
  5880. client := &http.Client{}
  5881. data["psn_no"] = his.PsnNo
  5882. data["mdtrt_id"] = his.Number
  5883. data["operator"] = roles.UserName
  5884. data["cert_no"] = his.IdCardNo
  5885. data["org_name"] = miConfig.OrgName
  5886. data["psn_name"] = his.Name
  5887. data["ipt_otp_no"] = his.IptOtpNo
  5888. data["ipt_psn_sp_flag_type"] = "0901"
  5889. data["ipt_psn_sp_flag"] = "1"
  5890. data["fixmedins_code"] = miConfig.Code
  5891. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5892. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5893. data["url"] = miConfig.Url
  5894. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5895. bytesData, _ := json.Marshal(data)
  5896. var req *http.Request
  5897. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5898. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5899. resp, _ := client.Do(req)
  5900. defer resp.Body.Close()
  5901. body, ioErr := ioutil.ReadAll(resp.Body)
  5902. if ioErr != nil {
  5903. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5905. return
  5906. }
  5907. var respJSON map[string]interface{}
  5908. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5909. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5911. return
  5912. }
  5913. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5914. if status == "0" {
  5915. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5916. c.ServeSuccessJSON(map[string]interface{}{
  5917. "failed_code": -10,
  5918. "msg": err_msg,
  5919. })
  5920. return
  5921. }
  5922. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5923. userJSONBytes, _ := json.Marshal(respJSON)
  5924. fmt.Println("log")
  5925. fmt.Println(string(userJSONBytes))
  5926. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5927. utils.ErrorLog("解析失败:%v", err)
  5928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5929. return
  5930. }
  5931. } else if miConfig.MdtrtareaAdmvs == "340699" {
  5932. data := make(map[string]interface{})
  5933. client := &http.Client{}
  5934. data["psn_no"] = his.PsnNo
  5935. data["mdtrt_id"] = his.Number
  5936. data["operator"] = roles.UserName
  5937. data["cert_no"] = his.IdCardNo
  5938. data["org_name"] = miConfig.OrgName
  5939. data["psn_name"] = his.Name
  5940. data["ipt_otp_no"] = his.IptOtpNo
  5941. data["ipt_psn_sp_flag_type"] = "0901"
  5942. data["ipt_psn_sp_flag"] = "1"
  5943. data["fixmedins_code"] = miConfig.Code
  5944. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5945. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5946. data["url"] = miConfig.Url
  5947. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  5948. bytesData, _ := json.Marshal(data)
  5949. var req *http.Request
  5950. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  5951. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  5952. resp, _ := client.Do(req)
  5953. defer resp.Body.Close()
  5954. body, ioErr := ioutil.ReadAll(resp.Body)
  5955. if ioErr != nil {
  5956. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5958. return
  5959. }
  5960. var respJSON map[string]interface{}
  5961. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5962. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5964. return
  5965. }
  5966. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5967. if status == "0" {
  5968. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5969. c.ServeSuccessJSON(map[string]interface{}{
  5970. "failed_code": -10,
  5971. "msg": err_msg,
  5972. })
  5973. return
  5974. }
  5975. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5976. userJSONBytes, _ := json.Marshal(respJSON)
  5977. fmt.Println("log")
  5978. fmt.Println(string(userJSONBytes))
  5979. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5980. utils.ErrorLog("解析失败:%v", err)
  5981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5982. return
  5983. }
  5984. }
  5985. if res2.Infcode != 0 {
  5986. adminUser := c.GetAdminUserInfo()
  5987. errlog := &models.HisOrderError{
  5988. UserOrgId: adminUser.CurrentOrgId,
  5989. Ctime: time.Now().Unix(),
  5990. Mtime: time.Now().Unix(),
  5991. ErrMsg: res2.ErrMsg,
  5992. Status: 1,
  5993. PatientId: id,
  5994. RecordTime: recordDateTime,
  5995. Stage: 3,
  5996. }
  5997. service.CreateErrMsgLog(errlog)
  5998. c.ServeSuccessJSON(map[string]interface{}{
  5999. "failed_code": -10,
  6000. "msg": res2.ErrMsg,
  6001. })
  6002. return
  6003. } else {
  6004. c.ServeSuccessJSON(map[string]interface{}{
  6005. "msg": "上传成功",
  6006. })
  6007. return
  6008. }
  6009. }
  6010. func (c *HisApiController) Get4105() {
  6011. }
  6012. func (c *HisApiController) Post5302() {
  6013. patient_id, _ := c.GetInt64("id")
  6014. admin_user_id, _ := c.GetInt64("admin_user_id")
  6015. p, _ := service.GetHisPatientById(patient_id)
  6016. adminUser := c.GetAdminUserInfo()
  6017. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6018. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6019. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  6020. }
  6021. func (c *HisApiController) Get4104() {
  6022. }
  6023. type Output struct {
  6024. CertNo string `json:"certno"`
  6025. PsnName string `json:"psn_name"`
  6026. CardNo string `json:"card_no"`
  6027. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  6028. CardSN string `json:"card_sn"`
  6029. PsnCertType string `json:"psn_cert_type"`
  6030. MdtrtCertNo string `json:"mdtrt_cert_no"`
  6031. MdtrtCertType string `json:"mdtrt_cert_type"`
  6032. QRCode string `json:"qrCode"`
  6033. EcToken string `json:"ecToken"`
  6034. }
  6035. type AHResponse struct {
  6036. Body AHBody `json:"body"`
  6037. Code int `json:"code"`
  6038. CSBCode int `json:"csbCode"`
  6039. Message string `json:"message"`
  6040. RequestID string `json:"requestId"`
  6041. State struct{} `json:"state"`
  6042. }
  6043. type AHBody struct {
  6044. ErrMsg string `json:"err_msg"`
  6045. InfRefMsgID string `json:"inf_refmsgid"`
  6046. InfCode int `json:"infcode"`
  6047. Output struct {
  6048. Result []struct {
  6049. BasMednFlag string `json:"bas_medn_flag"`
  6050. ChldMedcFlag string `json:"chld_medc_flag"`
  6051. ChrgitmLv string `json:"chrgitm_lv"`
  6052. Cnt float64 `json:"cnt"`
  6053. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  6054. DrtReimFlag string `json:"drt_reim_flag"`
  6055. FeedetlSn string `json:"feedetl_sn"`
  6056. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  6057. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  6058. InscpScpAmt float64 `json:"inscp_scp_amt"`
  6059. ListSpItemFlag string `json:"list_sp_item_flag"`
  6060. LmtUsedFlag string `json:"lmt_used_flag"`
  6061. MedChrgitmType string `json:"med_chrgitm_type"`
  6062. Memo string `json:"memo"`
  6063. OverlmtAmt float64 `json:"overlmt_amt"`
  6064. PreselfpayAmt float64 `json:"preselfpay_amt"`
  6065. Pric float64 `json:"pric"`
  6066. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  6067. SelfpayProp float64 `json:"selfpay_prop"`
  6068. } `json:"result"`
  6069. } `json:"output"`
  6070. }
  6071. type Response struct {
  6072. Output Output `json:"output"`
  6073. Infcode int `json:"infcode"`
  6074. InfRefMsgID string `json:"inf_refmsgid"`
  6075. RefMsgTime string `json:"refmsg_time"`
  6076. RespondTime string `json:"respond_time"`
  6077. ErrMsg string `json:"err_msg"`
  6078. WarnMsg string `json:"warn_msg"`
  6079. SignType string `json:"signtype"`
  6080. CAInfo string `json:"cainfo"`
  6081. }
  6082. func (c *HisApiController) Getquerydata() {
  6083. query_type, _ := c.GetInt64("type")
  6084. refd_setl_flag := c.GetString("refd_setl_flag")
  6085. med_type := c.GetString("med_type")
  6086. //admin_user_id,_ := c.GetInt64("admin_user_id")
  6087. cert_no := c.GetString("cert_no")
  6088. psn_no := c.GetString("psn_no")
  6089. start_time := c.GetString("start_time")
  6090. end_time := c.GetString("end_time")
  6091. page, _ := c.GetInt64("page")
  6092. limit, _ := c.GetInt64("limit")
  6093. var bp models.BusinessParams5262
  6094. bp.RefdSetlFlag = refd_setl_flag
  6095. bp.MedType = med_type
  6096. bp.Certno = cert_no
  6097. bp.Psnno = psn_no
  6098. bp.QBegntime = start_time
  6099. bp.QEndtime = end_time
  6100. if query_type == 1 { //本地
  6101. Post5262(c, bp, page, limit)
  6102. } else { //异地
  6103. Post5267(c, bp, page, limit)
  6104. }
  6105. }
  6106. func (c *HisApiController) Drugscheck() {
  6107. admin_user_id, _ := c.GetInt64("admin_user_id")
  6108. adminUser := c.GetAdminUserInfo()
  6109. var queryResult []QueryResult
  6110. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  6111. for _, item := range drugs {
  6112. result := QueryResult{
  6113. ID: item.ID,
  6114. Name: item.DrugName,
  6115. Code: item.MedicalInsuranceNumber,
  6116. List_type_code: "101",
  6117. }
  6118. queryResult = append(queryResult, result)
  6119. }
  6120. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6121. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6122. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6123. for _, item := range queryResult {
  6124. 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)
  6125. }
  6126. }
  6127. func (c *HisApiController) Goodcheck() {
  6128. admin_user_id, _ := c.GetInt64("admin_user_id")
  6129. adminUser := c.GetAdminUserInfo()
  6130. var queryResult []QueryResult
  6131. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  6132. for _, item := range goods {
  6133. result := QueryResult{
  6134. ID: item.ID,
  6135. Name: item.GoodName,
  6136. Code: item.SocialSecurityDirectoryCode,
  6137. List_type_code: "301",
  6138. }
  6139. queryResult = append(queryResult, result)
  6140. }
  6141. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6142. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6143. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6144. for _, item := range queryResult {
  6145. 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)
  6146. //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)
  6147. }
  6148. }
  6149. func (c *HisApiController) Projectcheck() {
  6150. admin_user_id, _ := c.GetInt64("admin_user_id")
  6151. adminUser := c.GetAdminUserInfo()
  6152. var queryResult []QueryResult
  6153. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  6154. for _, item := range projects {
  6155. result := QueryResult{
  6156. ID: item.ID,
  6157. Name: item.ProjectName,
  6158. Code: item.MedicalCode,
  6159. List_type_code: "201",
  6160. }
  6161. queryResult = append(queryResult, result)
  6162. }
  6163. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6164. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6165. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6166. for _, item := range queryResult {
  6167. 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)
  6168. }
  6169. }
  6170. //func (c *HisApiController)CancleDia(){
  6171. //
  6172. // id, _ := c.GetInt64("id")
  6173. // record_time := c.GetString("record_time")
  6174. // his_patient_id, _ := c.GetInt64("his_patient_id")
  6175. //
  6176. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6177. //
  6178. // diagnosis_id := c.GetString("diagnosis")
  6179. // sick_type, _ := c.GetInt64("sick_type")
  6180. // reg_type, _ := c.GetInt64("p_type")
  6181. // begin_time := c.GetString("begin_time")
  6182. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  6183. //
  6184. //
  6185. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  6186. //
  6187. // fmt.Println(acct_used_flag)
  6188. //
  6189. //
  6190. // timeLayout := "2006-01-02"
  6191. // loc, _ := time.LoadLocation("Local")
  6192. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6193. // if err != nil {
  6194. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6195. // return
  6196. // }
  6197. // recordDateTime := theTime.Unix()
  6198. // adminUser := c.GetAdminUserInfo()
  6199. //
  6200. //
  6201. //
  6202. //
  6203. //
  6204. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6205. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6206. // var patientPrescription models.HisPrescriptionInfo
  6207. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6208. // if patientPrescription.ID == 0 {
  6209. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6210. // }
  6211. // //if patientPrescription.Do
  6212. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6213. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6214. //
  6215. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6216. //
  6217. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  6218. //
  6219. // var config []*models.HisXtDiagnoseConfig
  6220. // for _, item := range diagnosis_ids {
  6221. // id, _ := strconv.ParseInt(item, 10, 64)
  6222. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  6223. // config = append(config, &diagnosisConfig)
  6224. // }
  6225. //
  6226. // sickConfig, _ := service.FindSickById(sick_type)
  6227. //
  6228. //
  6229. // data := make(map[string]interface{})
  6230. // client := &http.Client{}
  6231. // data["psn_no"] = his.PsnNo
  6232. // data["mdtrt_id"] = his.Number
  6233. // data["doctor"] = roles.UserName
  6234. // data["department"] = department.Name
  6235. // data["org_name"] = miConfig.OrgName
  6236. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  6237. // data["doctor_id"] = doctor_info.DoctorNumber
  6238. // data["new_doctor_name"] = doctor_info.UserName
  6239. // data["fixmedins_code"] = miConfig.Code
  6240. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6241. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6242. // data["secret_key"] = miConfig.SecretKey
  6243. // data["sick_code"] = sickConfig.CountryCode
  6244. // data["sick_name"] = sickConfig.ClassName
  6245. // data["url"] = miConfig.Url
  6246. // data["ak"] = miConfig.AccessKey
  6247. // data["begin_time"] = begin_time
  6248. // data["cainfo"] = miConfig.Cainfo
  6249. // data["is_vaild"] = "0"
  6250. //
  6251. // data["dept"] = strconv.FormatInt(department.ID, 10)
  6252. // data["config"] = config
  6253. // bytesData, _ := json.Marshal(data)
  6254. //
  6255. // var req *http.Request
  6256. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  6257. // resp, _ := client.Do(req)
  6258. // defer resp.Body.Close()
  6259. // body, ioErr := ioutil.ReadAll(resp.Body)
  6260. // if ioErr != nil {
  6261. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6262. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6263. // return
  6264. // }
  6265. // var respJSON map[string]interface{}
  6266. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6267. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6268. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6269. // return
  6270. // }
  6271. //
  6272. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6273. // userJSONBytes, _ := json.Marshal(respJSON)
  6274. // fmt.Println("log")
  6275. // fmt.Println(string(userJSONBytes))
  6276. //
  6277. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  6278. // utils.ErrorLog("解析失败:%v", err)
  6279. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6280. // return
  6281. // }
  6282. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  6283. // res2.Output = ressix10265.Output
  6284. // res2.ErrMsg = ressix10265.ErrMsg
  6285. // res2.Cainfo = ressix10265.Cainfo
  6286. // res2.WarnMsg = ressix10265.WarnMsg
  6287. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  6288. // res2.Infcode = infocode
  6289. //
  6290. //}
  6291. func (c *HisApiController) Get4102() {
  6292. order_id, _ := c.GetInt64("order_id")
  6293. admin_user_id, _ := c.GetInt64("admin_user_id")
  6294. stas_type := c.GetString("stas_type")
  6295. order, _ := service.GetHisOrderByIDTwo(order_id)
  6296. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6297. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6298. var pp models.PublicParams
  6299. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6300. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6301. pp.FixmedinsName = miConfig.OrgName
  6302. pp.FixmedinsCode = miConfig.Code
  6303. pp.RequestUrl = miConfig.Url
  6304. pp.Cainfo = miConfig.Cainfo
  6305. pp.SecretKey = miConfig.SecretKey
  6306. pp.AccessKey = miConfig.AccessKey
  6307. pp.OpterName = curRoles.UserName
  6308. if miConfig.MdtrtareaAdmvs == "350500" {
  6309. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  6310. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  6311. saveLog(result, request, "4102", "清单确认")
  6312. var dat map[string]interface{}
  6313. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6314. fmt.Println(dat)
  6315. } else {
  6316. fmt.Println(err)
  6317. }
  6318. var empty ResultFourteen
  6319. userJSONBytes, _ := json.Marshal(dat)
  6320. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  6321. utils.ErrorLog("解析失败:%v", err)
  6322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6323. return
  6324. }
  6325. if empty.Infcode == 0 {
  6326. c.ServeSuccessJSON(map[string]interface{}{
  6327. "msg": "确认成功",
  6328. })
  6329. return
  6330. }
  6331. } else {
  6332. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  6333. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  6334. result3, request3 := service.Jxyb4105(pp)
  6335. saveLog(result, request, "4102", "清单确认")
  6336. saveLog(result2, request2, "4103", "清单确认")
  6337. saveLog(result3, request3, "4105", "清单统计")
  6338. var dat map[string]interface{}
  6339. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6340. fmt.Println(dat)
  6341. } else {
  6342. fmt.Println(err)
  6343. }
  6344. var empty ResultFourteen
  6345. userJSONBytes, _ := json.Marshal(dat)
  6346. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  6347. utils.ErrorLog("解析失败:%v", err)
  6348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6349. return
  6350. }
  6351. if empty.Infcode == 0 {
  6352. c.ServeSuccessJSON(map[string]interface{}{
  6353. "msg": "确认成功",
  6354. })
  6355. return
  6356. }
  6357. }
  6358. }
  6359. // 对账权限查询
  6360. func (c *HisApiController) Get3260() {
  6361. admin_user_id, _ := c.GetInt64("admin_user_id")
  6362. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6363. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6364. var api string
  6365. var res models.JSResult3260
  6366. if miConfig.MdtrtareaAdmvs == "320830" {
  6367. api = miConfig.AppSecret + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6368. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6369. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6370. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6371. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6372. } else {
  6373. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6374. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6375. }
  6376. resp, requestErr := http.Get(api)
  6377. if requestErr != nil {
  6378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6379. return
  6380. }
  6381. body, ioErr := ioutil.ReadAll(resp.Body)
  6382. if ioErr != nil {
  6383. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6385. return
  6386. }
  6387. var respJSON map[string]interface{}
  6388. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6389. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6391. return
  6392. }
  6393. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6394. result, _ := json.Marshal(respJSON)
  6395. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6396. utils.ErrorLog("解析失败:%v", err)
  6397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6398. return
  6399. }
  6400. if res.Infcode == "0" {
  6401. c.ServeSuccessJSON(map[string]interface{}{
  6402. "result": res.Output.Data,
  6403. })
  6404. } else {
  6405. c.ServeSuccessJSON(map[string]interface{}{
  6406. "failed_code": -10,
  6407. "msg": res.ErrMsg,
  6408. })
  6409. return
  6410. }
  6411. }
  6412. func (c *HisApiController) Get3261() {
  6413. admin_user_id, _ := c.GetInt64("admin_user_id")
  6414. //month := c.GetString("month")
  6415. startTime := c.GetString("start_time")
  6416. //endTime, _ := c.GetString("end_time")
  6417. times := strings.Split(startTime, "-")
  6418. stmt_mon := times[0] + times[1]
  6419. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6420. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6421. var api string
  6422. var res models.JSResult3261
  6423. //var res10265 Result5301For10265
  6424. if miConfig.MdtrtareaAdmvs == "320830" {
  6425. api = miConfig.AppSecret + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6426. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6427. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6428. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6429. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6430. } else {
  6431. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  6432. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  6433. }
  6434. resp, requestErr := http.Get(api)
  6435. if requestErr != nil {
  6436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6437. return
  6438. }
  6439. body, ioErr := ioutil.ReadAll(resp.Body)
  6440. if ioErr != nil {
  6441. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6443. return
  6444. }
  6445. var respJSON map[string]interface{}
  6446. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6447. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6449. return
  6450. }
  6451. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6452. result, _ := json.Marshal(respJSON)
  6453. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6454. utils.ErrorLog("解析失败:%v", err)
  6455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6456. return
  6457. }
  6458. if res.Infcode == "0" {
  6459. c.ServeSuccessJSON(map[string]interface{}{
  6460. "result": res.Output,
  6461. })
  6462. } else {
  6463. c.ServeSuccessJSON(map[string]interface{}{
  6464. "failed_code": -10,
  6465. "msg": res.ErrMsg,
  6466. })
  6467. return
  6468. }
  6469. }
  6470. type TempFun struct {
  6471. FundKey string
  6472. FundCode string
  6473. }
  6474. func (c *HisApiController) Get3262() {
  6475. admin_user_id, _ := c.GetInt64("admin_user_id")
  6476. startTime := c.GetString("start_time")
  6477. endTime := c.GetString("end_time")
  6478. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6479. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6480. //timeLayout := "2006-01-02"
  6481. //loc, _ := time.LoadLocation("Local")
  6482. //var theStartTIme int64
  6483. //if len(startTime) > 0 {
  6484. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  6485. // if err != nil {
  6486. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6487. // return
  6488. // }
  6489. // theStartTIme = theTime.Unix()
  6490. //}
  6491. //var theEndtTIme int64
  6492. //if len(endTime) > 0 {
  6493. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  6494. // if err != nil {
  6495. // utils.ErrorLog(err.Error())
  6496. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6497. // return
  6498. // }
  6499. // theEndtTIme = theTime.Unix()
  6500. //}
  6501. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6502. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  6503. for _, team := range datas {
  6504. fmt.Println(team.PsnTime)
  6505. for _, team_two := range datas_two {
  6506. fmt.Println(team_two.PsnTime)
  6507. if team.FundKey == team_two.FundKey {
  6508. fmt.Println(team_two.PsnTime)
  6509. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  6510. fmt.Println(team.PsnTime)
  6511. }
  6512. }
  6513. }
  6514. fmt.Println("1111")
  6515. fmt.Println(datas)
  6516. fmt.Println("1111")
  6517. var twos []models.FixMonRecDetailFileInTwo
  6518. for _, team := range datas {
  6519. var two models.FixMonRecDetailFileInTwo
  6520. two.MedType = team.MedType
  6521. two.Insutype = team.Insutype
  6522. two.PsnType = team.PsnType
  6523. two.MedType = team.MedType
  6524. two.FixBlngAdmdvs = "999999"
  6525. two.InsuAdmdvs = "555555"
  6526. two.PsnTime = team.PsnTime
  6527. two.PsnCnt = team.PsnCnt
  6528. two.FundKey = team.FundKey
  6529. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  6530. fps, _ := strconv.ParseFloat(team.Fund, 64)
  6531. ia, _ := strconv.ParseFloat(team.Amt, 64)
  6532. two.MedfeeSumAmt = ms
  6533. two.InscpAmt = ia
  6534. two.FundPaySumAmt = fps
  6535. twos = append(twos, two)
  6536. }
  6537. //startTime := c.GetString("start_time")
  6538. //endTime, _ := c.GetString("end_time")
  6539. times := strings.Split(startTime, "-")
  6540. stmt_mon := times[0] + times[1]
  6541. var funs []models.FundDetail
  6542. for _, item := range datas {
  6543. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  6544. funs = append(funs, fun...)
  6545. }
  6546. var funInfos []models.Fund
  6547. //for _, item := range funs {
  6548. // var rf []models.FundInfo
  6549. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  6550. // for _, subitem := range rf {
  6551. // var fund models.Fund
  6552. // fund.FundCode = subitem.FundPayType
  6553. // fund.FundName = subitem.FundPayTypeName
  6554. // fund.FundAmt = subitem.FundPayAmt
  6555. // fund.FundKey = item.FundKey
  6556. // fund.InsuAdmdvs = "555555"
  6557. // fund.FixBlngAdmdvs = "999999"
  6558. // funInfos = append(funInfos, fund)
  6559. // }
  6560. //}
  6561. var tempFuns []TempFun
  6562. for _, funInfo := range funInfos {
  6563. var tempFun TempFun
  6564. tempFun.FundKey = funInfo.FundKey
  6565. tempFun.FundCode = funInfo.FundCode
  6566. tempFuns = append(tempFuns, tempFun)
  6567. }
  6568. tempFuns = RemoveRepeatedFunElement(tempFuns)
  6569. fmt.Println(tempFuns)
  6570. var funInfosTwo []models.Fund
  6571. decimal.DivisionPrecision = 2
  6572. for _, item := range tempFuns {
  6573. var fund models.Fund
  6574. for _, subItem := range funInfos {
  6575. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  6576. fund.FundKey = subItem.FundKey
  6577. fund.InsuAdmdvs = subItem.InsuAdmdvs
  6578. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  6579. fund.FundName = subItem.FundName
  6580. fund.FundCode = subItem.FundCode
  6581. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  6582. }
  6583. }
  6584. funInfosTwo = append(funInfosTwo, fund)
  6585. }
  6586. fmt.Println("funInfosTwo")
  6587. fmt.Println(funInfosTwo)
  6588. var upld_btch string
  6589. var empty models.JSResultEmpty
  6590. data := make(map[string]interface{})
  6591. data["org_name"] = miConfig.OrgName
  6592. data["doctor"] = curRoles.UserName
  6593. data["doctor_name"] = curRoles.UserName
  6594. data["fixmedins_code"] = miConfig.Code
  6595. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6596. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6597. data["secret_key"] = miConfig.SecretKey
  6598. data["url"] = miConfig.Url
  6599. data["ak"] = miConfig.AccessKey
  6600. data["cainfo"] = miConfig.Cainfo
  6601. data["datas"] = twos
  6602. data["fund"] = funInfosTwo
  6603. fmt.Println(twos)
  6604. month := time.Unix(1557042972, 0).Format("1")
  6605. year := time.Now().Format("2006")
  6606. month = time.Now().Format("01")
  6607. day := time.Now().Format("02")
  6608. hour := time.Now().Format("15")
  6609. min := time.Now().Format("04")
  6610. sec := time.Now().Format("05")
  6611. fix_fill_date := year + month + day + hour + min + sec
  6612. data["fix_fill_dept"] = miConfig.OrgName
  6613. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6614. data["fix_fill_psn"] = curRoles.UserName
  6615. data["fix_fill_date"] = fix_fill_date
  6616. data["stmt_loc"] = "2"
  6617. data["setl_mon"] = stmt_mon
  6618. upld_btch = "0"
  6619. data["upld_btch"] = upld_btch
  6620. //fmt.Println(data)
  6621. client := &http.Client{}
  6622. bytesData, _ := json.Marshal(data)
  6623. var req *http.Request
  6624. if miConfig.MdtrtareaAdmvs == "320830" {
  6625. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3262", bytes.NewReader(bytesData))
  6626. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6627. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6628. } else {
  6629. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  6630. }
  6631. resp, _ := client.Do(req)
  6632. defer resp.Body.Close()
  6633. body, ioErr := ioutil.ReadAll(resp.Body)
  6634. if ioErr != nil {
  6635. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6637. }
  6638. var respJSON map[string]interface{}
  6639. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6640. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6642. }
  6643. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6644. //fmt.Println(respJSON)
  6645. result, _ := json.Marshal(respJSON)
  6646. //fmt.Println(result)
  6647. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  6648. utils.ErrorLog("解析失败:%v", err)
  6649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6650. }
  6651. if empty.Infcode != "0" {
  6652. c.ServeSuccessJSON(map[string]interface{}{
  6653. "failed_code": -10,
  6654. "msg": empty.ErrMsg,
  6655. })
  6656. return
  6657. } else {
  6658. c.ServeSuccessJSON(map[string]interface{}{
  6659. "msg": "上传成功",
  6660. })
  6661. return
  6662. }
  6663. }
  6664. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  6665. newArr = make([]TempFun, 0)
  6666. for i := 0; i < len(arr); i++ {
  6667. repeat := false
  6668. for j := i + 1; j < len(arr); j++ {
  6669. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  6670. repeat = true
  6671. break
  6672. }
  6673. }
  6674. if !repeat {
  6675. newArr = append(newArr, arr[i])
  6676. }
  6677. }
  6678. return
  6679. }
  6680. func (c *HisApiController) Get3263() {
  6681. admin_user_id, _ := c.GetInt64("admin_user_id")
  6682. startTime := c.GetString("start_time")
  6683. //endTime, _ := c.GetString("end_time")
  6684. times := strings.Split(startTime, "-")
  6685. setl_mon := times[0] + times[1]
  6686. upld_btch := "0"
  6687. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6688. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6689. var result3263 models.JSResult3263
  6690. data := make(map[string]interface{})
  6691. data["org_name"] = miConfig.OrgName
  6692. data["doctor"] = curRoles.UserName
  6693. data["doctor_name"] = curRoles.UserName
  6694. data["fixmedins_code"] = miConfig.Code
  6695. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6696. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6697. data["secret_key"] = miConfig.SecretKey
  6698. data["url"] = miConfig.Url
  6699. data["ak"] = miConfig.AccessKey
  6700. data["cainfo"] = miConfig.Cainfo
  6701. data["setl_mon"] = setl_mon
  6702. data["stmt_loc"] = "2"
  6703. data["upld_btch"] = upld_btch
  6704. client := &http.Client{}
  6705. bytesData, _ := json.Marshal(data)
  6706. var req *http.Request
  6707. if miConfig.MdtrtareaAdmvs == "320830" {
  6708. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3263", bytes.NewReader(bytesData))
  6709. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6710. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6711. } else {
  6712. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6713. }
  6714. resp, _ := client.Do(req)
  6715. defer resp.Body.Close()
  6716. body, ioErr := ioutil.ReadAll(resp.Body)
  6717. if ioErr != nil {
  6718. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6720. }
  6721. var respJSON map[string]interface{}
  6722. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6723. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6725. }
  6726. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6727. fmt.Println(respJSON)
  6728. result, _ := json.Marshal(respJSON)
  6729. fmt.Println(result)
  6730. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6731. utils.ErrorLog("解析失败:%v", err)
  6732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6733. }
  6734. if result3263.Infcode != "0" {
  6735. c.ServeSuccessJSON(map[string]interface{}{
  6736. "failed_code": -10,
  6737. "msg": result3263.ErrMsg,
  6738. })
  6739. return
  6740. } else {
  6741. c.ServeSuccessJSON(map[string]interface{}{
  6742. "list": result3263.Output,
  6743. })
  6744. return
  6745. }
  6746. }
  6747. func (c *HisApiController) Get3264() {
  6748. admin_user_id, _ := c.GetInt64("admin_user_id")
  6749. startTime := c.GetString("start_time")
  6750. //endTime, _ := c.GetString("end_time")
  6751. times := strings.Split(startTime, "-")
  6752. setl_mon := times[0] + times[1]
  6753. upld_btch := "0"
  6754. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6755. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6756. //solidify_id := []
  6757. var result3263 models.JSResult3263
  6758. data := make(map[string]interface{})
  6759. data["org_name"] = miConfig.OrgName
  6760. data["doctor"] = curRoles.UserName
  6761. data["doctor_name"] = curRoles.UserName
  6762. data["fixmedins_code"] = miConfig.Code
  6763. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6764. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6765. data["secret_key"] = miConfig.SecretKey
  6766. data["url"] = miConfig.Url
  6767. data["ak"] = miConfig.AccessKey
  6768. data["cainfo"] = miConfig.Cainfo
  6769. data["setl_mon"] = setl_mon
  6770. data["stmt_loc"] = "2"
  6771. data["upld_btch"] = upld_btch
  6772. client := &http.Client{}
  6773. bytesData, _ := json.Marshal(data)
  6774. var req3263 *http.Request
  6775. if miConfig.MdtrtareaAdmvs == "320830" {
  6776. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3263", bytes.NewReader(bytesData))
  6777. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6778. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6779. } else {
  6780. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  6781. }
  6782. resp, _ := client.Do(req3263)
  6783. defer resp.Body.Close()
  6784. body, ioErr := ioutil.ReadAll(resp.Body)
  6785. if ioErr != nil {
  6786. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6788. }
  6789. var respJSON3263 map[string]interface{}
  6790. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  6791. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6793. }
  6794. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6795. fmt.Println(respJSON3263)
  6796. result, _ := json.Marshal(respJSON3263)
  6797. fmt.Println(result)
  6798. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  6799. utils.ErrorLog("解析失败:%v", err)
  6800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6801. }
  6802. var ids []string
  6803. for _, item := range result3263.Output {
  6804. ids = append(ids, item.SolidifyID)
  6805. }
  6806. var empty models.JSResultEmpty
  6807. data2 := make(map[string]interface{})
  6808. data2["org_name"] = miConfig.OrgName
  6809. data2["doctor"] = curRoles.UserName
  6810. data2["doctor_name"] = curRoles.UserName
  6811. data2["fixmedins_code"] = miConfig.Code
  6812. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6813. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6814. data2["secret_key"] = miConfig.SecretKey
  6815. data2["url"] = miConfig.Url
  6816. data2["ak"] = miConfig.AccessKey
  6817. data2["cainfo"] = miConfig.Cainfo
  6818. data2["setl_mon"] = setl_mon
  6819. data2["stmt_loc"] = "2"
  6820. data2["upld_btch"] = upld_btch
  6821. data2["solidify_id"] = ids
  6822. client2 := &http.Client{}
  6823. bytesData2, _ := json.Marshal(data2)
  6824. var req *http.Request
  6825. if miConfig.MdtrtareaAdmvs == "320830" {
  6826. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3264", bytes.NewReader(bytesData))
  6827. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6828. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6829. } else {
  6830. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  6831. }
  6832. resp2, _ := client2.Do(req)
  6833. defer resp.Body.Close()
  6834. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6835. if ioErr2 != nil {
  6836. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6838. }
  6839. var respJSON map[string]interface{}
  6840. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  6841. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6843. }
  6844. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6845. fmt.Println(respJSON)
  6846. result2, _ := json.Marshal(respJSON)
  6847. fmt.Println(result2)
  6848. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  6849. utils.ErrorLog("解析失败:%v", err)
  6850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6851. }
  6852. if empty.Infcode != "0" {
  6853. c.ServeSuccessJSON(map[string]interface{}{
  6854. "failed_code": -10,
  6855. "msg": empty.ErrMsg,
  6856. })
  6857. return
  6858. } else {
  6859. c.ServeSuccessJSON(map[string]interface{}{
  6860. "msg": "",
  6861. })
  6862. return
  6863. }
  6864. }
  6865. func (c *HisApiController) Get3265() {
  6866. admin_user_id, _ := c.GetInt64("admin_user_id")
  6867. startTime := c.GetString("start_time")
  6868. //endTime, _ := c.GetString("end_time")
  6869. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6870. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6871. times := strings.Split(startTime, "-")
  6872. setl_mon := times[0] + times[1]
  6873. var upld_btch string
  6874. upld_btch = "0"
  6875. //var empty models.JSResultEmpty
  6876. var result3265 models.JSResult3264
  6877. var result3263 models.JSResult3263
  6878. data2 := make(map[string]interface{})
  6879. data2["org_name"] = miConfig.OrgName
  6880. data2["doctor"] = curRoles.UserName
  6881. data2["doctor_name"] = curRoles.UserName
  6882. data2["fixmedins_code"] = miConfig.Code
  6883. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6884. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6885. data2["secret_key"] = miConfig.SecretKey
  6886. data2["url"] = miConfig.Url
  6887. data2["ak"] = miConfig.AccessKey
  6888. data2["cainfo"] = miConfig.Cainfo
  6889. data2["setl_mon"] = setl_mon
  6890. data2["stmt_loc"] = "2"
  6891. data2["upld_btch"] = upld_btch
  6892. client2 := &http.Client{}
  6893. bytesData2, _ := json.Marshal(data2)
  6894. var req3263 *http.Request
  6895. if miConfig.MdtrtareaAdmvs == "320830" {
  6896. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3263", bytes.NewReader(bytesData2))
  6897. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6898. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6899. } else {
  6900. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  6901. }
  6902. resp2, _ := client2.Do(req3263)
  6903. defer resp2.Body.Close()
  6904. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6905. if ioErr2 != nil {
  6906. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6908. }
  6909. var respJSON3263 map[string]interface{}
  6910. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  6911. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6913. }
  6914. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6915. fmt.Println(respJSON3263)
  6916. result2, _ := json.Marshal(respJSON3263)
  6917. fmt.Println(result2)
  6918. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  6919. utils.ErrorLog("解析失败:%v", err)
  6920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6921. }
  6922. var ids []string
  6923. for _, item := range result3263.Output {
  6924. ids = append(ids, item.SolidifyID)
  6925. }
  6926. data := make(map[string]interface{})
  6927. data["org_name"] = miConfig.OrgName
  6928. data["doctor"] = curRoles.UserName
  6929. data["doctor_name"] = curRoles.UserName
  6930. data["fixmedins_code"] = miConfig.Code
  6931. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6932. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6933. data["secret_key"] = miConfig.SecretKey
  6934. data["url"] = miConfig.Url
  6935. data["ak"] = miConfig.AccessKey
  6936. data["cainfo"] = miConfig.Cainfo
  6937. data["setl_mon"] = setl_mon
  6938. data["solidify_id"] = ids
  6939. month := time.Unix(1557042972, 0).Format("1")
  6940. year := time.Now().Format("2006")
  6941. month = time.Now().Format("01")
  6942. day := time.Now().Format("02")
  6943. hour := time.Now().Format("15")
  6944. min := time.Now().Format("04")
  6945. sec := time.Now().Format("05")
  6946. fix_fill_date := year + month + day + hour + min + sec
  6947. data["fix_fill_dept"] = miConfig.OrgName
  6948. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  6949. data["fix_fill_psn"] = curRoles.UserName
  6950. data["fix_fill_date"] = fix_fill_date
  6951. data["stmt_loc"] = "2"
  6952. data["upld_btch"] = upld_btch
  6953. client := &http.Client{}
  6954. bytesData, _ := json.Marshal(data)
  6955. var req *http.Request
  6956. if miConfig.MdtrtareaAdmvs == "320830" {
  6957. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3265", bytes.NewReader(bytesData2))
  6958. } else if miConfig.MdtrtareaAdmvs == "320921" {
  6959. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6960. } else {
  6961. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  6962. }
  6963. resp, _ := client.Do(req)
  6964. defer resp.Body.Close()
  6965. body, ioErr := ioutil.ReadAll(resp.Body)
  6966. if ioErr != nil {
  6967. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6969. }
  6970. var respJSON map[string]interface{}
  6971. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6972. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6974. }
  6975. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6976. fmt.Println(respJSON)
  6977. result, _ := json.Marshal(respJSON)
  6978. fmt.Println(result)
  6979. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  6980. utils.ErrorLog("解析失败:%v", err)
  6981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6982. }
  6983. if result3265.Infcode != "0" {
  6984. c.ServeSuccessJSON(map[string]interface{}{
  6985. "failed_code": -10,
  6986. "msg": result3265.ErrMsg,
  6987. })
  6988. return
  6989. } else {
  6990. c.ServeSuccessJSON(map[string]interface{}{
  6991. "info": result3265.Output,
  6992. })
  6993. return
  6994. }
  6995. }
  6996. func (c *HisApiController) Get3266() {
  6997. admin_user_id, _ := c.GetInt64("admin_user_id")
  6998. startTime := c.GetString("start_time")
  6999. //endTime, _ := c.GetString("end_time")
  7000. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7001. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7002. times := strings.Split(startTime, "-")
  7003. stmt_mon := times[0] + times[1]
  7004. var upld_btch string
  7005. //var empty models.JSResultEmpty
  7006. var result3265 models.JSResult3264
  7007. data := make(map[string]interface{})
  7008. data["org_name"] = miConfig.OrgName
  7009. data["doctor"] = curRoles.UserName
  7010. data["doctor_name"] = curRoles.UserName
  7011. data["fixmedins_code"] = miConfig.Code
  7012. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7013. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7014. data["secret_key"] = miConfig.SecretKey
  7015. data["url"] = miConfig.Url
  7016. data["ak"] = miConfig.AccessKey
  7017. data["cainfo"] = miConfig.Cainfo
  7018. data["setl_mon"] = stmt_mon
  7019. month := time.Unix(1557042972, 0).Format("1")
  7020. year := time.Now().Format("2006")
  7021. month = time.Now().Format("01")
  7022. day := time.Now().Format("02")
  7023. hour := time.Now().Format("15")
  7024. min := time.Now().Format("04")
  7025. sec := time.Now().Format("05")
  7026. fix_fill_date := year + month + day + hour + min + sec
  7027. data["fix_fill_dept"] = miConfig.OrgName
  7028. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7029. data["fix_fill_psn"] = curRoles.UserName
  7030. data["fix_fill_date"] = fix_fill_date
  7031. data["stmt_loc"] = "2"
  7032. upld_btch = "0"
  7033. data["upld_btch"] = upld_btch
  7034. client := &http.Client{}
  7035. bytesData, _ := json.Marshal(data)
  7036. var req *http.Request
  7037. if miConfig.MdtrtareaAdmvs == "320830" {
  7038. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3266", bytes.NewReader(bytesData))
  7039. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7040. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  7041. } else {
  7042. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  7043. }
  7044. resp, _ := client.Do(req)
  7045. defer resp.Body.Close()
  7046. body, ioErr := ioutil.ReadAll(resp.Body)
  7047. if ioErr != nil {
  7048. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7050. }
  7051. var respJSON map[string]interface{}
  7052. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7053. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7055. }
  7056. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7057. fmt.Println(respJSON)
  7058. result, _ := json.Marshal(respJSON)
  7059. fmt.Println(result)
  7060. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7061. utils.ErrorLog("解析失败:%v", err)
  7062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7063. }
  7064. if result3265.Infcode != "0" {
  7065. c.ServeSuccessJSON(map[string]interface{}{
  7066. "failed_code": -10,
  7067. "msg": result3265.ErrMsg,
  7068. })
  7069. return
  7070. } else {
  7071. c.ServeSuccessJSON(map[string]interface{}{
  7072. "info": result3265.Output,
  7073. })
  7074. return
  7075. }
  7076. }
  7077. func (c *HisApiController) Get3267() {
  7078. admin_user_id, _ := c.GetInt64("admin_user_id")
  7079. startTime := c.GetString("start_time")
  7080. //endTime, _ := c.GetString("end_time")
  7081. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7082. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7083. times := strings.Split(startTime, "-")
  7084. setl_mon := times[0] + times[1]
  7085. var upld_btch string
  7086. //var empty models.JSResultEmpty
  7087. var result3265 models.JSResult3264
  7088. upld_btch = "0"
  7089. data := make(map[string]interface{})
  7090. data["org_name"] = miConfig.OrgName
  7091. data["doctor"] = curRoles.UserName
  7092. data["doctor_name"] = curRoles.UserName
  7093. data["fixmedins_code"] = miConfig.Code
  7094. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7095. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7096. data["secret_key"] = miConfig.SecretKey
  7097. data["url"] = miConfig.Url
  7098. data["ak"] = miConfig.AccessKey
  7099. data["cainfo"] = miConfig.Cainfo
  7100. data["setl_mon"] = setl_mon
  7101. data["stmt_loc"] = "2"
  7102. data["upld_btch"] = upld_btch
  7103. client := &http.Client{}
  7104. bytesData, _ := json.Marshal(data)
  7105. var req *http.Request
  7106. if miConfig.MdtrtareaAdmvs == "320830" {
  7107. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3267", bytes.NewReader(bytesData))
  7108. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7109. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  7110. } else {
  7111. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  7112. }
  7113. resp, _ := client.Do(req)
  7114. defer resp.Body.Close()
  7115. body, ioErr := ioutil.ReadAll(resp.Body)
  7116. if ioErr != nil {
  7117. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7119. }
  7120. var respJSON map[string]interface{}
  7121. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7122. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7124. }
  7125. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7126. fmt.Println(respJSON)
  7127. result, _ := json.Marshal(respJSON)
  7128. fmt.Println(result)
  7129. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7130. utils.ErrorLog("解析失败:%v", err)
  7131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7132. }
  7133. if result3265.Infcode != "0" {
  7134. c.ServeSuccessJSON(map[string]interface{}{
  7135. "failed_code": -10,
  7136. "msg": result3265.ErrMsg,
  7137. })
  7138. return
  7139. } else {
  7140. c.ServeSuccessJSON(map[string]interface{}{
  7141. "info": result3265.Output.Data,
  7142. })
  7143. return
  7144. }
  7145. }
  7146. func (c *HisApiController) Get3268() {
  7147. admin_user_id, _ := c.GetInt64("admin_user_id")
  7148. startTime := c.GetString("start_time")
  7149. endTime := c.GetString("end_time")
  7150. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7151. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7152. times := strings.Split(startTime, "-")
  7153. setl_mon := times[0] + times[1]
  7154. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  7155. var twos []models.FixMonRecDetailFileInTwo
  7156. var funs []models.FundDetail
  7157. for _, item := range datas {
  7158. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  7159. funs = append(funs, fun...)
  7160. }
  7161. var funInfos []models.Fund
  7162. //for _, item := range funs {
  7163. // var rf []models.FundInfo
  7164. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  7165. // for _, subitem := range rf {
  7166. // var fund models.Fund
  7167. // fund.FundCode = subitem.FundPayType
  7168. // fund.FundName = subitem.FundPayTypeName
  7169. // fund.FundAmt = subitem.FundPayAmt
  7170. // fund.FundKey = item.FundKey
  7171. // fund.InsuAdmdvs = "555555"
  7172. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  7173. // funInfos = append(funInfos, fund)
  7174. // }
  7175. //}
  7176. for _, team := range datas {
  7177. var two models.FixMonRecDetailFileInTwo
  7178. two.SetlDate = time.Now().Format("2006-01-02")
  7179. two.MedType = team.MedType
  7180. two.Insutype = team.Insutype
  7181. two.PsnType = team.PsnType
  7182. two.MedType = team.MedType
  7183. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  7184. two.InsuAdmdvs = team.InsuAdmdvs
  7185. two.PsnTime = team.PsnTime
  7186. two.PsnCnt = team.PsnCnt
  7187. two.FundKey = team.FundKey
  7188. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  7189. fps, _ := strconv.ParseFloat(team.Fund, 64)
  7190. ia, _ := strconv.ParseFloat(team.Amt, 64)
  7191. two.MedfeeSumAmt = ms
  7192. two.InscpAmt = ia
  7193. two.FundPaySumAmt = fps
  7194. twos = append(twos, two)
  7195. }
  7196. var upld_btch string
  7197. upld_btch = "0"
  7198. var empty models.JSResultEmpty
  7199. data := make(map[string]interface{})
  7200. data["org_name"] = miConfig.OrgName
  7201. data["doctor"] = curRoles.UserName
  7202. data["doctor_name"] = curRoles.UserName
  7203. data["fixmedins_code"] = miConfig.Code
  7204. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7205. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7206. data["secret_key"] = miConfig.SecretKey
  7207. data["url"] = miConfig.Url
  7208. data["ak"] = miConfig.AccessKey
  7209. data["cainfo"] = miConfig.Cainfo
  7210. data["datas"] = twos
  7211. data["fund"] = funInfos
  7212. data["setl_mon"] = setl_mon
  7213. month := time.Unix(1557042972, 0).Format("1")
  7214. year := time.Now().Format("2006")
  7215. month = time.Now().Format("01")
  7216. day := time.Now().Format("02")
  7217. hour := time.Now().Format("15")
  7218. min := time.Now().Format("04")
  7219. sec := time.Now().Format("05")
  7220. fix_fill_date := year + month + day + hour + min + sec
  7221. data["fix_fill_dept"] = miConfig.OrgName
  7222. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7223. data["fix_fill_psn"] = curRoles.UserName
  7224. data["fix_fill_date"] = fix_fill_date
  7225. data["stmt_loc"] = "2"
  7226. data["upld_btch"] = upld_btch
  7227. client := &http.Client{}
  7228. bytesData, _ := json.Marshal(data)
  7229. var req *http.Request
  7230. if miConfig.MdtrtareaAdmvs == "320830" {
  7231. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3268", bytes.NewReader(bytesData))
  7232. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7233. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  7234. } else {
  7235. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  7236. }
  7237. resp, _ := client.Do(req)
  7238. defer resp.Body.Close()
  7239. body, ioErr := ioutil.ReadAll(resp.Body)
  7240. if ioErr != nil {
  7241. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7243. }
  7244. var respJSON map[string]interface{}
  7245. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7246. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7248. }
  7249. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7250. fmt.Println(respJSON)
  7251. result, _ := json.Marshal(respJSON)
  7252. fmt.Println(result)
  7253. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  7254. utils.ErrorLog("解析失败:%v", err)
  7255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7256. }
  7257. if empty.Infcode != "0" {
  7258. c.ServeSuccessJSON(map[string]interface{}{
  7259. "failed_code": -10,
  7260. "msg": empty.ErrMsg,
  7261. })
  7262. return
  7263. } else {
  7264. c.ServeSuccessJSON(map[string]interface{}{
  7265. "msg": "上传成功",
  7266. })
  7267. return
  7268. }
  7269. }
  7270. func (c *HisApiController) Get3269() {
  7271. admin_user_id, _ := c.GetInt64("admin_user_id")
  7272. startTime := c.GetString("start_time")
  7273. //endTime, _ := c.GetString("end_time")
  7274. times := strings.Split(startTime, "-")
  7275. setl_mon := times[0] + times[1]
  7276. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7277. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7278. var result3263 models.JSResult3263
  7279. data := make(map[string]interface{})
  7280. data["org_name"] = miConfig.OrgName
  7281. data["doctor"] = curRoles.UserName
  7282. data["doctor_name"] = curRoles.UserName
  7283. data["fixmedins_code"] = miConfig.Code
  7284. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7285. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7286. data["secret_key"] = miConfig.SecretKey
  7287. data["url"] = miConfig.Url
  7288. data["ak"] = miConfig.AccessKey
  7289. data["cainfo"] = miConfig.Cainfo
  7290. data["setl_mon"] = setl_mon
  7291. data["stmt_loc"] = "2"
  7292. client := &http.Client{}
  7293. bytesData, _ := json.Marshal(data)
  7294. var req *http.Request
  7295. if miConfig.MdtrtareaAdmvs == "320830" {
  7296. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3269", bytes.NewReader(bytesData))
  7297. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7298. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  7299. } else {
  7300. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  7301. }
  7302. resp, _ := client.Do(req)
  7303. defer resp.Body.Close()
  7304. body, ioErr := ioutil.ReadAll(resp.Body)
  7305. if ioErr != nil {
  7306. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7308. }
  7309. var respJSON map[string]interface{}
  7310. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7311. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7313. }
  7314. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7315. fmt.Println(respJSON)
  7316. result, _ := json.Marshal(respJSON)
  7317. fmt.Println(result)
  7318. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  7319. utils.ErrorLog("解析失败:%v", err)
  7320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7321. }
  7322. if result3263.Infcode != "0" {
  7323. c.ServeSuccessJSON(map[string]interface{}{
  7324. "failed_code": -10,
  7325. "msg": result3263.ErrMsg,
  7326. })
  7327. return
  7328. } else {
  7329. c.ServeSuccessJSON(map[string]interface{}{
  7330. "msg": "上传成功",
  7331. })
  7332. return
  7333. }
  7334. }
  7335. func (c *HisApiController) Get3270() {
  7336. admin_user_id, _ := c.GetInt64("admin_user_id")
  7337. startTime := c.GetString("start_time")
  7338. //endTime, _ := c.GetString("end_time")
  7339. times := strings.Split(startTime, "-")
  7340. setl_mon := times[0] + times[1]
  7341. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7342. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7343. var result3263 models.JSResult3263
  7344. data2 := make(map[string]interface{})
  7345. data2["org_name"] = miConfig.OrgName
  7346. data2["doctor"] = curRoles.UserName
  7347. data2["doctor_name"] = curRoles.UserName
  7348. data2["fixmedins_code"] = miConfig.Code
  7349. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7350. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7351. data2["secret_key"] = miConfig.SecretKey
  7352. data2["url"] = miConfig.Url
  7353. data2["ak"] = miConfig.AccessKey
  7354. data2["cainfo"] = miConfig.Cainfo
  7355. data2["setl_mon"] = setl_mon
  7356. data2["stmt_loc"] = "2"
  7357. client2 := &http.Client{}
  7358. bytesData2, _ := json.Marshal(data2)
  7359. var req3263 *http.Request
  7360. if miConfig.MdtrtareaAdmvs == "320830" {
  7361. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3269", bytes.NewReader(bytesData2))
  7362. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7363. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7364. } else {
  7365. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7366. }
  7367. resp2, _ := client2.Do(req3263)
  7368. defer resp2.Body.Close()
  7369. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7370. if ioErr2 != nil {
  7371. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7373. }
  7374. var respJSON3263 map[string]interface{}
  7375. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7376. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7378. }
  7379. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7380. fmt.Println(respJSON3263)
  7381. result2, _ := json.Marshal(respJSON3263)
  7382. fmt.Println(result2)
  7383. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7384. utils.ErrorLog("解析失败:%v", err)
  7385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7386. }
  7387. var ids []string
  7388. for _, item := range result3263.Output {
  7389. ids = append(ids, item.SolidifyID)
  7390. }
  7391. var result3264 models.JSResult3264
  7392. data := make(map[string]interface{})
  7393. data["org_name"] = miConfig.OrgName
  7394. data["doctor"] = curRoles.UserName
  7395. data["doctor_name"] = curRoles.UserName
  7396. data["fixmedins_code"] = miConfig.Code
  7397. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7398. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7399. data["secret_key"] = miConfig.SecretKey
  7400. data["url"] = miConfig.Url
  7401. data["ak"] = miConfig.AccessKey
  7402. data["cainfo"] = miConfig.Cainfo
  7403. data["setl_mon"] = setl_mon
  7404. data["stmt_loc"] = "2"
  7405. data["solidify_id"] = ids
  7406. client := &http.Client{}
  7407. bytesData, _ := json.Marshal(data)
  7408. var req *http.Request
  7409. if miConfig.MdtrtareaAdmvs == "320830" {
  7410. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3270", bytes.NewReader(bytesData))
  7411. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7412. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7413. } else {
  7414. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  7415. }
  7416. resp, _ := client.Do(req)
  7417. defer resp.Body.Close()
  7418. body, ioErr := ioutil.ReadAll(resp.Body)
  7419. if ioErr != nil {
  7420. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7422. }
  7423. var respJSON map[string]interface{}
  7424. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7425. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7427. }
  7428. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7429. fmt.Println(respJSON)
  7430. result, _ := json.Marshal(respJSON)
  7431. fmt.Println(result)
  7432. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  7433. utils.ErrorLog("解析失败:%v", err)
  7434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7435. }
  7436. if result3264.Infcode != "0" {
  7437. c.ServeSuccessJSON(map[string]interface{}{
  7438. "failed_code": -10,
  7439. "msg": result3264.ErrMsg,
  7440. })
  7441. return
  7442. } else {
  7443. c.ServeSuccessJSON(map[string]interface{}{
  7444. "info": result3264.Output,
  7445. })
  7446. return
  7447. }
  7448. }
  7449. func (c *HisApiController) Get3271() {
  7450. admin_user_id, _ := c.GetInt64("admin_user_id")
  7451. startTime := c.GetString("start_time")
  7452. //endTime, _ := c.GetString("end_time")
  7453. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7454. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7455. times := strings.Split(startTime, "-")
  7456. setl_mon := times[0] + times[1]
  7457. //var empty models.JSResultEmpty
  7458. var result3265 models.JSResult3264
  7459. var result3263 models.JSResult3263
  7460. data2 := make(map[string]interface{})
  7461. data2["org_name"] = miConfig.OrgName
  7462. data2["doctor"] = curRoles.UserName
  7463. data2["doctor_name"] = curRoles.UserName
  7464. data2["fixmedins_code"] = miConfig.Code
  7465. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7466. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7467. data2["secret_key"] = miConfig.SecretKey
  7468. data2["url"] = miConfig.Url
  7469. data2["ak"] = miConfig.AccessKey
  7470. data2["cainfo"] = miConfig.Cainfo
  7471. data2["setl_mon"] = setl_mon
  7472. data2["stmt_loc"] = "2"
  7473. client2 := &http.Client{}
  7474. bytesData2, _ := json.Marshal(data2)
  7475. var req3263 *http.Request
  7476. if miConfig.MdtrtareaAdmvs == "320830" {
  7477. req3263, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3269", bytes.NewReader(bytesData2))
  7478. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7479. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7480. } else {
  7481. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  7482. }
  7483. resp2, _ := client2.Do(req3263)
  7484. defer resp2.Body.Close()
  7485. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7486. if ioErr2 != nil {
  7487. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7489. }
  7490. var respJSON3263 map[string]interface{}
  7491. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  7492. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7494. }
  7495. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7496. fmt.Println(respJSON3263)
  7497. result2, _ := json.Marshal(respJSON3263)
  7498. fmt.Println(result2)
  7499. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  7500. utils.ErrorLog("解析失败:%v", err)
  7501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7502. }
  7503. var ids []string
  7504. for _, item := range result3263.Output {
  7505. ids = append(ids, item.SolidifyID)
  7506. }
  7507. data := make(map[string]interface{})
  7508. data["org_name"] = miConfig.OrgName
  7509. data["doctor"] = curRoles.UserName
  7510. data["doctor_name"] = curRoles.UserName
  7511. data["fixmedins_code"] = miConfig.Code
  7512. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7513. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7514. data["secret_key"] = miConfig.SecretKey
  7515. data["url"] = miConfig.Url
  7516. data["ak"] = miConfig.AccessKey
  7517. data["cainfo"] = miConfig.Cainfo
  7518. data["setl_mon"] = setl_mon
  7519. data["solidify_id"] = ids
  7520. month := time.Unix(1557042972, 0).Format("1")
  7521. year := time.Now().Format("2006")
  7522. month = time.Now().Format("01")
  7523. day := time.Now().Format("02")
  7524. hour := time.Now().Format("15")
  7525. min := time.Now().Format("04")
  7526. sec := time.Now().Format("05")
  7527. fix_fill_date := year + month + day + hour + min + sec
  7528. data["fix_fill_dept"] = miConfig.OrgName
  7529. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7530. data["fix_fill_psn"] = curRoles.UserName
  7531. data["fix_fill_date"] = fix_fill_date
  7532. data["stmt_loc"] = "2"
  7533. client := &http.Client{}
  7534. bytesData, _ := json.Marshal(data)
  7535. var req *http.Request
  7536. if miConfig.MdtrtareaAdmvs == "320830" {
  7537. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3271", bytes.NewReader(bytesData2))
  7538. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7539. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7540. } else {
  7541. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  7542. }
  7543. resp, _ := client.Do(req)
  7544. defer resp.Body.Close()
  7545. body, ioErr := ioutil.ReadAll(resp.Body)
  7546. if ioErr != nil {
  7547. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7549. }
  7550. var respJSON map[string]interface{}
  7551. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7552. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7554. }
  7555. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7556. fmt.Println(respJSON)
  7557. result, _ := json.Marshal(respJSON)
  7558. fmt.Println(result)
  7559. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7560. utils.ErrorLog("解析失败:%v", err)
  7561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7562. }
  7563. if result3265.Infcode != "0" {
  7564. c.ServeSuccessJSON(map[string]interface{}{
  7565. "failed_code": -10,
  7566. "msg": result3265.ErrMsg,
  7567. })
  7568. return
  7569. } else {
  7570. c.ServeSuccessJSON(map[string]interface{}{
  7571. "info": result3265.Output.Data,
  7572. })
  7573. return
  7574. }
  7575. }
  7576. func (c *HisApiController) Get3272() {
  7577. admin_user_id, _ := c.GetInt64("admin_user_id")
  7578. startTime := c.GetString("start_time")
  7579. //endTime, _ := c.GetString("end_time")
  7580. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7581. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7582. times := strings.Split(startTime, "-")
  7583. setl_mon := times[0] + times[1]
  7584. var upld_btch string
  7585. //var empty models.JSResultEmpty
  7586. var result3265 models.JSResult3264
  7587. data := make(map[string]interface{})
  7588. data["org_name"] = miConfig.OrgName
  7589. data["doctor"] = curRoles.UserName
  7590. data["doctor_name"] = curRoles.UserName
  7591. data["fixmedins_code"] = miConfig.Code
  7592. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7593. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7594. data["secret_key"] = miConfig.SecretKey
  7595. data["url"] = miConfig.Url
  7596. data["ak"] = miConfig.AccessKey
  7597. data["cainfo"] = miConfig.Cainfo
  7598. data["setl_mon"] = setl_mon
  7599. month := time.Unix(1557042972, 0).Format("1")
  7600. year := time.Now().Format("2006")
  7601. month = time.Now().Format("01")
  7602. day := time.Now().Format("02")
  7603. hour := time.Now().Format("15")
  7604. min := time.Now().Format("04")
  7605. sec := time.Now().Format("05")
  7606. fix_fill_date := year + month + day + hour + min + sec
  7607. data["fix_fill_dept"] = miConfig.OrgName
  7608. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  7609. data["fix_fill_psn"] = curRoles.UserName
  7610. data["fix_fill_date"] = fix_fill_date
  7611. data["stmt_loc"] = "2"
  7612. data["upld_btch"] = upld_btch
  7613. client := &http.Client{}
  7614. bytesData, _ := json.Marshal(data)
  7615. var req *http.Request
  7616. if miConfig.MdtrtareaAdmvs == "320830" {
  7617. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3272", bytes.NewReader(bytesData))
  7618. } else if miConfig.MdtrtareaAdmvs == "320921" {
  7619. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7620. } else {
  7621. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  7622. }
  7623. resp, _ := client.Do(req)
  7624. defer resp.Body.Close()
  7625. body, ioErr := ioutil.ReadAll(resp.Body)
  7626. if ioErr != nil {
  7627. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7629. }
  7630. var respJSON map[string]interface{}
  7631. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7632. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7634. }
  7635. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7636. fmt.Println(respJSON)
  7637. result, _ := json.Marshal(respJSON)
  7638. fmt.Println(result)
  7639. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7640. utils.ErrorLog("解析失败:%v", err)
  7641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7642. }
  7643. if result3265.Infcode != "0" {
  7644. c.ServeSuccessJSON(map[string]interface{}{
  7645. "failed_code": -10,
  7646. "msg": result3265.ErrMsg,
  7647. })
  7648. return
  7649. } else {
  7650. c.ServeSuccessJSON(map[string]interface{}{
  7651. "info": result3265.Output,
  7652. })
  7653. return
  7654. }
  7655. }
  7656. func (c *HisApiController) Get3273() {
  7657. admin_user_id, _ := c.GetInt64("admin_user_id")
  7658. startTime := c.GetString("start_time")
  7659. //endTime, _ := c.GetString("end_time")
  7660. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7661. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7662. times := strings.Split(startTime, "-")
  7663. setl_mon := times[0] + times[1]
  7664. var result3265 models.JSResult3264
  7665. data := make(map[string]interface{})
  7666. data["org_name"] = miConfig.OrgName
  7667. data["doctor"] = curRoles.UserName
  7668. data["doctor_name"] = curRoles.UserName
  7669. data["fixmedins_code"] = miConfig.Code
  7670. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7671. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7672. data["secret_key"] = miConfig.SecretKey
  7673. data["url"] = miConfig.Url
  7674. data["ak"] = miConfig.AccessKey
  7675. data["cainfo"] = miConfig.Cainfo
  7676. data["setl_mon"] = setl_mon
  7677. data["stmt_loc"] = "2"
  7678. client := &http.Client{}
  7679. bytesData, _ := json.Marshal(data)
  7680. var req *http.Request
  7681. if miConfig.MdtrtareaAdmvs == "320921" {
  7682. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7683. } else {
  7684. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  7685. }
  7686. resp, _ := client.Do(req)
  7687. defer resp.Body.Close()
  7688. body, ioErr := ioutil.ReadAll(resp.Body)
  7689. if ioErr != nil {
  7690. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7692. }
  7693. var respJSON map[string]interface{}
  7694. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7695. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7697. }
  7698. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7699. fmt.Println(respJSON)
  7700. result, _ := json.Marshal(respJSON)
  7701. fmt.Println(result)
  7702. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  7703. utils.ErrorLog("解析失败:%v", err)
  7704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7705. }
  7706. if result3265.Infcode != "0" {
  7707. c.ServeSuccessJSON(map[string]interface{}{
  7708. "failed_code": -10,
  7709. "msg": result3265.ErrMsg,
  7710. })
  7711. return
  7712. } else {
  7713. c.ServeSuccessJSON(map[string]interface{}{
  7714. "info": result3265.Output.Data,
  7715. })
  7716. return
  7717. }
  7718. }
  7719. func (c *HisApiController) Get3274() {
  7720. //if miConfig.MdtrtareaAdmvs == "320921" {
  7721. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7722. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7723. // "&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
  7724. //
  7725. //} else {
  7726. // api = "http://192.168.5.251:9532/" + "jsyb/3274?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. //}
  7731. }
  7732. func (c *HisApiController) Get3275() {
  7733. //if miConfig.MdtrtareaAdmvs == "320921" {
  7734. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7735. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7736. // "&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
  7737. //
  7738. //} else {
  7739. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  7740. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  7741. // "&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
  7742. //
  7743. //}
  7744. }
  7745. func (c *HisApiController) Get3276() {
  7746. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7747. //month := c.GetString("month")
  7748. //
  7749. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7750. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7751. //var api string
  7752. //var res Result5301
  7753. //
  7754. //if miConfig.MdtrtareaAdmvs == "320921" {
  7755. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7756. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7757. //} else {
  7758. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7759. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7760. //}
  7761. //
  7762. //resp, requestErr := http.Get(api)
  7763. //if requestErr != nil {
  7764. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7765. // return
  7766. //}
  7767. //
  7768. //body, ioErr := ioutil.ReadAll(resp.Body)
  7769. //if ioErr != nil {
  7770. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7771. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7772. // return
  7773. //}
  7774. //var respJSON map[string]interface{}
  7775. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7776. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7777. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7778. // return
  7779. //}
  7780. //
  7781. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7782. //result, _ := json.Marshal(respJSON)
  7783. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7784. // utils.ErrorLog("解析失败:%v", err)
  7785. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7786. // return
  7787. //}
  7788. }
  7789. func (c *HisApiController) Get3277() {
  7790. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7791. //month := c.GetString("month")
  7792. //
  7793. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7794. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7795. //var api string
  7796. //var res Result5301
  7797. //
  7798. //if miConfig.MdtrtareaAdmvs == "320921" {
  7799. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7800. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7801. //} else {
  7802. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  7803. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  7804. //}
  7805. //
  7806. //resp, requestErr := http.Get(api)
  7807. //if requestErr != nil {
  7808. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7809. // return
  7810. //}
  7811. //
  7812. //body, ioErr := ioutil.ReadAll(resp.Body)
  7813. //if ioErr != nil {
  7814. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7815. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7816. // return
  7817. //}
  7818. //var respJSON map[string]interface{}
  7819. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7820. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7821. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7822. // return
  7823. //}
  7824. //
  7825. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7826. //result, _ := json.Marshal(respJSON)
  7827. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7828. // utils.ErrorLog("解析失败:%v", err)
  7829. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7830. // return
  7831. //}
  7832. }
  7833. func (c *HisApiController) GetCFYLJG001() {
  7834. admin_user_id, _ := c.GetInt64("admin_user_id")
  7835. patient_id, _ := c.GetInt64("patient_id")
  7836. his_patient_id, _ := c.GetInt64("his_patient_id")
  7837. record_time := c.GetString("record_time")
  7838. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7839. psn, _ := service.GetPsnByPatientId(patient_id)
  7840. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7841. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7842. var cFYLJG001 models.CFYLJG001
  7843. timeLayout := "2006-01-02"
  7844. loc, _ := time.LoadLocation("Local")
  7845. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7846. if err != nil {
  7847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7848. return
  7849. }
  7850. recordDateTime := theTime.Unix()
  7851. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7852. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7853. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  7854. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  7855. //dept, _ := service.GetDepartMentDetail(info.Departments)
  7856. for _, item := range prescriptions {
  7857. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  7858. if his.IdCardType == 1 {
  7859. bas := strings.Split(psn.CardInfo, "|")
  7860. basNumber := bas[1]
  7861. fmt.Println(basNumber)
  7862. card_sn := bas[3]
  7863. card_no := bas[2]
  7864. cFYLJG001.MdtrtCertType = "03"
  7865. cFYLJG001.CardSn = card_sn
  7866. cFYLJG001.MdtrtCertNo = card_no
  7867. cFYLJG001.EcToken = ""
  7868. cFYLJG001.AuthNo = ""
  7869. } else if his.IdCardType == 2 {
  7870. cFYLJG001.MdtrtCertType = "02"
  7871. cFYLJG001.CardSn = ""
  7872. cFYLJG001.MdtrtCertNo = his.IdCardNo
  7873. cFYLJG001.EcToken = ""
  7874. cFYLJG001.AuthNo = ""
  7875. } else if his.IdCardType == 4 {
  7876. cFYLJG001.MdtrtCertType = "01"
  7877. cFYLJG001.CardSn = ""
  7878. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  7879. cFYLJG001.EcToken = psn.VerifyNumber
  7880. cFYLJG001.AuthNo = ""
  7881. }
  7882. cFYLJG001.BizTypeCode = "01"
  7883. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  7884. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  7885. cFYLJG001.RxTypeCode = "1"
  7886. tempTime := time.Unix(item.PreTime, 0)
  7887. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  7888. cFYLJG001.PrscTime = timeFormatOne
  7889. var count float64
  7890. if item.Type == 1 {
  7891. for _, sumItem := range item.HisDoctorAdviceInfo {
  7892. count = count + sumItem.PrescribingNumber
  7893. }
  7894. }
  7895. cFYLJG001.RxDrugCnt = count
  7896. cFYLJG001.ValiDays = "2"
  7897. ts := time.Unix(item.PreTime, 0)
  7898. record_time2 := ts.AddDate(0, 0, int(2)).Unix()
  7899. tempTime3 := time.Unix(record_time2, 0)
  7900. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  7901. cFYLJG001.ValiEndTime = timeFormat3
  7902. cFYLJG001.RxCotnFlag = "0"
  7903. for _, subItem := range item.HisDoctorAdviceInfo {
  7904. var drug models.RxDrug
  7905. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7906. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  7907. drug.RxItemTypeCode = "11"
  7908. drug.DrugDosform = "剂" //TODO
  7909. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  7910. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7911. }
  7912. drug.MedcWayDscr = subItem.DeliveryWay
  7913. tempTime2 := time.Unix(subItem.StartTime, 0)
  7914. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7915. drug.MedcBegntime = timeFormatTwo
  7916. if subItem.Day > 0 {
  7917. ts := time.Unix(subItem.StartTime, 0)
  7918. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  7919. tempTime4 := time.Unix(record_time, 0)
  7920. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  7921. drug.MedcEndtime = timeFormat5
  7922. } else {
  7923. tempTime2 := time.Unix(subItem.StartTime, 0)
  7924. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  7925. drug.MedcEndtime = timeFormatTwo
  7926. }
  7927. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  7928. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  7929. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  7930. drug.DrugCnt = subItem.PrescribingNumber
  7931. drug.DrugDosunt = subItem.PrescribingNumberUnit
  7932. drug.DrugGenname = subItem.AdviceName
  7933. drug.MedcWayCodg = subItem.DeliveryWay
  7934. //drug.DrugTotlcnt = subItem.PrescribingNumber
  7935. drug.SinDoscnt = subItem.SingleDose
  7936. drug.SinDosunt = subItem.SingleDoseUnit
  7937. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  7938. drug.UsedFrquName = subItem.ExecutionFrequency
  7939. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7940. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  7941. drug.HospApprFlag = "1"
  7942. cFYLJG001.List = append(cFYLJG001.List, drug)
  7943. }
  7944. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  7945. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.OrgName
  7946. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  7947. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  7948. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  7949. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  7950. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  7951. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  7952. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  7953. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  7954. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7955. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  7956. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  7957. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  7958. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  7959. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  7960. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  7961. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  7962. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  7963. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  7964. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  7965. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  7966. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  7967. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  7968. tempTime2 := time.Now().Unix()
  7969. tempTime6 := time.Unix(tempTime2, 0)
  7970. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  7971. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  7972. cFYLJG001.Mdtrtinfo.DiseCodg = ""
  7973. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  7974. cFYLJG001.Mdtrtinfo.MaindiagCode = "I10.x00x002"
  7975. cFYLJG001.Mdtrtinfo.MaindiagName = "高血压"
  7976. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  7977. var config []*models.HisXtDiagnoseConfig
  7978. for _, item := range diagnosis_ids {
  7979. id, _ := strconv.ParseInt(item, 10, 64)
  7980. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7981. config = append(config, &diagnosisConfig)
  7982. }
  7983. for index, subitem := range config {
  7984. if index == 0 {
  7985. var dia models.DiseInfo
  7986. dia.DiagType = "1"
  7987. dia.MaindiagFlag = "1"
  7988. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  7989. dia.DiagCode = subitem.CountryCode
  7990. dia.DiagName = subitem.ClassName
  7991. dia.DiagDept = "肾内科"
  7992. dia.DiagDrNo = doctor.DoctorNumber
  7993. dia.DiagDrName = doctor.UserName
  7994. tempTime3 := time.Unix(item.PreTime, 0)
  7995. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  7996. dia.DiagTime = timeFormatTwo
  7997. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  7998. } else {
  7999. var dia models.DiseInfo
  8000. dia.DiagType = "1"
  8001. dia.MaindiagFlag = "0"
  8002. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  8003. dia.DiagCode = subitem.CountryCode
  8004. dia.DiagName = subitem.ClassName
  8005. dia.DiagDept = "肾内科"
  8006. dia.DiagDrNo = doctor.DoctorNumber
  8007. dia.DiagDrName = doctor.UserName
  8008. tempTime3 := time.Unix(item.PreTime, 0)
  8009. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  8010. dia.DiagTime = timeFormatTwo
  8011. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  8012. }
  8013. }
  8014. if miConfig.MdtrtareaAdmvs == "340699" {
  8015. result, request := service.GetAHCFYLJG001("http://10.66.149.64:8080/epc/api", cFYLJG001, his.Insutype)
  8016. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  8017. var res ResultCFYLJG001AH
  8018. var respJSON2 map[string]interface{}
  8019. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8020. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8022. return
  8023. }
  8024. userJSONBytes2, _ := json.Marshal(respJSON2)
  8025. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8026. utils.ErrorLog("解析失败:%v", err)
  8027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8028. return
  8029. }
  8030. var flow models.HisPrescriptionFlow
  8031. flow.Ctime = time.Now().Unix()
  8032. flow.SignDigest = ""
  8033. flow.RxTraceCode = res.RxTraceCode
  8034. flow.HiRxno = res.HiRxno
  8035. flow.MID = his.Number
  8036. flow.Status = 1
  8037. flow.DCode = doctor_info.DoctorNumber
  8038. flow.OriginalRxFile = ""
  8039. flow.OriginalValue = ""
  8040. flow.SignCertDn = ""
  8041. flow.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  8042. flow.SignCertSn = ""
  8043. flow.Mtime = time.Now().Unix()
  8044. service.Createflow(&flow)
  8045. c.ServeSuccessJSON(map[string]interface{}{
  8046. "msg": "上传成功",
  8047. })
  8048. } else {
  8049. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  8050. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  8051. var res ResultCFYLJG001
  8052. var respJSON2 map[string]interface{}
  8053. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8056. return
  8057. }
  8058. userJSONBytes2, _ := json.Marshal(respJSON2)
  8059. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8060. utils.ErrorLog("解析失败:%v", err)
  8061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8062. return
  8063. }
  8064. if res.Infcode == -1 {
  8065. c.ServeSuccessJSON(map[string]interface{}{
  8066. "failed_code": -10,
  8067. "msg": res.ErrMsg,
  8068. })
  8069. return
  8070. } else {
  8071. var flow models.HisPrescriptionFlow
  8072. flow.Ctime = time.Now().Unix()
  8073. flow.SignDigest = ""
  8074. flow.RxTraceCode = res.Output.RxTraceCode
  8075. flow.HiRxno = res.Output.HiRxno
  8076. flow.MID = his.Number
  8077. flow.Status = 1
  8078. flow.DCode = doctor_info.DoctorNumber
  8079. flow.OriginalRxFile = ""
  8080. flow.OriginalValue = ""
  8081. flow.SignCertDn = ""
  8082. flow.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  8083. flow.SignCertSn = ""
  8084. flow.Mtime = time.Now().Unix()
  8085. service.Createflow(&flow)
  8086. c.ServeSuccessJSON(map[string]interface{}{
  8087. "msg": "上传成功",
  8088. })
  8089. }
  8090. }
  8091. }
  8092. }
  8093. func (c *HisApiController) GetCFYLJG12() {
  8094. admin_user_id, _ := c.GetInt64("admin_user_id")
  8095. his_patient_id, _ := c.GetInt64("his_patient_id")
  8096. record_time := c.GetString("record_time")
  8097. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8098. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8099. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8100. flow, _ := service.Getflowtwo(his.Number)
  8101. patient_id, _ := c.GetInt64("patient_id")
  8102. timeLayout := "2006-01-02"
  8103. loc, _ := time.LoadLocation("Local")
  8104. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8105. if err != nil {
  8106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8107. return
  8108. }
  8109. recordDateTime := theTime.Unix()
  8110. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8111. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8112. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8113. dept, _ := service.GetDepartMentDetail(info.Departments)
  8114. inputData := make(map[string]interface{})
  8115. inputData["rxTraceCode"] = flow.RxTraceCode
  8116. inputData["hiRxno"] = flow.HiRxno
  8117. inputData["mdtrtId"] = flow.MID
  8118. inputData["patnName"] = his.PsnName
  8119. inputData["psnCertType"] = his.PsnCertType
  8120. inputData["certno"] = his.Certno
  8121. inputData["fixmedinsName"] = miConfig.OrgName
  8122. inputData["fixmedinsCode"] = miConfig.Code
  8123. inputData["drCode"] = doctor_info.DoctorNumber
  8124. inputData["prscDrName"] = doctor_info.UserName
  8125. inputData["pharDeptName"] = dept.Name
  8126. inputData["pharDeptCode"] = dept.Number
  8127. inputData["pharProfttlCodg"] = ""
  8128. inputData["pharProfttlName"] = ""
  8129. inputData["pharCode"] = "HY340621000425"
  8130. inputData["pharCertType"] = "01"
  8131. inputData["pharCertno"] = ""
  8132. inputData["pharName"] = "孙莉侠"
  8133. inputData["pharPracCertNo"] = ""
  8134. tempTime2 := time.Unix(info.Ctime, 0)
  8135. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8136. inputData["pharChkTime"] = timeFormatTwo
  8137. bytesData, _ := json.Marshal(inputData)
  8138. fmt.Println(string(bytesData))
  8139. encoded := base64.StdEncoding.EncodeToString(bytesData)
  8140. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  8141. if err != nil {
  8142. fmt.Println("Error reading PDF file:", err)
  8143. return
  8144. }
  8145. // 将 PDF 文件内容进行 Base64 编码
  8146. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  8147. fmt.Println(err)
  8148. if miConfig.MdtrtareaAdmvs == "340699" {
  8149. data := make(map[string]interface{})
  8150. data["rx_encoded"] = rx_encoded
  8151. data["code"] = miConfig.Code
  8152. data["url"] = "http://10.66.149.64:8080/epc/api"
  8153. data["encoded"] = encoded
  8154. client := &http.Client{}
  8155. bytesData, _ := json.Marshal(data)
  8156. var req *http.Request
  8157. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/02", bytes.NewReader(bytesData))
  8158. resp, _ := client.Do(req)
  8159. defer resp.Body.Close()
  8160. body, ioErr := ioutil.ReadAll(resp.Body)
  8161. if ioErr != nil {
  8162. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8163. }
  8164. var respJSON map[string]interface{}
  8165. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8166. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8168. return
  8169. }
  8170. var resSix10265 ResultSix10265 //1101结果
  8171. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8172. result, _ := json.Marshal(respJSON)
  8173. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  8174. utils.ErrorLog("解析失败:%v", err)
  8175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8176. return
  8177. }
  8178. utils.ErrorLog("接口返回数据解析JSON失败: %v", result)
  8179. //saveLog(result, "", "GetCFYLJG002", "GetCFYLJG002")
  8180. } else {
  8181. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8182. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  8183. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8184. var res2 AhResult002
  8185. var respJSON2 map[string]interface{}
  8186. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8187. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8189. return
  8190. }
  8191. userJSONBytes2, _ := json.Marshal(respJSON2)
  8192. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8193. utils.ErrorLog("解析失败:%v", err)
  8194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8195. return
  8196. }
  8197. flow.Ctime = time.Now().Unix()
  8198. flow.SignDigest = res2.SignDigest
  8199. flow.RxFile = res2.RxFile
  8200. flow.MID = his.Number
  8201. flow.Status = 1
  8202. flow.DCode = doctor_info.DoctorNumber
  8203. flow.OriginalRxFile = rx_encoded
  8204. flow.OriginalValue = encoded
  8205. flow.SignCertDn = res2.SignCertDn
  8206. flow.SignCertSn = res2.SignCertSn
  8207. flow.Mtime = time.Now().Unix()
  8208. service.Saveflow(flow)
  8209. c.ServeSuccessJSON(map[string]interface{}{
  8210. "msg": "预签名成功",
  8211. })
  8212. }
  8213. }
  8214. func (c *HisApiController) GetCFYLJG13() {
  8215. admin_user_id, _ := c.GetInt64("admin_user_id")
  8216. his_patient_id, _ := c.GetInt64("his_patient_id")
  8217. record_time := c.GetString("record_time")
  8218. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8219. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8220. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8221. flow, _ := service.Getflowtwo(his.Number)
  8222. patient_id, _ := c.GetInt64("patient_id")
  8223. timeLayout := "2006-01-02"
  8224. loc, _ := time.LoadLocation("Local")
  8225. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8226. if err != nil {
  8227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8228. return
  8229. }
  8230. recordDateTime := theTime.Unix()
  8231. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8232. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8233. dept, _ := service.GetDepartMentDetail(info.Departments)
  8234. var cFYLJG003 models.CFYLJG003
  8235. cFYLJG003.RxTraceCode = flow.RxTraceCode
  8236. cFYLJG003.HiRxno = flow.HiRxno
  8237. cFYLJG003.MdtrtID = flow.MID
  8238. cFYLJG003.PatnName = his.Name
  8239. cFYLJG003.Certno = his.Certno
  8240. cFYLJG003.FixmedinsName = miConfig.OrgName
  8241. cFYLJG003.FixmedinsCode = miConfig.Code
  8242. cFYLJG003.DrCode = doctor_info.DoctorNumber
  8243. cFYLJG003.PrscDrName = doctor_info.UserName
  8244. cFYLJG003.PharDeptName = dept.Name
  8245. cFYLJG003.PharDeptCode = dept.Number
  8246. if c.GetAdminUserInfo().CurrentOrgId == 10721 {
  8247. cFYLJG003.PharName = "孙莉侠"
  8248. cFYLJG003.PharPracCertNo = "060399"
  8249. cFYLJG003.PharCode = "HY340621000425"
  8250. cFYLJG003.PharCertType = "01"
  8251. cFYLJG003.PharCertno = ""
  8252. } else {
  8253. cFYLJG003.PharName = "彭斯遥"
  8254. cFYLJG003.PharPracCertNo = "30220200943042010052"
  8255. cFYLJG003.PharCode = "HY440309002107"
  8256. cFYLJG003.PharCertType = "01"
  8257. cFYLJG003.PharCertno = "430482199408260023"
  8258. }
  8259. cFYLJG003.PsnCertType = "01"
  8260. cFYLJG003.RxFile = flow.RxFile
  8261. cFYLJG003.SignDigest = flow.SignDigest
  8262. cFYLJG003.FixmedinsCode = miConfig.Code
  8263. cFYLJG003.PsnCertType = "01"
  8264. cFYLJG003.PharProfttlCodg = dept.Name
  8265. tempTime2 := time.Unix(info.Ctime, 0)
  8266. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8267. cFYLJG003.PharChkTime = timeFormatTwo
  8268. if miConfig.MdtrtareaAdmvs == "340699" {
  8269. data := make(map[string]interface{})
  8270. data["url"] = "http://10.66.149.64:8080/epc/api"
  8271. data["13"] = cFYLJG003
  8272. client := &http.Client{}
  8273. bytesData, _ := json.Marshal(data)
  8274. var req *http.Request
  8275. req, _ = http.NewRequest("POST", miConfig.Url+"ahyb/03", bytes.NewReader(bytesData))
  8276. resp, _ := client.Do(req)
  8277. defer resp.Body.Close()
  8278. body, ioErr := ioutil.ReadAll(resp.Body)
  8279. if ioErr != nil {
  8280. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8281. }
  8282. var respJSON map[string]interface{}
  8283. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  8284. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8286. return
  8287. }
  8288. var resSix10265 ResultSix10265 //1101结果
  8289. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8290. result, _ := json.Marshal(respJSON)
  8291. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  8292. utils.ErrorLog("解析失败:%v", err)
  8293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8294. return
  8295. }
  8296. utils.ErrorLog("接口返回数据解析JSON失败: %v", result)
  8297. //saveLog(result, "", "GetCFYLJG013", "GetCFYLJG013")
  8298. } else {
  8299. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8300. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  8301. var res ResultCFYLJG003
  8302. var respJSON2 map[string]interface{}
  8303. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8304. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8306. return
  8307. }
  8308. userJSONBytes2, _ := json.Marshal(respJSON2)
  8309. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8310. utils.ErrorLog("解析失败:%v", err)
  8311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8312. return
  8313. }
  8314. if res.Infcode == -1 {
  8315. c.ServeSuccessJSON(map[string]interface{}{
  8316. "failed_code": -10,
  8317. "msg": res.ErrMsg,
  8318. })
  8319. return
  8320. } else {
  8321. c.ServeSuccessJSON(map[string]interface{}{
  8322. "info": res.Output,
  8323. })
  8324. }
  8325. }
  8326. }
  8327. func (c *HisApiController) GetCFYLJG002() {
  8328. admin_user_id, _ := c.GetInt64("admin_user_id")
  8329. his_patient_id, _ := c.GetInt64("his_patient_id")
  8330. record_time := c.GetString("record_time")
  8331. admin_user_id = 3626
  8332. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8333. //id, _ := c.GetInt64("id")
  8334. admin_user_id = 3626
  8335. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8336. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8337. flow, _ := service.Getflowtwo(his.Number)
  8338. //his, _ := service.GetHisPatientByNumber(flow.MID)
  8339. //record_time := c.GetString("record_time")
  8340. patient_id, _ := c.GetInt64("patient_id")
  8341. //patient_id = 23834
  8342. //record_time = "2023-09-18"
  8343. timeLayout := "2006-01-02"
  8344. loc, _ := time.LoadLocation("Local")
  8345. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8346. if err != nil {
  8347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8348. return
  8349. }
  8350. recordDateTime := theTime.Unix()
  8351. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8352. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8353. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8354. dept, _ := service.GetDepartMentDetail(info.Departments)
  8355. inputData := make(map[string]interface{})
  8356. inputData["rxTraceCode"] = flow.RxTraceCode
  8357. inputData["hiRxno"] = flow.HiRxno
  8358. inputData["mdtrtId"] = flow.MID
  8359. inputData["patnName"] = his.PsnName
  8360. inputData["psnCertType"] = his.PsnCertType
  8361. inputData["certno"] = his.Certno
  8362. inputData["fixmedinsName"] = miConfig.OrgName
  8363. inputData["fixmedinsCode"] = miConfig.Code
  8364. inputData["drCode"] = doctor_info.DoctorNumber
  8365. inputData["prscDrName"] = doctor_info.UserName
  8366. inputData["pharDeptName"] = dept.Name
  8367. inputData["pharDeptCode"] = dept.Number
  8368. inputData["pharProfttlCodg"] = ""
  8369. inputData["pharProfttlName"] = ""
  8370. inputData["pharCode"] = "HY340621000425"
  8371. inputData["pharCertType"] = "01"
  8372. inputData["pharCertno"] = ""
  8373. inputData["pharName"] = "孙莉侠"
  8374. inputData["pharPracCertNo"] = "060399"
  8375. tempTime2 := time.Unix(info.Ctime, 0)
  8376. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8377. inputData["pharChkTime"] = timeFormatTwo
  8378. bytesData, _ := json.Marshal(inputData)
  8379. fmt.Println(string(bytesData))
  8380. encoded := base64.StdEncoding.EncodeToString(bytesData)
  8381. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  8382. if err != nil {
  8383. fmt.Println("Error reading PDF file:", err)
  8384. return
  8385. }
  8386. // 将 PDF 文件内容进行 Base64 编码
  8387. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  8388. fmt.Println(err)
  8389. if miConfig.MdtrtareaAdmvs == "340699" {
  8390. result, request := service.GetAHCFYLJG002(miConfig.Code, "http://10.66.149.64:8080/epc/api", encoded, rx_encoded, "")
  8391. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8392. var res2 AhResult002
  8393. var respJSON2 map[string]interface{}
  8394. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8395. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8397. return
  8398. }
  8399. userJSONBytes2, _ := json.Marshal(respJSON2)
  8400. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8401. utils.ErrorLog("解析失败:%v", err)
  8402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8403. return
  8404. }
  8405. flow.Ctime = time.Now().Unix()
  8406. flow.SignDigest = res2.SignDigest
  8407. flow.RxFile = res2.RxFile
  8408. flow.MID = his.Number
  8409. flow.Status = 1
  8410. flow.DCode = doctor_info.DoctorNumber
  8411. flow.OriginalRxFile = rx_encoded
  8412. flow.OriginalValue = encoded
  8413. flow.SignCertDn = res2.SignCertDn
  8414. flow.SignCertSn = res2.SignCertSn
  8415. flow.Mtime = time.Now().Unix()
  8416. service.Saveflow(flow)
  8417. c.ServeSuccessJSON(map[string]interface{}{
  8418. "msg": "预签名成功",
  8419. })
  8420. } else {
  8421. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8422. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  8423. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  8424. var res2 Result002
  8425. var respJSON2 map[string]interface{}
  8426. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8427. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8429. return
  8430. }
  8431. userJSONBytes2, _ := json.Marshal(respJSON2)
  8432. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8433. utils.ErrorLog("解析失败:%v", err)
  8434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8435. return
  8436. }
  8437. if res2.Infcode == 0 {
  8438. flow.Ctime = time.Now().Unix()
  8439. flow.SignDigest = res2.Output.SignDigest
  8440. flow.RxFile = res2.Output.RxFile
  8441. flow.MID = his.Number
  8442. flow.Status = 1
  8443. flow.DCode = doctor_info.DoctorNumber
  8444. flow.OriginalRxFile = rx_encoded
  8445. flow.OriginalValue = encoded
  8446. flow.SignCertDn = res2.Output.SignCertDn
  8447. flow.SignCertSn = res2.Output.SignCertSn
  8448. flow.Mtime = time.Now().Unix()
  8449. service.Saveflow(flow)
  8450. c.ServeSuccessJSON(map[string]interface{}{
  8451. "msg": "预签名成功",
  8452. })
  8453. } else {
  8454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8455. return
  8456. }
  8457. }
  8458. }
  8459. func (c *HisApiController) GetCFYLJG003() {
  8460. admin_user_id, _ := c.GetInt64("admin_user_id")
  8461. his_patient_id, _ := c.GetInt64("his_patient_id")
  8462. record_time := c.GetString("record_time")
  8463. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8464. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8465. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8466. flow, _ := service.Getflowtwo(his.Number)
  8467. patient_id, _ := c.GetInt64("patient_id")
  8468. timeLayout := "2006-01-02"
  8469. loc, _ := time.LoadLocation("Local")
  8470. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8471. if err != nil {
  8472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8473. return
  8474. }
  8475. recordDateTime := theTime.Unix()
  8476. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8477. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8478. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8479. dept, _ := service.GetDepartMentDetail(info.Departments)
  8480. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  8481. var cFYLJG003 models.CFYLJG003
  8482. cFYLJG003.RxTraceCode = flow.RxTraceCode
  8483. cFYLJG003.HiRxno = flow.HiRxno
  8484. cFYLJG003.MdtrtID = flow.MID
  8485. cFYLJG003.PatnName = his.PsnName
  8486. cFYLJG003.Certno = his.Certno
  8487. cFYLJG003.FixmedinsName = miConfig.OrgName
  8488. cFYLJG003.FixmedinsCode = miConfig.Code
  8489. cFYLJG003.DrCode = doctor_info.DoctorNumber
  8490. cFYLJG003.PrscDrName = doctor_info.UserName
  8491. cFYLJG003.PharDeptName = dept.Name
  8492. cFYLJG003.PharDeptCode = dept.Number
  8493. if c.GetAdminUserInfo().CurrentOrgId == 10721 {
  8494. cFYLJG003.PharName = "孙莉侠"
  8495. cFYLJG003.PharPracCertNo = "060399"
  8496. cFYLJG003.PharCode = "HY340621000425"
  8497. cFYLJG003.PharCertType = "01"
  8498. cFYLJG003.PharCertno = ""
  8499. } else {
  8500. cFYLJG003.PharName = "彭斯遥"
  8501. cFYLJG003.PharPracCertNo = "30220200943042010052"
  8502. cFYLJG003.PharCode = "HY440309002107"
  8503. cFYLJG003.PharCertType = "01"
  8504. cFYLJG003.PharCertno = "430482199408260023"
  8505. }
  8506. cFYLJG003.RxFile = flow.RxFile
  8507. cFYLJG003.SignDigest = flow.SignDigest
  8508. cFYLJG003.FixmedinsCode = miConfig.Code
  8509. cFYLJG003.PsnCertType = his.PsnCertType
  8510. tempTime2 := time.Unix(info.Ctime, 0)
  8511. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  8512. cFYLJG003.PharChkTime = timeFormatTwo
  8513. if miConfig.MdtrtareaAdmvs == "340699" {
  8514. result, request := service.GetAHCFYLJG003("http://10.66.149.64:8080/epc/api", cFYLJG003)
  8515. saveLog(result, request, "GetAHCFYLJG003", "GetAHCFYLJG003")
  8516. var res AHResult003
  8517. var respJSON2 map[string]interface{}
  8518. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8519. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8521. return
  8522. }
  8523. userJSONBytes2, _ := json.Marshal(respJSON2)
  8524. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8525. utils.ErrorLog("解析失败:%v", err)
  8526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8527. return
  8528. }
  8529. {
  8530. c.ServeSuccessJSON(map[string]interface{}{
  8531. "info": res,
  8532. })
  8533. }
  8534. } else {
  8535. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8536. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  8537. var res ResultCFYLJG003
  8538. var respJSON2 map[string]interface{}
  8539. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8540. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8542. return
  8543. }
  8544. userJSONBytes2, _ := json.Marshal(respJSON2)
  8545. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8546. utils.ErrorLog("解析失败:%v", err)
  8547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8548. return
  8549. }
  8550. if res.Infcode == -1 {
  8551. c.ServeSuccessJSON(map[string]interface{}{
  8552. "failed_code": -10,
  8553. "msg": res.ErrMsg,
  8554. })
  8555. return
  8556. } else {
  8557. c.ServeSuccessJSON(map[string]interface{}{
  8558. "info": res.Output,
  8559. })
  8560. }
  8561. }
  8562. }
  8563. func (c *HisApiController) GetCFYLJG004() {
  8564. admin_user_id, _ := c.GetInt64("admin_user_id")
  8565. his_patient_id, _ := c.GetInt64("his_patient_id")
  8566. record_time := c.GetString("record_time")
  8567. admin_user_id = 3626
  8568. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8569. //id, _ := c.GetInt64("id")
  8570. admin_user_id = 3626
  8571. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8572. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8573. flow, _ := service.Getflowtwo(his.Number)
  8574. //id = 3
  8575. patient_id, _ := c.GetInt64("patient_id")
  8576. //patient_id = 23834
  8577. //record_time = "2023-09-18"
  8578. timeLayout := "2006-01-02"
  8579. loc, _ := time.LoadLocation("Local")
  8580. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8581. if err != nil {
  8582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8583. return
  8584. }
  8585. recordDateTime := theTime.Unix()
  8586. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8587. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  8588. var cFYLJG004 models.CFYLJG004
  8589. cFYLJG004.HiRxno = flow.HiRxno
  8590. cFYLJG004.FixmedinsCode = miConfig.Code
  8591. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  8592. cFYLJG004.UndoDrCertType = "01"
  8593. cFYLJG004.UndoRea = "撤销处方"
  8594. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  8595. cFYLJG004.UndoDrName = doctor_info.UserName
  8596. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  8597. if miConfig.MdtrtareaAdmvs == "340699" {
  8598. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8599. //result, request := service.GetAHCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  8600. //saveLog(result, request, "GetAHCFYLJG004", "GetAHCFYLJG004")
  8601. } else {
  8602. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  8603. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  8604. var res ResultCFYLJG004
  8605. var respJSON2 map[string]interface{}
  8606. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8607. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8609. return
  8610. }
  8611. userJSONBytes2, _ := json.Marshal(respJSON2)
  8612. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8613. utils.ErrorLog("解析失败:%v", err)
  8614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8615. return
  8616. }
  8617. if res.Infcode == -1 {
  8618. c.ServeSuccessJSON(map[string]interface{}{
  8619. "failed_code": -10,
  8620. "msg": res.ErrMsg,
  8621. })
  8622. return
  8623. } else {
  8624. flow.Status = 0
  8625. service.Saveflow(flow)
  8626. c.ServeSuccessJSON(map[string]interface{}{
  8627. "msg": "撤销成功",
  8628. })
  8629. return
  8630. }
  8631. }
  8632. }
  8633. func (c *HisApiController) GetCFYLJG005() {
  8634. admin_user_id, _ := c.GetInt64("admin_user_id")
  8635. his_patient_id, _ := c.GetInt64("his_patient_id")
  8636. //record_time := c.GetString("record_time")
  8637. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8638. //id, _ := c.GetInt64("id")
  8639. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8640. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8641. flow, _ := service.Getflowtwo(his.Number)
  8642. //id = 3
  8643. var cFYLJG005 models.CFYLJG005
  8644. //patient_id, _ := c.GetInt64("patient_id")
  8645. cFYLJG005.HiRxno = flow.HiRxno
  8646. cFYLJG005.MdtrtID = flow.MID
  8647. cFYLJG005.EcToken = ""
  8648. cFYLJG005.PsnName = his.Name
  8649. cFYLJG005.PsnCertType = "01"
  8650. cFYLJG005.Certno = his.IdCardNo
  8651. if miConfig.MdtrtareaAdmvs == "340699" {
  8652. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8653. result, request := service.GetAHCFYLJG005(miConfig.Code, cFYLJG005)
  8654. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  8655. } else {
  8656. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  8657. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  8658. var res ResultCFYLJG005
  8659. var respJSON2 map[string]interface{}
  8660. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8661. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8663. return
  8664. }
  8665. userJSONBytes2, _ := json.Marshal(respJSON2)
  8666. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8667. utils.ErrorLog("解析失败:%v", err)
  8668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8669. return
  8670. }
  8671. if res.Infcode == -1 {
  8672. c.ServeSuccessJSON(map[string]interface{}{
  8673. "failed_code": -10,
  8674. "msg": res.ErrMsg,
  8675. })
  8676. return
  8677. } else {
  8678. c.ServeSuccessJSON(map[string]interface{}{
  8679. "info": res.Output,
  8680. })
  8681. return
  8682. }
  8683. }
  8684. }
  8685. func (c *HisApiController) GetCFYLJG006() {
  8686. admin_user_id, _ := c.GetInt64("admin_user_id")
  8687. his_patient_id, _ := c.GetInt64("his_patient_id")
  8688. admin_user_id = 3626
  8689. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8690. //id, _ := c.GetInt64("id")
  8691. admin_user_id = 3626
  8692. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8693. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8694. flow, _ := service.Getflowtwo(his.Number)
  8695. //id = 3
  8696. patient_id, _ := c.GetInt64("patient_id")
  8697. var cFYLJG006 models.CFYLJG006
  8698. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8699. cFYLJG006.HiRxno = flow.HiRxno
  8700. cFYLJG006.MdtrtID = flow.MID
  8701. cFYLJG006.PsnName = patient.Name
  8702. cFYLJG006.PsnCertType = "01"
  8703. cFYLJG006.Certno = patient.IdCardNo
  8704. if miConfig.MdtrtareaAdmvs == "340699" {
  8705. //result, request := service.GetAHCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  8706. //result, request := service.GetAHCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8707. //saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8708. } else {
  8709. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  8710. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  8711. var res ResultCFYLJG006
  8712. var respJSON2 map[string]interface{}
  8713. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8714. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8716. return
  8717. }
  8718. userJSONBytes2, _ := json.Marshal(respJSON2)
  8719. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8720. utils.ErrorLog("解析失败:%v", err)
  8721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8722. return
  8723. }
  8724. if res.Infcode == -1 {
  8725. c.ServeSuccessJSON(map[string]interface{}{
  8726. "failed_code": -10,
  8727. "msg": res.ErrMsg,
  8728. })
  8729. return
  8730. } else {
  8731. c.ServeSuccessJSON(map[string]interface{}{
  8732. "info": res.Output,
  8733. })
  8734. return
  8735. }
  8736. }
  8737. }
  8738. func (c *HisApiController) GetCFYLJG007() {
  8739. admin_user_id, _ := c.GetInt64("admin_user_id")
  8740. his_patient_id, _ := c.GetInt64("his_patient_id")
  8741. admin_user_id = 3626
  8742. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8743. //id, _ := c.GetInt64("id")
  8744. admin_user_id = 3626
  8745. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8746. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8747. flow, _ := service.Getflowtwo(his.Number)
  8748. //id = 3
  8749. patient_id, _ := c.GetInt64("patient_id")
  8750. var cFYLJG007 models.CFYLJG007
  8751. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  8752. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8753. cFYLJG007.HiRxno = flow.HiRxno
  8754. cFYLJG007.MdtrtID = flow.MID
  8755. cFYLJG007.PsnNo = his.PsnNo
  8756. cFYLJG007.PsnCertType = "01"
  8757. cFYLJG007.Certno = patient.IdCardNo
  8758. cFYLJG007.PsnName = patient.Name
  8759. if miConfig.MdtrtareaAdmvs == "340699" {
  8760. //result, request := service.GetAHCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8761. //saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8762. } else {
  8763. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  8764. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  8765. var res ResultCFYLJG007
  8766. var respJSON2 map[string]interface{}
  8767. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8768. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8770. return
  8771. }
  8772. userJSONBytes2, _ := json.Marshal(respJSON2)
  8773. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8774. utils.ErrorLog("解析失败:%v", err)
  8775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8776. return
  8777. }
  8778. if res.Infcode == -1 {
  8779. c.ServeSuccessJSON(map[string]interface{}{
  8780. "failed_code": -10,
  8781. "msg": res.ErrMsg,
  8782. })
  8783. return
  8784. } else {
  8785. c.ServeSuccessJSON(map[string]interface{}{
  8786. "info": res,
  8787. })
  8788. return
  8789. }
  8790. }
  8791. }
  8792. func (c *HisApiController) GetCFYLJG008() {
  8793. admin_user_id, _ := c.GetInt64("admin_user_id")
  8794. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8795. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8796. var cFYLJG008 models.CFYLJG008
  8797. //id, _ := c.GetInt64("id")
  8798. patient_id, _ := c.GetInt64("patient_id")
  8799. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8800. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  8801. //id = 3
  8802. //flow, _ := service.Getflow(id)
  8803. //his, _ := service.GetHisPatientByNumber(flow.MID)
  8804. //
  8805. //admin_user_id, _ := c.GetInt64("admin_user_id")
  8806. //patient_id, _ := c.GetInt64("patient_id")
  8807. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8808. record_time := c.GetString("record_time")
  8809. admin_user_id = 3626
  8810. patient_id = 19424
  8811. //his_patient_id = 263947
  8812. record_time = "2023-08-29"
  8813. timeLayout := "2006-01-02"
  8814. loc, _ := time.LoadLocation("Local")
  8815. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8816. if err != nil {
  8817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8818. return
  8819. }
  8820. recordDateTime := theTime.Unix()
  8821. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  8822. cFYLJG008.FixmedinsName = ""
  8823. cFYLJG008.Lat = ""
  8824. cFYLJG008.Lng = ""
  8825. cFYLJG008.OrderType = "1"
  8826. cFYLJG008.PoolareaNo = ""
  8827. cFYLJG008.Lng = ""
  8828. cFYLJG008.PageNum = 1
  8829. cFYLJG008.PageSize = 10
  8830. var MPI models.MedinsProdInvChgDDTO
  8831. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  8832. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  8833. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  8834. if miConfig.MdtrtareaAdmvs == "340699" {
  8835. //result, request := service.GetAHCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8836. //saveLog(result, request, "GetAHCFYLJG008", "GetAHCFYLJG008")
  8837. } else {
  8838. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  8839. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  8840. var res ResultCFYLJG008
  8841. var respJSON2 map[string]interface{}
  8842. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  8843. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8845. return
  8846. }
  8847. userJSONBytes2, _ := json.Marshal(respJSON2)
  8848. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  8849. utils.ErrorLog("解析失败:%v", err)
  8850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8851. return
  8852. }
  8853. if res.Infcode == -1 {
  8854. c.ServeSuccessJSON(map[string]interface{}{
  8855. "failed_code": -10,
  8856. "msg": res.ErrMsg,
  8857. })
  8858. return
  8859. } else {
  8860. c.ServeSuccessJSON(map[string]interface{}{
  8861. "info": res.Output,
  8862. })
  8863. return
  8864. }
  8865. }
  8866. }
  8867. func (c *HisApiController) GetBL4201A() {
  8868. order_id, _ := c.GetInt64("order_id")
  8869. admin_user_id, _ := c.GetInt64("admin_user_id")
  8870. order, _ := service.GetHisOrderByIDTwo(order_id)
  8871. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8872. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  8873. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  8874. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8875. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8876. department, _ := service.GetDepartMentDetail(his.Departments)
  8877. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  8878. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  8879. if order.ID == 0 {
  8880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  8881. return
  8882. }
  8883. var struct4201A models.Struct4201A
  8884. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  8885. for _, items := range order_info {
  8886. memo := make(map[string]interface{})
  8887. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  8888. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  8889. fsiOPFLD.MedType = "14"
  8890. fsiOPFLD.BkkpSn = items.FeedetlSn
  8891. fsiOPFLD.FixmedinsCode = miConfig.Code
  8892. fsiOPFLD.FixmedinsName = miConfig.OrgName
  8893. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  8894. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  8895. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  8896. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  8897. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  8898. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8899. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  8900. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8901. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  8902. fsiOPFLD.BilgDeptName = department.Name
  8903. fsiOPFLD.BilgDeptCodg = department.Number
  8904. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8905. fsiOPFLD.BilgDrName = doctor.UserName
  8906. fsiOPFLD.MedChrgitmType = "09"
  8907. memo["hosp_appr_flag"] = "1"
  8908. memo["invoice_no"] = order.MdtrtId
  8909. memo["memo"] = "自费"
  8910. bytesData, _ := json.Marshal(memo)
  8911. fsiOPFLD.Memo = string(bytesData)
  8912. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8913. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  8914. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  8915. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8916. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8917. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  8918. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  8919. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  8920. fsiOPFLD.BilgDeptName = department.Name
  8921. fsiOPFLD.BilgDeptCodg = department.Number
  8922. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8923. fsiOPFLD.BilgDrName = doctor.UserName
  8924. switch items.HisPrescriptionProject.HisProject.CostClassify {
  8925. case 0:
  8926. break
  8927. case 1:
  8928. fsiOPFLD.MedChrgitmType = "14"
  8929. break
  8930. case 2:
  8931. fsiOPFLD.MedChrgitmType = "05"
  8932. break
  8933. case 3:
  8934. fsiOPFLD.MedChrgitmType = "03"
  8935. break
  8936. case 4:
  8937. fsiOPFLD.MedChrgitmType = "03"
  8938. break
  8939. case 5:
  8940. fsiOPFLD.MedChrgitmType = "08"
  8941. break
  8942. case 6:
  8943. fsiOPFLD.MedChrgitmType = "14"
  8944. break
  8945. case 7:
  8946. fsiOPFLD.MedChrgitmType = "14"
  8947. break
  8948. case 8:
  8949. fsiOPFLD.MedChrgitmType = "03"
  8950. break
  8951. case 9:
  8952. fsiOPFLD.MedChrgitmType = "14"
  8953. break
  8954. case 10:
  8955. fsiOPFLD.MedChrgitmType = "14"
  8956. break
  8957. case 11:
  8958. fsiOPFLD.MedChrgitmType = "06"
  8959. break
  8960. case 12:
  8961. fsiOPFLD.MedChrgitmType = "12"
  8962. break
  8963. case 13:
  8964. fsiOPFLD.MedChrgitmType = "01"
  8965. break
  8966. case 14:
  8967. fsiOPFLD.MedChrgitmType = "04"
  8968. break
  8969. case 15:
  8970. fsiOPFLD.MedChrgitmType = "14"
  8971. break
  8972. }
  8973. memo["hosp_appr_flag"] = "1"
  8974. memo["invoice_no"] = order.MdtrtId
  8975. memo["memo"] = "自费"
  8976. bytesData, _ := json.Marshal(memo)
  8977. fsiOPFLD.Memo = string(bytesData)
  8978. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8979. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  8980. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  8981. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8982. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  8983. fsiOPFLD.BilgDeptName = department.Name
  8984. fsiOPFLD.BilgDeptCodg = department.Number
  8985. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  8986. fsiOPFLD.BilgDrName = doctor.UserName
  8987. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  8988. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  8989. fsiOPFLD.MedChrgitmType = "08"
  8990. memo["hosp_appr_flag"] = "1"
  8991. memo["invoice_no"] = order.MdtrtId
  8992. memo["memo"] = "自费"
  8993. bytesData, _ := json.Marshal(memo)
  8994. fsiOPFLD.Memo = string(bytesData)
  8995. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  8996. }
  8997. }
  8998. }
  8999. for _, items := range order_info_two {
  9000. memo := make(map[string]interface{})
  9001. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9002. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9003. fsiOPFLD.MedType = "14"
  9004. fsiOPFLD.BkkpSn = items.FeedetlSn
  9005. fsiOPFLD.FixmedinsCode = miConfig.Code
  9006. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9007. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9008. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9009. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9010. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9011. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9012. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9013. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9014. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9015. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9016. fsiOPFLD.BilgDeptName = department.Name
  9017. fsiOPFLD.BilgDeptCodg = department.Number
  9018. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9019. fsiOPFLD.BilgDrName = doctor.UserName
  9020. fsiOPFLD.MedChrgitmType = "09"
  9021. memo["hosp_appr_flag"] = "1"
  9022. memo["invoice_no"] = order.MdtrtId
  9023. memo["memo"] = "自费"
  9024. bytesData, _ := json.Marshal(memo)
  9025. fsiOPFLD.Memo = string(bytesData)
  9026. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9027. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9028. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9029. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9030. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9031. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9032. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9033. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9034. fsiOPFLD.BilgDeptName = department.Name
  9035. fsiOPFLD.BilgDeptCodg = department.Number
  9036. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9037. fsiOPFLD.BilgDrName = doctor.UserName
  9038. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9039. case 0:
  9040. break
  9041. case 1:
  9042. fsiOPFLD.MedChrgitmType = "14"
  9043. break
  9044. case 2:
  9045. fsiOPFLD.MedChrgitmType = "05"
  9046. break
  9047. case 3:
  9048. fsiOPFLD.MedChrgitmType = "03"
  9049. break
  9050. case 4:
  9051. fsiOPFLD.MedChrgitmType = "03"
  9052. break
  9053. case 5:
  9054. fsiOPFLD.MedChrgitmType = "08"
  9055. break
  9056. case 6:
  9057. fsiOPFLD.MedChrgitmType = "14"
  9058. break
  9059. case 7:
  9060. fsiOPFLD.MedChrgitmType = "14"
  9061. break
  9062. case 8:
  9063. fsiOPFLD.MedChrgitmType = "03"
  9064. break
  9065. case 9:
  9066. fsiOPFLD.MedChrgitmType = "14"
  9067. break
  9068. case 10:
  9069. fsiOPFLD.MedChrgitmType = "14"
  9070. break
  9071. case 11:
  9072. fsiOPFLD.MedChrgitmType = "06"
  9073. break
  9074. case 12:
  9075. fsiOPFLD.MedChrgitmType = "12"
  9076. break
  9077. case 13:
  9078. fsiOPFLD.MedChrgitmType = "01"
  9079. break
  9080. case 14:
  9081. fsiOPFLD.MedChrgitmType = "04"
  9082. break
  9083. case 15:
  9084. fsiOPFLD.MedChrgitmType = "14"
  9085. break
  9086. }
  9087. memo["hosp_appr_flag"] = "1"
  9088. memo["invoice_no"] = order.MdtrtId
  9089. memo["memo"] = "自费"
  9090. bytesData, _ := json.Marshal(memo)
  9091. fsiOPFLD.Memo = string(bytesData)
  9092. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9093. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9094. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9095. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9096. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9097. fsiOPFLD.BilgDeptName = department.Name
  9098. fsiOPFLD.BilgDeptCodg = department.Number
  9099. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9100. fsiOPFLD.BilgDrName = doctor.UserName
  9101. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9102. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9103. fsiOPFLD.MedChrgitmType = "08"
  9104. memo["hosp_appr_flag"] = "1"
  9105. memo["invoice_no"] = order.MdtrtId
  9106. memo["memo"] = "自费"
  9107. bytesData, _ := json.Marshal(memo)
  9108. fsiOPFLD.Memo = string(bytesData)
  9109. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9110. }
  9111. }
  9112. }
  9113. fmt.Println(fsiOPFLDs)
  9114. struct4201A.Fopfd = fsiOPFLDs
  9115. fmt.Println(struct4201A.Fopfd)
  9116. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  9117. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  9118. var res2 ResultSix
  9119. var respJSON2 map[string]interface{}
  9120. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9121. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9123. return
  9124. }
  9125. userJSONBytes2, _ := json.Marshal(respJSON2)
  9126. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9127. utils.ErrorLog("解析失败:%v", err)
  9128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9129. return
  9130. }
  9131. if res2.Infcode != 0 {
  9132. c.ServeSuccessJSON(map[string]interface{}{
  9133. "failed_code": -10,
  9134. "msg": res2.ErrMsg,
  9135. })
  9136. return
  9137. } else {
  9138. order.IsUploadOrderInfo = 1
  9139. service.UpdateOrder(order)
  9140. c.ServeSuccessJSON(map[string]interface{}{
  9141. "msg": "上传成功",
  9142. })
  9143. }
  9144. }
  9145. func (c *HisApiController) Get3103() {
  9146. admin_user_id, _ := c.GetInt64("admin_user_id")
  9147. warm_type, _ := c.GetInt64("warm_type")
  9148. fk_state, _ := c.GetInt64("fk_state")
  9149. warm_ids := c.GetString("warm_ids")
  9150. desc := c.GetString("desc")
  9151. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9152. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9153. result, requestLog := service.Gdyb3103(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, warm_type, warm_ids, fk_state, desc)
  9154. saveLog(result, requestLog, "3103", "反馈")
  9155. var res2 ResultSix3103
  9156. var respJSON2 map[string]interface{}
  9157. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9158. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9160. return
  9161. }
  9162. userJSONBytes2, _ := json.Marshal(respJSON2)
  9163. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9164. utils.ErrorLog("解析失败:%v", err)
  9165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9166. return
  9167. }
  9168. if res2.Infcode != 0 {
  9169. c.ServeSuccessJSON(map[string]interface{}{
  9170. "failed_code": -10,
  9171. "msg": res2.ErrMsg,
  9172. })
  9173. return
  9174. } else {
  9175. c.ServeSuccessJSON(map[string]interface{}{
  9176. "msg": "反馈成功",
  9177. })
  9178. return
  9179. }
  9180. }
  9181. func (c *HisApiController) Get4201A() {
  9182. order_id, _ := c.GetInt64("order_id")
  9183. admin_user_id, _ := c.GetInt64("admin_user_id")
  9184. order, _ := service.GetHisOrderByIDTwo(order_id)
  9185. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9186. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  9187. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  9188. //order_info = append(order_info, order_info_two...)
  9189. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9190. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9191. department, _ := service.GetDepartMentDetail(his.Departments)
  9192. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  9193. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  9194. if order.ID == 0 {
  9195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9196. return
  9197. }
  9198. var struct4201A models.Struct4201A
  9199. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  9200. for _, items := range order_info {
  9201. memo := make(map[string]interface{})
  9202. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9203. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9204. fsiOPFLD.MedType = "14"
  9205. fsiOPFLD.BkkpSn = items.FeedetlSn
  9206. fsiOPFLD.FixmedinsCode = miConfig.Code
  9207. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9208. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9209. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9210. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9211. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9212. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9213. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9214. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9215. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9216. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9217. fsiOPFLD.BilgDeptName = department.Name
  9218. fsiOPFLD.BilgDeptCodg = department.Number
  9219. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9220. fsiOPFLD.BilgDrName = doctor.UserName
  9221. fsiOPFLD.MedChrgitmType = "09"
  9222. memo["hosp_appr_flag"] = "1"
  9223. memo["invoice_no"] = order.MdtrtId
  9224. memo["memo"] = "自费"
  9225. bytesData, _ := json.Marshal(memo)
  9226. fsiOPFLD.Memo = string(bytesData)
  9227. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9228. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9229. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9230. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9231. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9232. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9233. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9234. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9235. fsiOPFLD.BilgDeptName = department.Name
  9236. fsiOPFLD.BilgDeptCodg = department.Number
  9237. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9238. fsiOPFLD.BilgDrName = doctor.UserName
  9239. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9240. case 0:
  9241. break
  9242. case 1:
  9243. fsiOPFLD.MedChrgitmType = "14"
  9244. break
  9245. case 2:
  9246. fsiOPFLD.MedChrgitmType = "05"
  9247. break
  9248. case 3:
  9249. fsiOPFLD.MedChrgitmType = "03"
  9250. break
  9251. case 4:
  9252. fsiOPFLD.MedChrgitmType = "03"
  9253. break
  9254. case 5:
  9255. fsiOPFLD.MedChrgitmType = "08"
  9256. break
  9257. case 6:
  9258. fsiOPFLD.MedChrgitmType = "14"
  9259. break
  9260. case 7:
  9261. fsiOPFLD.MedChrgitmType = "14"
  9262. break
  9263. case 8:
  9264. fsiOPFLD.MedChrgitmType = "03"
  9265. break
  9266. case 9:
  9267. fsiOPFLD.MedChrgitmType = "14"
  9268. break
  9269. case 10:
  9270. fsiOPFLD.MedChrgitmType = "14"
  9271. break
  9272. case 11:
  9273. fsiOPFLD.MedChrgitmType = "06"
  9274. break
  9275. case 12:
  9276. fsiOPFLD.MedChrgitmType = "12"
  9277. break
  9278. case 13:
  9279. fsiOPFLD.MedChrgitmType = "01"
  9280. break
  9281. case 14:
  9282. fsiOPFLD.MedChrgitmType = "04"
  9283. break
  9284. case 15:
  9285. fsiOPFLD.MedChrgitmType = "14"
  9286. break
  9287. }
  9288. memo["hosp_appr_flag"] = "1"
  9289. memo["invoice_no"] = order.MdtrtId
  9290. memo["memo"] = "自费"
  9291. bytesData, _ := json.Marshal(memo)
  9292. fsiOPFLD.Memo = string(bytesData)
  9293. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9294. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9295. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9296. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9297. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9298. fsiOPFLD.BilgDeptName = department.Name
  9299. fsiOPFLD.BilgDeptCodg = department.Number
  9300. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9301. fsiOPFLD.BilgDrName = doctor.UserName
  9302. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9303. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9304. fsiOPFLD.MedChrgitmType = "08"
  9305. memo["hosp_appr_flag"] = "1"
  9306. memo["invoice_no"] = order.MdtrtId
  9307. memo["memo"] = "自费"
  9308. bytesData, _ := json.Marshal(memo)
  9309. fsiOPFLD.Memo = string(bytesData)
  9310. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9311. }
  9312. }
  9313. }
  9314. for _, items := range order_info_two {
  9315. memo := make(map[string]interface{})
  9316. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9317. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9318. fsiOPFLD.MedType = "14"
  9319. fsiOPFLD.BkkpSn = items.FeedetlSn
  9320. fsiOPFLD.FixmedinsCode = miConfig.Code
  9321. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9322. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9323. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9324. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9325. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9326. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9327. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9328. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9329. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9330. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9331. fsiOPFLD.BilgDeptName = department.Name
  9332. fsiOPFLD.BilgDeptCodg = department.Number
  9333. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9334. fsiOPFLD.BilgDrName = doctor.UserName
  9335. fsiOPFLD.MedChrgitmType = "09"
  9336. memo["hosp_appr_flag"] = "1"
  9337. memo["invoice_no"] = order.MdtrtId
  9338. memo["memo"] = "自费"
  9339. bytesData, _ := json.Marshal(memo)
  9340. fsiOPFLD.Memo = string(bytesData)
  9341. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9342. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9343. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9344. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9345. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9346. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9347. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9348. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9349. fsiOPFLD.BilgDeptName = department.Name
  9350. fsiOPFLD.BilgDeptCodg = department.Number
  9351. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9352. fsiOPFLD.BilgDrName = doctor.UserName
  9353. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9354. case 0:
  9355. break
  9356. case 1:
  9357. fsiOPFLD.MedChrgitmType = "14"
  9358. break
  9359. case 2:
  9360. fsiOPFLD.MedChrgitmType = "05"
  9361. break
  9362. case 3:
  9363. fsiOPFLD.MedChrgitmType = "03"
  9364. break
  9365. case 4:
  9366. fsiOPFLD.MedChrgitmType = "03"
  9367. break
  9368. case 5:
  9369. fsiOPFLD.MedChrgitmType = "08"
  9370. break
  9371. case 6:
  9372. fsiOPFLD.MedChrgitmType = "14"
  9373. break
  9374. case 7:
  9375. fsiOPFLD.MedChrgitmType = "14"
  9376. break
  9377. case 8:
  9378. fsiOPFLD.MedChrgitmType = "03"
  9379. break
  9380. case 9:
  9381. fsiOPFLD.MedChrgitmType = "14"
  9382. break
  9383. case 10:
  9384. fsiOPFLD.MedChrgitmType = "14"
  9385. break
  9386. case 11:
  9387. fsiOPFLD.MedChrgitmType = "06"
  9388. break
  9389. case 12:
  9390. fsiOPFLD.MedChrgitmType = "12"
  9391. break
  9392. case 13:
  9393. fsiOPFLD.MedChrgitmType = "01"
  9394. break
  9395. case 14:
  9396. fsiOPFLD.MedChrgitmType = "04"
  9397. break
  9398. case 15:
  9399. fsiOPFLD.MedChrgitmType = "14"
  9400. break
  9401. }
  9402. memo["hosp_appr_flag"] = "1"
  9403. memo["invoice_no"] = order.MdtrtId
  9404. memo["memo"] = "自费"
  9405. bytesData, _ := json.Marshal(memo)
  9406. fsiOPFLD.Memo = string(bytesData)
  9407. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9408. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9409. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9410. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9411. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9412. fsiOPFLD.BilgDeptName = department.Name
  9413. fsiOPFLD.BilgDeptCodg = department.Number
  9414. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9415. fsiOPFLD.BilgDrName = doctor.UserName
  9416. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9417. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9418. fsiOPFLD.MedChrgitmType = "08"
  9419. memo["hosp_appr_flag"] = "1"
  9420. memo["invoice_no"] = order.MdtrtId
  9421. memo["memo"] = "自费"
  9422. bytesData, _ := json.Marshal(memo)
  9423. fsiOPFLD.Memo = string(bytesData)
  9424. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9425. }
  9426. }
  9427. }
  9428. fmt.Println(fsiOPFLDs)
  9429. struct4201A.Fopfd = fsiOPFLDs
  9430. fmt.Println(struct4201A.Fopfd)
  9431. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  9432. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  9433. var res2 ResultSix
  9434. var respJSON2 map[string]interface{}
  9435. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9436. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9438. return
  9439. }
  9440. userJSONBytes2, _ := json.Marshal(respJSON2)
  9441. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9442. utils.ErrorLog("解析失败:%v", err)
  9443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9444. return
  9445. }
  9446. if res2.Infcode != 0 {
  9447. c.ServeSuccessJSON(map[string]interface{}{
  9448. "failed_code": -10,
  9449. "msg": res2.ErrMsg,
  9450. })
  9451. return
  9452. } else {
  9453. order.IsUploadOrderInfo = 1
  9454. service.UpdateOrder(order)
  9455. c.ServeSuccessJSON(map[string]interface{}{
  9456. "msg": "上传成功",
  9457. })
  9458. }
  9459. }
  9460. func (c *HisApiController) Get4202() {
  9461. order_id, _ := c.GetInt64("order_id")
  9462. admin_user_id, _ := c.GetInt64("admin_user_id")
  9463. order, _ := service.GetHisOrderByIDTwo(order_id)
  9464. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9465. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9466. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9467. if order.ID == 0 {
  9468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9469. return
  9470. }
  9471. var struct4202 models.Struct4202
  9472. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9473. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9474. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9475. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9476. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9477. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9478. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  9479. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  9480. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9481. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9482. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9483. var config []*models.HisXtDiagnoseConfig
  9484. for _, item := range diagnosis_ids {
  9485. id, _ := strconv.ParseInt(item, 10, 64)
  9486. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9487. config = append(config, &diagnosisConfig)
  9488. }
  9489. var tempDiaginfos []models.OwnPayPatnDiagListD
  9490. for index, item := range config {
  9491. if index == 0 {
  9492. var tempDiaginfo models.OwnPayPatnDiagListD
  9493. tempDiaginfo.InoutDiagType = "1"
  9494. tempDiaginfo.DiagCode = item.CountryCode
  9495. tempDiaginfo.DiagName = item.CountryContentName
  9496. tempDiaginfo.DiagType = "1"
  9497. tempDiaginfo.DiagSrtNo = "1"
  9498. tempDiaginfo.MaindiagFlag = "1"
  9499. tempDiaginfo.ValiFlag = "1"
  9500. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9501. } else {
  9502. var tempDiaginfo models.OwnPayPatnDiagListD
  9503. tempDiaginfo.DiagCode = item.CountryCode
  9504. tempDiaginfo.DiagName = item.CountryContentName
  9505. tempDiaginfo.DiagType = "2"
  9506. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9507. tempDiaginfo.MaindiagFlag = "0"
  9508. tempDiaginfo.ValiFlag = "1"
  9509. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9510. }
  9511. }
  9512. struct4202.ODiagListD = tempDiaginfos
  9513. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  9514. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  9515. var res2 ResultSix
  9516. var respJSON2 map[string]interface{}
  9517. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9518. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9520. return
  9521. }
  9522. userJSONBytes2, _ := json.Marshal(respJSON2)
  9523. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9524. utils.ErrorLog("解析失败:%v", err)
  9525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9526. return
  9527. }
  9528. if res2.Infcode != 0 {
  9529. c.ServeSuccessJSON(map[string]interface{}{
  9530. "failed_code": -10,
  9531. "msg": res2.ErrMsg,
  9532. })
  9533. return
  9534. } else {
  9535. order.IsUploadDiagnose = 1
  9536. service.UpdateOrder(order)
  9537. c.ServeSuccessJSON(map[string]interface{}{
  9538. "msg": "上传成功",
  9539. })
  9540. }
  9541. }
  9542. func (c *HisApiController) Get4203() {
  9543. admin_user_id, _ := c.GetInt64("admin_user_id")
  9544. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9545. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9546. order_id, _ := c.GetInt64("order_id")
  9547. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  9548. number := ""
  9549. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9550. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9551. if his.ID == 0 {
  9552. number = hospital.Number
  9553. } else {
  9554. number = his.Number
  9555. }
  9556. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  9557. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  9558. var res2 ResultSix
  9559. var respJSON2 map[string]interface{}
  9560. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9561. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9563. return
  9564. }
  9565. userJSONBytes2, _ := json.Marshal(respJSON2)
  9566. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9567. utils.ErrorLog("解析失败:%v", err)
  9568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9569. return
  9570. }
  9571. if res2.Infcode != 0 {
  9572. c.ServeSuccessJSON(map[string]interface{}{
  9573. "failed_code": -10,
  9574. "msg": res2.ErrMsg,
  9575. })
  9576. return
  9577. } else {
  9578. order.IsUploadSuccess = 1
  9579. service.UpdateOrderTwo(order)
  9580. c.ServeSuccessJSON(map[string]interface{}{
  9581. "msg": "上传成功",
  9582. })
  9583. }
  9584. }
  9585. func (c *HisApiController) Get4205() {
  9586. order_id, _ := c.GetInt64("order_id")
  9587. admin_user_id, _ := c.GetInt64("admin_user_id")
  9588. fapiao_code := c.GetString("fapiao_code")
  9589. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  9590. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9591. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9592. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9593. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  9594. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  9595. //order_info = append(order_info, order_info_two...)
  9596. department, _ := service.GetDepartMentDetail(his.Departments)
  9597. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  9598. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  9599. if order.ID == 0 {
  9600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  9601. return
  9602. }
  9603. var struct4201A models.Struct4201A
  9604. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  9605. for _, items := range order_info {
  9606. memo := make(map[string]interface{})
  9607. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9608. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9609. fsiOPFLD.MedType = pre.MedType
  9610. fsiOPFLD.FixmedinsCode = miConfig.Code
  9611. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9612. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9613. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9614. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9615. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9616. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.StartTime, 0).Format("2006-01-02 15:04:05")
  9617. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9618. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  9619. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9620. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9621. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9622. fsiOPFLD.BilgDeptName = department.Name
  9623. fsiOPFLD.BilgDeptCodg = department.Number
  9624. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9625. fsiOPFLD.BilgDrName = doctor.UserName
  9626. fsiOPFLD.MedChrgitmType = "09"
  9627. memo["hosp_appr_flag"] = "1"
  9628. memo["invoice_no"] = fapiao_code
  9629. memo["memo"] = "自费"
  9630. bytesData, _ := json.Marshal(memo)
  9631. fsiOPFLD.Memo = string(bytesData)
  9632. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9633. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9634. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9635. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9636. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.StartTime, 0).Format("2006-01-02 15:04:05")
  9637. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9638. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9639. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9640. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9641. fsiOPFLD.BilgDeptName = department.Name
  9642. fsiOPFLD.BilgDeptCodg = department.Number
  9643. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9644. fsiOPFLD.BilgDrName = doctor.UserName
  9645. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9646. case 0:
  9647. break
  9648. case 1:
  9649. fsiOPFLD.MedChrgitmType = "14"
  9650. break
  9651. case 2:
  9652. fsiOPFLD.MedChrgitmType = "05"
  9653. break
  9654. case 3:
  9655. fsiOPFLD.MedChrgitmType = "03"
  9656. break
  9657. case 4:
  9658. fsiOPFLD.MedChrgitmType = "03"
  9659. break
  9660. case 5:
  9661. fsiOPFLD.MedChrgitmType = "08"
  9662. break
  9663. case 6:
  9664. fsiOPFLD.MedChrgitmType = "14"
  9665. break
  9666. case 7:
  9667. fsiOPFLD.MedChrgitmType = "14"
  9668. break
  9669. case 8:
  9670. fsiOPFLD.MedChrgitmType = "03"
  9671. break
  9672. case 9:
  9673. fsiOPFLD.MedChrgitmType = "14"
  9674. break
  9675. case 10:
  9676. fsiOPFLD.MedChrgitmType = "14"
  9677. break
  9678. case 11:
  9679. fsiOPFLD.MedChrgitmType = "06"
  9680. break
  9681. case 12:
  9682. fsiOPFLD.MedChrgitmType = "12"
  9683. break
  9684. case 13:
  9685. fsiOPFLD.MedChrgitmType = "01"
  9686. break
  9687. case 14:
  9688. fsiOPFLD.MedChrgitmType = "04"
  9689. break
  9690. case 15:
  9691. fsiOPFLD.MedChrgitmType = "14"
  9692. break
  9693. }
  9694. memo["hosp_appr_flag"] = "1"
  9695. memo["invoice_no"] = fapiao_code
  9696. memo["memo"] = "自费"
  9697. bytesData, _ := json.Marshal(memo)
  9698. fsiOPFLD.Memo = string(bytesData)
  9699. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9700. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  9701. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9702. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9703. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9704. fsiOPFLD.BilgDeptName = department.Name
  9705. fsiOPFLD.BilgDeptCodg = department.Number
  9706. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9707. fsiOPFLD.BilgDrName = doctor.UserName
  9708. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9709. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9710. fsiOPFLD.MedChrgitmType = "08"
  9711. memo["hosp_appr_flag"] = "1"
  9712. memo["invoice_no"] = fapiao_code
  9713. memo["memo"] = "自费"
  9714. bytesData, _ := json.Marshal(memo)
  9715. fsiOPFLD.Memo = string(bytesData)
  9716. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9717. }
  9718. }
  9719. }
  9720. for _, items := range order_info_two {
  9721. memo := make(map[string]interface{})
  9722. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  9723. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  9724. fsiOPFLD.MedType = pre.MedType
  9725. fsiOPFLD.BkkpSn = items.FeedetlSn
  9726. fsiOPFLD.FixmedinsCode = miConfig.Code
  9727. fsiOPFLD.FixmedinsName = miConfig.OrgName
  9728. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  9729. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  9730. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  9731. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  9732. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  9733. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9734. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  9735. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9736. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  9737. fsiOPFLD.BilgDeptName = department.Name
  9738. fsiOPFLD.BilgDeptCodg = department.Number
  9739. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9740. fsiOPFLD.BilgDrName = doctor.UserName
  9741. fsiOPFLD.MedChrgitmType = "09"
  9742. memo["hosp_appr_flag"] = "1"
  9743. memo["invoice_no"] = fapiao_code
  9744. memo["memo"] = "自费"
  9745. bytesData, _ := json.Marshal(memo)
  9746. fsiOPFLD.Memo = string(bytesData)
  9747. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9748. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  9749. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  9750. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  9751. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9752. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9753. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  9754. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  9755. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  9756. fsiOPFLD.BilgDeptName = department.Name
  9757. fsiOPFLD.BilgDeptCodg = department.Number
  9758. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9759. fsiOPFLD.BilgDrName = doctor.UserName
  9760. switch items.HisPrescriptionProject.HisProject.CostClassify {
  9761. case 0:
  9762. break
  9763. case 1:
  9764. fsiOPFLD.MedChrgitmType = "14"
  9765. break
  9766. case 2:
  9767. fsiOPFLD.MedChrgitmType = "05"
  9768. break
  9769. case 3:
  9770. fsiOPFLD.MedChrgitmType = "03"
  9771. break
  9772. case 4:
  9773. fsiOPFLD.MedChrgitmType = "03"
  9774. break
  9775. case 5:
  9776. fsiOPFLD.MedChrgitmType = "08"
  9777. break
  9778. case 6:
  9779. fsiOPFLD.MedChrgitmType = "14"
  9780. break
  9781. case 7:
  9782. fsiOPFLD.MedChrgitmType = "14"
  9783. break
  9784. case 8:
  9785. fsiOPFLD.MedChrgitmType = "03"
  9786. break
  9787. case 9:
  9788. fsiOPFLD.MedChrgitmType = "14"
  9789. break
  9790. case 10:
  9791. fsiOPFLD.MedChrgitmType = "14"
  9792. break
  9793. case 11:
  9794. fsiOPFLD.MedChrgitmType = "06"
  9795. break
  9796. case 12:
  9797. fsiOPFLD.MedChrgitmType = "12"
  9798. break
  9799. case 13:
  9800. fsiOPFLD.MedChrgitmType = "01"
  9801. break
  9802. case 14:
  9803. fsiOPFLD.MedChrgitmType = "04"
  9804. break
  9805. case 15:
  9806. fsiOPFLD.MedChrgitmType = "14"
  9807. break
  9808. }
  9809. memo["hosp_appr_flag"] = "1"
  9810. memo["invoice_no"] = fapiao_code
  9811. memo["memo"] = "自费"
  9812. bytesData, _ := json.Marshal(memo)
  9813. fsiOPFLD.Memo = string(bytesData)
  9814. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9815. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  9816. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  9817. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9818. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  9819. fsiOPFLD.BilgDeptName = department.Name
  9820. fsiOPFLD.BilgDeptCodg = department.Number
  9821. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  9822. fsiOPFLD.BilgDrName = doctor.UserName
  9823. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  9824. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  9825. fsiOPFLD.MedChrgitmType = "08"
  9826. memo["hosp_appr_flag"] = "1"
  9827. memo["invoice_no"] = fapiao_code
  9828. memo["memo"] = "自费"
  9829. bytesData, _ := json.Marshal(memo)
  9830. fsiOPFLD.Memo = string(bytesData)
  9831. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  9832. }
  9833. }
  9834. }
  9835. fmt.Println(fsiOPFLDs)
  9836. struct4201A.Fopfd = fsiOPFLDs
  9837. fmt.Println(struct4201A.Fopfd)
  9838. var struct4202 models.Struct4202
  9839. timeLayout := "2006-01-02 15:04:05"
  9840. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  9841. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  9842. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  9843. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  9844. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  9845. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  9846. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  9847. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  9848. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  9849. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  9850. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  9851. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  9852. var config []*models.HisXtDiagnoseConfig
  9853. for _, item := range diagnosis_ids {
  9854. id, _ := strconv.ParseInt(item, 10, 64)
  9855. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9856. config = append(config, &diagnosisConfig)
  9857. }
  9858. var tempDiaginfos []models.OwnPayPatnDiagListD
  9859. for index, item := range config {
  9860. if index == 0 {
  9861. var tempDiaginfo models.OwnPayPatnDiagListD
  9862. tempDiaginfo.InoutDiagType = "1"
  9863. tempDiaginfo.DiagCode = item.CountryCode
  9864. tempDiaginfo.DiagName = item.CountryContentName
  9865. tempDiaginfo.DiagType = "1"
  9866. tempDiaginfo.DiagSrtNo = "1"
  9867. tempDiaginfo.MaindiagFlag = "1"
  9868. tempDiaginfo.ValiFlag = "1"
  9869. tempDiaginfo.DiagDrName = doctor.UserName
  9870. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9871. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9872. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9873. } else {
  9874. var tempDiaginfo models.OwnPayPatnDiagListD
  9875. tempDiaginfo.DiagCode = item.CountryCode
  9876. tempDiaginfo.DiagName = item.CountryContentName
  9877. tempDiaginfo.DiagType = "2"
  9878. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  9879. tempDiaginfo.MaindiagFlag = "0"
  9880. tempDiaginfo.ValiFlag = "1"
  9881. tempDiaginfo.DiagDrName = doctor.UserName
  9882. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  9883. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  9884. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  9885. }
  9886. }
  9887. struct4202.ODiagListD = tempDiaginfos
  9888. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  9889. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  9890. var res2 ResultSix
  9891. var respJSON2 map[string]interface{}
  9892. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9893. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9895. return
  9896. }
  9897. userJSONBytes2, _ := json.Marshal(respJSON2)
  9898. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9899. utils.ErrorLog("解析失败:%v", err)
  9900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9901. return
  9902. }
  9903. if res2.Infcode != 0 {
  9904. c.ServeSuccessJSON(map[string]interface{}{
  9905. "failed_code": -10,
  9906. "msg": res2.ErrMsg,
  9907. })
  9908. return
  9909. } else {
  9910. order.IsUploadDiagnose = 1
  9911. order.IsUploadOrderInfo = 1
  9912. service.UpdateOrderTwo(order)
  9913. c.ServeSuccessJSON(map[string]interface{}{
  9914. "msg": "上传成功",
  9915. })
  9916. }
  9917. }
  9918. func (c *HisApiController) Get4207() {
  9919. admin_user_id, _ := c.GetInt64("admin_user_id")
  9920. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9921. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9922. order_id, _ := c.GetInt64("order_id")
  9923. order, _ := service.GetHisOrderByIDTwo(order_id)
  9924. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9925. var struct4207 models.Struct4207
  9926. struct4207.PageNum = "1"
  9927. struct4207.PageSize = "1000"
  9928. struct4207.FixmedinsCode = miConfig.Code
  9929. struct4207.FixmedinsMdtrtID = order.Number
  9930. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  9931. saveLog(result, requestLog, "4207", "查询")
  9932. var res2 ResultSix
  9933. var respJSON2 map[string]interface{}
  9934. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9935. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9937. return
  9938. }
  9939. userJSONBytes2, _ := json.Marshal(respJSON2)
  9940. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9941. utils.ErrorLog("解析失败:%v", err)
  9942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9943. return
  9944. }
  9945. if res2.Infcode != 0 {
  9946. c.ServeSuccessJSON(map[string]interface{}{
  9947. "failed_code": -10,
  9948. "msg": res2.ErrMsg,
  9949. })
  9950. return
  9951. } else {
  9952. c.ServeSuccessJSON(map[string]interface{}{
  9953. "msg": "查询成功",
  9954. })
  9955. }
  9956. }
  9957. func (c *HisApiController) Get4208() {
  9958. admin_user_id, _ := c.GetInt64("admin_user_id")
  9959. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9960. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9961. order_id, _ := c.GetInt64("order_id")
  9962. order, _ := service.GetHisOrderByIDTwo(order_id)
  9963. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9964. var struct4208 models.Struct4208
  9965. struct4208.PageNum = "1"
  9966. struct4208.PageSize = "1000"
  9967. struct4208.PsnCertType = "01"
  9968. struct4208.Certno = his.Certno
  9969. struct4208.MedType = order.MedType
  9970. struct4208.PsnName = his.Name
  9971. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  9972. saveLog(result, requestLog, "4208", "查询")
  9973. var res2 ResultSix
  9974. var respJSON2 map[string]interface{}
  9975. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9976. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9978. return
  9979. }
  9980. userJSONBytes2, _ := json.Marshal(respJSON2)
  9981. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9982. utils.ErrorLog("解析失败:%v", err)
  9983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9984. return
  9985. }
  9986. if res2.Infcode != 0 {
  9987. c.ServeSuccessJSON(map[string]interface{}{
  9988. "failed_code": -10,
  9989. "msg": res2.ErrMsg,
  9990. })
  9991. return
  9992. } else {
  9993. c.ServeSuccessJSON(map[string]interface{}{
  9994. "msg": "查询成功",
  9995. })
  9996. }
  9997. }
  9998. func (c *HisApiController) Get4209() {
  9999. admin_user_id, _ := c.GetInt64("admin_user_id")
  10000. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10001. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10002. order_id, _ := c.GetInt64("order_id")
  10003. order, _ := service.GetHisOrderByIDTwo(order_id)
  10004. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  10005. var struct4209 models.Struct4209
  10006. struct4209.FixmedinsMdtrtID = order.Number
  10007. struct4209.FixmedinsCode = miConfig.Code
  10008. struct4209.PageSize = "1000"
  10009. struct4209.PageNum = "1"
  10010. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  10011. saveLog(result, requestLog, "4209", "查询")
  10012. var res2 ResultSix
  10013. var respJSON2 map[string]interface{}
  10014. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  10015. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10017. return
  10018. }
  10019. userJSONBytes2, _ := json.Marshal(respJSON2)
  10020. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10021. utils.ErrorLog("解析失败:%v", err)
  10022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10023. return
  10024. }
  10025. if res2.Infcode != 0 {
  10026. c.ServeSuccessJSON(map[string]interface{}{
  10027. "failed_code": -10,
  10028. "msg": res2.ErrMsg,
  10029. })
  10030. return
  10031. } else {
  10032. c.ServeSuccessJSON(map[string]interface{}{
  10033. "msg": "查询成功",
  10034. })
  10035. }
  10036. }
  10037. type Result3101 struct {
  10038. Infcode string `json:"infcode"`
  10039. InfRefmsgid string `json:"inf_refmsgid"`
  10040. RefmsgTime string `json:"refmsg_time"`
  10041. RespondTime string `json:"respond_time"`
  10042. Enctype string `json:"enctype"`
  10043. Signtype string `json:"signtype"`
  10044. ErrMsg string `json:"err_msg"`
  10045. Output struct {
  10046. Result []struct {
  10047. JudgeResultDetailDtos []struct {
  10048. VolaItemType string `json:"vola_item_type"`
  10049. MdtrtID string `json:"mdtrt_id"`
  10050. JrdID string `json:"jrd_id"`
  10051. PatnID string `json:"patn_id"`
  10052. RxID string `json:"rx_id"`
  10053. VolaAmt interface{} `json:"vola_amt"`
  10054. } `json:"judge_result_detail_dtos"`
  10055. RuleID string `json:"rule_id"`
  10056. VolaEvid string `json:"vola_evid"`
  10057. MdtrtID string `json:"mdtrt_id"`
  10058. RuleName string `json:"rule_name"`
  10059. VolaAmtStas string `json:"vola_amt_stas"`
  10060. JrID string `json:"jr_id"`
  10061. PatnID string `json:"patn_id"`
  10062. SevDeg string `json:"sev_deg"`
  10063. VolaAmt float64 `json:"vola_amt"`
  10064. VolaBhvrType string `json:"vola_bhvr_type"`
  10065. VolaCont string `json:"vola_cont"`
  10066. } `json:"result"`
  10067. } `json:"output"`
  10068. }
  10069. type Resultgd3101 struct {
  10070. Infcode int64 `json:"infcode"`
  10071. InfRefmsgid string `json:"inf_refmsgid"`
  10072. RefmsgTime string `json:"refmsg_time"`
  10073. RespondTime string `json:"respond_time"`
  10074. Enctype string `json:"enctype"`
  10075. Signtype string `json:"signtype"`
  10076. ErrMsg string `json:"err_msg"`
  10077. Output struct {
  10078. Result []struct {
  10079. JudgeResultDetailDtos []struct {
  10080. VolaItemType string `json:"vola_item_type"`
  10081. MdtrtID string `json:"mdtrt_id"`
  10082. JrdID string `json:"jrd_id"`
  10083. PatnID string `json:"patn_id"`
  10084. RxID string `json:"rx_id"`
  10085. VolaAmt interface{} `json:"vola_amt"`
  10086. } `json:"judge_result_detail_dtos"`
  10087. RuleID string `json:"rule_id"`
  10088. VolaEvid string `json:"vola_evid"`
  10089. MdtrtID string `json:"mdtrt_id"`
  10090. RuleName string `json:"rule_name"`
  10091. VolaAmtStas string `json:"vola_amt_stas"`
  10092. JrID string `json:"jr_id"`
  10093. PatnID string `json:"patn_id"`
  10094. SevDeg string `json:"sev_deg"`
  10095. VolaAmt float64 `json:"vola_amt"`
  10096. VolaBhvrType string `json:"vola_bhvr_type"`
  10097. VolaCont string `json:"vola_cont"`
  10098. } `json:"result"`
  10099. } `json:"output"`
  10100. }
  10101. func (c *HisApiController) ReadEleToken() {
  10102. admin_user_id, _ := c.GetInt64("admin_user_id")
  10103. his_patient_id, _ := c.GetInt64("his_patient_id")
  10104. adminUser := c.GetAdminUserInfo()
  10105. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10106. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10107. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10108. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  10109. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10110. if len(tokens) > 0 {
  10111. c.ServeSuccessJSON(map[string]interface{}{
  10112. "msg": "读取成功",
  10113. })
  10114. } else {
  10115. c.ServeSuccessJSON(map[string]interface{}{
  10116. "failed_code": -10,
  10117. "msg": "读取失败",
  10118. })
  10119. }
  10120. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10121. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10122. if len(tokens) > 0 {
  10123. c.ServeSuccessJSON(map[string]interface{}{
  10124. "msg": "读取成功",
  10125. })
  10126. } else {
  10127. c.ServeSuccessJSON(map[string]interface{}{
  10128. "failed_code": -10,
  10129. "msg": "读取失败",
  10130. })
  10131. }
  10132. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10133. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10134. if len(tokens) > 0 {
  10135. c.ServeSuccessJSON(map[string]interface{}{
  10136. "msg": "读取成功",
  10137. })
  10138. } else {
  10139. c.ServeSuccessJSON(map[string]interface{}{
  10140. "failed_code": -10,
  10141. "msg": "读取失败",
  10142. })
  10143. }
  10144. } else if miConfig.MdtrtareaAdmvs == "150499" {
  10145. var api string
  10146. 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 +
  10147. "&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"
  10148. resp, requestErr := http.Get(api)
  10149. if requestErr != nil {
  10150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10151. }
  10152. body, ioErr := ioutil.ReadAll(resp.Body)
  10153. if ioErr != nil {
  10154. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10156. }
  10157. var respJSON map[string]interface{}
  10158. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10159. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10161. return
  10162. }
  10163. var status string
  10164. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10165. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10166. var token string
  10167. var res ResultTwo //1101结果
  10168. var res10265 ResultTwo10265 //1101结果
  10169. if status == "0" { //读卡成功
  10170. var card_info string //卡信息
  10171. var busi_card_info string
  10172. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10173. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10174. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10175. fmt.Println(card_info)
  10176. fmt.Println(busi_card_info)
  10177. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10178. result, _ := json.Marshal(respJSON)
  10179. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10180. utils.ErrorLog("解析失败:%v", err)
  10181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10182. return
  10183. }
  10184. res.ErrMsg = res10265.ErrMsg
  10185. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10186. res.Infcode = infocode
  10187. res.Output = res10265.Output
  10188. res.InfRefmsgid = res10265.InfRefmsgid
  10189. if res.Infcode == 0 {
  10190. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10191. if err == gorm.ErrRecordNotFound {
  10192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10193. return
  10194. } else if err != nil {
  10195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10196. return
  10197. } else {
  10198. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10199. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10200. infoStr := string(Iinfos)
  10201. idetinfoStr := string(Idetinfos)
  10202. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  10203. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  10204. psn := &models.HisPsn{
  10205. PsnNo: res.Output.Baseinfo.PsnNo,
  10206. PatientId: patient.ID,
  10207. Certno: res.Output.Baseinfo.Certno,
  10208. Gend: res.Output.Baseinfo.Gend,
  10209. Naty: res.Output.Baseinfo.Naty,
  10210. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10211. PsnName: res.Output.Baseinfo.PsnName,
  10212. Age: float64(age),
  10213. Brdy: b,
  10214. Idetinfo: idetinfoStr,
  10215. Insuinfo: infoStr,
  10216. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10217. CardInfo: card_info,
  10218. VerifyNumber: token,
  10219. IdCardType: 4,
  10220. }
  10221. var rf []*ResultFive
  10222. json.Unmarshal([]byte(infoStr), &rf)
  10223. var insutypes []*ResultFive
  10224. var insutype string
  10225. var is390 int = 0
  10226. var is310 int = 0
  10227. for _, item := range rf {
  10228. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10229. insutypes = append(insutypes, item)
  10230. }
  10231. }
  10232. if len(insutypes) == 1 {
  10233. insutype = insutypes[0].Insutype
  10234. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10235. } else {
  10236. for _, i := range insutypes {
  10237. if i.Insutype == "390" {
  10238. is390 = 1
  10239. }
  10240. if i.Insutype == "310" {
  10241. is310 = 1
  10242. }
  10243. }
  10244. }
  10245. if is390 == 1 {
  10246. insutype = "390"
  10247. }
  10248. if is310 == 1 {
  10249. insutype = "310"
  10250. }
  10251. if len(insutypes) == 0 {
  10252. insutype = "310"
  10253. }
  10254. service.CreateHisPsn(psn)
  10255. c.ServeSuccessJSON(map[string]interface{}{
  10256. "patient": patient,
  10257. "number": token,
  10258. "insutype": insutype,
  10259. })
  10260. }
  10261. } else {
  10262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10263. return
  10264. }
  10265. } else { //读卡失败
  10266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10267. return
  10268. }
  10269. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10270. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  10271. if len(errMsg) == 0 {
  10272. type ELeData struct {
  10273. Data struct {
  10274. IdNo string `json:"idNo"`
  10275. IdType string `json:"idType"`
  10276. UserName string `json:"userName"`
  10277. EcToken string `json:"ecToken"`
  10278. InsuOrg string `json:"insuOrg"`
  10279. Gender string `json:"gender"`
  10280. Birthday string `json:"birthday"`
  10281. Nationality string `json:"nationality"`
  10282. Email string `json:"email"`
  10283. Extra string `json:"extra"`
  10284. } `json:"data"`
  10285. Code int `json:"code"`
  10286. Message string `json:"message"`
  10287. }
  10288. var ele ELeData
  10289. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10290. if err != nil {
  10291. utils.ErrorLog("解析失败:%v", err)
  10292. }
  10293. token := ele.Data.EcToken
  10294. if len(token) > 0 {
  10295. psn := &models.HisPsn{
  10296. PsnNo: his.PsnNo,
  10297. Age: 0,
  10298. PatientId: his.PatientId,
  10299. Certno: his.Certno,
  10300. Brdy: his.Brdy,
  10301. Gend: his.Gend,
  10302. Naty: his.Naty,
  10303. PsnCertType: his.PsnCertType,
  10304. PsnName: his.PsnName,
  10305. Idetinfo: his.Idetinfo,
  10306. Insuinfo: his.Iinfo,
  10307. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10308. CardInfo: outPutInfo,
  10309. VerifyNumber: token,
  10310. }
  10311. service.CreateHisPsn(psn)
  10312. }
  10313. if len(token) > 0 {
  10314. c.ServeSuccessJSON(map[string]interface{}{
  10315. "msg": "读取成功",
  10316. })
  10317. } else {
  10318. c.ServeSuccessJSON(map[string]interface{}{
  10319. "failed_code": -10,
  10320. "msg": "读取失败",
  10321. })
  10322. }
  10323. }
  10324. } else if miConfig.MdtrtareaAdmvs == "360302" {
  10325. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10326. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10327. type ELeData struct {
  10328. Data struct {
  10329. IdNo string `json:"idNo"`
  10330. IdType string `json:"idType"`
  10331. UserName string `json:"userName"`
  10332. EcToken string `json:"ecToken"`
  10333. InsuOrg string `json:"insuOrg"`
  10334. Gender string `json:"gender"`
  10335. Birthday string `json:"birthday"`
  10336. Nationality string `json:"nationality"`
  10337. Email string `json:"email"`
  10338. Extra string `json:"extra"`
  10339. } `json:"data"`
  10340. Code int `json:"code"`
  10341. Message string `json:"message"`
  10342. }
  10343. var ele ELeData
  10344. err := json.Unmarshal([]byte(result), &ele)
  10345. if err != nil {
  10346. utils.ErrorLog("解析失败:%v", err)
  10347. }
  10348. token := ele.Data.EcToken
  10349. token = Remove0000(token)
  10350. fmt.Println(ele.Data.UserName)
  10351. 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)
  10352. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10353. var res ResultTwo
  10354. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10355. utils.ErrorLog("解析失败:%v", err)
  10356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10357. return
  10358. }
  10359. if res.Infcode == 0 {
  10360. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10361. if err == gorm.ErrRecordNotFound {
  10362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10363. return
  10364. } else if err != nil {
  10365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10366. return
  10367. } else {
  10368. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10369. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10370. infoStr := string(Iinfos)
  10371. idetinfoStr := string(Idetinfos)
  10372. psn := &models.HisPsn{
  10373. PsnNo: res.Output.Baseinfo.PsnNo,
  10374. PatientId: patient.ID,
  10375. Certno: res.Output.Baseinfo.Certno,
  10376. Gend: res.Output.Baseinfo.Gend,
  10377. Naty: res.Output.Baseinfo.Naty,
  10378. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10379. PsnName: res.Output.Baseinfo.PsnName,
  10380. Idetinfo: idetinfoStr,
  10381. Insuinfo: infoStr,
  10382. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10383. CardInfo: "",
  10384. VerifyNumber: token,
  10385. }
  10386. service.CreateHisPsn(psn)
  10387. c.ServeSuccessJSON(map[string]interface{}{
  10388. "patient": patient,
  10389. "number": token,
  10390. })
  10391. }
  10392. } else {
  10393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10394. return
  10395. }
  10396. } else if miConfig.MdtrtareaAdmvs == "361025" {
  10397. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10398. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10399. type ELeData struct {
  10400. Data struct {
  10401. IdNo string `json:"idNo"`
  10402. IdType string `json:"idType"`
  10403. UserName string `json:"userName"`
  10404. EcToken string `json:"ecToken"`
  10405. InsuOrg string `json:"insuOrg"`
  10406. Gender string `json:"gender"`
  10407. Birthday string `json:"birthday"`
  10408. Nationality string `json:"nationality"`
  10409. Email string `json:"email"`
  10410. Extra string `json:"extra"`
  10411. } `json:"data"`
  10412. Code int `json:"code"`
  10413. Message string `json:"message"`
  10414. }
  10415. var ele ELeData
  10416. err := json.Unmarshal([]byte(result), &ele)
  10417. if err != nil {
  10418. utils.ErrorLog("解析失败:%v", err)
  10419. }
  10420. token := ele.Data.EcToken
  10421. token = Remove0000(token)
  10422. fmt.Println(ele.Data.UserName)
  10423. 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)
  10424. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10425. var res ResultTwo
  10426. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10427. utils.ErrorLog("解析失败:%v", err)
  10428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10429. return
  10430. }
  10431. if res.Infcode == 0 {
  10432. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10433. if err == gorm.ErrRecordNotFound {
  10434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10435. return
  10436. } else if err != nil {
  10437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10438. return
  10439. } else {
  10440. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10441. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10442. infoStr := string(Iinfos)
  10443. idetinfoStr := string(Idetinfos)
  10444. psn := &models.HisPsn{
  10445. PsnNo: res.Output.Baseinfo.PsnNo,
  10446. PatientId: patient.ID,
  10447. Certno: res.Output.Baseinfo.Certno,
  10448. Gend: res.Output.Baseinfo.Gend,
  10449. Naty: res.Output.Baseinfo.Naty,
  10450. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10451. PsnName: res.Output.Baseinfo.PsnName,
  10452. Idetinfo: idetinfoStr,
  10453. Insuinfo: infoStr,
  10454. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10455. CardInfo: "",
  10456. VerifyNumber: token,
  10457. }
  10458. service.CreateHisPsn(psn)
  10459. c.ServeSuccessJSON(map[string]interface{}{
  10460. "patient": patient,
  10461. "number": token,
  10462. })
  10463. }
  10464. } else {
  10465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10466. return
  10467. }
  10468. } else if miConfig.MdtrtareaAdmvs == "360100" {
  10469. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10470. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10471. type ELeData struct {
  10472. Data struct {
  10473. IdNo string `json:"idNo"`
  10474. IdType string `json:"idType"`
  10475. UserName string `json:"userName"`
  10476. EcToken string `json:"ecToken"`
  10477. InsuOrg string `json:"insuOrg"`
  10478. Gender string `json:"gender"`
  10479. Birthday string `json:"birthday"`
  10480. Nationality string `json:"nationality"`
  10481. Email string `json:"email"`
  10482. Extra string `json:"extra"`
  10483. } `json:"data"`
  10484. Code int `json:"code"`
  10485. Message string `json:"message"`
  10486. }
  10487. var ele ELeData
  10488. err := json.Unmarshal([]byte(result), &ele)
  10489. if err != nil {
  10490. utils.ErrorLog("解析失败:%v", err)
  10491. }
  10492. token := ele.Data.EcToken
  10493. token = Remove0000(token)
  10494. fmt.Println(ele.Data.UserName)
  10495. 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)
  10496. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10497. var res ResultTwo
  10498. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10499. utils.ErrorLog("解析失败:%v", err)
  10500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10501. return
  10502. }
  10503. if res.Infcode == 0 {
  10504. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10505. if err == gorm.ErrRecordNotFound {
  10506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10507. return
  10508. } else if err != nil {
  10509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10510. return
  10511. } else {
  10512. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10513. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10514. infoStr := string(Iinfos)
  10515. idetinfoStr := string(Idetinfos)
  10516. psn := &models.HisPsn{
  10517. PsnNo: res.Output.Baseinfo.PsnNo,
  10518. PatientId: patient.ID,
  10519. Certno: res.Output.Baseinfo.Certno,
  10520. Gend: res.Output.Baseinfo.Gend,
  10521. Naty: res.Output.Baseinfo.Naty,
  10522. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10523. PsnName: res.Output.Baseinfo.PsnName,
  10524. Idetinfo: idetinfoStr,
  10525. Insuinfo: infoStr,
  10526. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10527. CardInfo: "",
  10528. VerifyNumber: token,
  10529. }
  10530. service.CreateHisPsn(psn)
  10531. c.ServeSuccessJSON(map[string]interface{}{
  10532. "patient": patient,
  10533. "number": token,
  10534. })
  10535. }
  10536. } else {
  10537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10538. return
  10539. }
  10540. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10541. //if initFlag == 0 {
  10542. //c.TestGetJiangXiBasBaseInit()
  10543. //}
  10544. //if initEleFlag == 0 {
  10545. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  10546. //}
  10547. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  10548. utils.ErrorLog("解析失败:%v", json_result)
  10549. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10550. type ELeData struct {
  10551. Data struct {
  10552. IdNo string `json:"idNo"`
  10553. IdType string `json:"idType"`
  10554. UserName string `json:"userName"`
  10555. EcToken string `json:"ecToken"`
  10556. InsuOrg string `json:"insuOrg"`
  10557. Gender string `json:"gender"`
  10558. Birthday string `json:"birthday"`
  10559. Nationality string `json:"nationality"`
  10560. Email string `json:"email"`
  10561. Extra string `json:"extra"`
  10562. } `json:"data"`
  10563. Code int `json:"code"`
  10564. Message string `json:"message"`
  10565. }
  10566. var ele ELeData
  10567. err := json.Unmarshal([]byte(json_result), &ele)
  10568. if err != nil {
  10569. utils.ErrorLog("解析失败:%v", err)
  10570. }
  10571. token := ele.Data.EcToken
  10572. token = Remove0000(token)
  10573. //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)
  10574. 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)
  10575. //result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  10576. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10577. var res ResultTwo
  10578. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10579. utils.ErrorLog("解析失败:%v", err)
  10580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10581. return
  10582. }
  10583. if res.Infcode == 0 {
  10584. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10585. if err == gorm.ErrRecordNotFound {
  10586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10587. return
  10588. } else if err != nil {
  10589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10590. return
  10591. } else {
  10592. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10593. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10594. infoStr := string(Iinfos)
  10595. idetinfoStr := string(Idetinfos)
  10596. psn := &models.HisPsn{
  10597. PsnNo: res.Output.Baseinfo.PsnNo,
  10598. PatientId: patient.ID,
  10599. Certno: res.Output.Baseinfo.Certno,
  10600. Gend: res.Output.Baseinfo.Gend,
  10601. Naty: res.Output.Baseinfo.Naty,
  10602. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10603. PsnName: res.Output.Baseinfo.PsnName,
  10604. Idetinfo: idetinfoStr,
  10605. Insuinfo: infoStr,
  10606. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10607. CardInfo: "",
  10608. VerifyNumber: token,
  10609. InsuplcAdmdvs: ele.Data.InsuOrg,
  10610. }
  10611. service.CreateHisPsn(psn)
  10612. c.ServeSuccessJSON(map[string]interface{}{
  10613. "patient": patient,
  10614. "number": token,
  10615. })
  10616. }
  10617. } else {
  10618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10619. return
  10620. }
  10621. } else if miConfig.MdtrtareaAdmvs == "450721" {
  10622. res := c.GetoleInfo()
  10623. if res.Infcode == 0 {
  10624. var result string
  10625. if res.Output.MdtrtCertType == "01" {
  10626. 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)
  10627. } else if res.Output.MdtrtCertType == "02" {
  10628. 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)
  10629. } else if res.Output.MdtrtCertType == "03" {
  10630. 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)
  10631. }
  10632. var dat map[string]interface{}
  10633. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10634. fmt.Println(dat)
  10635. } else {
  10636. fmt.Println(err)
  10637. }
  10638. userJSONBytes, _ := json.Marshal(dat)
  10639. var res2 ResultTwo
  10640. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10641. utils.ErrorLog("解析失败:%v", err)
  10642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10643. return
  10644. }
  10645. if res2.Infcode == 0 {
  10646. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  10647. if err == gorm.ErrRecordNotFound {
  10648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10649. return
  10650. } else if err != nil {
  10651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10652. return
  10653. } else {
  10654. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  10655. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  10656. infoStr := string(Iinfos)
  10657. idetinfoStr := string(Idetinfos)
  10658. var rf []*ResultFive
  10659. json.Unmarshal([]byte(infoStr), &rf)
  10660. var insutypes []*ResultFive
  10661. var insutype string
  10662. var is390 int = 0
  10663. var is310 int = 0
  10664. //var insuplc_admdvs string
  10665. for _, item := range rf {
  10666. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10667. insutypes = append(insutypes, item)
  10668. }
  10669. }
  10670. if len(insutypes) == 1 {
  10671. insutype = insutypes[0].Insutype
  10672. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10673. } else {
  10674. for _, i := range insutypes {
  10675. if i.Insutype == "390" {
  10676. is390 = 1
  10677. }
  10678. if i.Insutype == "310" {
  10679. is310 = 1
  10680. }
  10681. }
  10682. }
  10683. if is390 == 1 {
  10684. insutype = "390"
  10685. }
  10686. if is310 == 1 {
  10687. insutype = "310"
  10688. }
  10689. if len(insutypes) == 0 {
  10690. insutype = "310"
  10691. }
  10692. psn := &models.HisPsn{
  10693. PsnNo: res2.Output.Baseinfo.PsnNo,
  10694. PatientId: patient.ID,
  10695. Certno: res2.Output.Baseinfo.Certno,
  10696. Gend: res2.Output.Baseinfo.Gend,
  10697. Naty: res2.Output.Baseinfo.Naty,
  10698. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  10699. PsnName: res2.Output.Baseinfo.PsnName,
  10700. Idetinfo: idetinfoStr,
  10701. Insuinfo: infoStr,
  10702. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10703. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  10704. VerifyNumber: res.Output.EcToken,
  10705. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  10706. }
  10707. service.CreateHisPsn(psn)
  10708. c.ServeSuccessJSON(map[string]interface{}{
  10709. "patient": patient,
  10710. "number": res.Output.CardNo,
  10711. "insutype": insutype,
  10712. })
  10713. }
  10714. } else {
  10715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10716. return
  10717. }
  10718. } else {
  10719. c.ServeSuccessJSON(map[string]interface{}{
  10720. "failed_code": -10,
  10721. "msg": res.ErrMsg,
  10722. })
  10723. }
  10724. } else {
  10725. //if initFlag == 0 {
  10726. // c.TestGetBasBaseInit()
  10727. //}
  10728. //token := c.GetEleBaseInfo()
  10729. //token = Remove0000(token)
  10730. type ELeData struct {
  10731. Code string `json:"code"`
  10732. Data struct {
  10733. Aac002 string `json:"aac002"`
  10734. Aaz500 string `json:"aaz500"`
  10735. ActCardNo string `json:"actCardNo"`
  10736. Bab520 string `json:"bab520"`
  10737. Bkz543 string `json:"bkz543"`
  10738. BusinessType string `json:"businessType"`
  10739. CertfCodg string `json:"certfCodg"`
  10740. EcIndexNo string `json:"ecIndexNo"`
  10741. EcToken string `json:"ecToken"`
  10742. ID0000 string `json:"id0000"`
  10743. IDNo string `json:"idNo"`
  10744. IDType string `json:"idType"`
  10745. Idcode string `json:"idcode"`
  10746. IdentityToken string `json:"identity_token"`
  10747. InsuOrg string `json:"insuOrg"`
  10748. OfficeID string `json:"officeId"`
  10749. OfficeName string `json:"officeName"`
  10750. OperatorID string `json:"operatorId"`
  10751. OperatorName string `json:"operatorName"`
  10752. OrgID string `json:"orgId"`
  10753. UserName string `json:"userName"`
  10754. } `json:"data"`
  10755. Infno interface{} `json:"infno"`
  10756. Message string `json:"message"`
  10757. OrgID string `json:"orgId"`
  10758. TransType string `json:"transType"`
  10759. }
  10760. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  10761. fmt.Println(result)
  10762. outPutInfo := Remove0000(result)
  10763. fmt.Println(outPutInfo)
  10764. var ele ELeData
  10765. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10766. if err != nil {
  10767. utils.ErrorLog("解析失败:%v", err)
  10768. }
  10769. token := ele.Data.EcToken
  10770. var result2 string
  10771. var requestLog2 string
  10772. if len(token) > 0 {
  10773. if strings.Contains(ele.Data.IDNo, "HKG") {
  10774. 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)
  10775. } else {
  10776. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  10777. }
  10778. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10779. var res ResultTwo
  10780. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10781. utils.ErrorLog("解析失败:%v", err)
  10782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10783. return
  10784. }
  10785. if res.Infcode == 0 {
  10786. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10787. if err == gorm.ErrRecordNotFound {
  10788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10789. return
  10790. } else if err != nil {
  10791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10792. return
  10793. } else {
  10794. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10795. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10796. infoStr := string(Iinfos)
  10797. idetinfoStr := string(Idetinfos)
  10798. psn := &models.HisPsn{
  10799. PsnNo: res.Output.Baseinfo.PsnNo,
  10800. PatientId: patient.ID,
  10801. Certno: res.Output.Baseinfo.Certno,
  10802. Gend: res.Output.Baseinfo.Gend,
  10803. Naty: res.Output.Baseinfo.Naty,
  10804. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10805. PsnName: res.Output.Baseinfo.PsnName,
  10806. Idetinfo: idetinfoStr,
  10807. Insuinfo: infoStr,
  10808. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10809. CardInfo: "",
  10810. VerifyNumber: token,
  10811. }
  10812. service.CreateHisPsn(psn)
  10813. c.ServeSuccessJSON(map[string]interface{}{
  10814. "msg": "读取成功",
  10815. })
  10816. }
  10817. } else {
  10818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10819. return
  10820. }
  10821. } else {
  10822. c.ServeSuccessJSON(map[string]interface{}{
  10823. "failed_code": -10,
  10824. "msg": "读取失败",
  10825. })
  10826. }
  10827. }
  10828. }
  10829. func (c *HisApiController) ReadEleFace() {
  10830. admin_user_id, _ := c.GetInt64("admin_user_id")
  10831. //his_patient_id, _ := c.GetInt64("his_patient_id")
  10832. adminUser := c.GetAdminUserInfo()
  10833. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10834. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10835. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  10836. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  10837. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  10838. if len(tokens) > 0 {
  10839. c.ServeSuccessJSON(map[string]interface{}{
  10840. "msg": "读取成功",
  10841. })
  10842. } else {
  10843. c.ServeSuccessJSON(map[string]interface{}{
  10844. "failed_code": -10,
  10845. "msg": "读取失败",
  10846. })
  10847. }
  10848. }
  10849. }
  10850. func timestampToBirthdayString(timestamp int64) string {
  10851. // 将时间戳转换为 time.Time
  10852. t := time.Unix(timestamp, 0)
  10853. // 格式化时间为生日字符串,例如 "2006-01-02"
  10854. birthday := t.Format("2006-01-02")
  10855. return birthday
  10856. }
  10857. func (c *HisApiController) Get9001() {
  10858. adminUser := c.GetAdminUserInfo()
  10859. admin_user_id, _ := c.GetInt64("admin_user_id")
  10860. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10861. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10862. if miConfig.MdtrtareaAdmvs == "350500" {
  10863. service.GetFjAuthorizationInfo(miConfig.Code)
  10864. } else if miConfig.MdtrtareaAdmvs == "131023" {
  10865. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10866. var dat map[string]interface{}
  10867. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10868. fmt.Println(dat)
  10869. } else {
  10870. fmt.Println(err)
  10871. }
  10872. userJSONBytes, _ := json.Marshal(dat)
  10873. var res models.Result9001
  10874. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10875. utils.ErrorLog("解析失败:%v", err)
  10876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10877. return
  10878. }
  10879. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10880. fmt.Println(miConfig.SecretKey)
  10881. var res models.Result9001Two
  10882. 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 +
  10883. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10884. resp, requestErr := http.Get(api)
  10885. if requestErr != nil {
  10886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10887. return
  10888. }
  10889. body, ioErr := ioutil.ReadAll(resp.Body)
  10890. if ioErr != nil {
  10891. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10893. return
  10894. }
  10895. var respJSON map[string]interface{}
  10896. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10897. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10899. return
  10900. }
  10901. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10902. if status == "0" {
  10903. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10904. c.ServeSuccessJSON(map[string]interface{}{
  10905. "failed_code": -10,
  10906. "msg": err_msg,
  10907. })
  10908. return
  10909. }
  10910. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10911. result, _ := json.Marshal(respJSON)
  10912. fmt.Println("log")
  10913. fmt.Println(string(result))
  10914. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10915. utils.ErrorLog("解析失败:%v", err)
  10916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10917. return
  10918. }
  10919. if res.Infcode == 0 {
  10920. sign := models.HisSignIn{
  10921. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10922. SignNo: res.Output.Signinoutb.SignNo,
  10923. SignTime: "",
  10924. Ctime: time.Now().Unix(),
  10925. Mtime: time.Now().Unix(),
  10926. Status: 1,
  10927. InputLog: "",
  10928. OutputLog: "",
  10929. FixmedinsCode: miConfig.Code,
  10930. }
  10931. err := service.CreateSignIn(&sign)
  10932. if err == nil {
  10933. c.ServeSuccessJSON(map[string]interface{}{
  10934. "msg": "签到成功",
  10935. })
  10936. }
  10937. } else {
  10938. c.ServeSuccessJSON(map[string]interface{}{
  10939. "failed_code": -10,
  10940. "msg": res.ErrMsg,
  10941. })
  10942. return
  10943. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10944. //return
  10945. }
  10946. } else if miConfig.MdtrtareaAdmvs == "340699" {
  10947. fmt.Println(miConfig.SecretKey)
  10948. var res models.Result9001Two
  10949. 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 +
  10950. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  10951. resp, requestErr := http.Get(api)
  10952. if requestErr != nil {
  10953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10954. return
  10955. }
  10956. body, ioErr := ioutil.ReadAll(resp.Body)
  10957. if ioErr != nil {
  10958. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10960. return
  10961. }
  10962. var respJSON map[string]interface{}
  10963. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10964. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10966. return
  10967. }
  10968. status := respJSON["data"].(map[string]interface{})["status"].(string)
  10969. if status == "0" {
  10970. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  10971. c.ServeSuccessJSON(map[string]interface{}{
  10972. "failed_code": -10,
  10973. "msg": err_msg,
  10974. })
  10975. return
  10976. }
  10977. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10978. result, _ := json.Marshal(respJSON)
  10979. fmt.Println("log")
  10980. fmt.Println(string(result))
  10981. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10982. utils.ErrorLog("解析失败:%v", err)
  10983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10984. return
  10985. }
  10986. if res.Infcode == 0 {
  10987. sign := models.HisSignIn{
  10988. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10989. SignNo: res.Output.Signinoutb.SignNo,
  10990. SignTime: "",
  10991. Ctime: time.Now().Unix(),
  10992. Mtime: time.Now().Unix(),
  10993. Status: 1,
  10994. InputLog: "",
  10995. OutputLog: "",
  10996. FixmedinsCode: miConfig.Code,
  10997. }
  10998. err := service.CreateSignIn(&sign)
  10999. if err == nil {
  11000. c.ServeSuccessJSON(map[string]interface{}{
  11001. "msg": "签到成功",
  11002. })
  11003. }
  11004. } else {
  11005. c.ServeSuccessJSON(map[string]interface{}{
  11006. "failed_code": -10,
  11007. "msg": res.ErrMsg,
  11008. })
  11009. return
  11010. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11011. //return
  11012. }
  11013. } else {
  11014. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  11015. var dat map[string]interface{}
  11016. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11017. fmt.Println(dat)
  11018. } else {
  11019. fmt.Println(err)
  11020. }
  11021. userJSONBytes, _ := json.Marshal(dat)
  11022. var res models.Result9001
  11023. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11024. utils.ErrorLog("解析失败:%v", err)
  11025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11026. return
  11027. }
  11028. if res.Infcode == 0 {
  11029. sign := models.HisSignIn{
  11030. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11031. SignNo: res.Output.Signinoutb.SignNo,
  11032. SignTime: res.Output.Signinoutb.SignTime,
  11033. Ctime: time.Now().Unix(),
  11034. Mtime: time.Now().Unix(),
  11035. Status: 1,
  11036. InputLog: "",
  11037. OutputLog: "",
  11038. FixmedinsCode: miConfig.Code,
  11039. }
  11040. err := service.CreateSignIn(&sign)
  11041. if err == nil {
  11042. c.ServeSuccessJSON(map[string]interface{}{
  11043. "msg": "签到成功",
  11044. })
  11045. }
  11046. }
  11047. }
  11048. }
  11049. 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) {
  11050. var res Result3101
  11051. adminUser := c.GetAdminUserInfo()
  11052. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11053. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11054. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11055. //record_time := c.GetString("record_time")
  11056. //trig_scen := c.GetString("trig_scen")
  11057. timeLayout := "2006-01-02"
  11058. loc, _ := time.LoadLocation("Local")
  11059. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11060. if err != nil {
  11061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11062. return res
  11063. }
  11064. recordDateTime := theTime.Unix()
  11065. var patientPrescription models.HisPrescriptionInfo
  11066. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11067. //if patientPrescription.ID == 0 {
  11068. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11069. //}
  11070. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11071. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11072. //
  11073. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11074. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11075. var pp models.PublicParams
  11076. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11077. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11078. pp.FixmedinsName = miConfig.OrgName
  11079. pp.FixmedinsCode = miConfig.Code
  11080. pp.RequestUrl = miConfig.Url
  11081. pp.Cainfo = miConfig.Cainfo
  11082. pp.SecretKey = miConfig.SecretKey
  11083. pp.AccessKey = miConfig.AccessKey
  11084. pp.OpterName = roles.UserName
  11085. var config []*models.HisXtDiagnoseConfig
  11086. for _, item := range diagnosis_ids {
  11087. id, _ := strconv.ParseInt(item, 10, 64)
  11088. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11089. config = append(config, &diagnosisConfig)
  11090. }
  11091. var pd models.PatientDtos
  11092. pd.PatnID = his.PsnNo
  11093. pd.PatnName = his.Name
  11094. pd.Gend = his.Gend
  11095. pd.Brdy = his.Brdy
  11096. pd.Poolarea = miConfig.MdtrtareaAdmvs
  11097. pd.CurrMdtrtID = his.Number
  11098. var fed models.FsiEncounterDtos
  11099. fed.MdtrtID = his.Number
  11100. fed.MedinsID = miConfig.Code
  11101. fed.MedinsName = miConfig.OrgName
  11102. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11103. fed.MedMdtrtType = "1"
  11104. fed.MedinsType = "1"
  11105. fed.MedinsLv = "11"
  11106. tm := time.Unix(his.RecordDate, 0)
  11107. s_tm := tm.Format("2006-01-02 15:04:05")
  11108. fed.AdmDate = s_tm
  11109. fed.DscgDate = s_tm
  11110. fed.DscgMainDiseCodg = config[0].CountryCode
  11111. fed.DscgMainDiseName = config[0].CountryContentName
  11112. //诊断信息
  11113. var fdds []*models.FsiDiagnoseDtos
  11114. for index, item := range config {
  11115. if index == 0 {
  11116. var fdd models.FsiDiagnoseDtos
  11117. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11118. fdd.InoutDiseType = "1"
  11119. fdd.MaindiseFlag = "1"
  11120. fdd.DiseDate = s_tm
  11121. fdd.DiasSrtNo = "1"
  11122. fdd.DiseName = item.CountryContentName
  11123. fdd.DiseCodg = item.CountryCode
  11124. fdds = append(fdds, &fdd)
  11125. } else {
  11126. var fdd models.FsiDiagnoseDtos
  11127. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11128. fdd.InoutDiseType = "1"
  11129. fdd.MaindiseFlag = "1"
  11130. fdd.DiseDate = s_tm
  11131. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11132. fdd.DiseName = item.CountryContentName
  11133. fdd.DiseCodg = item.CountryCode
  11134. fdds = append(fdds, &fdd)
  11135. }
  11136. }
  11137. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11138. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  11139. fed.AdmDeptName = de.Name
  11140. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  11141. fed.DscgDeptName = de.Name
  11142. fed.MedMdtrtType = "1"
  11143. fed.MedType = "11"
  11144. //if his.Insutype == "390" {
  11145. // fed.MedType = "1402"
  11146. //} else {
  11147. // fed.MedType = "9933"
  11148. //}
  11149. var orders []*models.FsiOrderDtos
  11150. if trig_scen == "2" {
  11151. //处方医嘱信息
  11152. for _, item := range prescriptions {
  11153. for _, subItem := range item.HisDoctorAdviceInfo {
  11154. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11155. var order models.FsiOrderDtos
  11156. order.RxID = strconv.FormatInt(item.ID, 10)
  11157. order.Rxno = strconv.FormatInt(item.ID, 10)
  11158. order.LongDrordFlag = "0"
  11159. order.HilistType = "1"
  11160. order.ChrgType = "1"
  11161. order.DrordBhvr = "-"
  11162. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11163. order.HosplistName = subItem.BaseDrugLib.DrugName
  11164. order.HilistLv = "1"
  11165. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11166. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11167. order.HosplistName = subItem.BaseDrugLib.DrugName
  11168. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11169. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11170. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11171. order.OwnpayAmt = ""
  11172. order.SelfpayAmt = ""
  11173. order.Spec = ""
  11174. order.SpecUnt = ""
  11175. order.DrordBegnDate = s_tm
  11176. order.DrordStopDate = ""
  11177. order.DrordDrCodg = doctor_info.DoctorNumber
  11178. order.DrordDeptName = department.Name
  11179. order.DrordDeptCodg = department.Number
  11180. order.DrordDrName = doctor_info.UserName
  11181. order.DrordDrProfttl = "234"
  11182. order.CurrDrordFlag = "1"
  11183. orders = append(orders, &order)
  11184. }
  11185. }
  11186. for _, subItem := range item.HisPrescriptionProject {
  11187. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11188. var order models.FsiOrderDtos
  11189. order.RxID = strconv.FormatInt(item.ID, 10)
  11190. order.Rxno = strconv.FormatInt(item.ID, 10)
  11191. order.LongDrordFlag = "0"
  11192. order.HilistType = "1"
  11193. order.ChrgType = "1"
  11194. order.DrordBhvr = "-"
  11195. order.HilistCode = subItem.HisProject.MedicalCode
  11196. order.HosplistName = subItem.HisProject.ProjectName
  11197. order.HilistLv = "1"
  11198. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11199. order.HosplistCode = subItem.HisProject.MedicalCode
  11200. order.HosplistName = subItem.HisProject.ProjectName
  11201. order.Cnt = subItem.Count
  11202. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11203. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11204. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11205. order.OwnpayAmt = ""
  11206. order.SelfpayAmt = ""
  11207. order.Spec = ""
  11208. order.SpecUnt = ""
  11209. order.DrordBegnDate = s_tm
  11210. order.DrordStopDate = ""
  11211. order.DrordDrCodg = doctor_info.DoctorNumber
  11212. order.DrordDeptName = department.Name
  11213. order.DrordDeptCodg = department.Number
  11214. order.DrordDrName = doctor_info.UserName
  11215. order.DrordDrProfttl = "234"
  11216. order.CurrDrordFlag = "1"
  11217. orders = append(orders, &order)
  11218. }
  11219. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11220. var order models.FsiOrderDtos
  11221. order.RxID = strconv.FormatInt(item.ID, 10)
  11222. order.Rxno = strconv.FormatInt(item.ID, 10)
  11223. order.LongDrordFlag = "0"
  11224. order.HilistType = "1"
  11225. order.ChrgType = "1"
  11226. order.DrordBhvr = "-"
  11227. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11228. order.HosplistName = subItem.GoodInfo.GoodName
  11229. order.HilistLv = "1"
  11230. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11231. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11232. order.HosplistName = subItem.GoodInfo.GoodName
  11233. order.Cnt = subItem.Count
  11234. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11235. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11236. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11237. order.OwnpayAmt = ""
  11238. order.SelfpayAmt = ""
  11239. order.Spec = ""
  11240. order.SpecUnt = ""
  11241. order.DrordBegnDate = s_tm
  11242. order.DrordStopDate = ""
  11243. order.DrordDrCodg = doctor_info.DoctorNumber
  11244. order.DrordDeptName = department.Name
  11245. order.DrordDeptCodg = department.Number
  11246. order.DrordDrName = doctor_info.UserName
  11247. order.DrordDrProfttl = "234"
  11248. order.CurrDrordFlag = "1"
  11249. orders = append(orders, &order)
  11250. }
  11251. }
  11252. }
  11253. //处方医嘱信息
  11254. }
  11255. fed.MatnStas = "0"
  11256. fed.MedfeeSumamt = "0"
  11257. fed.OwnpayAmt = "0"
  11258. fed.SelfpayAmt = "0"
  11259. fed.AcctPayamt = "0"
  11260. fed.MaAmt = "0"
  11261. fed.HifpPayamt = "0"
  11262. fed.SetlTotlnum = "1"
  11263. fed.Insutype = his.Insutype
  11264. fed.ReimFlag = "0"
  11265. fed.OutSetlFlag = "0"
  11266. var fopd []*models.FsiOperationDtosData
  11267. data := make(map[string]interface{})
  11268. data["fed"] = fed
  11269. data["fdd"] = fdds
  11270. data["fod"] = orders
  11271. data["pd"] = pd
  11272. data["pp"] = pp
  11273. data["fopd"] = fopd
  11274. data["trig_scen"] = trig_scen
  11275. fmt.Println(data)
  11276. fmt.Println(fed)
  11277. fmt.Println(fdds)
  11278. fmt.Println(orders)
  11279. fmt.Println(pd)
  11280. fmt.Println(pp)
  11281. fmt.Println(fopd)
  11282. client := &http.Client{}
  11283. bytesData, _ := json.Marshal(data)
  11284. var req *http.Request
  11285. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  11286. if miConfig.MdtrtareaAdmvs == "320830" {
  11287. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  11288. } else if miConfig.MdtrtareaAdmvs == "320921" {
  11289. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11290. } else {
  11291. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11292. }
  11293. resp, _ := client.Do(req)
  11294. defer resp.Body.Close()
  11295. body, ioErr := ioutil.ReadAll(resp.Body)
  11296. if ioErr != nil {
  11297. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11299. return res
  11300. }
  11301. var respJSON map[string]interface{}
  11302. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11303. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11305. return res
  11306. }
  11307. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11308. fmt.Println(respJSON)
  11309. result, _ := json.Marshal(respJSON)
  11310. fmt.Println(result)
  11311. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11312. utils.ErrorLog("解析失败:%v", err)
  11313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11314. return res
  11315. }
  11316. return res
  11317. } else {
  11318. //if miConfig.MdtrtareaAdmvs == "441202" {
  11319. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11320. saveLog(output, input, "3101", "事前")
  11321. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11322. utils.ErrorLog("解析失败:%v", err)
  11323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11324. return
  11325. }
  11326. return res
  11327. //}
  11328. }
  11329. }
  11330. 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) {
  11331. adminUser := c.GetAdminUserInfo()
  11332. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11333. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11334. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11335. //record_time := c.GetString("record_time")
  11336. //trig_scen := c.GetString("trig_scen")
  11337. timeLayout := "2006-01-02"
  11338. loc, _ := time.LoadLocation("Local")
  11339. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11340. if err != nil {
  11341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11342. return res
  11343. }
  11344. recordDateTime := theTime.Unix()
  11345. var patientPrescription models.HisPrescriptionInfo
  11346. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11347. if patientPrescription.ID == 0 {
  11348. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11349. }
  11350. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11351. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11352. //
  11353. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  11354. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11355. var pp models.PublicParams
  11356. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11357. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11358. pp.FixmedinsName = miConfig.OrgName
  11359. pp.FixmedinsCode = miConfig.Code
  11360. pp.RequestUrl = miConfig.Url
  11361. pp.Cainfo = miConfig.Cainfo
  11362. pp.SecretKey = miConfig.SecretKey
  11363. pp.AccessKey = miConfig.AccessKey
  11364. pp.OpterName = roles.UserName
  11365. var config []*models.HisXtDiagnoseConfig
  11366. for _, item := range diagnosis_ids {
  11367. id, _ := strconv.ParseInt(item, 10, 64)
  11368. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11369. config = append(config, &diagnosisConfig)
  11370. }
  11371. var pd models.PatientDtos
  11372. pd.PatnID = his.PsnNo
  11373. pd.PatnName = his.Name
  11374. pd.Gend = his.Gend
  11375. pd.Brdy = his.Brdy
  11376. pd.Poolarea = his.InsuplcAdmdvs
  11377. pd.CurrMdtrtID = his.Number
  11378. var fed models.FsiEncounterDtos
  11379. fed.MdtrtID = his.Number
  11380. fed.MedinsID = miConfig.Code
  11381. fed.MedinsName = miConfig.OrgName
  11382. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11383. fed.MedMdtrtType = "1"
  11384. fed.MedinsType = "1"
  11385. fed.MedinsLv = "11"
  11386. tm := time.Unix(his.RecordDate, 0)
  11387. s_tm := tm.Format("2006-01-02 15:04:05")
  11388. fed.AdmDate = s_tm
  11389. fed.DscgDate = s_tm
  11390. fed.DscgMainDiseCodg = config[0].CountryCode
  11391. fed.DscgMainDiseName = config[0].CountryContentName
  11392. //诊断信息
  11393. var fdds []*models.FsiDiagnoseDtos
  11394. for index, item := range config {
  11395. if index == 0 {
  11396. var fdd models.FsiDiagnoseDtos
  11397. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11398. fdd.InoutDiseType = "1"
  11399. fdd.MaindiseFlag = "1"
  11400. fdd.DiseDate = s_tm
  11401. fdd.DiasSrtNo = "1"
  11402. fdd.DiseName = item.CountryContentName
  11403. fdd.DiseCodg = item.CountryCode
  11404. fdds = append(fdds, &fdd)
  11405. } else {
  11406. var fdd models.FsiDiagnoseDtos
  11407. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11408. fdd.InoutDiseType = "1"
  11409. fdd.MaindiseFlag = "1"
  11410. fdd.DiseDate = s_tm
  11411. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11412. fdd.DiseName = item.CountryContentName
  11413. fdd.DiseCodg = item.CountryCode
  11414. fdds = append(fdds, &fdd)
  11415. }
  11416. }
  11417. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11418. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11419. fed.AdmDeptName = department.Name
  11420. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11421. fed.DscgDeptName = department.Name
  11422. fed.MedMdtrtType = "1"
  11423. fed.MedType = "11"
  11424. //if his.Insutype == "390" {
  11425. // fed.MedType = "1402"
  11426. //} else {
  11427. // fed.MedType = "9933"
  11428. //}
  11429. var orders []*models.FsiOrderDtos
  11430. if trig_scen == "2" {
  11431. //处方医嘱信息
  11432. for _, item := range prescriptions {
  11433. for _, subItem := range item.HisDoctorAdviceInfo {
  11434. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11435. var order models.FsiOrderDtos
  11436. order.RxID = strconv.FormatInt(item.ID, 10)
  11437. order.Rxno = strconv.FormatInt(item.ID, 10)
  11438. order.LongDrordFlag = "0"
  11439. order.HilistType = "1"
  11440. order.ChrgType = "1"
  11441. order.DrordBhvr = "-"
  11442. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11443. order.HosplistName = subItem.BaseDrugLib.DrugName
  11444. order.HilistLv = "1"
  11445. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11446. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11447. order.HosplistName = subItem.BaseDrugLib.DrugName
  11448. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11449. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11450. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11451. order.OwnpayAmt = ""
  11452. order.SelfpayAmt = ""
  11453. order.Spec = ""
  11454. order.SpecUnt = ""
  11455. order.DrordBegnDate = s_tm
  11456. order.DrordStopDate = ""
  11457. order.DrordDrCodg = doctor_info.DoctorNumber
  11458. order.DrordDeptName = department.Name
  11459. order.DrordDeptCodg = department.Number
  11460. order.DrordDrName = doctor_info.UserName
  11461. order.DrordDrProfttl = "234"
  11462. order.CurrDrordFlag = "1"
  11463. orders = append(orders, &order)
  11464. }
  11465. }
  11466. for _, subItem := range item.HisPrescriptionProject {
  11467. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11468. var order models.FsiOrderDtos
  11469. order.RxID = strconv.FormatInt(item.ID, 10)
  11470. order.Rxno = strconv.FormatInt(item.ID, 10)
  11471. order.LongDrordFlag = "0"
  11472. order.HilistType = "1"
  11473. order.ChrgType = "1"
  11474. order.DrordBhvr = "-"
  11475. order.HilistCode = subItem.HisProject.MedicalCode
  11476. order.HosplistName = subItem.HisProject.ProjectName
  11477. order.HilistLv = "1"
  11478. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11479. order.HosplistCode = subItem.HisProject.MedicalCode
  11480. order.HosplistName = subItem.HisProject.ProjectName
  11481. order.Cnt = subItem.Count
  11482. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11483. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11484. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11485. order.OwnpayAmt = ""
  11486. order.SelfpayAmt = ""
  11487. order.Spec = ""
  11488. order.SpecUnt = ""
  11489. order.DrordBegnDate = s_tm
  11490. order.DrordStopDate = ""
  11491. order.DrordDrCodg = doctor_info.DoctorNumber
  11492. order.DrordDeptName = department.Name
  11493. order.DrordDeptCodg = department.Number
  11494. order.DrordDrName = doctor_info.UserName
  11495. order.DrordDrProfttl = "234"
  11496. order.CurrDrordFlag = "1"
  11497. orders = append(orders, &order)
  11498. }
  11499. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11500. var order models.FsiOrderDtos
  11501. order.RxID = strconv.FormatInt(item.ID, 10)
  11502. order.Rxno = strconv.FormatInt(item.ID, 10)
  11503. order.LongDrordFlag = "0"
  11504. order.HilistType = "1"
  11505. order.ChrgType = "1"
  11506. order.DrordBhvr = "-"
  11507. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11508. order.HosplistName = subItem.GoodInfo.GoodName
  11509. order.HilistLv = "1"
  11510. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11511. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11512. order.HosplistName = subItem.GoodInfo.GoodName
  11513. order.Cnt = subItem.Count
  11514. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11515. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11516. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11517. order.OwnpayAmt = ""
  11518. order.SelfpayAmt = ""
  11519. order.Spec = ""
  11520. order.SpecUnt = ""
  11521. order.DrordBegnDate = s_tm
  11522. order.DrordStopDate = ""
  11523. order.DrordDrCodg = doctor_info.DoctorNumber
  11524. order.DrordDeptName = department.Name
  11525. order.DrordDeptCodg = department.Number
  11526. order.DrordDrName = doctor_info.UserName
  11527. order.DrordDrProfttl = "234"
  11528. order.CurrDrordFlag = "1"
  11529. orders = append(orders, &order)
  11530. }
  11531. }
  11532. }
  11533. //处方医嘱信息
  11534. }
  11535. fed.MatnStas = "0"
  11536. fed.MedfeeSumamt = "0"
  11537. fed.OwnpayAmt = "0"
  11538. fed.SelfpayAmt = "0"
  11539. fed.AcctPayamt = "0"
  11540. fed.MaAmt = "0"
  11541. fed.HifpPayamt = "0"
  11542. fed.SetlTotlnum = "1"
  11543. fed.Insutype = his.Insutype
  11544. fed.ReimFlag = "0"
  11545. fed.OutSetlFlag = "0"
  11546. var fopd []*models.FsiOperationDtosData
  11547. data := make(map[string]interface{})
  11548. data["fed"] = fed
  11549. data["fdd"] = fdds
  11550. data["fod"] = orders
  11551. data["pd"] = pd
  11552. data["pp"] = pp
  11553. data["fopd"] = fopd
  11554. data["trig_scen"] = trig_scen
  11555. fmt.Println(data)
  11556. fmt.Println(fed)
  11557. fmt.Println(fdds)
  11558. fmt.Println(orders)
  11559. fmt.Println(pd)
  11560. fmt.Println(pp)
  11561. fmt.Println(fopd)
  11562. client := &http.Client{}
  11563. bytesData, _ := json.Marshal(data)
  11564. var req *http.Request
  11565. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  11566. if miConfig.MdtrtareaAdmvs == "320830" {
  11567. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  11568. } else if miConfig.MdtrtareaAdmvs == "320921" {
  11569. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11570. } else {
  11571. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  11572. }
  11573. resp, _ := client.Do(req)
  11574. defer resp.Body.Close()
  11575. body, ioErr := ioutil.ReadAll(resp.Body)
  11576. if ioErr != nil {
  11577. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11579. return res
  11580. }
  11581. var respJSON map[string]interface{}
  11582. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11583. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11585. return res
  11586. }
  11587. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11588. fmt.Println(respJSON)
  11589. result, _ := json.Marshal(respJSON)
  11590. fmt.Println(result)
  11591. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11592. utils.ErrorLog("解析失败:%v", err)
  11593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11594. return res
  11595. }
  11596. return res
  11597. } else {
  11598. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11599. saveLog(output, input, "3101", "事前")
  11600. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11601. utils.ErrorLog("解析失败:%v", err)
  11602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11603. return
  11604. }
  11605. return res
  11606. }
  11607. return res
  11608. }
  11609. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  11610. ////patient_id, _ := c.GetInt64("patient_id")
  11611. //order_id, _ := c.GetInt64("order_id")
  11612. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  11613. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  11614. //trig_scen := c.GetString("trig_scen")
  11615. adminUser := c.GetAdminUserInfo()
  11616. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11617. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11618. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11619. record_time := c.GetString("record_time")
  11620. order, _ := service.GetHisOrderByID(order_id)
  11621. psn_info, _ := service.GetPsnByPatientId(patient_id)
  11622. timeLayout := "2006-01-02"
  11623. loc, _ := time.LoadLocation("Local")
  11624. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11625. if err != nil {
  11626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11627. return
  11628. }
  11629. recordDateTime := theTime.Unix()
  11630. var patientPrescription models.HisPrescriptionInfo
  11631. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11632. if patientPrescription.ID == 0 {
  11633. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  11634. }
  11635. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11636. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11637. //
  11638. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11639. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11640. var pp models.PublicParams
  11641. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11642. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11643. pp.FixmedinsName = miConfig.OrgName
  11644. pp.FixmedinsCode = miConfig.Code
  11645. pp.RequestUrl = miConfig.Url
  11646. pp.Cainfo = miConfig.Cainfo
  11647. pp.SecretKey = miConfig.SecretKey
  11648. pp.AccessKey = miConfig.AccessKey
  11649. pp.OpterName = roles.UserName
  11650. var config []*models.HisXtDiagnoseConfig
  11651. for _, item := range diagnosis_ids {
  11652. id, _ := strconv.ParseInt(item, 10, 64)
  11653. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11654. config = append(config, &diagnosisConfig)
  11655. }
  11656. var pd models.PatientDtos
  11657. pd.PatnID = his.PsnNo
  11658. pd.PatnName = his.Name
  11659. pd.Gend = his.Gend
  11660. pd.Brdy = psn_info.Brdy
  11661. pd.Poolarea = his.InsuplcAdmdvs
  11662. pd.CurrMdtrtID = his.Number
  11663. var fed models.FsiEncounterDtos
  11664. fed.MdtrtID = his.Number
  11665. fed.MedinsID = miConfig.Code
  11666. fed.MedinsName = miConfig.OrgName
  11667. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  11668. fed.MedMdtrtType = "1"
  11669. fed.MedinsType = "1"
  11670. fed.MedinsLv = "11"
  11671. tm := time.Unix(his.RecordDate, 0)
  11672. s_tm := tm.Format("2006-01-02 15:04:05")
  11673. fed.AdmDate = s_tm
  11674. fed.DscgDate = s_tm
  11675. fed.DscgMainDiseCodg = config[0].CountryCode
  11676. fed.DscgMainDiseName = config[0].CountryContentName
  11677. //诊断信息
  11678. var fdds []*models.FsiDiagnoseDtos
  11679. for index, item := range config {
  11680. if index == 0 {
  11681. var fdd models.FsiDiagnoseDtos
  11682. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11683. fdd.InoutDiseType = "1"
  11684. fdd.MaindiseFlag = "1"
  11685. fdd.DiseDate = s_tm
  11686. fdd.DiasSrtNo = "1"
  11687. fdd.DiseName = item.CountryContentName
  11688. fdd.DiseCodg = item.CountryCode
  11689. fdds = append(fdds, &fdd)
  11690. } else {
  11691. var fdd models.FsiDiagnoseDtos
  11692. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  11693. fdd.InoutDiseType = "1"
  11694. fdd.MaindiseFlag = "1"
  11695. fdd.DiseDate = s_tm
  11696. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  11697. fdd.DiseName = item.CountryContentName
  11698. fdd.DiseCodg = item.CountryCode
  11699. fdds = append(fdds, &fdd)
  11700. }
  11701. }
  11702. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  11703. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  11704. fed.AdmDeptName = department.Name
  11705. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  11706. fed.DscgDeptName = department.Name
  11707. fed.MedType = order.MedType
  11708. //处方医嘱信息
  11709. var orders []*models.FsiOrderDtos
  11710. //for _, item := range prescriptions {
  11711. // for _, subItem := range item.HisDoctorAdviceInfo {
  11712. // var order models.FsiOrderDtos
  11713. // order.RxID = strconv.FormatInt(item.ID, 10)
  11714. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11715. // order.LongDrordFlag = "0"
  11716. // order.HilistType = "1"
  11717. // order.ChrgType = "1"
  11718. // order.DrordBhvr = "-"
  11719. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11720. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11721. // order.HilistLv = "1"
  11722. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11723. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11724. // order.HosplistName = subItem.BaseDrugLib.DrugName
  11725. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  11726. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11727. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  11728. // order.OwnpayAmt = ""
  11729. // order.SelfpayAmt = ""
  11730. // order.Spec = ""
  11731. // order.SpecUnt = ""
  11732. // order.DrordBegnDate = s_tm
  11733. // order.DrordStopDate = ""
  11734. // order.DrordDrCodg = "1"
  11735. // order.DrordDeptName = department.Name
  11736. // order.DrordDrCodg = "1"
  11737. // order.DrordDrName = doctor_info.UserName
  11738. // order.DrordDrProfttl = ""
  11739. // order.CurrDrordFlag = "1"
  11740. // orders = append(orders, &order)
  11741. // }
  11742. // for _, subItem := range item.HisPrescriptionProject {
  11743. // if subItem.Type == 2 {
  11744. // var order models.FsiOrderDtos
  11745. // order.RxID = strconv.FormatInt(item.ID, 10)
  11746. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11747. // order.LongDrordFlag = "0"
  11748. // order.HilistType = "1"
  11749. // order.ChrgType = "1"
  11750. // order.DrordBhvr = "-"
  11751. // order.HilistCode = subItem.HisProject.MedicalCode
  11752. // order.HosplistName = subItem.HisProject.ProjectName
  11753. // order.HilistLv = "1"
  11754. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11755. // order.HosplistCode = subItem.HisProject.MedicalCode
  11756. // order.HosplistName = subItem.HisProject.ProjectName
  11757. // order.Cnt = subItem.Count
  11758. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11759. //
  11760. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11761. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11762. // order.OwnpayAmt = ""
  11763. // order.SelfpayAmt = ""
  11764. // order.Spec = ""
  11765. // order.SpecUnt = ""
  11766. // order.DrordBegnDate = s_tm
  11767. // order.DrordStopDate = ""
  11768. // order.DrordDrCodg = "1"
  11769. // order.DrordDeptName = department.Name
  11770. // order.DrordDrCodg = "1"
  11771. // order.DrordDrName = doctor_info.UserName
  11772. // order.DrordDrProfttl = ""
  11773. // order.CurrDrordFlag = "1"
  11774. // orders = append(orders, &order)
  11775. //
  11776. // }
  11777. // if subItem.Type == 3 {
  11778. //
  11779. // var order models.FsiOrderDtos
  11780. // order.RxID = strconv.FormatInt(item.ID, 10)
  11781. // order.Rxno = strconv.FormatInt(item.ID, 10)
  11782. // order.LongDrordFlag = "0"
  11783. // order.HilistType = "1"
  11784. // order.ChrgType = "1"
  11785. // order.DrordBhvr = "-"
  11786. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11787. // order.HosplistName = subItem.GoodInfo.GoodName
  11788. // order.HilistLv = "1"
  11789. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11790. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11791. // order.HosplistName = subItem.GoodInfo.GoodName
  11792. // order.Cnt = subItem.Count
  11793. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11794. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  11795. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  11796. // order.OwnpayAmt = ""
  11797. // order.SelfpayAmt = ""
  11798. // order.Spec = ""
  11799. // order.SpecUnt = ""
  11800. // order.DrordBegnDate = s_tm
  11801. // order.DrordStopDate = ""
  11802. // order.DrordDrCodg = "1"
  11803. // order.DrordDeptName = department.Name
  11804. // order.DrordDrCodg = "1"
  11805. // order.DrordDrName = doctor_info.UserName
  11806. // order.DrordDrProfttl = ""
  11807. // order.CurrDrordFlag = "1"
  11808. // orders = append(orders, &order)
  11809. //
  11810. // }
  11811. // }
  11812. //}
  11813. for _, item := range prescriptions {
  11814. for _, subItem := range item.HisDoctorAdviceInfo {
  11815. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  11816. var order models.FsiOrderDtos
  11817. order.RxID = strconv.FormatInt(item.ID, 10)
  11818. order.Rxno = strconv.FormatInt(item.ID, 10)
  11819. order.LongDrordFlag = "0"
  11820. order.HilistType = "101"
  11821. order.ChrgType = "1"
  11822. order.DrordBhvr = "-"
  11823. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11824. order.HosplistName = subItem.BaseDrugLib.DrugName
  11825. order.HilistLv = "1"
  11826. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11827. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  11828. order.HosplistName = subItem.BaseDrugLib.DrugName
  11829. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  11830. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11831. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  11832. order.OwnpayAmt = ""
  11833. order.SelfpayAmt = ""
  11834. order.Spec = ""
  11835. order.SpecUnt = ""
  11836. order.DrordBegnDate = s_tm
  11837. order.DrordStopDate = ""
  11838. order.DrordDrCodg = doctor_info.DoctorNumber
  11839. order.DrordDeptName = department.Name
  11840. order.DrordDeptCodg = department.Number
  11841. order.DrordDrName = doctor_info.UserName
  11842. order.DrordDrProfttl = "234"
  11843. order.CurrDrordFlag = "1"
  11844. orders = append(orders, &order)
  11845. }
  11846. }
  11847. for _, subItem := range item.HisPrescriptionProject {
  11848. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  11849. var order models.FsiOrderDtos
  11850. order.RxID = strconv.FormatInt(item.ID, 10)
  11851. order.Rxno = strconv.FormatInt(item.ID, 10)
  11852. order.LongDrordFlag = "0"
  11853. order.HilistType = "201"
  11854. order.ChrgType = "1"
  11855. order.DrordBhvr = "-"
  11856. order.HilistCode = subItem.HisProject.MedicalCode
  11857. order.HosplistName = subItem.HisProject.ProjectName
  11858. order.HilistLv = "1"
  11859. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11860. order.HosplistCode = subItem.HisProject.MedicalCode
  11861. order.HosplistName = subItem.HisProject.ProjectName
  11862. order.Cnt = subItem.Count
  11863. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11864. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11865. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11866. order.OwnpayAmt = ""
  11867. order.SelfpayAmt = ""
  11868. order.Spec = ""
  11869. order.SpecUnt = ""
  11870. order.DrordBegnDate = s_tm
  11871. order.DrordStopDate = ""
  11872. order.DrordDrCodg = doctor_info.DoctorNumber
  11873. order.DrordDeptName = department.Name
  11874. order.DrordDeptCodg = department.Number
  11875. order.DrordDrName = doctor_info.UserName
  11876. order.DrordDrProfttl = "234"
  11877. order.CurrDrordFlag = "1"
  11878. orders = append(orders, &order)
  11879. }
  11880. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  11881. var order models.FsiOrderDtos
  11882. order.RxID = strconv.FormatInt(item.ID, 10)
  11883. order.Rxno = strconv.FormatInt(item.ID, 10)
  11884. order.LongDrordFlag = "0"
  11885. order.HilistType = "301"
  11886. order.ChrgType = "1"
  11887. order.DrordBhvr = "0"
  11888. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11889. order.HosplistName = subItem.GoodInfo.GoodName
  11890. order.HilistLv = "1"
  11891. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  11892. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  11893. order.HosplistName = subItem.GoodInfo.GoodName
  11894. order.Cnt = subItem.Count
  11895. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11896. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  11897. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  11898. order.OwnpayAmt = ""
  11899. order.SelfpayAmt = ""
  11900. order.Spec = ""
  11901. order.SpecUnt = ""
  11902. order.DrordBegnDate = s_tm
  11903. order.DrordStopDate = ""
  11904. order.DrordDrCodg = doctor_info.DoctorNumber
  11905. order.DrordDeptName = department.Name
  11906. order.DrordDeptCodg = department.Number
  11907. order.DrordDrName = doctor_info.UserName
  11908. order.DrordDrProfttl = "234"
  11909. order.CurrDrordFlag = "1"
  11910. orders = append(orders, &order)
  11911. }
  11912. }
  11913. }
  11914. //处方医嘱信息
  11915. fed.MatnStas = "0"
  11916. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  11917. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  11918. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  11919. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  11920. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  11921. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  11922. fed.SetlTotlnum = "1"
  11923. fed.Insutype = his.Insutype
  11924. fed.ReimFlag = "0"
  11925. fed.OutSetlFlag = "0"
  11926. var fopd []*models.FsiOperationDtosData
  11927. data := make(map[string]interface{})
  11928. data["fed"] = fed
  11929. data["fdd"] = fdds
  11930. data["fod"] = orders
  11931. data["pd"] = pd
  11932. data["pp"] = pp
  11933. data["fopd"] = fopd
  11934. data["trig_scen"] = trig_scen
  11935. client := &http.Client{}
  11936. bytesData, _ := json.Marshal(data)
  11937. var req *http.Request
  11938. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  11939. if miConfig.MdtrtareaAdmvs == "320830" {
  11940. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3102", bytes.NewReader(bytesData))
  11941. } else if miConfig.MdtrtareaAdmvs == "320921" {
  11942. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11943. } else {
  11944. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  11945. }
  11946. resp, _ := client.Do(req)
  11947. defer resp.Body.Close()
  11948. body, ioErr := ioutil.ReadAll(resp.Body)
  11949. if ioErr != nil {
  11950. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11952. return res
  11953. }
  11954. var respJSON map[string]interface{}
  11955. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11956. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11958. return res
  11959. }
  11960. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11961. result, _ := json.Marshal(respJSON)
  11962. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11963. utils.ErrorLog("解析失败:%v", err)
  11964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11965. return res
  11966. }
  11967. return res
  11968. } else {
  11969. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  11970. saveLog(output, input, "3102", "事中")
  11971. if err := json.Unmarshal([]byte(output), &res); err != nil {
  11972. utils.ErrorLog("解析失败:%v", err)
  11973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11974. return
  11975. }
  11976. return res
  11977. }
  11978. return res
  11979. }
  11980. 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) {
  11981. var res Resultgd3101
  11982. adminUser := c.GetAdminUserInfo()
  11983. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11984. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  11985. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11986. //record_time := c.GetString("record_time")
  11987. //trig_scen := c.GetString("trig_scen")
  11988. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  11989. //psn_info, _ := service.GetPatientId(patient_id)
  11990. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  11991. timeLayout := "2006-01-02"
  11992. loc, _ := time.LoadLocation("Local")
  11993. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11994. if err != nil {
  11995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11996. return res
  11997. }
  11998. recordDateTime := theTime.Unix()
  11999. var patientPrescription models.HisPrescriptionInfo
  12000. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12001. //if patientPrescription.ID == 0 {
  12002. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12003. //}
  12004. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12005. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12006. //
  12007. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  12008. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12009. var str string
  12010. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  12011. str = timestampToBirthdayString(patient.Birthday)
  12012. } else {
  12013. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  12014. }
  12015. var pp models.PublicParams
  12016. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12017. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12018. pp.FixmedinsName = miConfig.OrgName
  12019. pp.FixmedinsCode = miConfig.Code
  12020. pp.RequestUrl = miConfig.Url
  12021. pp.Cainfo = miConfig.Cainfo
  12022. pp.SecretKey = miConfig.SecretKey
  12023. pp.AccessKey = miConfig.AccessKey
  12024. pp.OpterName = roles.UserName
  12025. var config []*models.HisXtDiagnoseConfig
  12026. for _, item := range diagnosis_ids {
  12027. id, _ := strconv.ParseInt(item, 10, 64)
  12028. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12029. config = append(config, &diagnosisConfig)
  12030. }
  12031. var pd models.PatientDtos
  12032. pd.PatnID = his.PsnNo
  12033. pd.PatnName = his.Name
  12034. pd.Gend = his.Gend
  12035. pd.Brdy = str
  12036. pd.Poolarea = miConfig.MdtrtareaAdmvs
  12037. pd.CurrMdtrtID = his.Number
  12038. var fed models.FsiEncounterDtos
  12039. fed.MdtrtID = his.Number
  12040. fed.MedinsID = miConfig.Code
  12041. fed.MedinsName = miConfig.OrgName
  12042. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12043. fed.MedMdtrtType = "1"
  12044. fed.MedinsType = "1"
  12045. fed.MedinsLv = "11"
  12046. tm := time.Unix(his.RecordDate, 0)
  12047. s_tm := tm.Format("2006-01-02 15:04:05")
  12048. fed.AdmDate = s_tm
  12049. fed.DscgDate = s_tm
  12050. fed.DscgMainDiseCodg = config[0].CountryCode
  12051. fed.DscgMainDiseName = config[0].CountryContentName
  12052. //诊断信息
  12053. var fdds []*models.FsiDiagnoseDtos
  12054. for index, item := range config {
  12055. if index == 0 {
  12056. var fdd models.FsiDiagnoseDtos
  12057. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12058. fdd.InoutDiseType = "1"
  12059. fdd.MaindiseFlag = "1"
  12060. fdd.DiseDate = s_tm
  12061. fdd.DiasSrtNo = "1"
  12062. fdd.DiseName = item.CountryContentName
  12063. fdd.DiseCodg = item.CountryCode
  12064. fdds = append(fdds, &fdd)
  12065. } else {
  12066. var fdd models.FsiDiagnoseDtos
  12067. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12068. fdd.InoutDiseType = "1"
  12069. fdd.MaindiseFlag = "1"
  12070. fdd.DiseDate = s_tm
  12071. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12072. fdd.DiseName = item.CountryContentName
  12073. fdd.DiseCodg = item.CountryCode
  12074. fdds = append(fdds, &fdd)
  12075. }
  12076. }
  12077. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12078. fed.AdmDeptCodg = strconv.FormatInt(de.ID, 10)
  12079. fed.AdmDeptName = de.Name
  12080. fed.DscgDeptCodg = strconv.FormatInt(de.ID, 10)
  12081. fed.DscgDeptName = de.Name
  12082. fed.MedMdtrtType = "1"
  12083. fed.MedType = "11"
  12084. //if his.Insutype == "390" {
  12085. // fed.MedType = "1402"
  12086. //} else {
  12087. // fed.MedType = "9933"
  12088. //}
  12089. var orders []*models.FsiOrderDtos
  12090. if trig_scen == "2" {
  12091. //处方医嘱信息
  12092. for _, item := range prescriptions {
  12093. for _, subItem := range item.HisDoctorAdviceInfo {
  12094. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12095. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12096. var order models.FsiOrderDtos
  12097. order.RxID = strconv.FormatInt(item.ID, 10)
  12098. order.Rxno = strconv.FormatInt(item.ID, 10)
  12099. order.LongDrordFlag = "0"
  12100. order.HilistType = "101"
  12101. order.ChrgType = "1"
  12102. order.DrordBhvr = "0"
  12103. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12104. order.HosplistName = subItem.BaseDrugLib.DrugName
  12105. order.HilistLv = "1"
  12106. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12107. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12108. order.HosplistName = subItem.BaseDrugLib.DrugName
  12109. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12110. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12111. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12112. order.OwnpayAmt = ""
  12113. order.SelfpayAmt = ""
  12114. order.Spec = spec
  12115. order.SpecUnt = subItem.PrescribingNumberUnit
  12116. order.DrordBegnDate = s_tm
  12117. order.DrordStopDate = ""
  12118. order.DrordDrCodg = doctor_info.DoctorNumber
  12119. order.DrordDeptName = department.Name
  12120. order.DrordDeptCodg = department.Number
  12121. order.DrordDrName = doctor_info.UserName
  12122. order.DrordDrProfttl = "234"
  12123. order.CurrDrordFlag = "1"
  12124. orders = append(orders, &order)
  12125. }
  12126. }
  12127. for _, subItem := range item.HisPrescriptionProject {
  12128. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12129. var order models.FsiOrderDtos
  12130. order.RxID = strconv.FormatInt(item.ID, 10)
  12131. order.Rxno = strconv.FormatInt(item.ID, 10)
  12132. order.LongDrordFlag = "0"
  12133. order.HilistType = "201"
  12134. order.ChrgType = "1"
  12135. order.DrordBhvr = "0"
  12136. order.HilistCode = subItem.HisProject.MedicalCode
  12137. order.HosplistName = subItem.HisProject.ProjectName
  12138. order.HilistLv = "1"
  12139. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12140. order.HosplistCode = subItem.HisProject.MedicalCode
  12141. order.HosplistName = subItem.HisProject.ProjectName
  12142. order.Cnt = subItem.Count
  12143. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12144. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12145. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12146. order.OwnpayAmt = ""
  12147. order.SelfpayAmt = ""
  12148. order.Spec = subItem.Unit
  12149. order.SpecUnt = subItem.Unit
  12150. order.DrordBegnDate = s_tm
  12151. order.DrordStopDate = ""
  12152. order.DrordDrCodg = doctor_info.DoctorNumber
  12153. order.DrordDeptName = department.Name
  12154. order.DrordDeptCodg = department.Number
  12155. order.DrordDrName = doctor_info.UserName
  12156. order.DrordDrProfttl = "234"
  12157. order.CurrDrordFlag = "1"
  12158. orders = append(orders, &order)
  12159. }
  12160. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12161. var order models.FsiOrderDtos
  12162. order.RxID = strconv.FormatInt(item.ID, 10)
  12163. order.Rxno = strconv.FormatInt(item.ID, 10)
  12164. order.LongDrordFlag = "0"
  12165. order.HilistType = "301"
  12166. order.ChrgType = "1"
  12167. order.DrordBhvr = "0"
  12168. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12169. order.HosplistName = subItem.GoodInfo.GoodName
  12170. order.HilistLv = "1"
  12171. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12172. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12173. order.HosplistName = subItem.GoodInfo.GoodName
  12174. order.Cnt = subItem.Count
  12175. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12176. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12177. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12178. order.OwnpayAmt = ""
  12179. order.SelfpayAmt = ""
  12180. order.Spec = subItem.GoodInfo.SpecificationName
  12181. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12182. order.DrordBegnDate = s_tm
  12183. order.DrordStopDate = ""
  12184. order.DrordDrCodg = doctor_info.DoctorNumber
  12185. order.DrordDeptName = department.Name
  12186. order.DrordDeptCodg = department.Number
  12187. order.DrordDrName = doctor_info.UserName
  12188. order.DrordDrProfttl = "234"
  12189. order.CurrDrordFlag = "1"
  12190. orders = append(orders, &order)
  12191. }
  12192. }
  12193. }
  12194. //处方医嘱信息
  12195. }
  12196. fed.MatnStas = "0"
  12197. fed.MedfeeSumamt = "0"
  12198. fed.OwnpayAmt = "0"
  12199. fed.SelfpayAmt = "0"
  12200. fed.AcctPayamt = "0"
  12201. fed.MaAmt = "0"
  12202. fed.HifpPayamt = "0"
  12203. fed.SetlTotlnum = "1"
  12204. fed.Insutype = his.Insutype
  12205. fed.ReimFlag = "0"
  12206. fed.OutSetlFlag = "0"
  12207. var fopd []*models.FsiOperationDtosData
  12208. data := make(map[string]interface{})
  12209. data["fed"] = fed
  12210. data["fdd"] = fdds
  12211. data["fod"] = orders
  12212. data["pd"] = pd
  12213. data["pp"] = pp
  12214. data["fopd"] = fopd
  12215. data["trig_scen"] = trig_scen
  12216. fmt.Println(data)
  12217. fmt.Println(fed)
  12218. fmt.Println(fdds)
  12219. fmt.Println(orders)
  12220. fmt.Println(pd)
  12221. fmt.Println(pp)
  12222. fmt.Println(fopd)
  12223. client := &http.Client{}
  12224. bytesData, _ := json.Marshal(data)
  12225. var req *http.Request
  12226. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12227. if miConfig.MdtrtareaAdmvs == "320830" {
  12228. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  12229. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12230. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12231. } else {
  12232. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12233. }
  12234. resp, _ := client.Do(req)
  12235. defer resp.Body.Close()
  12236. body, ioErr := ioutil.ReadAll(resp.Body)
  12237. if ioErr != nil {
  12238. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12240. return res
  12241. }
  12242. var respJSON map[string]interface{}
  12243. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12244. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12246. return res
  12247. }
  12248. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12249. fmt.Println(respJSON)
  12250. result, _ := json.Marshal(respJSON)
  12251. fmt.Println(result)
  12252. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12253. utils.ErrorLog("解析失败:%v", err)
  12254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12255. return res
  12256. }
  12257. return res
  12258. } else {
  12259. //if miConfig.MdtrtareaAdmvs == "441202" {
  12260. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12261. saveLog(output, input, "3101", "事前")
  12262. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12263. utils.ErrorLog("解析失败:%v", err)
  12264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12265. return
  12266. }
  12267. return res
  12268. //}
  12269. }
  12270. }
  12271. 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) {
  12272. adminUser := c.GetAdminUserInfo()
  12273. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12274. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12275. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12276. //record_time := c.GetString("record_time")
  12277. //trig_scen := c.GetString("trig_scen")
  12278. //psn_info, _ := service.GetPsnByPatientId(patient_id)
  12279. timeLayout := "2006-01-02"
  12280. loc, _ := time.LoadLocation("Local")
  12281. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12282. if err != nil {
  12283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12284. return res
  12285. }
  12286. recordDateTime := theTime.Unix()
  12287. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  12288. var patientPrescription models.HisPrescriptionInfo
  12289. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12290. if patientPrescription.ID == 0 {
  12291. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12292. }
  12293. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12294. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12295. //
  12296. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  12297. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12298. var pp models.PublicParams
  12299. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12300. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12301. pp.FixmedinsName = miConfig.OrgName
  12302. pp.FixmedinsCode = miConfig.Code
  12303. pp.RequestUrl = miConfig.Url
  12304. pp.Cainfo = miConfig.Cainfo
  12305. pp.SecretKey = miConfig.SecretKey
  12306. pp.AccessKey = miConfig.AccessKey
  12307. pp.OpterName = roles.UserName
  12308. var config []*models.HisXtDiagnoseConfig
  12309. for _, item := range diagnosis_ids {
  12310. id, _ := strconv.ParseInt(item, 10, 64)
  12311. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12312. config = append(config, &diagnosisConfig)
  12313. }
  12314. //str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  12315. var str string
  12316. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  12317. str = timestampToBirthdayString(patient.Birthday)
  12318. } else {
  12319. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  12320. }
  12321. var pd models.PatientDtos
  12322. pd.PatnID = his.PsnNo
  12323. pd.PatnName = his.Name
  12324. pd.Gend = his.Gend
  12325. pd.Brdy = str
  12326. pd.Poolarea = his.InsuplcAdmdvs
  12327. pd.CurrMdtrtID = his.Number
  12328. var fed models.FsiEncounterDtos
  12329. fed.MdtrtID = his.Number
  12330. fed.MedinsID = miConfig.Code
  12331. fed.MedinsName = miConfig.OrgName
  12332. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12333. fed.MedMdtrtType = "1"
  12334. fed.MedinsType = "1"
  12335. fed.MedinsLv = "11"
  12336. tm := time.Unix(his.RecordDate, 0)
  12337. s_tm := tm.Format("2006-01-02 15:04:05")
  12338. fed.AdmDate = s_tm
  12339. fed.DscgDate = s_tm
  12340. fed.DscgMainDiseCodg = config[0].CountryCode
  12341. fed.DscgMainDiseName = config[0].CountryContentName
  12342. //诊断信息
  12343. var fdds []*models.FsiDiagnoseDtos
  12344. for index, item := range config {
  12345. if index == 0 {
  12346. var fdd models.FsiDiagnoseDtos
  12347. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12348. fdd.InoutDiseType = "1"
  12349. fdd.MaindiseFlag = "1"
  12350. fdd.DiseDate = s_tm
  12351. fdd.DiasSrtNo = "1"
  12352. fdd.DiseName = item.CountryContentName
  12353. fdd.DiseCodg = item.CountryCode
  12354. fdds = append(fdds, &fdd)
  12355. } else {
  12356. var fdd models.FsiDiagnoseDtos
  12357. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12358. fdd.InoutDiseType = "1"
  12359. fdd.MaindiseFlag = "1"
  12360. fdd.DiseDate = s_tm
  12361. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12362. fdd.DiseName = item.CountryContentName
  12363. fdd.DiseCodg = item.CountryCode
  12364. fdds = append(fdds, &fdd)
  12365. }
  12366. }
  12367. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12368. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  12369. fed.AdmDeptName = department.Name
  12370. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  12371. fed.DscgDeptName = department.Name
  12372. fed.MedMdtrtType = "1"
  12373. fed.MedType = "11"
  12374. //if his.Insutype == "390" {
  12375. // fed.MedType = "1402"
  12376. //} else {
  12377. // fed.MedType = "9933"
  12378. //}
  12379. var orders []*models.FsiOrderDtos
  12380. if trig_scen == "2" {
  12381. //处方医嘱信息
  12382. for _, item := range prescriptions {
  12383. for _, subItem := range item.HisDoctorAdviceInfo {
  12384. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12385. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12386. var order models.FsiOrderDtos
  12387. order.RxID = strconv.FormatInt(item.ID, 10)
  12388. order.Rxno = strconv.FormatInt(item.ID, 10)
  12389. order.LongDrordFlag = "0"
  12390. order.HilistType = "101"
  12391. order.ChrgType = "1"
  12392. order.DrordBhvr = "0"
  12393. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12394. order.HosplistName = subItem.BaseDrugLib.DrugName
  12395. order.HilistLv = "1"
  12396. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12397. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12398. order.HosplistName = subItem.BaseDrugLib.DrugName
  12399. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12400. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12401. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12402. order.OwnpayAmt = ""
  12403. order.SelfpayAmt = ""
  12404. order.Spec = spec
  12405. order.SpecUnt = subItem.PrescribingNumberUnit
  12406. order.DrordBegnDate = s_tm
  12407. order.DrordStopDate = ""
  12408. order.DrordDrCodg = doctor_info.DoctorNumber
  12409. order.DrordDeptName = department.Name
  12410. order.DrordDeptCodg = department.Number
  12411. order.DrordDrName = doctor_info.UserName
  12412. order.DrordDrProfttl = "234"
  12413. order.CurrDrordFlag = "1"
  12414. orders = append(orders, &order)
  12415. }
  12416. }
  12417. for _, subItem := range item.HisPrescriptionProject {
  12418. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12419. var order models.FsiOrderDtos
  12420. order.RxID = strconv.FormatInt(item.ID, 10)
  12421. order.Rxno = strconv.FormatInt(item.ID, 10)
  12422. order.LongDrordFlag = "0"
  12423. order.HilistType = "201"
  12424. order.ChrgType = "1"
  12425. order.DrordBhvr = "0"
  12426. order.HilistCode = subItem.HisProject.MedicalCode
  12427. order.HosplistName = subItem.HisProject.ProjectName
  12428. order.HilistLv = "1"
  12429. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12430. order.HosplistCode = subItem.HisProject.MedicalCode
  12431. order.HosplistName = subItem.HisProject.ProjectName
  12432. order.Cnt = subItem.Count
  12433. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12434. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12435. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12436. order.OwnpayAmt = ""
  12437. order.SelfpayAmt = ""
  12438. order.Spec = subItem.Unit
  12439. order.SpecUnt = subItem.Unit
  12440. order.DrordBegnDate = s_tm
  12441. order.DrordStopDate = ""
  12442. order.DrordDrCodg = doctor_info.DoctorNumber
  12443. order.DrordDeptName = department.Name
  12444. order.DrordDeptCodg = department.Number
  12445. order.DrordDrName = doctor_info.UserName
  12446. order.DrordDrProfttl = "234"
  12447. order.CurrDrordFlag = "1"
  12448. orders = append(orders, &order)
  12449. }
  12450. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12451. var order models.FsiOrderDtos
  12452. order.RxID = strconv.FormatInt(item.ID, 10)
  12453. order.Rxno = strconv.FormatInt(item.ID, 10)
  12454. order.LongDrordFlag = "0"
  12455. order.HilistType = "301"
  12456. order.ChrgType = "1"
  12457. order.DrordBhvr = "0"
  12458. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12459. order.HosplistName = subItem.GoodInfo.GoodName
  12460. order.HilistLv = "1"
  12461. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12462. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12463. order.HosplistName = subItem.GoodInfo.GoodName
  12464. order.Cnt = subItem.Count
  12465. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12466. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12467. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12468. order.OwnpayAmt = ""
  12469. order.SelfpayAmt = ""
  12470. order.Spec = subItem.GoodInfo.SpecificationName
  12471. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12472. order.DrordBegnDate = s_tm
  12473. order.DrordStopDate = ""
  12474. order.DrordDrCodg = doctor_info.DoctorNumber
  12475. order.DrordDeptName = department.Name
  12476. order.DrordDeptCodg = department.Number
  12477. order.DrordDrName = doctor_info.UserName
  12478. order.DrordDrProfttl = "234"
  12479. order.CurrDrordFlag = "1"
  12480. orders = append(orders, &order)
  12481. }
  12482. }
  12483. }
  12484. //处方医嘱信息
  12485. }
  12486. fed.MatnStas = "0"
  12487. fed.MedfeeSumamt = "0"
  12488. fed.OwnpayAmt = "0"
  12489. fed.SelfpayAmt = "0"
  12490. fed.AcctPayamt = "0"
  12491. fed.MaAmt = "0"
  12492. fed.HifpPayamt = "0"
  12493. fed.SetlTotlnum = "1"
  12494. fed.Insutype = his.Insutype
  12495. fed.ReimFlag = "0"
  12496. fed.OutSetlFlag = "0"
  12497. var fopd []*models.FsiOperationDtosData
  12498. data := make(map[string]interface{})
  12499. data["fed"] = fed
  12500. data["fdd"] = fdds
  12501. data["fod"] = orders
  12502. data["pd"] = pd
  12503. data["pp"] = pp
  12504. data["fopd"] = fopd
  12505. data["trig_scen"] = trig_scen
  12506. fmt.Println(data)
  12507. fmt.Println(fed)
  12508. fmt.Println(fdds)
  12509. fmt.Println(orders)
  12510. fmt.Println(pd)
  12511. fmt.Println(pp)
  12512. fmt.Println(fopd)
  12513. client := &http.Client{}
  12514. bytesData, _ := json.Marshal(data)
  12515. var req *http.Request
  12516. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12517. if miConfig.MdtrtareaAdmvs == "320830" {
  12518. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3101", bytes.NewReader(bytesData))
  12519. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12520. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12521. } else {
  12522. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  12523. }
  12524. resp, _ := client.Do(req)
  12525. defer resp.Body.Close()
  12526. body, ioErr := ioutil.ReadAll(resp.Body)
  12527. if ioErr != nil {
  12528. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12530. return res
  12531. }
  12532. var respJSON map[string]interface{}
  12533. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12534. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12536. return res
  12537. }
  12538. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12539. fmt.Println(respJSON)
  12540. result, _ := json.Marshal(respJSON)
  12541. fmt.Println(result)
  12542. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12543. utils.ErrorLog("解析失败:%v", err)
  12544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12545. return res
  12546. }
  12547. return res
  12548. } else {
  12549. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12550. saveLog(output, input, "3101", "事前")
  12551. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12552. utils.ErrorLog("解析失败:%v", err)
  12553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12554. return
  12555. }
  12556. return res
  12557. }
  12558. return res
  12559. }
  12560. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  12561. adminUser := c.GetAdminUserInfo()
  12562. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12563. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  12564. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12565. record_time := c.GetString("record_time")
  12566. order, _ := service.GetHisOrderByID(order_id)
  12567. timeLayout := "2006-01-02"
  12568. loc, _ := time.LoadLocation("Local")
  12569. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12570. if err != nil {
  12571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12572. return
  12573. }
  12574. recordDateTime := theTime.Unix()
  12575. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  12576. var patientPrescription models.HisPrescriptionInfo
  12577. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12578. if patientPrescription.ID == 0 {
  12579. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12580. }
  12581. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  12582. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  12583. //
  12584. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  12585. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12586. var pp models.PublicParams
  12587. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12588. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12589. pp.FixmedinsName = miConfig.OrgName
  12590. pp.FixmedinsCode = miConfig.Code
  12591. pp.RequestUrl = miConfig.Url
  12592. pp.Cainfo = miConfig.Cainfo
  12593. pp.SecretKey = miConfig.SecretKey
  12594. pp.AccessKey = miConfig.AccessKey
  12595. pp.OpterName = roles.UserName
  12596. var config []*models.HisXtDiagnoseConfig
  12597. for _, item := range diagnosis_ids {
  12598. id, _ := strconv.ParseInt(item, 10, 64)
  12599. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12600. config = append(config, &diagnosisConfig)
  12601. }
  12602. //str, _ := getBirthDateFromIDCard(patient.IdCardNo)
  12603. var str string
  12604. if strings.Contains(patient.IdCardNo, "H") || strings.Contains(patient.IdCardNo, "K") {
  12605. str = timestampToBirthdayString(patient.Birthday)
  12606. } else {
  12607. str, _ = getBirthDateFromIDCard(patient.IdCardNo)
  12608. }
  12609. var pd models.PatientDtos
  12610. pd.PatnID = his.PsnNo
  12611. pd.PatnName = his.Name
  12612. pd.Gend = his.Gend
  12613. pd.Brdy = str
  12614. pd.Poolarea = his.InsuplcAdmdvs
  12615. pd.CurrMdtrtID = his.Number
  12616. var fed models.FsiEncounterDtos
  12617. fed.MdtrtID = his.Number
  12618. fed.MedinsID = miConfig.Code
  12619. fed.MedinsName = miConfig.OrgName
  12620. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  12621. fed.MedMdtrtType = "1"
  12622. fed.MedinsType = "1"
  12623. fed.MedinsLv = "11"
  12624. tm := time.Unix(his.RecordDate, 0)
  12625. s_tm := tm.Format("2006-01-02 15:04:05")
  12626. fed.AdmDate = s_tm
  12627. fed.DscgDate = s_tm
  12628. fed.DscgMainDiseCodg = config[0].CountryCode
  12629. fed.DscgMainDiseName = config[0].CountryContentName
  12630. //诊断信息
  12631. var fdds []*models.FsiDiagnoseDtos
  12632. for index, item := range config {
  12633. if index == 0 {
  12634. var fdd models.FsiDiagnoseDtos
  12635. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12636. fdd.InoutDiseType = "1"
  12637. fdd.MaindiseFlag = "1"
  12638. fdd.DiseDate = s_tm
  12639. fdd.DiasSrtNo = "1"
  12640. fdd.DiseName = item.CountryContentName
  12641. fdd.DiseCodg = item.CountryCode
  12642. fdds = append(fdds, &fdd)
  12643. } else {
  12644. var fdd models.FsiDiagnoseDtos
  12645. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  12646. fdd.InoutDiseType = "1"
  12647. fdd.MaindiseFlag = "1"
  12648. fdd.DiseDate = s_tm
  12649. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  12650. fdd.DiseName = item.CountryContentName
  12651. fdd.DiseCodg = item.CountryCode
  12652. fdds = append(fdds, &fdd)
  12653. }
  12654. }
  12655. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  12656. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  12657. fed.AdmDeptName = department.Name
  12658. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  12659. fed.DscgDeptName = department.Name
  12660. fed.MedType = order.MedType
  12661. //处方医嘱信息
  12662. var orders []*models.FsiOrderDtos
  12663. //for _, item := range prescriptions {
  12664. // for _, subItem := range item.HisDoctorAdviceInfo {
  12665. // var order models.FsiOrderDtos
  12666. // order.RxID = strconv.FormatInt(item.ID, 10)
  12667. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12668. // order.LongDrordFlag = "0"
  12669. // order.HilistType = "1"
  12670. // order.ChrgType = "1"
  12671. // order.DrordBhvr = "-"
  12672. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12673. // order.HosplistName = subItem.BaseDrugLib.DrugName
  12674. // order.HilistLv = "1"
  12675. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12676. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12677. // order.HosplistName = subItem.BaseDrugLib.DrugName
  12678. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  12679. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12680. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  12681. // order.OwnpayAmt = ""
  12682. // order.SelfpayAmt = ""
  12683. // order.Spec = ""
  12684. // order.SpecUnt = ""
  12685. // order.DrordBegnDate = s_tm
  12686. // order.DrordStopDate = ""
  12687. // order.DrordDrCodg = "1"
  12688. // order.DrordDeptName = department.Name
  12689. // order.DrordDrCodg = "1"
  12690. // order.DrordDrName = doctor_info.UserName
  12691. // order.DrordDrProfttl = ""
  12692. // order.CurrDrordFlag = "1"
  12693. // orders = append(orders, &order)
  12694. // }
  12695. // for _, subItem := range item.HisPrescriptionProject {
  12696. // if subItem.Type == 2 {
  12697. // var order models.FsiOrderDtos
  12698. // order.RxID = strconv.FormatInt(item.ID, 10)
  12699. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12700. // order.LongDrordFlag = "0"
  12701. // order.HilistType = "1"
  12702. // order.ChrgType = "1"
  12703. // order.DrordBhvr = "-"
  12704. // order.HilistCode = subItem.HisProject.MedicalCode
  12705. // order.HosplistName = subItem.HisProject.ProjectName
  12706. // order.HilistLv = "1"
  12707. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12708. // order.HosplistCode = subItem.HisProject.MedicalCode
  12709. // order.HosplistName = subItem.HisProject.ProjectName
  12710. // order.Cnt = subItem.Count
  12711. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12712. //
  12713. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12714. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  12715. // order.OwnpayAmt = ""
  12716. // order.SelfpayAmt = ""
  12717. // order.Spec = ""
  12718. // order.SpecUnt = ""
  12719. // order.DrordBegnDate = s_tm
  12720. // order.DrordStopDate = ""
  12721. // order.DrordDrCodg = "1"
  12722. // order.DrordDeptName = department.Name
  12723. // order.DrordDrCodg = "1"
  12724. // order.DrordDrName = doctor_info.UserName
  12725. // order.DrordDrProfttl = ""
  12726. // order.CurrDrordFlag = "1"
  12727. // orders = append(orders, &order)
  12728. //
  12729. // }
  12730. // if subItem.Type == 3 {
  12731. //
  12732. // var order models.FsiOrderDtos
  12733. // order.RxID = strconv.FormatInt(item.ID, 10)
  12734. // order.Rxno = strconv.FormatInt(item.ID, 10)
  12735. // order.LongDrordFlag = "0"
  12736. // order.HilistType = "1"
  12737. // order.ChrgType = "1"
  12738. // order.DrordBhvr = "-"
  12739. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12740. // order.HosplistName = subItem.GoodInfo.GoodName
  12741. // order.HilistLv = "1"
  12742. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12743. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12744. // order.HosplistName = subItem.GoodInfo.GoodName
  12745. // order.Cnt = subItem.Count
  12746. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12747. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  12748. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  12749. // order.OwnpayAmt = ""
  12750. // order.SelfpayAmt = ""
  12751. // order.Spec = ""
  12752. // order.SpecUnt = ""
  12753. // order.DrordBegnDate = s_tm
  12754. // order.DrordStopDate = ""
  12755. // order.DrordDrCodg = "1"
  12756. // order.DrordDeptName = department.Name
  12757. // order.DrordDrCodg = "1"
  12758. // order.DrordDrName = doctor_info.UserName
  12759. // order.DrordDrProfttl = ""
  12760. // order.CurrDrordFlag = "1"
  12761. // orders = append(orders, &order)
  12762. //
  12763. // }
  12764. // }
  12765. //}
  12766. for _, item := range prescriptions {
  12767. for _, subItem := range item.HisDoctorAdviceInfo {
  12768. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  12769. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  12770. var order models.FsiOrderDtos
  12771. order.RxID = strconv.FormatInt(item.ID, 10)
  12772. order.Rxno = strconv.FormatInt(item.ID, 10)
  12773. order.LongDrordFlag = "0"
  12774. order.HilistType = "101"
  12775. order.ChrgType = "01"
  12776. order.DrordBhvr = "0"
  12777. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12778. order.HosplistName = subItem.BaseDrugLib.DrugName
  12779. order.HilistLv = "1"
  12780. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12781. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  12782. order.HosplistName = subItem.BaseDrugLib.DrugName
  12783. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  12784. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12785. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  12786. order.OwnpayAmt = ""
  12787. order.SelfpayAmt = ""
  12788. order.Spec = spec
  12789. order.SpecUnt = subItem.PrescribingNumberUnit
  12790. order.DrordBegnDate = s_tm
  12791. order.DrordStopDate = ""
  12792. order.DrordDrCodg = doctor_info.DoctorNumber
  12793. order.DrordDeptName = department.Name
  12794. order.DrordDeptCodg = department.Number
  12795. order.DrordDrName = doctor_info.UserName
  12796. order.DrordDrProfttl = "234"
  12797. order.CurrDrordFlag = "1"
  12798. orders = append(orders, &order)
  12799. }
  12800. }
  12801. for _, subItem := range item.HisPrescriptionProject {
  12802. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  12803. var order models.FsiOrderDtos
  12804. order.RxID = strconv.FormatInt(item.ID, 10)
  12805. order.Rxno = strconv.FormatInt(item.ID, 10)
  12806. order.LongDrordFlag = "0"
  12807. order.HilistType = "201"
  12808. order.ChrgType = "05"
  12809. order.DrordBhvr = "0"
  12810. order.HilistCode = subItem.HisProject.MedicalCode
  12811. order.HosplistName = subItem.HisProject.ProjectName
  12812. order.HilistLv = "1"
  12813. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12814. order.HosplistCode = subItem.HisProject.MedicalCode
  12815. order.HosplistName = subItem.HisProject.ProjectName
  12816. order.Cnt = subItem.Count
  12817. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12818. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12819. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12820. order.OwnpayAmt = ""
  12821. order.SelfpayAmt = ""
  12822. order.Spec = subItem.Unit
  12823. order.SpecUnt = subItem.Unit
  12824. order.DrordBegnDate = s_tm
  12825. order.DrordStopDate = ""
  12826. order.DrordDrCodg = doctor_info.DoctorNumber
  12827. order.DrordDeptName = department.Name
  12828. order.DrordDeptCodg = department.Number
  12829. order.DrordDrName = doctor_info.UserName
  12830. order.DrordDrProfttl = "234"
  12831. order.CurrDrordFlag = "1"
  12832. orders = append(orders, &order)
  12833. }
  12834. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  12835. var order models.FsiOrderDtos
  12836. order.RxID = strconv.FormatInt(item.ID, 10)
  12837. order.Rxno = strconv.FormatInt(item.ID, 10)
  12838. order.LongDrordFlag = "0"
  12839. order.HilistType = "301"
  12840. order.ChrgType = "08"
  12841. order.DrordBhvr = "0"
  12842. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12843. order.HosplistName = subItem.GoodInfo.GoodName
  12844. order.HilistLv = "1"
  12845. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  12846. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  12847. order.HosplistName = subItem.GoodInfo.GoodName
  12848. order.Cnt = subItem.Count
  12849. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12850. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  12851. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  12852. order.OwnpayAmt = ""
  12853. order.SelfpayAmt = ""
  12854. order.Spec = subItem.GoodInfo.SpecificationName
  12855. order.SpecUnt = subItem.GoodInfo.PackingUnit
  12856. order.DrordBegnDate = s_tm
  12857. order.DrordStopDate = ""
  12858. order.DrordDrCodg = doctor_info.DoctorNumber
  12859. order.DrordDeptName = department.Name
  12860. order.DrordDeptCodg = department.Number
  12861. order.DrordDrName = doctor_info.UserName
  12862. order.DrordDrProfttl = "234"
  12863. order.CurrDrordFlag = "1"
  12864. orders = append(orders, &order)
  12865. }
  12866. }
  12867. }
  12868. //处方医嘱信息
  12869. fed.MatnStas = "0"
  12870. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  12871. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  12872. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  12873. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  12874. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  12875. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  12876. fed.SetlTotlnum = "1"
  12877. fed.Insutype = his.Insutype
  12878. fed.ReimFlag = "0"
  12879. fed.OutSetlFlag = "0"
  12880. var fopd []*models.FsiOperationDtosData
  12881. data := make(map[string]interface{})
  12882. data["fed"] = fed
  12883. data["fdd"] = fdds
  12884. data["fod"] = orders
  12885. data["pd"] = pd
  12886. data["pp"] = pp
  12887. data["fopd"] = fopd
  12888. data["trig_scen"] = trig_scen
  12889. client := &http.Client{}
  12890. bytesData, _ := json.Marshal(data)
  12891. var req *http.Request
  12892. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12893. if miConfig.MdtrtareaAdmvs == "320830" {
  12894. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3102", bytes.NewReader(bytesData))
  12895. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12896. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12897. } else {
  12898. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  12899. }
  12900. resp, _ := client.Do(req)
  12901. defer resp.Body.Close()
  12902. body, ioErr := ioutil.ReadAll(resp.Body)
  12903. if ioErr != nil {
  12904. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12906. return res
  12907. }
  12908. var respJSON map[string]interface{}
  12909. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12910. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12912. return res
  12913. }
  12914. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12915. result, _ := json.Marshal(respJSON)
  12916. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12917. utils.ErrorLog("解析失败:%v", err)
  12918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12919. return res
  12920. }
  12921. return res
  12922. } else {
  12923. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  12924. saveLog(output, input, "3102", "事中")
  12925. if err := json.Unmarshal([]byte(output), &res); err != nil {
  12926. utils.ErrorLog("解析失败:%v", err)
  12927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12928. return
  12929. }
  12930. return res
  12931. }
  12932. return res
  12933. }
  12934. func (c *HisApiController) Check() {
  12935. psn_no := c.GetString("psn_no")
  12936. in := c.GetString("in")
  12937. mt := c.GetString("mt")
  12938. baseParams := models.BaseParams{
  12939. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  12940. FixmedinsCode: "H15049901371",
  12941. InsuplcAdmdvs: "150499",
  12942. MdtrtareaAdmvs: "150499",
  12943. OrgName: "赤峰费森血液透析中心",
  12944. Doctor: "1111",
  12945. }
  12946. service.Gdyb2001(baseParams, psn_no, in, mt)
  12947. }
  12948. func (c *HisApiController) GetPsnNcdsInfo() {
  12949. admin_user_id, _ := c.GetInt64("admin_user_id")
  12950. patient_id, _ := c.GetInt64("patient_id")
  12951. //id, _ := c.GetInt64("id")
  12952. adminUser := c.GetAdminUserInfo()
  12953. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12954. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12955. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  12956. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12957. //psn_record, _ := service.GetP(id)
  12958. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12959. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  12960. //
  12961. //if psn_record.ID == 0 {
  12962. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  12963. // return
  12964. //}
  12965. var res Result5301
  12966. var res10265 Result5301For10265
  12967. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  12968. psn_info, _ := service.GetPsnByPatientId(patient_id)
  12969. var api string
  12970. if miConfig.MdtrtareaAdmvs == "320830" {
  12971. api = miConfig.AppSecret + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  12972. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12973. } else if miConfig.MdtrtareaAdmvs == "320921" {
  12974. 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 +
  12975. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12976. } else {
  12977. 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 +
  12978. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  12979. }
  12980. resp, requestErr := http.Get(api)
  12981. if requestErr != nil {
  12982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12983. return
  12984. }
  12985. body, ioErr := ioutil.ReadAll(resp.Body)
  12986. if ioErr != nil {
  12987. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12989. return
  12990. }
  12991. var respJSON map[string]interface{}
  12992. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12993. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12995. return
  12996. }
  12997. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12998. result, _ := json.Marshal(respJSON)
  12999. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  13000. utils.ErrorLog("解析失败:%v", err)
  13001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13002. return
  13003. }
  13004. res.ErrMsg = res10265.ErrMsg
  13005. res.Output = res10265.Output
  13006. res.InfRefmsgid = res10265.InfRefmsgid
  13007. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13008. res.Infcode = infocode
  13009. } else if miConfig.MdtrtareaAdmvs == "341203" {
  13010. psn_info, _ := service.GetPsnByPatientId(patient_id)
  13011. var api string
  13012. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  13013. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  13014. resp, requestErr := http.Get(api)
  13015. if requestErr != nil {
  13016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13017. return
  13018. }
  13019. body, ioErr := ioutil.ReadAll(resp.Body)
  13020. if ioErr != nil {
  13021. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13023. return
  13024. }
  13025. var respJSON map[string]interface{}
  13026. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13027. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13029. return
  13030. }
  13031. status := respJSON["data"].(map[string]interface{})["status"].(string)
  13032. if status == "0" {
  13033. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  13034. c.ServeSuccessJSON(map[string]interface{}{
  13035. "failed_code": -10,
  13036. "msg": err_msg,
  13037. })
  13038. return
  13039. }
  13040. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13041. result, _ := json.Marshal(respJSON)
  13042. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13043. utils.ErrorLog("解析失败:%v", err)
  13044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13045. return
  13046. }
  13047. } else if miConfig.MdtrtareaAdmvs == "340699" {
  13048. psn_info, _ := service.GetHisPatientByPatientId(patient_id)
  13049. var api string
  13050. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  13051. "&insuplc_admdvs=" + psn_info.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  13052. resp, requestErr := http.Get(api)
  13053. if requestErr != nil {
  13054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13055. return
  13056. }
  13057. body, ioErr := ioutil.ReadAll(resp.Body)
  13058. if ioErr != nil {
  13059. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13061. return
  13062. }
  13063. var respJSON map[string]interface{}
  13064. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13065. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13067. return
  13068. }
  13069. status := respJSON["data"].(map[string]interface{})["status"].(string)
  13070. if status == "0" {
  13071. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  13072. c.ServeSuccessJSON(map[string]interface{}{
  13073. "failed_code": -10,
  13074. "msg": err_msg,
  13075. })
  13076. return
  13077. }
  13078. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13079. result, _ := json.Marshal(respJSON)
  13080. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13081. utils.ErrorLog("解析失败:%v", err)
  13082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13083. return
  13084. }
  13085. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13086. p, _ := service.GetHisPatientById(patient_id)
  13087. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13088. var dat map[string]interface{}
  13089. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13090. fmt.Println(dat)
  13091. } else {
  13092. fmt.Println(err)
  13093. }
  13094. userJSONBytes, _ := json.Marshal(dat)
  13095. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13096. utils.ErrorLog("解析失败:%v", err)
  13097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13098. return
  13099. }
  13100. } else if miConfig.MdtrtareaAdmvs == "361025" {
  13101. p, _ := service.GetHisPatientById(patient_id)
  13102. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13103. var dat map[string]interface{}
  13104. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13105. fmt.Println(dat)
  13106. } else {
  13107. fmt.Println(err)
  13108. }
  13109. userJSONBytes, _ := json.Marshal(dat)
  13110. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13111. utils.ErrorLog("解析失败:%v", err)
  13112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13113. return
  13114. }
  13115. } else if miConfig.MdtrtareaAdmvs == "360100" {
  13116. p, _ := service.GetHisPatientById(patient_id)
  13117. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13118. var dat map[string]interface{}
  13119. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13120. fmt.Println(dat)
  13121. } else {
  13122. fmt.Println(err)
  13123. }
  13124. userJSONBytes, _ := json.Marshal(dat)
  13125. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13126. utils.ErrorLog("解析失败:%v", err)
  13127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13128. return
  13129. }
  13130. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13131. p, _ := service.GetHisPatientById(patient_id)
  13132. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  13133. var dat map[string]interface{}
  13134. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13135. fmt.Println(dat)
  13136. } else {
  13137. fmt.Println(err)
  13138. }
  13139. userJSONBytes, _ := json.Marshal(dat)
  13140. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13141. utils.ErrorLog("解析失败:%v", err)
  13142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13143. return
  13144. }
  13145. } else if miConfig.MdtrtareaAdmvs == "420200" {
  13146. p, _ := service.GetHisPatientById(patient_id)
  13147. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  13148. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13149. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13150. resp, requestErr := http.Get(api)
  13151. if requestErr != nil {
  13152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13153. return
  13154. }
  13155. body, ioErr := ioutil.ReadAll(resp.Body)
  13156. if ioErr != nil {
  13157. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13159. return
  13160. }
  13161. var respJSON map[string]interface{}
  13162. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13163. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13165. return
  13166. }
  13167. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13168. result, _ := json.Marshal(respJSON)
  13169. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13170. utils.ErrorLog("解析失败:%v", err)
  13171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13172. return
  13173. }
  13174. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13175. p, _ := service.GetHisPatientById(patient_id)
  13176. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  13177. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13178. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13179. resp, requestErr := http.Get(api)
  13180. if requestErr != nil {
  13181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13182. return
  13183. }
  13184. body, ioErr := ioutil.ReadAll(resp.Body)
  13185. if ioErr != nil {
  13186. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13188. return
  13189. }
  13190. var respJSON map[string]interface{}
  13191. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13192. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13194. return
  13195. }
  13196. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13197. result, _ := json.Marshal(respJSON)
  13198. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13199. utils.ErrorLog("解析失败:%v", err)
  13200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13201. return
  13202. }
  13203. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13204. p, _ := service.GetHisPatientById(patient_id)
  13205. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  13206. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13207. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13208. resp, requestErr := http.Get(api)
  13209. if requestErr != nil {
  13210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13211. return
  13212. }
  13213. body, ioErr := ioutil.ReadAll(resp.Body)
  13214. if ioErr != nil {
  13215. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13217. return
  13218. }
  13219. var respJSON map[string]interface{}
  13220. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13221. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13223. return
  13224. }
  13225. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13226. result, _ := json.Marshal(respJSON)
  13227. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13228. utils.ErrorLog("解析失败:%v", err)
  13229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13230. return
  13231. }
  13232. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13233. p, _ := service.GetHisPatientById(patient_id)
  13234. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  13235. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13236. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13237. resp, requestErr := http.Get(api)
  13238. if requestErr != nil {
  13239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13240. return
  13241. }
  13242. body, ioErr := ioutil.ReadAll(resp.Body)
  13243. if ioErr != nil {
  13244. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13246. return
  13247. }
  13248. var respJSON map[string]interface{}
  13249. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13250. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13252. return
  13253. }
  13254. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13255. result, _ := json.Marshal(respJSON)
  13256. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13257. utils.ErrorLog("解析失败:%v", err)
  13258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13259. return
  13260. }
  13261. } else if miConfig.MdtrtareaAdmvs == "421300" {
  13262. p, _ := service.GetHisPatientById(patient_id)
  13263. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  13264. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13265. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13266. resp, requestErr := http.Get(api)
  13267. if requestErr != nil {
  13268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13269. return
  13270. }
  13271. body, ioErr := ioutil.ReadAll(resp.Body)
  13272. if ioErr != nil {
  13273. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13275. return
  13276. }
  13277. var respJSON map[string]interface{}
  13278. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13279. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13281. return
  13282. }
  13283. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13284. result, _ := json.Marshal(respJSON)
  13285. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13286. utils.ErrorLog("解析失败:%v", err)
  13287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13288. return
  13289. }
  13290. } else if miConfig.MdtrtareaAdmvs == "441799" {
  13291. p, _ := service.GetHisPatientById(patient_id)
  13292. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  13293. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  13294. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13295. resp, requestErr := http.Get(api)
  13296. if requestErr != nil {
  13297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13298. return
  13299. }
  13300. body, ioErr := ioutil.ReadAll(resp.Body)
  13301. if ioErr != nil {
  13302. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13304. return
  13305. }
  13306. var respJSON map[string]interface{}
  13307. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13308. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13310. return
  13311. }
  13312. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13313. result, _ := json.Marshal(respJSON)
  13314. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13315. utils.ErrorLog("解析失败:%v", err)
  13316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13317. return
  13318. }
  13319. } else {
  13320. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  13321. var dat map[string]interface{}
  13322. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13323. fmt.Println(dat)
  13324. } else {
  13325. fmt.Println(err)
  13326. }
  13327. userJSONBytes, _ := json.Marshal(dat)
  13328. if miConfig.Code == "H15049901371" {
  13329. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  13330. utils.ErrorLog("解析失败:%v", err)
  13331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13332. return
  13333. }
  13334. res.InfRefmsgid = res10265.InfRefmsgid
  13335. res.Output = res10265.Output
  13336. res.ErrMsg = res10265.ErrMsg
  13337. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  13338. res.Infcode = infocode
  13339. } else {
  13340. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13341. utils.ErrorLog("解析失败:%v", err)
  13342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13343. return
  13344. }
  13345. }
  13346. }
  13347. if res.Infcode == 0 {
  13348. c.ServeSuccessJSON(map[string]interface{}{
  13349. "result": res.Output.Result,
  13350. })
  13351. }
  13352. }
  13353. func (c *HisApiController) CheckInsutype() {
  13354. his_patient_id, _ := c.GetInt64("his_patient_id")
  13355. admin_user_id, _ := c.GetInt64("admin_user_id")
  13356. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13357. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  13358. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13359. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  13360. var dat map[string]interface{}
  13361. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13362. fmt.Println(dat)
  13363. } else {
  13364. fmt.Println(err)
  13365. }
  13366. userJSONBytes, _ := json.Marshal(dat)
  13367. var res Result90100
  13368. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13369. utils.ErrorLog("解析失败:%v", err)
  13370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13371. return
  13372. }
  13373. if res.Infcode != 0 {
  13374. c.ServeSuccessJSON(map[string]interface{}{
  13375. "failed_code": -10,
  13376. "msg": res.ErrMsg,
  13377. })
  13378. return
  13379. } else {
  13380. fmt.Println(res)
  13381. }
  13382. }
  13383. func (c *HisApiController) CheckCardPWD() {
  13384. card_pwd := c.GetString("card_pwd")
  13385. his_patient_id, _ := c.GetInt64("his_patient_id")
  13386. admin_user_id, _ := c.GetInt64("admin_user_id")
  13387. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13388. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13389. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  13390. psn, _ := service.GetPsnByPatientId(his.PatientId)
  13391. bas := strings.Split(psn.CardInfo, "|")
  13392. basNumber := bas[2]
  13393. if psn.InsuplcAdmdvs[:4] == "4403" {
  13394. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  13395. var dat map[string]interface{}
  13396. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13397. fmt.Println(dat)
  13398. } else {
  13399. fmt.Println(err)
  13400. }
  13401. userJSONBytes, _ := json.Marshal(dat)
  13402. var res Result90991
  13403. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13404. utils.ErrorLog("解析失败:%v", err)
  13405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13406. return
  13407. }
  13408. if res.Infcode != 0 {
  13409. c.ServeSuccessJSON(map[string]interface{}{
  13410. "failed_code": -10,
  13411. "msg": res.ErrMsg,
  13412. })
  13413. return
  13414. } else {
  13415. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  13416. var msg string
  13417. switch res.Output.Result.CardStat {
  13418. case "00":
  13419. msg = "未激活"
  13420. break
  13421. case "10":
  13422. msg = "激活"
  13423. break
  13424. case "20":
  13425. msg = "窗口挂失"
  13426. break
  13427. case "21":
  13428. msg = "电话挂失"
  13429. break
  13430. case "22":
  13431. msg = "单位网上申报挂失"
  13432. break
  13433. case "23":
  13434. msg = "保健办挂失"
  13435. break
  13436. case "24":
  13437. msg = "个人网上挂失"
  13438. break
  13439. case "25":
  13440. msg = "网上服务大厅挂失"
  13441. break
  13442. case "30":
  13443. msg = "注销"
  13444. break
  13445. case "40":
  13446. msg = "回收"
  13447. break
  13448. case "99":
  13449. msg = "制卡中(无效卡)"
  13450. break
  13451. }
  13452. c.ServeSuccessJSON(map[string]interface{}{
  13453. "failed_code": -10,
  13454. "msg": msg,
  13455. })
  13456. return
  13457. } else {
  13458. c.ServeSuccessJSON(map[string]interface{}{
  13459. "msg": "校验成功",
  13460. })
  13461. return
  13462. }
  13463. }
  13464. } else {
  13465. c.ServeSuccessJSON(map[string]interface{}{
  13466. "msg": "校验成功",
  13467. })
  13468. return
  13469. }
  13470. }
  13471. func (c *HisApiController) CheckCardPWDTwo() {
  13472. //card_pwd := c.GetString("card_pwd")
  13473. //his_patient_id, _ := c.GetInt64("his_patient_id")
  13474. admin_user_id, _ := c.GetInt64("admin_user_id")
  13475. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13476. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13477. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  13478. var dat map[string]interface{}
  13479. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13480. fmt.Println(dat)
  13481. } else {
  13482. fmt.Println(err)
  13483. }
  13484. userJSONBytes, _ := json.Marshal(dat)
  13485. var res Result90991
  13486. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13487. utils.ErrorLog("解析失败:%v", err)
  13488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13489. return
  13490. }
  13491. if res.Infcode != 0 {
  13492. c.ServeSuccessJSON(map[string]interface{}{
  13493. "failed_code": -10,
  13494. "msg": res.ErrMsg,
  13495. })
  13496. return
  13497. } else {
  13498. if res.Output.Result.SscnoCheckStat == "0" {
  13499. var msg string
  13500. switch res.Output.Result.CardStat {
  13501. case "00":
  13502. msg = "未激活"
  13503. break
  13504. case "10":
  13505. msg = "激活"
  13506. break
  13507. case "20":
  13508. msg = "窗口挂失"
  13509. break
  13510. case "21":
  13511. msg = "电话挂失"
  13512. break
  13513. case "22":
  13514. msg = "单位网上申报挂失"
  13515. break
  13516. case "23":
  13517. msg = "保健办挂失"
  13518. break
  13519. case "24":
  13520. msg = "个人网上挂失"
  13521. break
  13522. case "25":
  13523. msg = "网上服务大厅挂失"
  13524. break
  13525. case "30":
  13526. msg = "注销"
  13527. break
  13528. case "40":
  13529. msg = "回收"
  13530. break
  13531. case "99":
  13532. msg = "制卡中(无效卡)"
  13533. break
  13534. }
  13535. c.ServeSuccessJSON(map[string]interface{}{
  13536. "failed_code": -10,
  13537. "msg": msg,
  13538. })
  13539. return
  13540. } else {
  13541. c.ServeSuccessJSON(map[string]interface{}{
  13542. "msg": "校验成功",
  13543. })
  13544. return
  13545. }
  13546. }
  13547. }
  13548. type ELeCertData struct {
  13549. Data struct {
  13550. Extra string `json:"extra"`
  13551. IDNo string `json:"idNo"`
  13552. IDType string `json:"idType"`
  13553. EcToken string `json:"ecToken"`
  13554. InsuOrg string `json:"insuOrg"`
  13555. UserName string `json:"userName"`
  13556. EcIndexNo string `json:"ecIndexNo"`
  13557. Gender string `json:"gender"`
  13558. Birthday string `json:"birthday"`
  13559. Nationality string `json:"nationality"`
  13560. Email string `json:"email"`
  13561. } `json:"OutData"`
  13562. }
  13563. func (c *HisApiController) ReadCard() {
  13564. id_card_type, _ := c.GetInt64("id_card_type")
  13565. admin_user_id, _ := c.GetInt64("admin_user_id")
  13566. certificates, _ := c.GetInt64("certificates")
  13567. //
  13568. insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  13569. id_card_no := c.GetString("id_card_no")
  13570. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  13571. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13572. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13573. switch id_card_type {
  13574. case 1:
  13575. if miConfig.MdtrtareaAdmvs == "421300" {
  13576. var res ResultTwo
  13577. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  13578. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13579. "&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)
  13580. resp, requestErr := http.Get(api)
  13581. if requestErr != nil {
  13582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13583. return
  13584. }
  13585. body, ioErr := ioutil.ReadAll(resp.Body)
  13586. if ioErr != nil {
  13587. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13589. return
  13590. }
  13591. var respJSON map[string]interface{}
  13592. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13593. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13595. return
  13596. }
  13597. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13598. result, _ := json.Marshal(respJSON)
  13599. fmt.Println("log")
  13600. fmt.Println(string(result))
  13601. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13602. utils.ErrorLog("解析失败:%v", err)
  13603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13604. return
  13605. }
  13606. if res.Infcode == 0 {
  13607. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13608. if err == gorm.ErrRecordNotFound {
  13609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13610. return
  13611. } else if err != nil {
  13612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13613. return
  13614. } else {
  13615. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13616. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13617. infoStr := string(Iinfos)
  13618. idetinfoStr := string(Idetinfos)
  13619. var rf []*ResultFive
  13620. json.Unmarshal([]byte(infoStr), &rf)
  13621. var insutypes []*ResultFive
  13622. var insutype string
  13623. var is390 int = 0
  13624. var is310 int = 0
  13625. for _, item := range rf {
  13626. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13627. insutypes = append(insutypes, item)
  13628. }
  13629. }
  13630. if len(insutypes) == 1 {
  13631. insutype = insutypes[0].Insutype
  13632. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13633. } else {
  13634. for _, i := range insutypes {
  13635. if i.Insutype == "390" {
  13636. is390 = 1
  13637. }
  13638. if i.Insutype == "310" {
  13639. is310 = 1
  13640. }
  13641. }
  13642. }
  13643. if is390 == 1 {
  13644. insutype = "390"
  13645. }
  13646. if is310 == 1 {
  13647. insutype = "310"
  13648. }
  13649. if len(insutypes) == 0 {
  13650. insutype = "390"
  13651. }
  13652. var insuplc_admdvs string
  13653. for _, item := range rf {
  13654. if item.Insutype == insutype {
  13655. insuplc_admdvs = item.InsuplcAdmdvs
  13656. }
  13657. }
  13658. if strings.Contains(insuplc_admdvs, "4213") {
  13659. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  13660. }
  13661. psn := &models.HisPsn{
  13662. PsnNo: res.Output.Baseinfo.PsnNo,
  13663. PatientId: patient.ID,
  13664. Certno: res.Output.Baseinfo.Certno,
  13665. Gend: res.Output.Baseinfo.Gend,
  13666. Naty: res.Output.Baseinfo.Naty,
  13667. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13668. PsnName: res.Output.Baseinfo.PsnName,
  13669. Idetinfo: idetinfoStr,
  13670. Insuinfo: infoStr,
  13671. InsuplcAdmdvs: insuplc_admdvs,
  13672. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13673. }
  13674. service.CreateHisPsn(psn)
  13675. c.ServeSuccessJSON(map[string]interface{}{
  13676. "patient": patient,
  13677. "number": res.Output.Baseinfo.Certno,
  13678. })
  13679. }
  13680. } else {
  13681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13682. return
  13683. }
  13684. } else if miConfig.MdtrtareaAdmvs == "420200" {
  13685. var res ResultTwo
  13686. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  13687. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13688. "&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)
  13689. resp, requestErr := http.Get(api)
  13690. if requestErr != nil {
  13691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13692. return
  13693. }
  13694. body, ioErr := ioutil.ReadAll(resp.Body)
  13695. if ioErr != nil {
  13696. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13698. return
  13699. }
  13700. var respJSON map[string]interface{}
  13701. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13704. return
  13705. }
  13706. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13707. result, _ := json.Marshal(respJSON)
  13708. fmt.Println("log")
  13709. fmt.Println(string(result))
  13710. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13711. utils.ErrorLog("解析失败:%v", err)
  13712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13713. return
  13714. }
  13715. if res.Infcode == 0 {
  13716. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13717. if err == gorm.ErrRecordNotFound {
  13718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13719. return
  13720. } else if err != nil {
  13721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13722. return
  13723. } else {
  13724. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13725. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13726. infoStr := string(Iinfos)
  13727. idetinfoStr := string(Idetinfos)
  13728. psn := &models.HisPsn{
  13729. PsnNo: res.Output.Baseinfo.PsnNo,
  13730. PatientId: patient.ID,
  13731. Certno: res.Output.Baseinfo.Certno,
  13732. Gend: res.Output.Baseinfo.Gend,
  13733. Naty: res.Output.Baseinfo.Naty,
  13734. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13735. PsnName: res.Output.Baseinfo.PsnName,
  13736. Idetinfo: idetinfoStr,
  13737. Insuinfo: infoStr,
  13738. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13739. }
  13740. service.CreateHisPsn(psn)
  13741. var rf []*ResultFive
  13742. json.Unmarshal([]byte(infoStr), &rf)
  13743. var insutypes []*ResultFive
  13744. var insutype string
  13745. var is390 int = 0
  13746. var is310 int = 0
  13747. for _, item := range rf {
  13748. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13749. insutypes = append(insutypes, item)
  13750. }
  13751. }
  13752. if len(insutypes) == 1 {
  13753. insutype = insutypes[0].Insutype
  13754. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13755. } else {
  13756. for _, i := range insutypes {
  13757. if i.Insutype == "390" {
  13758. is390 = 1
  13759. }
  13760. if i.Insutype == "310" {
  13761. is310 = 1
  13762. }
  13763. }
  13764. }
  13765. if is390 == 1 {
  13766. insutype = "390"
  13767. }
  13768. if is310 == 1 {
  13769. insutype = "310"
  13770. }
  13771. if len(insutypes) == 0 {
  13772. insutype = "310"
  13773. }
  13774. c.ServeSuccessJSON(map[string]interface{}{
  13775. "patient": patient,
  13776. "number": res.Output.Baseinfo.Certno,
  13777. "insutype": insutype,
  13778. })
  13779. }
  13780. } else {
  13781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13782. return
  13783. }
  13784. } else if miConfig.MdtrtareaAdmvs == "420902" {
  13785. var res ResultTwo
  13786. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  13787. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13788. "&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)
  13789. resp, requestErr := http.Get(api)
  13790. if requestErr != nil {
  13791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13792. return
  13793. }
  13794. body, ioErr := ioutil.ReadAll(resp.Body)
  13795. if ioErr != nil {
  13796. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13798. return
  13799. }
  13800. var respJSON map[string]interface{}
  13801. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13802. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13804. return
  13805. }
  13806. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13807. result, _ := json.Marshal(respJSON)
  13808. fmt.Println("log")
  13809. fmt.Println(string(result))
  13810. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13811. utils.ErrorLog("解析失败:%v", err)
  13812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13813. return
  13814. }
  13815. if res.Infcode == 0 {
  13816. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13817. if err == gorm.ErrRecordNotFound {
  13818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13819. return
  13820. } else if err != nil {
  13821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13822. return
  13823. } else {
  13824. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13825. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13826. infoStr := string(Iinfos)
  13827. idetinfoStr := string(Idetinfos)
  13828. var rf []*ResultFive
  13829. json.Unmarshal([]byte(infoStr), &rf)
  13830. var insutypes []*ResultFive
  13831. var insutype string
  13832. var is390 int = 0
  13833. var is310 int = 0
  13834. for _, item := range rf {
  13835. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  13836. insutypes = append(insutypes, item)
  13837. }
  13838. }
  13839. if len(insutypes) == 1 {
  13840. insutype = insutypes[0].Insutype
  13841. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13842. } else {
  13843. for _, i := range insutypes {
  13844. if i.Insutype == "390" {
  13845. is390 = 1
  13846. }
  13847. if i.Insutype == "310" {
  13848. is310 = 1
  13849. }
  13850. }
  13851. }
  13852. if is390 == 1 {
  13853. insutype = "390"
  13854. }
  13855. if is310 == 1 {
  13856. insutype = "310"
  13857. }
  13858. if len(insutypes) == 0 {
  13859. insutype = "390"
  13860. }
  13861. var insuplc_admdvs string
  13862. for _, item := range rf {
  13863. if item.Insutype == insutype {
  13864. insuplc_admdvs = item.InsuplcAdmdvs
  13865. }
  13866. }
  13867. psn := &models.HisPsn{
  13868. PsnNo: res.Output.Baseinfo.PsnNo,
  13869. PatientId: patient.ID,
  13870. Certno: res.Output.Baseinfo.Certno,
  13871. Gend: res.Output.Baseinfo.Gend,
  13872. Naty: res.Output.Baseinfo.Naty,
  13873. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13874. PsnName: res.Output.Baseinfo.PsnName,
  13875. Idetinfo: idetinfoStr,
  13876. Insuinfo: infoStr,
  13877. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13878. InsuplcAdmdvs: insuplc_admdvs,
  13879. }
  13880. service.CreateHisPsn(psn)
  13881. for _, item := range rf {
  13882. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13883. insutypes = append(insutypes, item)
  13884. }
  13885. }
  13886. if len(insutypes) == 1 {
  13887. insutype = insutypes[0].Insutype
  13888. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13889. } else {
  13890. for _, i := range insutypes {
  13891. if i.Insutype == "390" {
  13892. is390 = 1
  13893. }
  13894. if i.Insutype == "310" {
  13895. is310 = 1
  13896. }
  13897. }
  13898. }
  13899. if is390 == 1 {
  13900. insutype = "390"
  13901. }
  13902. if is310 == 1 {
  13903. insutype = "310"
  13904. }
  13905. if len(insutypes) == 0 {
  13906. insutype = "310"
  13907. }
  13908. c.ServeSuccessJSON(map[string]interface{}{
  13909. "patient": patient,
  13910. "number": res.Output.Baseinfo.Certno,
  13911. "insutype": insutype,
  13912. })
  13913. }
  13914. } else {
  13915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  13916. return
  13917. }
  13918. } else if miConfig.MdtrtareaAdmvs == "421182" {
  13919. var res ResultTwo
  13920. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  13921. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  13922. "&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)
  13923. resp, requestErr := http.Get(api)
  13924. if requestErr != nil {
  13925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13926. return
  13927. }
  13928. body, ioErr := ioutil.ReadAll(resp.Body)
  13929. if ioErr != nil {
  13930. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13932. return
  13933. }
  13934. var respJSON map[string]interface{}
  13935. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13936. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13938. return
  13939. }
  13940. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13941. result, _ := json.Marshal(respJSON)
  13942. fmt.Println("log")
  13943. fmt.Println(string(result))
  13944. if err := json.Unmarshal([]byte(result), &res); err != nil {
  13945. utils.ErrorLog("解析失败:%v", err)
  13946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13947. return
  13948. }
  13949. if res.Infcode == 0 {
  13950. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  13951. if err == gorm.ErrRecordNotFound {
  13952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  13953. return
  13954. } else if err != nil {
  13955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  13956. return
  13957. } else {
  13958. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  13959. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  13960. infoStr := string(Iinfos)
  13961. idetinfoStr := string(Idetinfos)
  13962. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  13963. psn := &models.HisPsn{
  13964. PsnNo: res.Output.Baseinfo.PsnNo,
  13965. PatientId: patient.ID,
  13966. Certno: res.Output.Baseinfo.Certno,
  13967. Brdy: b,
  13968. Age: float64(age),
  13969. Gend: res.Output.Baseinfo.Gend,
  13970. Naty: res.Output.Baseinfo.Naty,
  13971. PsnCertType: res.Output.Baseinfo.PsnCertType,
  13972. PsnName: res.Output.Baseinfo.PsnName,
  13973. Idetinfo: idetinfoStr,
  13974. Insuinfo: infoStr,
  13975. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13976. }
  13977. service.CreateHisPsn(psn)
  13978. var rf []*ResultFive
  13979. json.Unmarshal([]byte(infoStr), &rf)
  13980. var insutypes []*ResultFive
  13981. var insutype string
  13982. var is390 int = 0
  13983. var is310 int = 0
  13984. for _, item := range rf {
  13985. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  13986. insutypes = append(insutypes, item)
  13987. }
  13988. }
  13989. if len(insutypes) == 1 {
  13990. insutype = insutypes[0].Insutype
  13991. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  13992. } else {
  13993. for _, i := range insutypes {
  13994. if i.Insutype == "390" {
  13995. is390 = 1
  13996. }
  13997. if i.Insutype == "310" {
  13998. is310 = 1
  13999. }
  14000. }
  14001. }
  14002. if is390 == 1 {
  14003. insutype = "390"
  14004. }
  14005. if is310 == 1 {
  14006. insutype = "310"
  14007. }
  14008. if len(insutypes) == 0 {
  14009. insutype = "310"
  14010. }
  14011. c.ServeSuccessJSON(map[string]interface{}{
  14012. "patient": patient,
  14013. "number": res.Output.Baseinfo.Certno,
  14014. "insutype": insutype,
  14015. })
  14016. }
  14017. } else {
  14018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14019. return
  14020. }
  14021. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  14022. var api string
  14023. if miConfig.MdtrtareaAdmvs == "320830" {
  14024. api = miConfig.AppSecret + "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) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  14026. fmt.Println(api)
  14027. } else if miConfig.MdtrtareaAdmvs == "320921" {
  14028. 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 +
  14029. "&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
  14030. fmt.Println(api)
  14031. } else {
  14032. 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 +
  14033. "&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)
  14034. }
  14035. resp, requestErr := http.Get(api)
  14036. if requestErr != nil {
  14037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14038. return
  14039. }
  14040. body, ioErr := ioutil.ReadAll(resp.Body)
  14041. if ioErr != nil {
  14042. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14044. return
  14045. }
  14046. var respJSON map[string]interface{}
  14047. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14048. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14050. return
  14051. }
  14052. var status string
  14053. status = respJSON["data"].(map[string]interface{})["status"].(string)
  14054. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  14055. //console.log()
  14056. fmt.Println("type===")
  14057. fmt.Println(card_type)
  14058. var token string
  14059. var res ResultTwo //1101结果
  14060. var res10265 ResultTwo10265 //1101结果
  14061. var card_info string //卡信息
  14062. var busi_card_info string
  14063. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  14064. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14065. if status == "0" { //读卡成功
  14066. if card_type == "1" {
  14067. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14068. result, _ := json.Marshal(respJSON)
  14069. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14070. utils.ErrorLog("解析失败:%v", err)
  14071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14072. return
  14073. }
  14074. res.ErrMsg = res10265.ErrMsg
  14075. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14076. res.Infcode = infocode
  14077. res.Output = res10265.Output
  14078. res.InfRefmsgid = res10265.InfRefmsgid
  14079. } else {
  14080. //var card_info string //卡信息
  14081. //var busi_card_info string
  14082. token = respJSON["data"].(map[string]interface{})["token"].(string)
  14083. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  14084. //fmt.Println(card_info)
  14085. //fmt.Println(busi_card_info)
  14086. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14087. result, _ := json.Marshal(respJSON)
  14088. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14089. utils.ErrorLog("解析失败:%v", err)
  14090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14091. return
  14092. }
  14093. res.ErrMsg = res10265.ErrMsg
  14094. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14095. res.Infcode = infocode
  14096. res.Output = res10265.Output
  14097. res.InfRefmsgid = res10265.InfRefmsgid
  14098. }
  14099. if res.Infcode == 0 {
  14100. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14101. if err == gorm.ErrRecordNotFound {
  14102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14103. return
  14104. } else if err != nil {
  14105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14106. return
  14107. } else {
  14108. if card_type == "1" {
  14109. bas := strings.Split(card_info, "|")
  14110. basNumber := bas[2]
  14111. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14112. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14113. infoStr := string(Iinfos)
  14114. idetinfoStr := string(Idetinfos)
  14115. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  14116. psn := &models.HisPsn{
  14117. PsnNo: res.Output.Baseinfo.PsnNo,
  14118. PatientId: patient.ID,
  14119. Certno: res.Output.Baseinfo.Certno,
  14120. Brdy: b,
  14121. Age: float64(age),
  14122. Gend: res.Output.Baseinfo.Gend,
  14123. Naty: res.Output.Baseinfo.Naty,
  14124. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14125. PsnName: res.Output.Baseinfo.PsnName,
  14126. Idetinfo: idetinfoStr,
  14127. Insuinfo: infoStr,
  14128. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14129. CardInfo: card_info,
  14130. VerifyNumber: busi_card_info,
  14131. }
  14132. service.CreateHisPsn(psn)
  14133. var rf []*ResultFive
  14134. json.Unmarshal([]byte(infoStr), &rf)
  14135. var insutypes []*ResultFive
  14136. var insutype string
  14137. var is390 int = 0
  14138. var is310 int = 0
  14139. for _, item := range rf {
  14140. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14141. insutypes = append(insutypes, item)
  14142. }
  14143. }
  14144. if len(insutypes) == 1 {
  14145. insutype = insutypes[0].Insutype
  14146. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14147. } else {
  14148. for _, i := range insutypes {
  14149. if i.Insutype == "390" {
  14150. is390 = 1
  14151. }
  14152. if i.Insutype == "310" {
  14153. is310 = 1
  14154. }
  14155. }
  14156. }
  14157. if is390 == 1 {
  14158. insutype = "390"
  14159. }
  14160. if is310 == 1 {
  14161. insutype = "310"
  14162. }
  14163. if len(insutypes) == 0 {
  14164. insutype = "310"
  14165. }
  14166. c.ServeSuccessJSON(map[string]interface{}{
  14167. "patient": patient,
  14168. "number": basNumber,
  14169. "insutype": insutype,
  14170. })
  14171. } else {
  14172. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14173. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14174. infoStr := string(Iinfos)
  14175. idetinfoStr := string(Idetinfos)
  14176. psn := &models.HisPsn{
  14177. PsnNo: res.Output.Baseinfo.PsnNo,
  14178. PatientId: patient.ID,
  14179. Certno: res.Output.Baseinfo.Certno,
  14180. Gend: res.Output.Baseinfo.Gend,
  14181. Naty: res.Output.Baseinfo.Naty,
  14182. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14183. PsnName: res.Output.Baseinfo.PsnName,
  14184. Idetinfo: idetinfoStr,
  14185. Insuinfo: infoStr,
  14186. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14187. CardInfo: card_info,
  14188. VerifyNumber: token,
  14189. }
  14190. service.CreateHisPsn(psn)
  14191. c.ServeSuccessJSON(map[string]interface{}{
  14192. "patient": patient,
  14193. "number": token,
  14194. })
  14195. }
  14196. }
  14197. } else {
  14198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14199. return
  14200. }
  14201. } else { //读卡失败
  14202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14203. return
  14204. }
  14205. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14206. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  14207. cardnum = DeleteExtraSpaceTwo(cardnum)
  14208. cardCode = DeleteExtraSpaceTwo(cardCode)
  14209. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  14210. name = DeleteExtraSpaceTwo(name)
  14211. errmsg = DeleteExtraSpaceTwo(errmsg)
  14212. cardnum = Remove0000(cardnum)
  14213. cardCode = Remove0000(cardCode)
  14214. id_card_no = Remove0000(id_card_no)
  14215. name = Remove0000(name)
  14216. errmsg = Remove0000(errmsg)
  14217. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  14218. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  14219. //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)
  14220. //fmt.Println(result2)
  14221. //fmt.Println(requestLog2)
  14222. //fmt.Println(errMsgLog2)
  14223. 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)
  14224. saveLog(result, requestLog, "1101", "获取人员信息")
  14225. fmt.Println(errMsgLog)
  14226. if len(errMsgLog) > 0 {
  14227. } else {
  14228. var dat map[string]interface{}
  14229. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14230. fmt.Println(dat)
  14231. } else {
  14232. fmt.Println(err)
  14233. }
  14234. userJSONBytes, _ := json.Marshal(dat)
  14235. var res ResultTwo
  14236. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14237. utils.ErrorLog("解析失败:%v", err)
  14238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14239. return
  14240. }
  14241. res.ErrMsg = errMsgLog
  14242. if res.Infcode == 0 {
  14243. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  14244. if err == gorm.ErrRecordNotFound {
  14245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14246. return
  14247. } else if err != nil {
  14248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14249. return
  14250. } else {
  14251. fmt.Println(res)
  14252. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14253. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14254. infoStr := string(Iinfos)
  14255. idetinfoStr := string(Idetinfos)
  14256. var rf []*ResultFive
  14257. json.Unmarshal([]byte(infoStr), &rf)
  14258. var insutypes []*ResultFive
  14259. var insutype string
  14260. var is390 int = 0
  14261. var is310 int = 0
  14262. for _, item := range rf {
  14263. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  14264. insutypes = append(insutypes, item)
  14265. }
  14266. }
  14267. if len(insutypes) == 1 {
  14268. insutype = insutypes[0].Insutype
  14269. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14270. } else {
  14271. for _, i := range insutypes {
  14272. if i.Insutype == "390" {
  14273. is390 = 1
  14274. }
  14275. if i.Insutype == "310" {
  14276. is310 = 1
  14277. }
  14278. }
  14279. }
  14280. if is390 == 1 {
  14281. insutype = "390"
  14282. }
  14283. if is310 == 1 {
  14284. insutype = "310"
  14285. }
  14286. if len(insutypes) == 0 {
  14287. insutype = "390"
  14288. }
  14289. var insuplc_admdvs string
  14290. for _, item := range rf {
  14291. if item.Insutype == insutype {
  14292. insuplc_admdvs = item.InsuplcAdmdvs
  14293. }
  14294. }
  14295. psn := &models.HisPsn{
  14296. PsnNo: res.Output.Baseinfo.PsnNo,
  14297. PatientId: patient.ID,
  14298. Certno: res.Output.Baseinfo.Certno,
  14299. Gend: res.Output.Baseinfo.Gend,
  14300. Naty: res.Output.Baseinfo.Naty,
  14301. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14302. PsnName: res.Output.Baseinfo.PsnName,
  14303. Idetinfo: idetinfoStr,
  14304. Insuinfo: infoStr,
  14305. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14306. CardInfo: basStr,
  14307. VerifyNumber: "",
  14308. InsuplcAdmdvs: insuplc_admdvs,
  14309. }
  14310. service.CreateHisPsn(psn)
  14311. c.ServeSuccessJSON(map[string]interface{}{
  14312. "patient": patient,
  14313. "number": cardnum,
  14314. "insutype": insutype,
  14315. })
  14316. }
  14317. } else {
  14318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14319. return
  14320. }
  14321. }
  14322. } else if miConfig.MdtrtareaAdmvs == "360302" {
  14323. fmt.Println(initFlag)
  14324. fmt.Println("initFlag")
  14325. if initFlag == 0 {
  14326. c.TestGetJiangXiBasBaseInit()
  14327. }
  14328. basStr := c.GetBasBaseInfo()
  14329. if len(basStr) == 0 {
  14330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14331. return
  14332. }
  14333. fmt.Println(basStr)
  14334. bas := strings.Split(basStr, "|")
  14335. basNumber := bas[1]
  14336. fmt.Println(basNumber)
  14337. card := bas[2]
  14338. card_sn := bas[3]
  14339. fmt.Println(card_sn)
  14340. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14341. 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)
  14342. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14343. var dat map[string]interface{}
  14344. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14345. fmt.Println(dat)
  14346. } else {
  14347. fmt.Println(err)
  14348. }
  14349. userJSONBytes, _ := json.Marshal(dat)
  14350. var res ResultTwo
  14351. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14352. utils.ErrorLog("解析失败:%v", err)
  14353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14354. return
  14355. }
  14356. if res.Infcode == 0 {
  14357. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14358. if err == gorm.ErrRecordNotFound {
  14359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14360. return
  14361. } else if err != nil {
  14362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14363. return
  14364. } else {
  14365. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14366. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14367. infoStr := string(Iinfos)
  14368. idetinfoStr := string(Idetinfos)
  14369. var rf []*ResultFive
  14370. json.Unmarshal([]byte(infoStr), &rf)
  14371. var insutypes []*ResultFive
  14372. var insutype string
  14373. var is390 int = 0
  14374. var is310 int = 0
  14375. var insuplc_admdvs string
  14376. for _, item := range rf {
  14377. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14378. insutypes = append(insutypes, item)
  14379. }
  14380. }
  14381. if len(insutypes) == 1 {
  14382. insutype = insutypes[0].Insutype
  14383. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14384. } else {
  14385. for _, i := range insutypes {
  14386. if i.Insutype == "390" {
  14387. is390 = 1
  14388. }
  14389. if i.Insutype == "310" {
  14390. is310 = 1
  14391. }
  14392. }
  14393. }
  14394. if is390 == 1 {
  14395. insutype = "390"
  14396. }
  14397. if is310 == 1 {
  14398. insutype = "310"
  14399. }
  14400. if len(insutypes) == 0 {
  14401. insutype = "310"
  14402. }
  14403. for _, item := range rf {
  14404. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14405. insuplc_admdvs = item.InsuplcAdmdvs
  14406. }
  14407. }
  14408. psn := &models.HisPsn{
  14409. PsnNo: res.Output.Baseinfo.PsnNo,
  14410. PatientId: patient.ID,
  14411. Certno: res.Output.Baseinfo.Certno,
  14412. Gend: res.Output.Baseinfo.Gend,
  14413. Naty: res.Output.Baseinfo.Naty,
  14414. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14415. PsnName: res.Output.Baseinfo.PsnName,
  14416. Idetinfo: idetinfoStr,
  14417. Insuinfo: infoStr,
  14418. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14419. CardInfo: basStr,
  14420. InsuplcAdmdvs: insuplc_admdvs,
  14421. VerifyNumber: "",
  14422. }
  14423. service.CreateHisPsn(psn)
  14424. c.ServeSuccessJSON(map[string]interface{}{
  14425. "patient": patient,
  14426. "number": basNumber,
  14427. "insutype": insutype,
  14428. })
  14429. }
  14430. } else {
  14431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14432. return
  14433. }
  14434. } else if miConfig.MdtrtareaAdmvs == "361025" {
  14435. basStr := c.GetBasBaseInfo22222()
  14436. fmt.Println(basStr)
  14437. if len(basStr) == 0 {
  14438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14439. return
  14440. }
  14441. fmt.Println(basStr)
  14442. bas := strings.Split(basStr, "|")
  14443. basNumber := bas[2] //卡号
  14444. card_sn := bas[3] //
  14445. id_card_No := bas[1] //卡号
  14446. fmt.Println(basNumber)
  14447. fmt.Println(card_sn)
  14448. fmt.Println(id_card_No)
  14449. var patient service.Patients
  14450. if len(id_card_No) == 0 {
  14451. patient, _ = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14452. } else {
  14453. patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14454. }
  14455. 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)
  14456. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14457. var dat map[string]interface{}
  14458. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14459. fmt.Println(dat)
  14460. } else {
  14461. fmt.Println(err)
  14462. }
  14463. userJSONBytes, _ := json.Marshal(dat)
  14464. var res ResultTwo
  14465. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14466. utils.ErrorLog("解析失败:%v", err)
  14467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14468. return
  14469. }
  14470. if res.Infcode == 0 {
  14471. var pateint2 service.Patients
  14472. var err error
  14473. if len(id_card_No) == 0 {
  14474. pateint2, err = service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14475. } else {
  14476. pateint2, err = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14477. //patient, _ = service.GetPatientByNumber(id_card_No, c.GetAdminUserInfo().CurrentOrgId)
  14478. }
  14479. if err == gorm.ErrRecordNotFound {
  14480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14481. return
  14482. } else if err != nil {
  14483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14484. return
  14485. } else {
  14486. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14487. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14488. infoStr := string(Iinfos)
  14489. idetinfoStr := string(Idetinfos)
  14490. var rf []*ResultFive
  14491. json.Unmarshal([]byte(infoStr), &rf)
  14492. var insutypes []*ResultFive
  14493. var insutype string
  14494. var is390 int = 0
  14495. var is310 int = 0
  14496. var insuplc_admdvs string
  14497. for _, item := range rf {
  14498. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14499. insutypes = append(insutypes, item)
  14500. }
  14501. }
  14502. if len(insutypes) == 1 {
  14503. insutype = insutypes[0].Insutype
  14504. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14505. } else {
  14506. for _, i := range insutypes {
  14507. if i.Insutype == "390" {
  14508. is390 = 1
  14509. }
  14510. if i.Insutype == "310" {
  14511. is310 = 1
  14512. }
  14513. }
  14514. }
  14515. if is390 == 1 {
  14516. insutype = "390"
  14517. }
  14518. if is310 == 1 {
  14519. insutype = "310"
  14520. }
  14521. if len(insutypes) == 0 {
  14522. insutype = "310"
  14523. }
  14524. for _, item := range rf {
  14525. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14526. insuplc_admdvs = item.InsuplcAdmdvs
  14527. }
  14528. }
  14529. psn := &models.HisPsn{
  14530. PsnNo: res.Output.Baseinfo.PsnNo,
  14531. PatientId: pateint2.ID,
  14532. Certno: res.Output.Baseinfo.Certno,
  14533. Gend: res.Output.Baseinfo.Gend,
  14534. Naty: res.Output.Baseinfo.Naty,
  14535. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14536. PsnName: res.Output.Baseinfo.PsnName,
  14537. Idetinfo: idetinfoStr,
  14538. Insuinfo: infoStr,
  14539. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14540. CardInfo: basStr,
  14541. InsuplcAdmdvs: insuplc_admdvs,
  14542. VerifyNumber: "",
  14543. }
  14544. service.CreateHisPsn(psn)
  14545. c.ServeSuccessJSON(map[string]interface{}{
  14546. "patient": patient,
  14547. "number": basNumber,
  14548. "insutype": insutype,
  14549. })
  14550. }
  14551. } else {
  14552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14553. return
  14554. }
  14555. } else if miConfig.MdtrtareaAdmvs == "360100" {
  14556. fmt.Println(initFlag)
  14557. fmt.Println("initFlag")
  14558. if initFlag == 0 {
  14559. c.TestGetJiangXiBasBaseInittwo()
  14560. }
  14561. basStr := c.GetBasBaseInfo()
  14562. if len(basStr) == 0 {
  14563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14564. return
  14565. }
  14566. fmt.Println(basStr)
  14567. bas := strings.Split(basStr, "|")
  14568. basNumber := bas[1]
  14569. fmt.Println(basNumber)
  14570. card_sn := bas[3]
  14571. fmt.Println(card_sn)
  14572. patient, _ := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14573. 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)
  14574. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14575. var dat map[string]interface{}
  14576. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14577. fmt.Println(dat)
  14578. } else {
  14579. fmt.Println(err)
  14580. }
  14581. userJSONBytes, _ := json.Marshal(dat)
  14582. var res ResultTwo
  14583. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14584. utils.ErrorLog("解析失败:%v", err)
  14585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14586. return
  14587. }
  14588. if res.Infcode == 0 {
  14589. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14590. if err == gorm.ErrRecordNotFound {
  14591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14592. return
  14593. } else if err != nil {
  14594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14595. return
  14596. } else {
  14597. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14598. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14599. infoStr := string(Iinfos)
  14600. idetinfoStr := string(Idetinfos)
  14601. var rf []*ResultFive
  14602. json.Unmarshal([]byte(infoStr), &rf)
  14603. var insutypes []*ResultFive
  14604. var insutype string
  14605. var is390 int = 0
  14606. var is310 int = 0
  14607. var insuplc_admdvs string
  14608. for _, item := range rf {
  14609. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14610. insutypes = append(insutypes, item)
  14611. }
  14612. }
  14613. if len(insutypes) == 1 {
  14614. insutype = insutypes[0].Insutype
  14615. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14616. } else {
  14617. for _, i := range insutypes {
  14618. if i.Insutype == "390" {
  14619. is390 = 1
  14620. }
  14621. if i.Insutype == "310" {
  14622. is310 = 1
  14623. }
  14624. }
  14625. }
  14626. if is390 == 1 {
  14627. insutype = "390"
  14628. }
  14629. if is310 == 1 {
  14630. insutype = "310"
  14631. }
  14632. if len(insutypes) == 0 {
  14633. insutype = "310"
  14634. }
  14635. for _, item := range rf {
  14636. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  14637. insuplc_admdvs = item.InsuplcAdmdvs
  14638. }
  14639. }
  14640. psn := &models.HisPsn{
  14641. PsnNo: res.Output.Baseinfo.PsnNo,
  14642. PatientId: patient.ID,
  14643. Certno: res.Output.Baseinfo.Certno,
  14644. Gend: res.Output.Baseinfo.Gend,
  14645. Naty: res.Output.Baseinfo.Naty,
  14646. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14647. PsnName: res.Output.Baseinfo.PsnName,
  14648. Idetinfo: idetinfoStr,
  14649. Insuinfo: infoStr,
  14650. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14651. CardInfo: basStr,
  14652. InsuplcAdmdvs: insuplc_admdvs,
  14653. VerifyNumber: "",
  14654. }
  14655. service.CreateHisPsn(psn)
  14656. c.ServeSuccessJSON(map[string]interface{}{
  14657. "patient": patient,
  14658. "number": basNumber,
  14659. "insutype": insutype,
  14660. })
  14661. }
  14662. } else {
  14663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14664. return
  14665. }
  14666. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14667. fmt.Println(initFlag)
  14668. fmt.Println("initFlag")
  14669. if initFlag == 0 {
  14670. c.TestGetHnBasBaseInit()
  14671. }
  14672. basStr := c.GetBasBaseInfo()
  14673. if len(basStr) == 0 {
  14674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  14675. return
  14676. }
  14677. fmt.Println(basStr)
  14678. bas := strings.Split(basStr, "|")
  14679. basNumber := bas[1]
  14680. fmt.Println(basNumber)
  14681. card_sn := bas[3]
  14682. card_no := bas[2]
  14683. fmt.Println(card_sn)
  14684. name := bas[4]
  14685. name = ConvertToString(name, "gbk", "utf-8")
  14686. 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)
  14687. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  14688. var dat map[string]interface{}
  14689. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14690. fmt.Println(dat)
  14691. } else {
  14692. fmt.Println(err)
  14693. }
  14694. userJSONBytes, _ := json.Marshal(dat)
  14695. var res ResultTwo
  14696. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14697. utils.ErrorLog("解析失败:%v", err)
  14698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14699. return
  14700. }
  14701. if res.Infcode == 0 {
  14702. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  14703. if err == gorm.ErrRecordNotFound {
  14704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14705. return
  14706. } else if err != nil {
  14707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14708. return
  14709. } else {
  14710. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14711. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14712. infoStr := string(Iinfos)
  14713. idetinfoStr := string(Idetinfos)
  14714. psn := &models.HisPsn{
  14715. PsnNo: res.Output.Baseinfo.PsnNo,
  14716. PatientId: patient.ID,
  14717. Certno: res.Output.Baseinfo.Certno,
  14718. Gend: res.Output.Baseinfo.Gend,
  14719. Naty: res.Output.Baseinfo.Naty,
  14720. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14721. PsnName: res.Output.Baseinfo.PsnName,
  14722. Idetinfo: idetinfoStr,
  14723. Insuinfo: infoStr,
  14724. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14725. CardInfo: basStr,
  14726. VerifyNumber: "",
  14727. }
  14728. service.CreateHisPsn(psn)
  14729. var rf []*ResultFive
  14730. json.Unmarshal([]byte(infoStr), &rf)
  14731. var insutypes []*ResultFive
  14732. var insutype string
  14733. var is390 int = 0
  14734. var is310 int = 0
  14735. for _, item := range rf {
  14736. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14737. insutypes = append(insutypes, item)
  14738. }
  14739. }
  14740. if len(insutypes) == 1 {
  14741. insutype = insutypes[0].Insutype
  14742. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14743. } else {
  14744. for _, i := range insutypes {
  14745. if i.Insutype == "390" {
  14746. is390 = 1
  14747. }
  14748. if i.Insutype == "310" {
  14749. is310 = 1
  14750. }
  14751. }
  14752. }
  14753. if is390 == 1 {
  14754. insutype = "390"
  14755. }
  14756. if is310 == 1 {
  14757. insutype = "310"
  14758. }
  14759. if len(insutypes) == 0 {
  14760. insutype = "310"
  14761. }
  14762. c.ServeSuccessJSON(map[string]interface{}{
  14763. "patient": patient,
  14764. "number": basNumber,
  14765. "insutype": insutype,
  14766. })
  14767. }
  14768. } else {
  14769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14770. return
  14771. }
  14772. } else if miConfig.MdtrtareaAdmvs == "150499" {
  14773. var api string
  14774. 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 +
  14775. "&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
  14776. fmt.Println(api)
  14777. resp, requestErr := http.Get(api)
  14778. if requestErr != nil {
  14779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14780. return
  14781. }
  14782. body, ioErr := ioutil.ReadAll(resp.Body)
  14783. if ioErr != nil {
  14784. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14786. return
  14787. }
  14788. var respJSON map[string]interface{}
  14789. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14790. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14792. return
  14793. }
  14794. var res ResultTwo //1101结果
  14795. var res10265 ResultTwo10265 //1101结果
  14796. var card_info string //卡信息
  14797. token := respJSON["data"].(map[string]interface{})["token"].(string)
  14798. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  14799. result, _ := json.Marshal(respJSON)
  14800. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14801. utils.ErrorLog("解析失败:%v", err)
  14802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14803. return
  14804. }
  14805. res.ErrMsg = res10265.ErrMsg
  14806. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14807. res.Infcode = infocode
  14808. res.Output = res10265.Output
  14809. res.InfRefmsgid = res10265.InfRefmsgid
  14810. if res.Infcode == 0 {
  14811. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  14812. if err == gorm.ErrRecordNotFound {
  14813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14814. return
  14815. } else if err != nil {
  14816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14817. return
  14818. } else {
  14819. bas := strings.Split(card_info, "|")
  14820. basNumber := bas[2]
  14821. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14822. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14823. infoStr := string(Iinfos)
  14824. idetinfoStr := string(Idetinfos)
  14825. psn := &models.HisPsn{
  14826. PsnNo: res.Output.Baseinfo.PsnNo,
  14827. PatientId: patient.ID,
  14828. Certno: res.Output.Baseinfo.Certno,
  14829. Gend: res.Output.Baseinfo.Gend,
  14830. Naty: res.Output.Baseinfo.Naty,
  14831. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14832. PsnName: res.Output.Baseinfo.PsnName,
  14833. Idetinfo: idetinfoStr,
  14834. Insuinfo: infoStr,
  14835. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14836. CardInfo: card_info,
  14837. VerifyNumber: token,
  14838. }
  14839. service.CreateHisPsn(psn)
  14840. var rf []*ResultFive
  14841. json.Unmarshal([]byte(infoStr), &rf)
  14842. var insutypes []*ResultFive
  14843. var insutype string
  14844. var is390 int = 0
  14845. var is310 int = 0
  14846. for _, item := range rf {
  14847. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14848. insutypes = append(insutypes, item)
  14849. }
  14850. }
  14851. if len(insutypes) == 1 {
  14852. insutype = insutypes[0].Insutype
  14853. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14854. } else {
  14855. for _, i := range insutypes {
  14856. if i.Insutype == "390" {
  14857. is390 = 1
  14858. }
  14859. if i.Insutype == "310" {
  14860. is310 = 1
  14861. }
  14862. }
  14863. }
  14864. if is390 == 1 {
  14865. insutype = "390"
  14866. }
  14867. if is310 == 1 {
  14868. insutype = "310"
  14869. }
  14870. if len(insutypes) == 0 {
  14871. insutype = "310"
  14872. }
  14873. c.ServeSuccessJSON(map[string]interface{}{
  14874. "patient": patient,
  14875. "number": basNumber,
  14876. "insutype": insutype,
  14877. })
  14878. }
  14879. } else {
  14880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14881. return
  14882. }
  14883. } else if miConfig.MdtrtareaAdmvs == "450721" {
  14884. res := c.GetoleInfo()
  14885. if res.Infcode == 0 {
  14886. var result string
  14887. if res.Output.MdtrtCertType == "01" {
  14888. 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)
  14889. } else if res.Output.MdtrtCertType == "02" {
  14890. 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)
  14891. } else if res.Output.MdtrtCertType == "03" {
  14892. 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)
  14893. }
  14894. var dat map[string]interface{}
  14895. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14896. fmt.Println(dat)
  14897. } else {
  14898. fmt.Println(err)
  14899. }
  14900. userJSONBytes, _ := json.Marshal(dat)
  14901. var res2 ResultTwo
  14902. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  14903. utils.ErrorLog("解析失败:%v", err)
  14904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14905. return
  14906. }
  14907. if res2.Infcode == 0 {
  14908. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  14909. if err == gorm.ErrRecordNotFound {
  14910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  14911. return
  14912. } else if err != nil {
  14913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  14914. return
  14915. } else {
  14916. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  14917. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  14918. infoStr := string(Iinfos)
  14919. idetinfoStr := string(Idetinfos)
  14920. var rf []*ResultFive
  14921. json.Unmarshal([]byte(infoStr), &rf)
  14922. var insutypes []*ResultFive
  14923. var insutype string
  14924. var is390 int = 0
  14925. var is310 int = 0
  14926. //var insuplc_admdvs string
  14927. for _, item := range rf {
  14928. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  14929. insutypes = append(insutypes, item)
  14930. }
  14931. }
  14932. if len(insutypes) == 1 {
  14933. insutype = insutypes[0].Insutype
  14934. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  14935. } else {
  14936. for _, i := range insutypes {
  14937. if i.Insutype == "390" {
  14938. is390 = 1
  14939. }
  14940. if i.Insutype == "310" {
  14941. is310 = 1
  14942. }
  14943. }
  14944. }
  14945. if is390 == 1 {
  14946. insutype = "390"
  14947. }
  14948. if is310 == 1 {
  14949. insutype = "310"
  14950. }
  14951. if len(insutypes) == 0 {
  14952. insutype = "310"
  14953. }
  14954. psn := &models.HisPsn{
  14955. PsnNo: res2.Output.Baseinfo.PsnNo,
  14956. PatientId: patient.ID,
  14957. Certno: res2.Output.Baseinfo.Certno,
  14958. Gend: res2.Output.Baseinfo.Gend,
  14959. Naty: res2.Output.Baseinfo.Naty,
  14960. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  14961. PsnName: res2.Output.Baseinfo.PsnName,
  14962. Idetinfo: idetinfoStr,
  14963. Insuinfo: infoStr,
  14964. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14965. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  14966. VerifyNumber: res.Output.EcToken,
  14967. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  14968. }
  14969. if res.Output.MdtrtCertType == "01" {
  14970. psn.VerifyNumber = res.Output.EcToken
  14971. //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)
  14972. } else if res.Output.MdtrtCertType == "02" {
  14973. psn.VerifyNumber = res.Output.MdtrtCertNo
  14974. //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)
  14975. } else if res.Output.MdtrtCertType == "03" {
  14976. psn.VerifyNumber = res.Output.MdtrtCertNo
  14977. //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)
  14978. }
  14979. var balc float64
  14980. for _, item := range rf {
  14981. if item.Insutype == insutype {
  14982. balc = item.Balc
  14983. }
  14984. }
  14985. service.CreateHisPsn(psn)
  14986. c.ServeSuccessJSON(map[string]interface{}{
  14987. "patient": patient,
  14988. "number": res.Output.CardNo,
  14989. "insutype": insutype,
  14990. "blac": balc,
  14991. "desc": idetinfoStr,
  14992. })
  14993. }
  14994. } else {
  14995. c.ServeSuccessJSON(map[string]interface{}{
  14996. "failed_code": -10,
  14997. "msg": res2.ErrMsg,
  14998. })
  14999. }
  15000. } else {
  15001. c.ServeSuccessJSON(map[string]interface{}{
  15002. "failed_code": -10,
  15003. "msg": res.ErrMsg,
  15004. })
  15005. }
  15006. } else if miConfig.MdtrtareaAdmvs == "341203" {
  15007. var api string
  15008. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15009. "&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
  15010. fmt.Println(api)
  15011. resp, requestErr := http.Get(api)
  15012. if requestErr != nil {
  15013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15014. return
  15015. }
  15016. body, ioErr := ioutil.ReadAll(resp.Body)
  15017. if ioErr != nil {
  15018. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15020. return
  15021. }
  15022. var respJSON map[string]interface{}
  15023. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15024. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15026. return
  15027. }
  15028. var status string
  15029. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15030. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15031. //console.log()
  15032. fmt.Println("type===")
  15033. fmt.Println(card_type)
  15034. var token string
  15035. var res ResultTwo //1101结果
  15036. //var res10265 ResultTwoesultTwo10265 //1101结果
  15037. var card_info string //卡信息
  15038. var busi_card_info string
  15039. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15040. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15041. if status == "0" { //读卡成功
  15042. if card_type == "1" {
  15043. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15044. result, _ := json.Marshal(respJSON)
  15045. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15046. utils.ErrorLog("解析失败:%v", err)
  15047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15048. return
  15049. }
  15050. } else {
  15051. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15052. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15053. result, _ := json.Marshal(respJSON)
  15054. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15055. utils.ErrorLog("解析失败:%v", err)
  15056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15057. return
  15058. }
  15059. }
  15060. if res.Infcode == 0 {
  15061. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15062. if err == gorm.ErrRecordNotFound {
  15063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15064. return
  15065. } else if err != nil {
  15066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15067. return
  15068. } else {
  15069. if card_type == "1" {
  15070. bas := strings.Split(card_info, "|")
  15071. basNumber := bas[2]
  15072. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15073. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15074. infoStr := string(Iinfos)
  15075. idetinfoStr := string(Idetinfos)
  15076. psn := &models.HisPsn{
  15077. PsnNo: res.Output.Baseinfo.PsnNo,
  15078. PatientId: patient.ID,
  15079. Certno: res.Output.Baseinfo.Certno,
  15080. Gend: res.Output.Baseinfo.Gend,
  15081. Naty: res.Output.Baseinfo.Naty,
  15082. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15083. PsnName: res.Output.Baseinfo.PsnName,
  15084. Idetinfo: idetinfoStr,
  15085. Insuinfo: infoStr,
  15086. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15087. CardInfo: card_info,
  15088. VerifyNumber: busi_card_info,
  15089. }
  15090. service.CreateHisPsn(psn)
  15091. var rf []*ResultFive
  15092. json.Unmarshal([]byte(infoStr), &rf)
  15093. var insutypes []*ResultFive
  15094. var insutype string
  15095. var is390 int = 0
  15096. var is310 int = 0
  15097. for _, item := range rf {
  15098. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15099. insutypes = append(insutypes, item)
  15100. }
  15101. }
  15102. if len(insutypes) == 1 {
  15103. insutype = insutypes[0].Insutype
  15104. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15105. } else {
  15106. for _, i := range insutypes {
  15107. if i.Insutype == "390" {
  15108. is390 = 1
  15109. }
  15110. if i.Insutype == "310" {
  15111. is310 = 1
  15112. }
  15113. }
  15114. }
  15115. if is390 == 1 {
  15116. insutype = "390"
  15117. }
  15118. if is310 == 1 {
  15119. insutype = "310"
  15120. }
  15121. if len(insutypes) == 0 {
  15122. insutype = "310"
  15123. }
  15124. c.ServeSuccessJSON(map[string]interface{}{
  15125. "patient": patient,
  15126. "number": basNumber,
  15127. "insutype": insutype,
  15128. })
  15129. } else {
  15130. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15131. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15132. infoStr := string(Iinfos)
  15133. idetinfoStr := string(Idetinfos)
  15134. psn := &models.HisPsn{
  15135. PsnNo: res.Output.Baseinfo.PsnNo,
  15136. PatientId: patient.ID,
  15137. Certno: res.Output.Baseinfo.Certno,
  15138. Gend: res.Output.Baseinfo.Gend,
  15139. Naty: res.Output.Baseinfo.Naty,
  15140. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15141. PsnName: res.Output.Baseinfo.PsnName,
  15142. Idetinfo: idetinfoStr,
  15143. Insuinfo: infoStr,
  15144. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15145. CardInfo: card_info,
  15146. VerifyNumber: token,
  15147. }
  15148. service.CreateHisPsn(psn)
  15149. c.ServeSuccessJSON(map[string]interface{}{
  15150. "patient": patient,
  15151. "number": token,
  15152. })
  15153. }
  15154. }
  15155. } else {
  15156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15157. return
  15158. }
  15159. } else { //读卡失败
  15160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15161. return
  15162. }
  15163. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15164. var api string
  15165. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  15166. "&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
  15167. fmt.Println(api)
  15168. resp, requestErr := http.Get(api)
  15169. if requestErr != nil {
  15170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15171. return
  15172. }
  15173. body, ioErr := ioutil.ReadAll(resp.Body)
  15174. if ioErr != nil {
  15175. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15177. return
  15178. }
  15179. var respJSON map[string]interface{}
  15180. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15181. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15183. return
  15184. }
  15185. var status string
  15186. status = respJSON["data"].(map[string]interface{})["status"].(string)
  15187. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  15188. //console.log()
  15189. fmt.Println("type===")
  15190. fmt.Println(card_type)
  15191. var token string
  15192. var res ResultTwo //1101结果
  15193. //var res10265 ResultTwoesultTwo10265 //1101结果
  15194. var card_info string //卡信息
  15195. //var busi_card_info string
  15196. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  15197. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  15198. if status == "0" { //读卡成功
  15199. if card_type == "1" {
  15200. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15201. result, _ := json.Marshal(respJSON)
  15202. fmt.Println(result)
  15203. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15204. utils.ErrorLog("解析失败:%v", err)
  15205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15206. return
  15207. }
  15208. fmt.Println(res)
  15209. } else {
  15210. token = respJSON["data"].(map[string]interface{})["token"].(string)
  15211. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  15212. result, _ := json.Marshal(respJSON)
  15213. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15214. utils.ErrorLog("解析失败:%v", err)
  15215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15216. return
  15217. }
  15218. }
  15219. if res.Infcode == 0 {
  15220. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15221. if err == gorm.ErrRecordNotFound {
  15222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15223. return
  15224. } else if err != nil {
  15225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15226. return
  15227. } else {
  15228. if card_type == "1" {
  15229. bas := strings.Split(card_info, "|")
  15230. basNumber := bas[2]
  15231. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15232. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15233. infoStr := string(Iinfos)
  15234. idetinfoStr := string(Idetinfos)
  15235. psn := &models.HisPsn{
  15236. PsnNo: res.Output.Baseinfo.PsnNo,
  15237. PatientId: patient.ID,
  15238. Certno: res.Output.Baseinfo.Certno,
  15239. Gend: res.Output.Baseinfo.Gend,
  15240. Naty: res.Output.Baseinfo.Naty,
  15241. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15242. PsnName: res.Output.Baseinfo.PsnName,
  15243. Idetinfo: idetinfoStr,
  15244. Insuinfo: infoStr,
  15245. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15246. CardInfo: card_info,
  15247. //VerifyNumber: busi_card_info,
  15248. }
  15249. service.CreateHisPsn(psn)
  15250. var rf []*ResultFive
  15251. json.Unmarshal([]byte(infoStr), &rf)
  15252. var insutypes []*ResultFive
  15253. var insutype string
  15254. var is390 int = 0
  15255. var is310 int = 0
  15256. for _, item := range rf {
  15257. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15258. insutypes = append(insutypes, item)
  15259. }
  15260. }
  15261. if len(insutypes) == 1 {
  15262. insutype = insutypes[0].Insutype
  15263. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15264. } else {
  15265. for _, i := range insutypes {
  15266. if i.Insutype == "390" {
  15267. is390 = 1
  15268. }
  15269. if i.Insutype == "310" {
  15270. is310 = 1
  15271. }
  15272. }
  15273. }
  15274. if is390 == 1 {
  15275. insutype = "390"
  15276. }
  15277. if is310 == 1 {
  15278. insutype = "310"
  15279. }
  15280. if len(insutypes) == 0 {
  15281. insutype = "310"
  15282. }
  15283. c.ServeSuccessJSON(map[string]interface{}{
  15284. "patient": patient,
  15285. "number": basNumber,
  15286. "insutype": insutype,
  15287. })
  15288. } else {
  15289. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15290. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15291. infoStr := string(Iinfos)
  15292. idetinfoStr := string(Idetinfos)
  15293. psn := &models.HisPsn{
  15294. PsnNo: res.Output.Baseinfo.PsnNo,
  15295. PatientId: patient.ID,
  15296. Certno: res.Output.Baseinfo.Certno,
  15297. Gend: res.Output.Baseinfo.Gend,
  15298. Naty: res.Output.Baseinfo.Naty,
  15299. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15300. PsnName: res.Output.Baseinfo.PsnName,
  15301. Idetinfo: idetinfoStr,
  15302. Insuinfo: infoStr,
  15303. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15304. CardInfo: card_info,
  15305. VerifyNumber: token,
  15306. }
  15307. service.CreateHisPsn(psn)
  15308. c.ServeSuccessJSON(map[string]interface{}{
  15309. "patient": patient,
  15310. "number": token,
  15311. })
  15312. }
  15313. }
  15314. } else {
  15315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15316. return
  15317. }
  15318. } else { //读卡失败
  15319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15320. return
  15321. }
  15322. } else {
  15323. if initFlag == 0 {
  15324. c.TestGetBasBaseInit()
  15325. }
  15326. basStr := c.GetBasBaseInfo()
  15327. if len(basStr) == 0 {
  15328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15329. return
  15330. }
  15331. fmt.Println(basStr)
  15332. bas := strings.Split(basStr, "|")
  15333. basNumber := bas[1]
  15334. fmt.Println(basNumber)
  15335. card_sn := bas[3]
  15336. fmt.Println(card_sn)
  15337. cardNumber := bas[2]
  15338. fmt.Println(cardNumber)
  15339. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  15340. var result string
  15341. if bas[0][:2] == "44" {
  15342. 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)
  15343. } else {
  15344. 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)
  15345. }
  15346. var dat map[string]interface{}
  15347. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15348. fmt.Println(dat)
  15349. } else {
  15350. fmt.Println(err)
  15351. }
  15352. userJSONBytes, _ := json.Marshal(dat)
  15353. var res ResultTwo
  15354. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15355. utils.ErrorLog("解析失败:%v", err)
  15356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15357. return
  15358. }
  15359. if res.Infcode == 0 {
  15360. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  15361. if err == gorm.ErrRecordNotFound {
  15362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15363. return
  15364. } else if err != nil {
  15365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15366. return
  15367. } else {
  15368. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15369. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15370. infoStr := string(Iinfos)
  15371. idetinfoStr := string(Idetinfos)
  15372. var rf []*ResultFive
  15373. json.Unmarshal([]byte(infoStr), &rf)
  15374. var insutypes []*ResultFive
  15375. var insutype string
  15376. var is390 int = 0
  15377. var is310 int = 0
  15378. var insuplc_admdvs string
  15379. for _, item := range rf {
  15380. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15381. insutypes = append(insutypes, item)
  15382. }
  15383. }
  15384. if len(insutypes) == 1 {
  15385. insutype = insutypes[0].Insutype
  15386. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15387. } else {
  15388. for _, i := range insutypes {
  15389. if i.Insutype == "390" {
  15390. is390 = 1
  15391. }
  15392. if i.Insutype == "310" {
  15393. is310 = 1
  15394. }
  15395. }
  15396. }
  15397. if is390 == 1 {
  15398. insutype = "390"
  15399. }
  15400. if is310 == 1 {
  15401. insutype = "310"
  15402. }
  15403. if len(insutypes) == 0 {
  15404. insutype = "310"
  15405. }
  15406. for _, item := range rf {
  15407. if item.Insutype == insutype {
  15408. insuplc_admdvs = item.InsuplcAdmdvs
  15409. }
  15410. }
  15411. psn := &models.HisPsn{
  15412. PsnNo: res.Output.Baseinfo.PsnNo,
  15413. PatientId: patient.ID,
  15414. Certno: res.Output.Baseinfo.Certno,
  15415. Gend: res.Output.Baseinfo.Gend,
  15416. Naty: res.Output.Baseinfo.Naty,
  15417. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15418. PsnName: res.Output.Baseinfo.PsnName,
  15419. Idetinfo: idetinfoStr,
  15420. Insuinfo: infoStr,
  15421. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15422. CardInfo: basStr,
  15423. VerifyNumber: "",
  15424. InsuplcAdmdvs: insuplc_admdvs,
  15425. }
  15426. service.CreateHisPsn(psn)
  15427. c.ServeSuccessJSON(map[string]interface{}{
  15428. "patient": patient,
  15429. "insutype": insutype,
  15430. "number": basNumber,
  15431. })
  15432. }
  15433. } else {
  15434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15435. return
  15436. }
  15437. break
  15438. }
  15439. case 2:
  15440. if miConfig.MdtrtareaAdmvs == "430800" {
  15441. if initFlag == 0 {
  15442. c.TestGetHnBasBaseInit()
  15443. }
  15444. SFZStr := c.GetSFZBaseInfo()
  15445. if len(SFZStr) == 0 {
  15446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  15447. return
  15448. }
  15449. fmt.Println(SFZStr)
  15450. id_card_str := strings.Split(SFZStr, "^")
  15451. card_no := id_card_str[0]
  15452. //patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  15453. //name := id_card_str[1]
  15454. //name = ConvertToString(name, "gbk", "utf-8")
  15455. 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)
  15456. var dat map[string]interface{}
  15457. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15458. fmt.Println(dat)
  15459. } else {
  15460. fmt.Println(err)
  15461. }
  15462. userJSONBytes, _ := json.Marshal(dat)
  15463. var res ResultTwo
  15464. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15465. utils.ErrorLog("解析失败:%v", err)
  15466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15467. return
  15468. }
  15469. if res.Infcode == 0 {
  15470. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  15471. if err == gorm.ErrRecordNotFound {
  15472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15473. return
  15474. } else if err != nil {
  15475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15476. return
  15477. } else {
  15478. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15479. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15480. infoStr := string(Iinfos)
  15481. idetinfoStr := string(Idetinfos)
  15482. var rf []*ResultFive
  15483. json.Unmarshal([]byte(infoStr), &rf)
  15484. var insutypes []*ResultFive
  15485. var insutype string
  15486. var is390 int = 0
  15487. var is310 int = 0
  15488. for _, item := range rf {
  15489. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15490. insutypes = append(insutypes, item)
  15491. }
  15492. }
  15493. if len(insutypes) == 1 {
  15494. insutype = insutypes[0].Insutype
  15495. } else {
  15496. for _, i := range insutypes {
  15497. if i.Insutype == "390" {
  15498. is390 = 1
  15499. }
  15500. if i.Insutype == "310" {
  15501. is310 = 1
  15502. }
  15503. }
  15504. }
  15505. if is390 == 1 {
  15506. insutype = "390"
  15507. }
  15508. if is310 == 1 {
  15509. insutype = "310"
  15510. }
  15511. if len(insutypes) == 0 {
  15512. insutype = "310"
  15513. }
  15514. var InsuplcAdmdvs string
  15515. for _, item := range rf {
  15516. if item.Insutype == insutype {
  15517. InsuplcAdmdvs = item.InsuplcAdmdvs
  15518. }
  15519. }
  15520. psn := &models.HisPsn{
  15521. PsnNo: res.Output.Baseinfo.PsnNo,
  15522. PatientId: patient.ID,
  15523. Certno: res.Output.Baseinfo.Certno,
  15524. Gend: res.Output.Baseinfo.Gend,
  15525. Naty: res.Output.Baseinfo.Naty,
  15526. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15527. PsnName: res.Output.Baseinfo.PsnName,
  15528. Idetinfo: idetinfoStr,
  15529. Insuinfo: infoStr,
  15530. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15531. CardInfo: SFZStr,
  15532. VerifyNumber: "",
  15533. InsuplcAdmdvs: InsuplcAdmdvs,
  15534. }
  15535. service.CreateHisPsn(psn)
  15536. c.ServeSuccessJSON(map[string]interface{}{
  15537. "patient": patient,
  15538. "number": card_no,
  15539. "insutype": insutype,
  15540. })
  15541. }
  15542. } else {
  15543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15544. return
  15545. }
  15546. } else if miConfig.MdtrtareaAdmvs == "420200" {
  15547. var res ResultTwo
  15548. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  15549. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15550. "&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)
  15551. resp, requestErr := http.Get(api)
  15552. if requestErr != nil {
  15553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15554. return
  15555. }
  15556. body, ioErr := ioutil.ReadAll(resp.Body)
  15557. if ioErr != nil {
  15558. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15560. return
  15561. }
  15562. var respJSON map[string]interface{}
  15563. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15564. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15566. return
  15567. }
  15568. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15569. result, _ := json.Marshal(respJSON)
  15570. fmt.Println("log")
  15571. fmt.Println(string(result))
  15572. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15573. utils.ErrorLog("解析失败:%v", err)
  15574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15575. return
  15576. }
  15577. if res.Infcode == 0 {
  15578. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15579. if err == gorm.ErrRecordNotFound {
  15580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15581. return
  15582. } else if err != nil {
  15583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15584. return
  15585. } else {
  15586. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15587. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15588. infoStr := string(Iinfos)
  15589. idetinfoStr := string(Idetinfos)
  15590. psn := &models.HisPsn{
  15591. PsnNo: res.Output.Baseinfo.PsnNo,
  15592. PatientId: patient.ID,
  15593. Certno: res.Output.Baseinfo.Certno,
  15594. Gend: res.Output.Baseinfo.Gend,
  15595. Naty: res.Output.Baseinfo.Naty,
  15596. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15597. PsnName: res.Output.Baseinfo.PsnName,
  15598. Idetinfo: idetinfoStr,
  15599. Insuinfo: infoStr,
  15600. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15601. }
  15602. service.CreateHisPsn(psn)
  15603. c.ServeSuccessJSON(map[string]interface{}{
  15604. "patient": patient,
  15605. "number": res.Output.Baseinfo.Certno,
  15606. })
  15607. }
  15608. } else {
  15609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15610. return
  15611. }
  15612. } else if miConfig.MdtrtareaAdmvs == "421182" {
  15613. var res ResultTwo
  15614. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  15615. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15616. "&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)
  15617. resp, requestErr := http.Get(api)
  15618. if requestErr != nil {
  15619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15620. return
  15621. }
  15622. body, ioErr := ioutil.ReadAll(resp.Body)
  15623. if ioErr != nil {
  15624. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15626. return
  15627. }
  15628. var respJSON map[string]interface{}
  15629. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15630. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15632. return
  15633. }
  15634. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15635. result, _ := json.Marshal(respJSON)
  15636. fmt.Println("log")
  15637. fmt.Println(string(result))
  15638. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15639. utils.ErrorLog("解析失败:%v", err)
  15640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15641. return
  15642. }
  15643. if res.Infcode == 0 {
  15644. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15645. if err == gorm.ErrRecordNotFound {
  15646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15647. return
  15648. } else if err != nil {
  15649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15650. return
  15651. } else {
  15652. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15653. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15654. infoStr := string(Iinfos)
  15655. idetinfoStr := string(Idetinfos)
  15656. psn := &models.HisPsn{
  15657. PsnNo: res.Output.Baseinfo.PsnNo,
  15658. PatientId: patient.ID,
  15659. Certno: res.Output.Baseinfo.Certno,
  15660. Gend: res.Output.Baseinfo.Gend,
  15661. Naty: res.Output.Baseinfo.Naty,
  15662. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15663. PsnName: res.Output.Baseinfo.PsnName,
  15664. Idetinfo: idetinfoStr,
  15665. Insuinfo: infoStr,
  15666. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15667. }
  15668. service.CreateHisPsn(psn)
  15669. c.ServeSuccessJSON(map[string]interface{}{
  15670. "patient": patient,
  15671. "number": res.Output.Baseinfo.Certno,
  15672. })
  15673. }
  15674. } else {
  15675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15676. return
  15677. }
  15678. } else if miConfig.MdtrtareaAdmvs == "420902" {
  15679. var res ResultTwo
  15680. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  15681. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15682. "&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)
  15683. resp, requestErr := http.Get(api)
  15684. if requestErr != nil {
  15685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15686. return
  15687. }
  15688. body, ioErr := ioutil.ReadAll(resp.Body)
  15689. if ioErr != nil {
  15690. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15692. return
  15693. }
  15694. var respJSON map[string]interface{}
  15695. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15696. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15698. return
  15699. }
  15700. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15701. result, _ := json.Marshal(respJSON)
  15702. fmt.Println("log")
  15703. fmt.Println(string(result))
  15704. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15705. utils.ErrorLog("解析失败:%v", err)
  15706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15707. return
  15708. }
  15709. if res.Infcode == 0 {
  15710. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15711. if err == gorm.ErrRecordNotFound {
  15712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15713. return
  15714. } else if err != nil {
  15715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15716. return
  15717. } else {
  15718. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15719. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15720. infoStr := string(Iinfos)
  15721. idetinfoStr := string(Idetinfos)
  15722. var rf []*ResultFive
  15723. json.Unmarshal([]byte(infoStr), &rf)
  15724. var insutypes []*ResultFive
  15725. var insutype string
  15726. var is390 int = 0
  15727. var is310 int = 0
  15728. for _, item := range rf {
  15729. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  15730. insutypes = append(insutypes, item)
  15731. }
  15732. }
  15733. if len(insutypes) == 1 {
  15734. insutype = insutypes[0].Insutype
  15735. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15736. } else {
  15737. for _, i := range insutypes {
  15738. if i.Insutype == "390" {
  15739. is390 = 1
  15740. }
  15741. if i.Insutype == "310" {
  15742. is310 = 1
  15743. }
  15744. }
  15745. }
  15746. if is390 == 1 {
  15747. insutype = "390"
  15748. }
  15749. if is310 == 1 {
  15750. insutype = "310"
  15751. }
  15752. if len(insutypes) == 0 {
  15753. insutype = "390"
  15754. }
  15755. var insuplc_admdvs string
  15756. for _, item := range rf {
  15757. if item.Insutype == insutype {
  15758. insuplc_admdvs = item.InsuplcAdmdvs
  15759. }
  15760. }
  15761. psn := &models.HisPsn{
  15762. PsnNo: res.Output.Baseinfo.PsnNo,
  15763. PatientId: patient.ID,
  15764. Certno: res.Output.Baseinfo.Certno,
  15765. Gend: res.Output.Baseinfo.Gend,
  15766. Naty: res.Output.Baseinfo.Naty,
  15767. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15768. PsnName: res.Output.Baseinfo.PsnName,
  15769. Idetinfo: idetinfoStr,
  15770. Insuinfo: infoStr,
  15771. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15772. InsuplcAdmdvs: insuplc_admdvs,
  15773. }
  15774. service.CreateHisPsn(psn)
  15775. c.ServeSuccessJSON(map[string]interface{}{
  15776. "patient": patient,
  15777. "number": res.Output.Baseinfo.Certno,
  15778. })
  15779. }
  15780. } else {
  15781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15782. return
  15783. }
  15784. } else if miConfig.MdtrtareaAdmvs == "450721" {
  15785. res := c.GetoleInfo()
  15786. if res.Infcode == 0 {
  15787. var result string
  15788. if res.Output.MdtrtCertType == "01" {
  15789. 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)
  15790. } else if res.Output.MdtrtCertType == "02" {
  15791. 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)
  15792. } else if res.Output.MdtrtCertType == "03" {
  15793. 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)
  15794. }
  15795. var dat map[string]interface{}
  15796. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15797. fmt.Println(dat)
  15798. } else {
  15799. fmt.Println(err)
  15800. }
  15801. userJSONBytes, _ := json.Marshal(dat)
  15802. var res2 ResultTwo
  15803. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15804. utils.ErrorLog("解析失败:%v", err)
  15805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15806. return
  15807. }
  15808. if res2.Infcode == 0 {
  15809. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  15810. if err == gorm.ErrRecordNotFound {
  15811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15812. return
  15813. } else if err != nil {
  15814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15815. return
  15816. } else {
  15817. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  15818. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  15819. infoStr := string(Iinfos)
  15820. idetinfoStr := string(Idetinfos)
  15821. var rf []*ResultFive
  15822. json.Unmarshal([]byte(infoStr), &rf)
  15823. var insutypes []*ResultFive
  15824. var insutype string
  15825. var is390 int = 0
  15826. var is310 int = 0
  15827. //var insuplc_admdvs string
  15828. for _, item := range rf {
  15829. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15830. insutypes = append(insutypes, item)
  15831. }
  15832. }
  15833. if len(insutypes) == 1 {
  15834. insutype = insutypes[0].Insutype
  15835. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15836. } else {
  15837. for _, i := range insutypes {
  15838. if i.Insutype == "390" {
  15839. is390 = 1
  15840. }
  15841. if i.Insutype == "310" {
  15842. is310 = 1
  15843. }
  15844. }
  15845. }
  15846. if is390 == 1 {
  15847. insutype = "390"
  15848. }
  15849. if is310 == 1 {
  15850. insutype = "310"
  15851. }
  15852. if len(insutypes) == 0 {
  15853. insutype = "310"
  15854. }
  15855. psn := &models.HisPsn{
  15856. PsnNo: res2.Output.Baseinfo.PsnNo,
  15857. PatientId: patient.ID,
  15858. //Brdy: res2.Output.Baseinfo.Brdy,
  15859. Certno: res2.Output.Baseinfo.Certno,
  15860. Gend: res2.Output.Baseinfo.Gend,
  15861. Naty: res2.Output.Baseinfo.Naty,
  15862. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  15863. PsnName: res2.Output.Baseinfo.PsnName,
  15864. Idetinfo: idetinfoStr,
  15865. Insuinfo: infoStr,
  15866. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15867. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  15868. VerifyNumber: res.Output.EcToken,
  15869. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  15870. }
  15871. service.CreateHisPsn(psn)
  15872. var balc float64
  15873. for _, item := range rf {
  15874. if item.Insutype == insutype {
  15875. balc = item.Balc
  15876. }
  15877. }
  15878. c.ServeSuccessJSON(map[string]interface{}{
  15879. "patient": patient,
  15880. "number": res.Output.CardNo,
  15881. "insutype": insutype,
  15882. "blac": balc,
  15883. "desc": idetinfoStr,
  15884. })
  15885. }
  15886. } else {
  15887. c.ServeSuccessJSON(map[string]interface{}{
  15888. "failed_code": -10,
  15889. "msg": res2.ErrMsg,
  15890. })
  15891. }
  15892. } else {
  15893. c.ServeSuccessJSON(map[string]interface{}{
  15894. "failed_code": -10,
  15895. "msg": res.ErrMsg,
  15896. })
  15897. }
  15898. } else if miConfig.MdtrtareaAdmvs == "340699" {
  15899. var insuplc_admdvs string
  15900. if len(patient.InsuplcAdmdvs) > 0 {
  15901. insuplc_admdvs = patient.InsuplcAdmdvs
  15902. } else {
  15903. if len(insuplc_admdvs_str) > 0 {
  15904. insuplc_admdvs = insuplc_admdvs_str
  15905. } else {
  15906. insuplc_admdvs = miConfig.InsuplcAdmdvs
  15907. }
  15908. }
  15909. //请求内网数据
  15910. api := miConfig.SecretKey + "ahyb/1101?url=" + miConfig.Url + "&cert_no=" + patient.IdCardNo +
  15911. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15912. "&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=" + ""
  15913. resp, requestErr := http.Get(api)
  15914. if requestErr != nil {
  15915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15916. return
  15917. }
  15918. body, ioErr := ioutil.ReadAll(resp.Body)
  15919. if ioErr != nil {
  15920. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15922. return
  15923. }
  15924. var respJSON map[string]interface{}
  15925. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15926. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15928. return
  15929. }
  15930. status := respJSON["data"].(map[string]interface{})["status"].(string)
  15931. if status == "0" {
  15932. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  15933. c.ServeSuccessJSON(map[string]interface{}{
  15934. "failed_code": -10,
  15935. "msg": err_msg,
  15936. })
  15937. return
  15938. }
  15939. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15940. var res ResultTwo
  15941. result, _ := json.Marshal(respJSON)
  15942. fmt.Println("log")
  15943. fmt.Println(string(result))
  15944. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15945. utils.ErrorLog("解析失败:%v", err)
  15946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15947. return
  15948. }
  15949. if res.Infcode == 0 {
  15950. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  15951. if err == gorm.ErrRecordNotFound {
  15952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  15953. return
  15954. } else if err != nil {
  15955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  15956. return
  15957. } else {
  15958. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15959. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15960. infoStr := string(Iinfos)
  15961. idetinfoStr := string(Idetinfos)
  15962. psn := &models.HisPsn{
  15963. PsnNo: res.Output.Baseinfo.PsnNo,
  15964. PatientId: patient.ID,
  15965. Certno: res.Output.Baseinfo.Certno,
  15966. Gend: res.Output.Baseinfo.Gend,
  15967. Naty: res.Output.Baseinfo.Naty,
  15968. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15969. PsnName: res.Output.Baseinfo.PsnName,
  15970. Idetinfo: idetinfoStr,
  15971. Insuinfo: infoStr,
  15972. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15973. }
  15974. service.CreateHisPsn(psn)
  15975. var rf []*ResultFive
  15976. json.Unmarshal([]byte(infoStr), &rf)
  15977. var insutypes []*ResultFive
  15978. var is390 int = 0
  15979. var is310 int = 0
  15980. var insutype string
  15981. for _, item := range rf {
  15982. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15983. insutypes = append(insutypes, item)
  15984. }
  15985. }
  15986. if len(insutypes) == 1 {
  15987. insutype = insutypes[0].Insutype
  15988. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15989. } else {
  15990. for _, i := range insutypes {
  15991. if i.Insutype == "390" {
  15992. is390 = 1
  15993. }
  15994. if i.Insutype == "310" {
  15995. is310 = 1
  15996. }
  15997. }
  15998. }
  15999. if is390 == 1 {
  16000. insutype = "390"
  16001. }
  16002. if is310 == 1 {
  16003. insutype = "310"
  16004. }
  16005. if len(insutypes) == 0 {
  16006. insutype = "390"
  16007. }
  16008. c.ServeSuccessJSON(map[string]interface{}{
  16009. "patient": patient,
  16010. "insutype": insutype,
  16011. "number": res.Output.Baseinfo.Certno,
  16012. "info": res,
  16013. })
  16014. }
  16015. } else {
  16016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16017. return
  16018. }
  16019. } else {
  16020. SFZStr := c.GetSFZBaseInfo()
  16021. id_card_str := strings.Split(SFZStr, "^")
  16022. id_card_number := id_card_str[0]
  16023. card_sn := ""
  16024. 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)
  16025. var dat map[string]interface{}
  16026. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16027. fmt.Println(dat)
  16028. } else {
  16029. fmt.Println(err)
  16030. }
  16031. userJSONBytes, _ := json.Marshal(dat)
  16032. var res ResultTwo
  16033. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16034. utils.ErrorLog("解析失败:%v", err)
  16035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16036. return
  16037. }
  16038. if res.Infcode == 0 {
  16039. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  16040. if err == gorm.ErrRecordNotFound {
  16041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16042. return
  16043. } else if err != nil {
  16044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16045. return
  16046. } else {
  16047. c.ServeSuccessJSON(map[string]interface{}{
  16048. "patient": patient,
  16049. "number": id_card_number,
  16050. })
  16051. }
  16052. } else {
  16053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16054. return
  16055. }
  16056. }
  16057. break
  16058. case 3:
  16059. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  16060. var api string
  16061. if miConfig.MdtrtareaAdmvs == "320830" {
  16062. api = miConfig.AppSecret + "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) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  16064. fmt.Println(api)
  16065. } else if miConfig.MdtrtareaAdmvs == "320921" {
  16066. 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 +
  16067. "&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
  16068. fmt.Println(api)
  16069. } else {
  16070. 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 +
  16071. "&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)
  16072. }
  16073. resp, requestErr := http.Get(api)
  16074. if requestErr != nil {
  16075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16076. return
  16077. }
  16078. body, ioErr := ioutil.ReadAll(resp.Body)
  16079. if ioErr != nil {
  16080. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16082. return
  16083. }
  16084. var respJSON map[string]interface{}
  16085. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16086. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16088. return
  16089. }
  16090. var status string
  16091. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16092. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16093. var token string
  16094. var res ResultTwo //1101结果
  16095. var res10265 ResultTwo10265 //1101结果
  16096. var card_info string //卡信息
  16097. var busi_card_info string
  16098. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16099. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16100. if status == "0" { //读卡成功
  16101. if card_type == "1" {
  16102. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16103. result, _ := json.Marshal(respJSON)
  16104. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16105. utils.ErrorLog("解析失败:%v", err)
  16106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16107. return
  16108. }
  16109. res.ErrMsg = res10265.ErrMsg
  16110. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16111. res.Infcode = infocode
  16112. res.Output = res10265.Output
  16113. res.InfRefmsgid = res10265.InfRefmsgid
  16114. } else {
  16115. //var card_info string //卡信息
  16116. //var busi_card_info string
  16117. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16118. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16119. //fmt.Println(card_info)
  16120. //fmt.Println(busi_card_info)
  16121. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16122. result, _ := json.Marshal(respJSON)
  16123. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16124. utils.ErrorLog("解析失败:%v", err)
  16125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16126. return
  16127. }
  16128. res.ErrMsg = res10265.ErrMsg
  16129. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16130. res.Infcode = infocode
  16131. res.Output = res10265.Output
  16132. res.InfRefmsgid = res10265.InfRefmsgid
  16133. }
  16134. if res.Infcode == 0 {
  16135. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16136. if err == gorm.ErrRecordNotFound {
  16137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16138. return
  16139. } else if err != nil {
  16140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16141. return
  16142. } else {
  16143. if card_type == "1" {
  16144. bas := strings.Split(card_info, "|")
  16145. basNumber := bas[2]
  16146. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16147. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16148. infoStr := string(Iinfos)
  16149. idetinfoStr := string(Idetinfos)
  16150. psn := &models.HisPsn{
  16151. PsnNo: res.Output.Baseinfo.PsnNo,
  16152. PatientId: patient.ID,
  16153. Certno: res.Output.Baseinfo.Certno,
  16154. //Brdy: res.Output.Baseinfo.Brdy,
  16155. Gend: res.Output.Baseinfo.Gend,
  16156. Naty: res.Output.Baseinfo.Naty,
  16157. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16158. PsnName: res.Output.Baseinfo.PsnName,
  16159. Idetinfo: idetinfoStr,
  16160. Insuinfo: infoStr,
  16161. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16162. CardInfo: card_info,
  16163. VerifyNumber: busi_card_info,
  16164. }
  16165. service.CreateHisPsn(psn)
  16166. c.ServeSuccessJSON(map[string]interface{}{
  16167. "patient": patient,
  16168. "number": basNumber,
  16169. })
  16170. } else {
  16171. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16172. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16173. infoStr := string(Iinfos)
  16174. idetinfoStr := string(Idetinfos)
  16175. psn := &models.HisPsn{
  16176. PsnNo: res.Output.Baseinfo.PsnNo,
  16177. PatientId: patient.ID,
  16178. Certno: res.Output.Baseinfo.Certno,
  16179. Gend: res.Output.Baseinfo.Gend,
  16180. Naty: res.Output.Baseinfo.Naty,
  16181. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16182. PsnName: res.Output.Baseinfo.PsnName,
  16183. Idetinfo: idetinfoStr,
  16184. Insuinfo: infoStr,
  16185. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16186. CardInfo: card_info,
  16187. VerifyNumber: token,
  16188. }
  16189. service.CreateHisPsn(psn)
  16190. var rf []*ResultFive
  16191. json.Unmarshal([]byte(infoStr), &rf)
  16192. var insutypes []*ResultFive
  16193. var insutype string
  16194. var is390 int = 0
  16195. var is310 int = 0
  16196. for _, item := range rf {
  16197. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16198. insutypes = append(insutypes, item)
  16199. }
  16200. }
  16201. if len(insutypes) == 1 {
  16202. insutype = insutypes[0].Insutype
  16203. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16204. } else {
  16205. for _, i := range insutypes {
  16206. if i.Insutype == "390" {
  16207. is390 = 1
  16208. }
  16209. if i.Insutype == "310" {
  16210. is310 = 1
  16211. }
  16212. }
  16213. }
  16214. if is390 == 1 {
  16215. insutype = "390"
  16216. }
  16217. if is310 == 1 {
  16218. insutype = "310"
  16219. }
  16220. if len(insutypes) == 0 {
  16221. insutype = "310"
  16222. }
  16223. c.ServeSuccessJSON(map[string]interface{}{
  16224. "patient": patient,
  16225. "number": token,
  16226. "insutype": insutype,
  16227. })
  16228. }
  16229. }
  16230. } else {
  16231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16232. return
  16233. }
  16234. } else { //读卡失败
  16235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16236. return
  16237. }
  16238. }
  16239. break
  16240. case 4:
  16241. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  16242. var api string
  16243. if miConfig.MdtrtareaAdmvs == "320830" {
  16244. api = miConfig.AppSecret + "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) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  16246. fmt.Println(api)
  16247. } else if miConfig.MdtrtareaAdmvs == "320921" {
  16248. 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 +
  16249. "&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
  16250. fmt.Println(api)
  16251. } else {
  16252. 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 +
  16253. "&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)
  16254. }
  16255. resp, requestErr := http.Get(api)
  16256. if requestErr != nil {
  16257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16258. return
  16259. }
  16260. body, ioErr := ioutil.ReadAll(resp.Body)
  16261. if ioErr != nil {
  16262. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16264. return
  16265. }
  16266. var respJSON map[string]interface{}
  16267. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16270. return
  16271. }
  16272. var status string
  16273. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16274. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16275. var token string
  16276. var res ResultTwo //1101结果
  16277. var res10265 ResultTwo10265 //1101结果
  16278. if status == "0" { //读卡成功
  16279. var card_info string //卡信息
  16280. var busi_card_info string
  16281. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16282. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16283. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16284. fmt.Println(card_info)
  16285. fmt.Println(busi_card_info)
  16286. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16287. result, _ := json.Marshal(respJSON)
  16288. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16289. utils.ErrorLog("解析失败:%v", err)
  16290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16291. return
  16292. }
  16293. res.ErrMsg = res10265.ErrMsg
  16294. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16295. res.Infcode = infocode
  16296. res.Output = res10265.Output
  16297. res.InfRefmsgid = res10265.InfRefmsgid
  16298. if res.Infcode == 0 {
  16299. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16300. if err == gorm.ErrRecordNotFound {
  16301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16302. return
  16303. } else if err != nil {
  16304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16305. return
  16306. } else {
  16307. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16308. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16309. infoStr := string(Iinfos)
  16310. idetinfoStr := string(Idetinfos)
  16311. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  16312. psn := &models.HisPsn{
  16313. PsnNo: res.Output.Baseinfo.PsnNo,
  16314. PatientId: patient.ID,
  16315. Certno: res.Output.Baseinfo.Certno,
  16316. Brdy: b,
  16317. Age: float64(age),
  16318. //Brdy: res.Output.Baseinfo.Brdy,
  16319. Gend: res.Output.Baseinfo.Gend,
  16320. Naty: res.Output.Baseinfo.Naty,
  16321. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16322. PsnName: res.Output.Baseinfo.PsnName,
  16323. Idetinfo: idetinfoStr,
  16324. Insuinfo: infoStr,
  16325. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16326. CardInfo: card_info,
  16327. VerifyNumber: token,
  16328. }
  16329. var rf []*ResultFive
  16330. json.Unmarshal([]byte(infoStr), &rf)
  16331. var insutypes []*ResultFive
  16332. var insutype string
  16333. var is390 int = 0
  16334. var is310 int = 0
  16335. for _, item := range rf {
  16336. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16337. insutypes = append(insutypes, item)
  16338. }
  16339. }
  16340. if len(insutypes) == 1 {
  16341. insutype = insutypes[0].Insutype
  16342. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16343. } else {
  16344. for _, i := range insutypes {
  16345. if i.Insutype == "390" {
  16346. is390 = 1
  16347. }
  16348. if i.Insutype == "310" {
  16349. is310 = 1
  16350. }
  16351. }
  16352. }
  16353. if is390 == 1 {
  16354. insutype = "390"
  16355. }
  16356. if is310 == 1 {
  16357. insutype = "310"
  16358. }
  16359. if len(insutypes) == 0 {
  16360. insutype = "310"
  16361. }
  16362. service.CreateHisPsn(psn)
  16363. c.ServeSuccessJSON(map[string]interface{}{
  16364. "patient": patient,
  16365. "number": token,
  16366. "insutype": insutype,
  16367. })
  16368. }
  16369. } else {
  16370. c.ServeSuccessJSON(map[string]interface{}{
  16371. "failed_code": -10,
  16372. "msg": res.ErrMsg,
  16373. })
  16374. }
  16375. } else { //读卡失败
  16376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16377. return
  16378. }
  16379. } else if miConfig.MdtrtareaAdmvs == "341203" {
  16380. var api string
  16381. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16382. "&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
  16383. resp, requestErr := http.Get(api)
  16384. if requestErr != nil {
  16385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16386. return
  16387. }
  16388. body, ioErr := ioutil.ReadAll(resp.Body)
  16389. if ioErr != nil {
  16390. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16392. return
  16393. }
  16394. var respJSON map[string]interface{}
  16395. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16396. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16398. return
  16399. }
  16400. var status string
  16401. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16402. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16403. var token string
  16404. var res ResultTwo //1101结果
  16405. if status == "1" { //读卡成功
  16406. var card_info string //卡信息
  16407. var busi_card_info string
  16408. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16409. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16410. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16411. fmt.Println(card_info)
  16412. fmt.Println(busi_card_info)
  16413. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16414. result, _ := json.Marshal(respJSON)
  16415. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16416. utils.ErrorLog("解析失败:%v", err)
  16417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16418. return
  16419. }
  16420. if res.Infcode == 0 {
  16421. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16422. if err == gorm.ErrRecordNotFound {
  16423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16424. return
  16425. } else if err != nil {
  16426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16427. return
  16428. } else {
  16429. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16430. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16431. infoStr := string(Iinfos)
  16432. idetinfoStr := string(Idetinfos)
  16433. psn := &models.HisPsn{
  16434. PsnNo: res.Output.Baseinfo.PsnNo,
  16435. PatientId: patient.ID,
  16436. Certno: res.Output.Baseinfo.Certno,
  16437. Gend: res.Output.Baseinfo.Gend,
  16438. Naty: res.Output.Baseinfo.Naty,
  16439. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16440. PsnName: res.Output.Baseinfo.PsnName,
  16441. Idetinfo: idetinfoStr,
  16442. Insuinfo: infoStr,
  16443. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16444. CardInfo: card_info,
  16445. VerifyNumber: token,
  16446. }
  16447. var rf []*ResultFive
  16448. json.Unmarshal([]byte(infoStr), &rf)
  16449. var insutypes []*ResultFive
  16450. var insutype string
  16451. var is390 int = 0
  16452. var is310 int = 0
  16453. for _, item := range rf {
  16454. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16455. insutypes = append(insutypes, item)
  16456. }
  16457. }
  16458. if len(insutypes) == 1 {
  16459. insutype = insutypes[0].Insutype
  16460. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16461. } else {
  16462. for _, i := range insutypes {
  16463. if i.Insutype == "390" {
  16464. is390 = 1
  16465. }
  16466. if i.Insutype == "310" {
  16467. is310 = 1
  16468. }
  16469. }
  16470. }
  16471. if is390 == 1 {
  16472. insutype = "390"
  16473. }
  16474. if is310 == 1 {
  16475. insutype = "310"
  16476. }
  16477. if len(insutypes) == 0 {
  16478. insutype = "310"
  16479. }
  16480. service.CreateHisPsn(psn)
  16481. c.ServeSuccessJSON(map[string]interface{}{
  16482. "patient": patient,
  16483. "number": token,
  16484. "insutype": insutype,
  16485. })
  16486. }
  16487. } else {
  16488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16489. return
  16490. }
  16491. } else { //读卡失败
  16492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16493. return
  16494. }
  16495. } else if miConfig.MdtrtareaAdmvs == "340699" {
  16496. var api string
  16497. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  16498. "&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
  16499. resp, requestErr := http.Get(api)
  16500. if requestErr != nil {
  16501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16502. return
  16503. }
  16504. body, ioErr := ioutil.ReadAll(resp.Body)
  16505. if ioErr != nil {
  16506. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16508. return
  16509. }
  16510. var respJSON map[string]interface{}
  16511. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16512. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16514. return
  16515. }
  16516. var status string
  16517. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16518. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16519. var token string
  16520. var res ResultTwo //1101结果
  16521. if status == "1" { //读卡成功
  16522. var card_info string //卡信息
  16523. var busi_card_info string
  16524. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16525. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16526. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16527. fmt.Println(card_info)
  16528. fmt.Println(busi_card_info)
  16529. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16530. result, _ := json.Marshal(respJSON)
  16531. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16532. utils.ErrorLog("解析失败:%v", err)
  16533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16534. return
  16535. }
  16536. if res.Infcode == 0 {
  16537. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16538. if err == gorm.ErrRecordNotFound {
  16539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16540. return
  16541. } else if err != nil {
  16542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16543. return
  16544. } else {
  16545. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16546. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16547. infoStr := string(Iinfos)
  16548. idetinfoStr := string(Idetinfos)
  16549. psn := &models.HisPsn{
  16550. PsnNo: res.Output.Baseinfo.PsnNo,
  16551. PatientId: patient.ID,
  16552. Certno: res.Output.Baseinfo.Certno,
  16553. Gend: res.Output.Baseinfo.Gend,
  16554. Naty: res.Output.Baseinfo.Naty,
  16555. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16556. PsnName: res.Output.Baseinfo.PsnName,
  16557. Idetinfo: idetinfoStr,
  16558. Insuinfo: infoStr,
  16559. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16560. CardInfo: card_info,
  16561. VerifyNumber: token,
  16562. }
  16563. var rf []*ResultFive
  16564. json.Unmarshal([]byte(infoStr), &rf)
  16565. var insutypes []*ResultFive
  16566. var insutype string
  16567. var is390 int = 0
  16568. var is310 int = 0
  16569. for _, item := range rf {
  16570. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16571. insutypes = append(insutypes, item)
  16572. }
  16573. }
  16574. if len(insutypes) == 1 {
  16575. insutype = insutypes[0].Insutype
  16576. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16577. } else {
  16578. for _, i := range insutypes {
  16579. if i.Insutype == "390" {
  16580. is390 = 1
  16581. }
  16582. if i.Insutype == "310" {
  16583. is310 = 1
  16584. }
  16585. }
  16586. }
  16587. if is390 == 1 {
  16588. insutype = "390"
  16589. }
  16590. if is310 == 1 {
  16591. insutype = "310"
  16592. }
  16593. if len(insutypes) == 0 {
  16594. insutype = "390"
  16595. }
  16596. service.CreateHisPsn(psn)
  16597. c.ServeSuccessJSON(map[string]interface{}{
  16598. "patient": patient,
  16599. "number": token,
  16600. "insutype": insutype,
  16601. })
  16602. }
  16603. } else {
  16604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16605. return
  16606. }
  16607. } else { //读卡失败
  16608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16609. return
  16610. }
  16611. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16612. //idNo := c.GetString("idNo")
  16613. //userName := c.GetString("userName")
  16614. //ecToken := c.GetString("ecToken")
  16615. //insuOrg := c.GetString("insuOrg")
  16616. _, json_result := GethnELeInfo(miConfig.Code, "1", roles.UserName)
  16617. utils.ErrorLog("解析失败:%v", json_result)
  16618. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16619. type ELeData struct {
  16620. Data struct {
  16621. IdNo string `json:"idNo"`
  16622. IdType string `json:"idType"`
  16623. UserName string `json:"userName"`
  16624. EcToken string `json:"ecToken"`
  16625. InsuOrg string `json:"insuOrg"`
  16626. Gender string `json:"gender"`
  16627. Birthday string `json:"birthday"`
  16628. Nationality string `json:"nationality"`
  16629. Email string `json:"email"`
  16630. Extra string `json:"extra"`
  16631. } `json:"data"`
  16632. Code int `json:"code"`
  16633. Message string `json:"message"`
  16634. }
  16635. var ele ELeData
  16636. err := json.Unmarshal([]byte(json_result), &ele)
  16637. if err != nil {
  16638. utils.ErrorLog("解析失败:%v", err)
  16639. }
  16640. token := ele.Data.EcToken
  16641. token = Remove0000(token)
  16642. 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)
  16643. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16644. var res ResultTwo
  16645. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16646. utils.ErrorLog("解析失败:%v", err)
  16647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16648. return
  16649. }
  16650. if res.Infcode == 0 {
  16651. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16652. if err == gorm.ErrRecordNotFound {
  16653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16654. return
  16655. } else if err != nil {
  16656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16657. return
  16658. } else {
  16659. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16660. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16661. infoStr := string(Iinfos)
  16662. idetinfoStr := string(Idetinfos)
  16663. psn := &models.HisPsn{
  16664. PsnNo: res.Output.Baseinfo.PsnNo,
  16665. PatientId: patient.ID,
  16666. Certno: res.Output.Baseinfo.Certno,
  16667. Gend: res.Output.Baseinfo.Gend,
  16668. Naty: res.Output.Baseinfo.Naty,
  16669. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16670. PsnName: res.Output.Baseinfo.PsnName,
  16671. Idetinfo: idetinfoStr,
  16672. Insuinfo: infoStr,
  16673. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16674. CardInfo: "",
  16675. Stage: "1",
  16676. VerifyNumber: token,
  16677. InsuplcAdmdvs: ele.Data.InsuOrg,
  16678. }
  16679. service.CreateHisPsn(psn)
  16680. var rf []*ResultFive
  16681. json.Unmarshal([]byte(infoStr), &rf)
  16682. var insutypes []*ResultFive
  16683. var insutype string
  16684. var is390 int = 0
  16685. var is310 int = 0
  16686. for _, item := range rf {
  16687. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16688. insutypes = append(insutypes, item)
  16689. }
  16690. }
  16691. if len(insutypes) == 1 {
  16692. insutype = insutypes[0].Insutype
  16693. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16694. } else {
  16695. for _, i := range insutypes {
  16696. if i.Insutype == "390" {
  16697. is390 = 1
  16698. }
  16699. if i.Insutype == "310" {
  16700. is310 = 1
  16701. }
  16702. }
  16703. }
  16704. if is390 == 1 {
  16705. insutype = "390"
  16706. }
  16707. if is310 == 1 {
  16708. insutype = "310"
  16709. }
  16710. if len(insutypes) == 0 {
  16711. insutype = "310"
  16712. }
  16713. c.ServeSuccessJSON(map[string]interface{}{
  16714. "patient": patient,
  16715. "number": token,
  16716. "insutype": insutype,
  16717. })
  16718. }
  16719. } else {
  16720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16721. return
  16722. }
  16723. } else if miConfig.MdtrtareaAdmvs == "360302" {
  16724. //if initFlag == 0 {
  16725. //c.TestGetJiangXiBasBaseInit()
  16726. //}
  16727. //if initEleFlag == 0 {
  16728. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16729. //}
  16730. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16731. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16732. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16733. type ELeData struct {
  16734. Data struct {
  16735. IdNo string `json:"idNo"`
  16736. IdType string `json:"idType"`
  16737. UserName string `json:"userName"`
  16738. EcToken string `json:"ecToken"`
  16739. InsuOrg string `json:"insuOrg"`
  16740. Gender string `json:"gender"`
  16741. Birthday string `json:"birthday"`
  16742. Nationality string `json:"nationality"`
  16743. Email string `json:"email"`
  16744. Extra string `json:"extra"`
  16745. } `json:"data"`
  16746. Code int `json:"code"`
  16747. Message string `json:"message"`
  16748. }
  16749. var ele ELeData
  16750. err := json.Unmarshal([]byte(result), &ele)
  16751. if err != nil {
  16752. utils.ErrorLog("解析失败:%v", err)
  16753. }
  16754. token := ele.Data.EcToken
  16755. token = Remove0000(token)
  16756. 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)
  16757. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16758. var res ResultTwo
  16759. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16760. utils.ErrorLog("解析失败:%v", err)
  16761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16762. return
  16763. }
  16764. if res.Infcode == 0 {
  16765. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16766. if err == gorm.ErrRecordNotFound {
  16767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16768. return
  16769. } else if err != nil {
  16770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16771. return
  16772. } else {
  16773. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16774. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16775. infoStr := string(Iinfos)
  16776. idetinfoStr := string(Idetinfos)
  16777. psn := &models.HisPsn{
  16778. PsnNo: res.Output.Baseinfo.PsnNo,
  16779. PatientId: patient.ID,
  16780. Certno: res.Output.Baseinfo.Certno,
  16781. Gend: res.Output.Baseinfo.Gend,
  16782. Naty: res.Output.Baseinfo.Naty,
  16783. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16784. PsnName: res.Output.Baseinfo.PsnName,
  16785. Idetinfo: idetinfoStr,
  16786. Insuinfo: infoStr,
  16787. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16788. CardInfo: "",
  16789. VerifyNumber: token,
  16790. InsuplcAdmdvs: ele.Data.InsuOrg,
  16791. }
  16792. service.CreateHisPsn(psn)
  16793. var rf []*ResultFive
  16794. json.Unmarshal([]byte(infoStr), &rf)
  16795. var insutypes []*ResultFive
  16796. var insutype string
  16797. var is390 int = 0
  16798. var is310 int = 0
  16799. for _, item := range rf {
  16800. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16801. insutypes = append(insutypes, item)
  16802. }
  16803. }
  16804. if len(insutypes) == 1 {
  16805. insutype = insutypes[0].Insutype
  16806. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16807. } else {
  16808. for _, i := range insutypes {
  16809. if i.Insutype == "390" {
  16810. is390 = 1
  16811. }
  16812. if i.Insutype == "310" {
  16813. is310 = 1
  16814. }
  16815. }
  16816. }
  16817. if is390 == 1 {
  16818. insutype = "390"
  16819. }
  16820. if is310 == 1 {
  16821. insutype = "310"
  16822. }
  16823. if len(insutypes) == 0 {
  16824. insutype = "310"
  16825. }
  16826. c.ServeSuccessJSON(map[string]interface{}{
  16827. "patient": patient,
  16828. "number": token,
  16829. "insutype": insutype,
  16830. })
  16831. }
  16832. } else {
  16833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16834. return
  16835. }
  16836. } else if miConfig.MdtrtareaAdmvs == "361025" {
  16837. //if initFlag == 0 {
  16838. //c.TestGetJiangXiBasBaseInit()
  16839. //}
  16840. //if initEleFlag == 0 {
  16841. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16842. //}
  16843. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16844. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16845. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16846. type ELeData struct {
  16847. Data struct {
  16848. IdNo string `json:"idNo"`
  16849. IdType string `json:"idType"`
  16850. UserName string `json:"userName"`
  16851. EcToken string `json:"ecToken"`
  16852. InsuOrg string `json:"insuOrg"`
  16853. Gender string `json:"gender"`
  16854. Birthday string `json:"birthday"`
  16855. Nationality string `json:"nationality"`
  16856. Email string `json:"email"`
  16857. Extra string `json:"extra"`
  16858. } `json:"data"`
  16859. Code int `json:"code"`
  16860. Message string `json:"message"`
  16861. }
  16862. var ele ELeData
  16863. err := json.Unmarshal([]byte(result), &ele)
  16864. if err != nil {
  16865. utils.ErrorLog("解析失败:%v", err)
  16866. }
  16867. token := ele.Data.EcToken
  16868. token = Remove0000(token)
  16869. 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)
  16870. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16871. var res ResultTwo
  16872. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16873. utils.ErrorLog("解析失败:%v", err)
  16874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16875. return
  16876. }
  16877. if res.Infcode == 0 {
  16878. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16879. if err == gorm.ErrRecordNotFound {
  16880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16881. return
  16882. } else if err != nil {
  16883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16884. return
  16885. } else {
  16886. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16887. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16888. infoStr := string(Iinfos)
  16889. idetinfoStr := string(Idetinfos)
  16890. psn := &models.HisPsn{
  16891. PsnNo: res.Output.Baseinfo.PsnNo,
  16892. PatientId: patient.ID,
  16893. Certno: res.Output.Baseinfo.Certno,
  16894. Gend: res.Output.Baseinfo.Gend,
  16895. Naty: res.Output.Baseinfo.Naty,
  16896. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16897. PsnName: res.Output.Baseinfo.PsnName,
  16898. Idetinfo: idetinfoStr,
  16899. Insuinfo: infoStr,
  16900. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16901. CardInfo: "",
  16902. VerifyNumber: token,
  16903. InsuplcAdmdvs: ele.Data.InsuOrg,
  16904. }
  16905. service.CreateHisPsn(psn)
  16906. var rf []*ResultFive
  16907. json.Unmarshal([]byte(infoStr), &rf)
  16908. var insutypes []*ResultFive
  16909. var insutype string
  16910. var is390 int = 0
  16911. var is310 int = 0
  16912. for _, item := range rf {
  16913. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16914. insutypes = append(insutypes, item)
  16915. }
  16916. }
  16917. if len(insutypes) == 1 {
  16918. insutype = insutypes[0].Insutype
  16919. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16920. } else {
  16921. for _, i := range insutypes {
  16922. if i.Insutype == "390" {
  16923. is390 = 1
  16924. }
  16925. if i.Insutype == "310" {
  16926. is310 = 1
  16927. }
  16928. }
  16929. }
  16930. if is390 == 1 {
  16931. insutype = "390"
  16932. }
  16933. if is310 == 1 {
  16934. insutype = "310"
  16935. }
  16936. if len(insutypes) == 0 {
  16937. insutype = "310"
  16938. }
  16939. c.ServeSuccessJSON(map[string]interface{}{
  16940. "patient": patient,
  16941. "number": token,
  16942. "insutype": insutype,
  16943. })
  16944. }
  16945. } else {
  16946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16947. return
  16948. }
  16949. } else if miConfig.MdtrtareaAdmvs == "360100" {
  16950. //if initFlag == 0 {
  16951. //c.TestGetJiangXiBasBaseInit()
  16952. //}
  16953. //if initEleFlag == 0 {
  16954. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  16955. //}
  16956. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  16957. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  16958. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  16959. type ELeData struct {
  16960. Data struct {
  16961. IdNo string `json:"idNo"`
  16962. IdType string `json:"idType"`
  16963. UserName string `json:"userName"`
  16964. EcToken string `json:"ecToken"`
  16965. InsuOrg string `json:"insuOrg"`
  16966. Gender string `json:"gender"`
  16967. Birthday string `json:"birthday"`
  16968. Nationality string `json:"nationality"`
  16969. Email string `json:"email"`
  16970. Extra string `json:"extra"`
  16971. } `json:"data"`
  16972. Code int `json:"code"`
  16973. Message string `json:"message"`
  16974. }
  16975. var ele ELeData
  16976. err := json.Unmarshal([]byte(result), &ele)
  16977. if err != nil {
  16978. utils.ErrorLog("解析失败:%v", err)
  16979. }
  16980. token := ele.Data.EcToken
  16981. token = Remove0000(token)
  16982. 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)
  16983. saveLog(result2, requestLog2, "1101", "获取人员信息")
  16984. var res ResultTwo
  16985. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  16986. utils.ErrorLog("解析失败:%v", err)
  16987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16988. return
  16989. }
  16990. if res.Infcode == 0 {
  16991. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16992. if err == gorm.ErrRecordNotFound {
  16993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16994. return
  16995. } else if err != nil {
  16996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16997. return
  16998. } else {
  16999. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17000. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17001. infoStr := string(Iinfos)
  17002. idetinfoStr := string(Idetinfos)
  17003. psn := &models.HisPsn{
  17004. PsnNo: res.Output.Baseinfo.PsnNo,
  17005. PatientId: patient.ID,
  17006. Certno: res.Output.Baseinfo.Certno,
  17007. Gend: res.Output.Baseinfo.Gend,
  17008. Naty: res.Output.Baseinfo.Naty,
  17009. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17010. PsnName: res.Output.Baseinfo.PsnName,
  17011. Idetinfo: idetinfoStr,
  17012. Insuinfo: infoStr,
  17013. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17014. CardInfo: "",
  17015. VerifyNumber: token,
  17016. InsuplcAdmdvs: ele.Data.InsuOrg,
  17017. }
  17018. service.CreateHisPsn(psn)
  17019. var rf []*ResultFive
  17020. json.Unmarshal([]byte(infoStr), &rf)
  17021. var insutypes []*ResultFive
  17022. var insutype string
  17023. var is390 int = 0
  17024. var is310 int = 0
  17025. for _, item := range rf {
  17026. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17027. insutypes = append(insutypes, item)
  17028. }
  17029. }
  17030. if len(insutypes) == 1 {
  17031. insutype = insutypes[0].Insutype
  17032. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17033. } else {
  17034. for _, i := range insutypes {
  17035. if i.Insutype == "390" {
  17036. is390 = 1
  17037. }
  17038. if i.Insutype == "310" {
  17039. is310 = 1
  17040. }
  17041. }
  17042. }
  17043. if is390 == 1 {
  17044. insutype = "390"
  17045. }
  17046. if is310 == 1 {
  17047. insutype = "310"
  17048. }
  17049. if len(insutypes) == 0 {
  17050. insutype = "310"
  17051. }
  17052. c.ServeSuccessJSON(map[string]interface{}{
  17053. "patient": patient,
  17054. "number": token,
  17055. "insutype": insutype,
  17056. })
  17057. }
  17058. } else {
  17059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17060. return
  17061. }
  17062. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17063. //if initFlag == 0 {
  17064. c.TestGetJiangXiBasBaseInit()
  17065. //}
  17066. //if initEleFlag == 0 {
  17067. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  17068. //}
  17069. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  17070. type ELeData struct {
  17071. Data struct {
  17072. IdNo string `json:"idNo"`
  17073. IdType string `json:"idType"`
  17074. UserName string `json:"userName"`
  17075. EcToken string `json:"ecToken"`
  17076. InsuOrg string `json:"insuOrg"`
  17077. Gender string `json:"gender"`
  17078. Birthday string `json:"birthday"`
  17079. Nationality string `json:"nationality"`
  17080. Email string `json:"email"`
  17081. Extra string `json:"extra"`
  17082. } `json:"data"`
  17083. Code int `json:"code"`
  17084. Message string `json:"message"`
  17085. }
  17086. var ele ELeData
  17087. err := json.Unmarshal([]byte(json_result), &ele)
  17088. if err != nil {
  17089. utils.ErrorLog("解析失败:%v", err)
  17090. }
  17091. token := ele.Data.EcToken
  17092. token = Remove0000(token)
  17093. 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)
  17094. saveLog(result2, requestLog2, "1101", "获取人员信息")
  17095. var res ResultTwo
  17096. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17097. utils.ErrorLog("解析失败:%v", err)
  17098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17099. return
  17100. }
  17101. if res.Infcode == 0 {
  17102. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17103. if err == gorm.ErrRecordNotFound {
  17104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17105. return
  17106. } else if err != nil {
  17107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17108. return
  17109. } else {
  17110. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17111. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17112. infoStr := string(Iinfos)
  17113. idetinfoStr := string(Idetinfos)
  17114. psn := &models.HisPsn{
  17115. PsnNo: res.Output.Baseinfo.PsnNo,
  17116. PatientId: patient.ID,
  17117. Certno: res.Output.Baseinfo.Certno,
  17118. Gend: res.Output.Baseinfo.Gend,
  17119. Naty: res.Output.Baseinfo.Naty,
  17120. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17121. PsnName: res.Output.Baseinfo.PsnName,
  17122. Idetinfo: idetinfoStr,
  17123. Insuinfo: infoStr,
  17124. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17125. CardInfo: "",
  17126. VerifyNumber: token,
  17127. }
  17128. service.CreateHisPsn(psn)
  17129. var rf []*ResultFive
  17130. json.Unmarshal([]byte(infoStr), &rf)
  17131. var insutypes []*ResultFive
  17132. var insutype string
  17133. var is390 int = 0
  17134. var is310 int = 0
  17135. for _, item := range rf {
  17136. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17137. insutypes = append(insutypes, item)
  17138. }
  17139. }
  17140. if len(insutypes) == 1 {
  17141. insutype = insutypes[0].Insutype
  17142. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17143. } else {
  17144. for _, i := range insutypes {
  17145. if i.Insutype == "390" {
  17146. is390 = 1
  17147. }
  17148. if i.Insutype == "310" {
  17149. is310 = 1
  17150. }
  17151. }
  17152. }
  17153. if is390 == 1 {
  17154. insutype = "390"
  17155. }
  17156. if is310 == 1 {
  17157. insutype = "310"
  17158. }
  17159. if len(insutypes) == 0 {
  17160. insutype = "310"
  17161. }
  17162. c.ServeSuccessJSON(map[string]interface{}{
  17163. "patient": patient,
  17164. "number": token,
  17165. "insutype": insutype,
  17166. })
  17167. }
  17168. } else {
  17169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17170. return
  17171. }
  17172. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17173. type ELeData struct {
  17174. Code string `json:"code"`
  17175. Data struct {
  17176. Aac002 string `json:"aac002"`
  17177. Aaz500 string `json:"aaz500"`
  17178. ActCardNo string `json:"actCardNo"`
  17179. Bab520 string `json:"bab520"`
  17180. Bkz543 string `json:"bkz543"`
  17181. BusinessType string `json:"businessType"`
  17182. CertfCodg string `json:"certfCodg"`
  17183. EcIndexNo string `json:"ecIndexNo"`
  17184. EcToken string `json:"ecToken"`
  17185. ID0000 string `json:"id0000"`
  17186. IDNo string `json:"idNo"`
  17187. IDType string `json:"idType"`
  17188. Idcode string `json:"idcode"`
  17189. IdentityToken string `json:"identity_token"`
  17190. InsuOrg string `json:"insuOrg"`
  17191. OfficeID string `json:"officeId"`
  17192. OfficeName string `json:"officeName"`
  17193. OperatorID string `json:"operatorId"`
  17194. OperatorName string `json:"operatorName"`
  17195. OrgID string `json:"orgId"`
  17196. UserName string `json:"userName"`
  17197. } `json:"data"`
  17198. Infno interface{} `json:"infno"`
  17199. Message string `json:"message"`
  17200. OrgID string `json:"orgId"`
  17201. TransType string `json:"transType"`
  17202. }
  17203. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  17204. outPutInfo = Remove0000(outPutInfo)
  17205. if len(outPutInfo) > 0 {
  17206. var ele ELeData
  17207. err := json.Unmarshal([]byte(outPutInfo), &ele)
  17208. if err != nil {
  17209. utils.ErrorLog("解析失败:%v", err)
  17210. }
  17211. token := ele.Data.EcToken
  17212. fmt.Println(inputInfo)
  17213. fmt.Println(outPutInfo)
  17214. 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)
  17215. saveLog(result, requestLog, "1101", "获取人员信息")
  17216. var dat map[string]interface{}
  17217. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17218. fmt.Println(dat)
  17219. } else {
  17220. fmt.Println(err)
  17221. }
  17222. userJSONBytes, _ := json.Marshal(dat)
  17223. var res ResultTwo
  17224. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17225. utils.ErrorLog("解析失败:%v", err)
  17226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17227. return
  17228. }
  17229. res.ErrMsg = errMsgLog
  17230. if res.Infcode == 0 {
  17231. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  17232. if err == gorm.ErrRecordNotFound {
  17233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17234. return
  17235. } else if err != nil {
  17236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17237. return
  17238. } else {
  17239. fmt.Println(res)
  17240. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17241. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17242. infoStr := string(Iinfos)
  17243. idetinfoStr := string(Idetinfos)
  17244. psn := &models.HisPsn{
  17245. PsnNo: res.Output.Baseinfo.PsnNo,
  17246. PatientId: patient.ID,
  17247. Certno: res.Output.Baseinfo.Certno,
  17248. Gend: res.Output.Baseinfo.Gend,
  17249. Naty: res.Output.Baseinfo.Naty,
  17250. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17251. PsnName: res.Output.Baseinfo.PsnName,
  17252. Idetinfo: idetinfoStr,
  17253. Insuinfo: infoStr,
  17254. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17255. CardInfo: outPutInfo,
  17256. VerifyNumber: token,
  17257. InsuplcAdmdvs: ele.Data.InsuOrg,
  17258. }
  17259. service.CreateHisPsn(psn)
  17260. var rf []*ResultFive
  17261. json.Unmarshal([]byte(infoStr), &rf)
  17262. var insutypes []*ResultFive
  17263. var insutype string
  17264. var is390 int = 0
  17265. var is310 int = 0
  17266. for _, item := range rf {
  17267. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  17268. insutypes = append(insutypes, item)
  17269. }
  17270. }
  17271. if len(insutypes) == 1 {
  17272. insutype = insutypes[0].Insutype
  17273. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17274. } else {
  17275. for _, i := range insutypes {
  17276. if i.Insutype == "390" {
  17277. is390 = 1
  17278. }
  17279. if i.Insutype == "310" {
  17280. is310 = 1
  17281. }
  17282. }
  17283. }
  17284. if is390 == 1 {
  17285. insutype = "390"
  17286. }
  17287. if is310 == 1 {
  17288. insutype = "310"
  17289. }
  17290. if len(insutypes) == 0 {
  17291. insutype = "310"
  17292. }
  17293. c.ServeSuccessJSON(map[string]interface{}{
  17294. "patient": patient,
  17295. "number": token,
  17296. "insutype": insutype,
  17297. })
  17298. }
  17299. } else {
  17300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17301. return
  17302. }
  17303. }
  17304. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17305. var api string
  17306. 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 +
  17307. "&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
  17308. resp, requestErr := http.Get(api)
  17309. if requestErr != nil {
  17310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17311. return
  17312. }
  17313. body, ioErr := ioutil.ReadAll(resp.Body)
  17314. if ioErr != nil {
  17315. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17317. return
  17318. }
  17319. var respJSON map[string]interface{}
  17320. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17321. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17323. return
  17324. }
  17325. var status string
  17326. status = respJSON["data"].(map[string]interface{})["status"].(string)
  17327. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  17328. var token string
  17329. var res ResultTwo //1101结果
  17330. var res10265 ResultTwo10265 //1101结果
  17331. if status == "0" { //读卡成功
  17332. var card_info string //卡信息
  17333. var busi_card_info string
  17334. token = respJSON["data"].(map[string]interface{})["token"].(string)
  17335. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  17336. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  17337. fmt.Println(card_info)
  17338. fmt.Println(busi_card_info)
  17339. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  17340. result, _ := json.Marshal(respJSON)
  17341. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17342. utils.ErrorLog("解析失败:%v", err)
  17343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17344. return
  17345. }
  17346. res.ErrMsg = res10265.ErrMsg
  17347. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  17348. res.Infcode = infocode
  17349. res.Output = res10265.Output
  17350. res.InfRefmsgid = res10265.InfRefmsgid
  17351. if res.Infcode == 0 {
  17352. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17353. if err == gorm.ErrRecordNotFound {
  17354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17355. return
  17356. } else if err != nil {
  17357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17358. return
  17359. } else {
  17360. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17361. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17362. infoStr := string(Iinfos)
  17363. idetinfoStr := string(Idetinfos)
  17364. psn := &models.HisPsn{
  17365. PsnNo: res.Output.Baseinfo.PsnNo,
  17366. PatientId: patient.ID,
  17367. Certno: res.Output.Baseinfo.Certno,
  17368. Gend: res.Output.Baseinfo.Gend,
  17369. Naty: res.Output.Baseinfo.Naty,
  17370. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17371. PsnName: res.Output.Baseinfo.PsnName,
  17372. Idetinfo: idetinfoStr,
  17373. Insuinfo: infoStr,
  17374. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17375. CardInfo: card_info,
  17376. VerifyNumber: token,
  17377. }
  17378. var rf []*ResultFive
  17379. json.Unmarshal([]byte(infoStr), &rf)
  17380. var insutypes []*ResultFive
  17381. var insutype string
  17382. var is390 int = 0
  17383. var is310 int = 0
  17384. for _, item := range rf {
  17385. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17386. insutypes = append(insutypes, item)
  17387. }
  17388. }
  17389. if len(insutypes) == 1 {
  17390. insutype = insutypes[0].Insutype
  17391. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17392. } else {
  17393. for _, i := range insutypes {
  17394. if i.Insutype == "390" {
  17395. is390 = 1
  17396. }
  17397. if i.Insutype == "310" {
  17398. is310 = 1
  17399. }
  17400. }
  17401. }
  17402. if is390 == 1 {
  17403. insutype = "390"
  17404. }
  17405. if is310 == 1 {
  17406. insutype = "310"
  17407. }
  17408. if len(insutypes) == 0 {
  17409. insutype = "310"
  17410. }
  17411. service.CreateHisPsn(psn)
  17412. c.ServeSuccessJSON(map[string]interface{}{
  17413. "patient": patient,
  17414. "number": token,
  17415. "insutype": insutype,
  17416. })
  17417. }
  17418. } else {
  17419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17420. return
  17421. }
  17422. } else { //读卡失败
  17423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17424. return
  17425. }
  17426. } else if miConfig.MdtrtareaAdmvs == "450721" {
  17427. res := c.GetoleInfo()
  17428. if res.Infcode == 0 {
  17429. var result string
  17430. if res.Output.MdtrtCertType == "01" {
  17431. 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)
  17432. } else if res.Output.MdtrtCertType == "02" {
  17433. 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)
  17434. } else if res.Output.MdtrtCertType == "03" {
  17435. 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)
  17436. }
  17437. var dat map[string]interface{}
  17438. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17439. fmt.Println(dat)
  17440. } else {
  17441. fmt.Println(err)
  17442. }
  17443. userJSONBytes, _ := json.Marshal(dat)
  17444. var res2 ResultTwo
  17445. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17446. utils.ErrorLog("解析失败:%v", err)
  17447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17448. return
  17449. }
  17450. if res2.Infcode == 0 {
  17451. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  17452. if err == gorm.ErrRecordNotFound {
  17453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17454. return
  17455. } else if err != nil {
  17456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17457. return
  17458. } else {
  17459. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  17460. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  17461. infoStr := string(Iinfos)
  17462. idetinfoStr := string(Idetinfos)
  17463. var rf []*ResultFive
  17464. json.Unmarshal([]byte(infoStr), &rf)
  17465. var insutypes []*ResultFive
  17466. var insutype string
  17467. var is390 int = 0
  17468. var is310 int = 0
  17469. //var insuplc_admdvs string
  17470. for _, item := range rf {
  17471. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17472. insutypes = append(insutypes, item)
  17473. }
  17474. }
  17475. if len(insutypes) == 1 {
  17476. insutype = insutypes[0].Insutype
  17477. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17478. } else {
  17479. for _, i := range insutypes {
  17480. if i.Insutype == "390" {
  17481. is390 = 1
  17482. }
  17483. if i.Insutype == "310" {
  17484. is310 = 1
  17485. }
  17486. }
  17487. }
  17488. if is390 == 1 {
  17489. insutype = "390"
  17490. }
  17491. if is310 == 1 {
  17492. insutype = "310"
  17493. }
  17494. if len(insutypes) == 0 {
  17495. insutype = "310"
  17496. }
  17497. psn := &models.HisPsn{
  17498. PsnNo: res2.Output.Baseinfo.PsnNo,
  17499. PatientId: patient.ID,
  17500. Certno: res2.Output.Baseinfo.Certno,
  17501. Gend: res2.Output.Baseinfo.Gend,
  17502. Naty: res2.Output.Baseinfo.Naty,
  17503. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  17504. PsnName: res2.Output.Baseinfo.PsnName,
  17505. Idetinfo: idetinfoStr,
  17506. Insuinfo: infoStr,
  17507. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17508. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  17509. VerifyNumber: res.Output.EcToken,
  17510. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  17511. }
  17512. if res.Output.MdtrtCertType == "01" {
  17513. psn.VerifyNumber = res.Output.EcToken
  17514. //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)
  17515. } else if res.Output.MdtrtCertType == "02" {
  17516. psn.VerifyNumber = res.Output.CardNo
  17517. //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)
  17518. } else if res.Output.MdtrtCertType == "03" {
  17519. psn.VerifyNumber = res.Output.MdtrtCertNo
  17520. //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)
  17521. }
  17522. service.CreateHisPsn(psn)
  17523. var balc float64
  17524. for _, item := range rf {
  17525. if item.Insutype == insutype {
  17526. balc = item.Balc
  17527. }
  17528. }
  17529. c.ServeSuccessJSON(map[string]interface{}{
  17530. "patient": patient,
  17531. "number": res.Output.CardNo,
  17532. "insutype": insutype,
  17533. "blac": balc,
  17534. "desc": idetinfoStr,
  17535. })
  17536. }
  17537. } else {
  17538. c.ServeSuccessJSON(map[string]interface{}{
  17539. "failed_code": -10,
  17540. "msg": res2.ErrMsg,
  17541. })
  17542. }
  17543. } else {
  17544. c.ServeSuccessJSON(map[string]interface{}{
  17545. "failed_code": -10,
  17546. "msg": res.ErrMsg,
  17547. })
  17548. }
  17549. } else if miConfig.MdtrtareaAdmvs == "420902" {
  17550. var res ResultTwo
  17551. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  17552. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  17553. "&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)
  17554. resp, requestErr := http.Get(api)
  17555. if requestErr != nil {
  17556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17557. return
  17558. }
  17559. body, ioErr := ioutil.ReadAll(resp.Body)
  17560. if ioErr != nil {
  17561. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17563. return
  17564. }
  17565. var respJSON map[string]interface{}
  17566. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17567. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17569. return
  17570. }
  17571. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17572. result, _ := json.Marshal(respJSON)
  17573. fmt.Println("log")
  17574. fmt.Println(string(result))
  17575. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17576. utils.ErrorLog("解析失败:%v", err)
  17577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17578. return
  17579. }
  17580. if res.Infcode == 0 {
  17581. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17582. if err == gorm.ErrRecordNotFound {
  17583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17584. return
  17585. } else if err != nil {
  17586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17587. return
  17588. } else {
  17589. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17590. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17591. infoStr := string(Iinfos)
  17592. idetinfoStr := string(Idetinfos)
  17593. var rf []*ResultFive
  17594. json.Unmarshal([]byte(infoStr), &rf)
  17595. var insutypes []*ResultFive
  17596. var insutype string
  17597. var is390 int = 0
  17598. var is310 int = 0
  17599. for _, item := range rf {
  17600. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  17601. insutypes = append(insutypes, item)
  17602. }
  17603. }
  17604. if len(insutypes) == 1 {
  17605. insutype = insutypes[0].Insutype
  17606. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17607. } else {
  17608. for _, i := range insutypes {
  17609. if i.Insutype == "390" {
  17610. is390 = 1
  17611. }
  17612. if i.Insutype == "310" {
  17613. is310 = 1
  17614. }
  17615. }
  17616. }
  17617. if is390 == 1 {
  17618. insutype = "390"
  17619. }
  17620. if is310 == 1 {
  17621. insutype = "310"
  17622. }
  17623. if len(insutypes) == 0 {
  17624. insutype = "390"
  17625. }
  17626. var insuplc_admdvs string
  17627. for _, item := range rf {
  17628. if item.Insutype == insutype {
  17629. insuplc_admdvs = item.InsuplcAdmdvs
  17630. }
  17631. }
  17632. psn := &models.HisPsn{
  17633. PsnNo: res.Output.Baseinfo.PsnNo,
  17634. PatientId: patient.ID,
  17635. Certno: res.Output.Baseinfo.Certno,
  17636. Gend: res.Output.Baseinfo.Gend,
  17637. Naty: res.Output.Baseinfo.Naty,
  17638. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17639. PsnName: res.Output.Baseinfo.PsnName,
  17640. Idetinfo: idetinfoStr,
  17641. Insuinfo: infoStr,
  17642. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17643. InsuplcAdmdvs: insuplc_admdvs,
  17644. }
  17645. service.CreateHisPsn(psn)
  17646. c.ServeSuccessJSON(map[string]interface{}{
  17647. "patient": patient,
  17648. "number": res.Output.Baseinfo.Certno,
  17649. })
  17650. }
  17651. } else {
  17652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17653. return
  17654. }
  17655. } else {
  17656. type ELeData struct {
  17657. Code string `json:"code"`
  17658. Data struct {
  17659. Aac002 string `json:"aac002"`
  17660. Aaz500 string `json:"aaz500"`
  17661. ActCardNo string `json:"actCardNo"`
  17662. Bab520 string `json:"bab520"`
  17663. Bkz543 string `json:"bkz543"`
  17664. BusinessType string `json:"businessType"`
  17665. CertfCodg string `json:"certfCodg"`
  17666. EcIndexNo string `json:"ecIndexNo"`
  17667. EcToken string `json:"ecToken"`
  17668. ID0000 string `json:"id0000"`
  17669. IDNo string `json:"idNo"`
  17670. IDType string `json:"idType"`
  17671. Idcode string `json:"idcode"`
  17672. IdentityToken string `json:"identity_token"`
  17673. InsuOrg string `json:"insuOrg"`
  17674. OfficeID string `json:"officeId"`
  17675. OfficeName string `json:"officeName"`
  17676. OperatorID string `json:"operatorId"`
  17677. OperatorName string `json:"operatorName"`
  17678. OrgID string `json:"orgId"`
  17679. UserName string `json:"userName"`
  17680. } `json:"data"`
  17681. Infno interface{} `json:"infno"`
  17682. Message string `json:"message"`
  17683. OrgID string `json:"orgId"`
  17684. TransType string `json:"transType"`
  17685. }
  17686. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  17687. fmt.Println(result)
  17688. outPutInfo := Remove0000(result)
  17689. fmt.Println(outPutInfo)
  17690. if len(outPutInfo) > 0 {
  17691. var ele ELeData
  17692. err := json.Unmarshal([]byte(outPutInfo), &ele)
  17693. if err != nil {
  17694. utils.ErrorLog("解析失败:%v", err)
  17695. }
  17696. token := ele.Data.EcToken
  17697. fmt.Println(outPutInfo)
  17698. 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)
  17699. saveLog(result, requestLog, "1101", "获取人员信息")
  17700. var dat map[string]interface{}
  17701. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17702. fmt.Println(dat)
  17703. } else {
  17704. fmt.Println(err)
  17705. }
  17706. userJSONBytes, _ := json.Marshal(dat)
  17707. var res ResultTwo
  17708. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17709. utils.ErrorLog("解析失败:%v", err)
  17710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17711. return
  17712. }
  17713. if res.Infcode == 0 {
  17714. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  17715. if err == gorm.ErrRecordNotFound {
  17716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17717. return
  17718. } else if err != nil {
  17719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17720. return
  17721. } else {
  17722. fmt.Println(res)
  17723. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17724. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17725. infoStr := string(Iinfos)
  17726. idetinfoStr := string(Idetinfos)
  17727. psn := &models.HisPsn{
  17728. PsnNo: res.Output.Baseinfo.PsnNo,
  17729. PatientId: patient.ID,
  17730. Certno: res.Output.Baseinfo.Certno,
  17731. Gend: res.Output.Baseinfo.Gend,
  17732. Naty: res.Output.Baseinfo.Naty,
  17733. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17734. PsnName: res.Output.Baseinfo.PsnName,
  17735. Idetinfo: idetinfoStr,
  17736. Insuinfo: infoStr,
  17737. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17738. CardInfo: outPutInfo,
  17739. VerifyNumber: token,
  17740. InsuplcAdmdvs: ele.Data.InsuOrg,
  17741. }
  17742. service.CreateHisPsn(psn)
  17743. var rf []*ResultFive
  17744. json.Unmarshal([]byte(infoStr), &rf)
  17745. var insutypes []*ResultFive
  17746. var insutype string
  17747. var is390 int = 0
  17748. var is310 int = 0
  17749. for _, item := range rf {
  17750. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17751. insutypes = append(insutypes, item)
  17752. }
  17753. }
  17754. if len(insutypes) == 1 {
  17755. insutype = insutypes[0].Insutype
  17756. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17757. } else {
  17758. for _, i := range insutypes {
  17759. if i.Insutype == "390" {
  17760. is390 = 1
  17761. }
  17762. if i.Insutype == "310" {
  17763. is310 = 1
  17764. }
  17765. }
  17766. }
  17767. if is390 == 1 {
  17768. insutype = "390"
  17769. }
  17770. if is310 == 1 {
  17771. insutype = "310"
  17772. }
  17773. if len(insutypes) == 0 {
  17774. insutype = "310"
  17775. }
  17776. c.ServeSuccessJSON(map[string]interface{}{
  17777. "patient": patient,
  17778. "number": token,
  17779. "insutype": insutype,
  17780. })
  17781. }
  17782. } else {
  17783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17784. return
  17785. }
  17786. }
  17787. //fmt.Println(result)
  17788. //
  17789. //if initFlag == 0 {
  17790. // c.TestGetBasBaseInit()
  17791. //}
  17792. //token := c.GetEleBaseInfo()
  17793. //
  17794. //token = Remove0000(token)
  17795. //
  17796. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  17797. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  17798. ////
  17799. //var res ResultTwo
  17800. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  17801. // utils.ErrorLog("解析失败:%v", err)
  17802. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17803. // return
  17804. //}
  17805. //
  17806. //if res.Infcode == 0 {
  17807. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17808. // if err == gorm.ErrRecordNotFound {
  17809. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17810. // return
  17811. // } else if err != nil {
  17812. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17813. // return
  17814. //
  17815. // } else {
  17816. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17817. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17818. // infoStr := string(Iinfos)
  17819. // idetinfoStr := string(Idetinfos)
  17820. //
  17821. //
  17822. //
  17823. //
  17824. // var rf []*ResultFive
  17825. // json.Unmarshal([]byte(infoStr), &rf)
  17826. //
  17827. // var insutypes []*ResultFive
  17828. // var insutype string
  17829. // var is390 int = 0
  17830. // var is310 int = 0
  17831. // var insuplc_admdvs string
  17832. //
  17833. // for _, item := range rf {
  17834. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17835. // insutypes = append(insutypes, item)
  17836. // }
  17837. // }
  17838. //
  17839. // if len(insutypes) == 1 {
  17840. // insutype = insutypes[0].Insutype
  17841. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17842. // } else {
  17843. // for _, i := range insutypes {
  17844. // if i.Insutype == "390" {
  17845. // is390 = 1
  17846. // }
  17847. //
  17848. // if i.Insutype == "310" {
  17849. // is310 = 1
  17850. // }
  17851. // }
  17852. // }
  17853. // if is390 == 1 {
  17854. // insutype = "390"
  17855. // }
  17856. //
  17857. // if is310 == 1 {
  17858. // insutype = "310"
  17859. // }
  17860. // if len(insutypes) == 0 {
  17861. // insutype = "310"
  17862. // }
  17863. // for _, item := range rf {
  17864. // if item.Insutype == insutype {
  17865. // insuplc_admdvs = item.InsuplcAdmdvs
  17866. // }
  17867. // }
  17868. // psn := &models.HisPsn{
  17869. // PsnNo: res.Output.Baseinfo.PsnNo,
  17870. // Age: res.Output.Baseinfo.Age,
  17871. // PatientId: patient.ID,
  17872. // Certno: res.Output.Baseinfo.Certno,
  17873. // Brdy: res.Output.Baseinfo.Brdy,
  17874. // Gend: res.Output.Baseinfo.Gend,
  17875. // Naty: res.Output.Baseinfo.Naty,
  17876. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  17877. // PsnName: res.Output.Baseinfo.PsnName,
  17878. // Idetinfo: idetinfoStr,
  17879. // Insuinfo: infoStr,
  17880. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17881. // CardInfo: "",
  17882. // VerifyNumber: token,
  17883. // InsuplcAdmdvs: insuplc_admdvs,
  17884. // }
  17885. // service.CreateHisPsn(psn)
  17886. //
  17887. // c.ServeSuccessJSON(map[string]interface{}{
  17888. // "patient": patient,
  17889. // "number": token,
  17890. // })
  17891. // }
  17892. //} else {
  17893. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  17894. // return
  17895. //}
  17896. }
  17897. break
  17898. case 5:
  17899. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  17900. var api string
  17901. if miConfig.MdtrtareaAdmvs == "320830" {
  17902. api = miConfig.AppSecret + "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) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  17904. fmt.Println(api)
  17905. } else if miConfig.MdtrtareaAdmvs == "320921" {
  17906. 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 +
  17907. "&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
  17908. fmt.Println(api)
  17909. } else {
  17910. 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 +
  17911. "&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)
  17912. }
  17913. resp, requestErr := http.Get(api)
  17914. if requestErr != nil {
  17915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17916. return
  17917. }
  17918. body, ioErr := ioutil.ReadAll(resp.Body)
  17919. if ioErr != nil {
  17920. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17922. return
  17923. }
  17924. var respJSON map[string]interface{}
  17925. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17926. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17928. return
  17929. }
  17930. var status string
  17931. status = respJSON["data"].(map[string]interface{})["status"].(string)
  17932. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  17933. var token string
  17934. var res ResultTwo //1101结果
  17935. var res10265 ResultTwo10265 //1101结果
  17936. if status == "0" { //读卡成功
  17937. var card_info string //卡信息
  17938. //var busi_card_info string
  17939. var auth_info string
  17940. token = respJSON["data"].(map[string]interface{})["token"].(string)
  17941. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  17942. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  17943. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  17944. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  17945. result, _ := json.Marshal(respJSON)
  17946. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17947. utils.ErrorLog("解析失败:%v", err)
  17948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17949. return
  17950. }
  17951. res.ErrMsg = res10265.ErrMsg
  17952. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  17953. res.Infcode = infocode
  17954. res.Output = res10265.Output
  17955. res.InfRefmsgid = res10265.InfRefmsgid
  17956. if res.Infcode == 0 {
  17957. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  17958. if err == gorm.ErrRecordNotFound {
  17959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  17960. return
  17961. } else if err != nil {
  17962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  17963. return
  17964. } else {
  17965. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17966. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17967. infoStr := string(Iinfos)
  17968. idetinfoStr := string(Idetinfos)
  17969. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  17970. psn := &models.HisPsn{
  17971. PsnNo: res.Output.Baseinfo.PsnNo,
  17972. PatientId: patient.ID,
  17973. Certno: res.Output.Baseinfo.Certno,
  17974. Gend: res.Output.Baseinfo.Gend,
  17975. Brdy: b,
  17976. Age: float64(age),
  17977. Naty: res.Output.Baseinfo.Naty,
  17978. PsnCertType: res.Output.Baseinfo.PsnCertType,
  17979. PsnName: res.Output.Baseinfo.PsnName,
  17980. Idetinfo: idetinfoStr,
  17981. Insuinfo: infoStr,
  17982. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  17983. CardInfo: card_info,
  17984. VerifyNumber: token,
  17985. AuthInfo: auth_info,
  17986. }
  17987. var rf []*ResultFive
  17988. json.Unmarshal([]byte(infoStr), &rf)
  17989. var insutypes []*ResultFive
  17990. var insutype string
  17991. var is390 int = 0
  17992. var is310 int = 0
  17993. for _, item := range rf {
  17994. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17995. insutypes = append(insutypes, item)
  17996. }
  17997. }
  17998. if len(insutypes) == 1 {
  17999. insutype = insutypes[0].Insutype
  18000. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  18001. } else {
  18002. for _, i := range insutypes {
  18003. if i.Insutype == "390" {
  18004. is390 = 1
  18005. }
  18006. if i.Insutype == "310" {
  18007. is310 = 1
  18008. }
  18009. }
  18010. }
  18011. if is390 == 1 {
  18012. insutype = "390"
  18013. }
  18014. if is310 == 1 {
  18015. insutype = "310"
  18016. }
  18017. if len(insutypes) == 0 {
  18018. insutype = "310"
  18019. }
  18020. service.CreateHisPsn(psn)
  18021. c.ServeSuccessJSON(map[string]interface{}{
  18022. "patient": patient,
  18023. "number": token,
  18024. "insutype": insutype,
  18025. })
  18026. }
  18027. } else {
  18028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18029. return
  18030. }
  18031. } else { //读卡失败
  18032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18033. return
  18034. }
  18035. }
  18036. break
  18037. }
  18038. }
  18039. var initFlag int64 = 0
  18040. var initEleFlag int64 = 0
  18041. func (c *HisApiController) TestGetBasBaseInit() {
  18042. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18043. Iinit := DllDef.MustFindProc("Init")
  18044. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18045. url := ""
  18046. if miConfig.InsuplcAdmdvs[:4] == "4403" {
  18047. url = "http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"
  18048. } else if miConfig.InsuplcAdmdvs[:4] == "4401" {
  18049. url = ""
  18050. } else {
  18051. url = "http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"
  18052. }
  18053. fmt.Println("SSCard的报错原因:", url)
  18054. fmt.Println("SSCard的报错原因:", miConfig.InsuplcAdmdvs)
  18055. ret, _, err := Iinit.Call(StrPtr(url), StrPtr(miConfig.InsuplcAdmdvs))
  18056. if ret != 0 {
  18057. fmt.Println("SSCard的报错原因:", err)
  18058. fmt.Println("SSCard的运算结果为:", ret)
  18059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18060. return
  18061. }
  18062. result := int(ret)
  18063. fmt.Println("SSCard的运算结果为1:", result)
  18064. initFlag = 1
  18065. return
  18066. }
  18067. func (c *HisApiController) HandleJiangXiReadCard() {
  18068. fmt.Println("~~~~~~")
  18069. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18070. admin_user_id, _ := c.GetInt64("admin_user_id")
  18071. id_card_type, _ := c.GetInt64("id_card_type")
  18072. //certificates, _ := c.GetInt64("certificates")
  18073. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18074. if initFlag == 0 {
  18075. c.TestGetJiangXiBasBaseInit()
  18076. }
  18077. basStr := c.GetBasBaseInfo()
  18078. if len(basStr) == 0 {
  18079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18080. return
  18081. }
  18082. fmt.Println(basStr)
  18083. bas := strings.Split(basStr, "|")
  18084. basNumber := bas[1]
  18085. fmt.Println(basNumber)
  18086. card_sn := bas[3]
  18087. fmt.Println(card_sn)
  18088. 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, "")
  18089. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  18090. var dat map[string]interface{}
  18091. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18092. fmt.Println(dat)
  18093. } else {
  18094. fmt.Println(err)
  18095. }
  18096. userJSONBytes, _ := json.Marshal(dat)
  18097. var res ResultTwo
  18098. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18099. utils.ErrorLog("解析失败:%v", err)
  18100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18101. return
  18102. }
  18103. if res.Infcode == 0 {
  18104. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  18105. if err == gorm.ErrRecordNotFound {
  18106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  18107. return
  18108. } else if err != nil {
  18109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  18110. return
  18111. } else {
  18112. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  18113. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  18114. infoStr := string(Iinfos)
  18115. idetinfoStr := string(Idetinfos)
  18116. psn := &models.HisPsn{
  18117. PsnNo: res.Output.Baseinfo.PsnNo,
  18118. PatientId: patient.ID,
  18119. Certno: res.Output.Baseinfo.Certno,
  18120. Gend: res.Output.Baseinfo.Gend,
  18121. Naty: res.Output.Baseinfo.Naty,
  18122. PsnCertType: res.Output.Baseinfo.PsnCertType,
  18123. PsnName: res.Output.Baseinfo.PsnName,
  18124. Idetinfo: idetinfoStr,
  18125. Insuinfo: infoStr,
  18126. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18127. CardInfo: basStr,
  18128. VerifyNumber: "",
  18129. }
  18130. service.CreateHisPsn(psn)
  18131. c.ServeSuccessJSON(map[string]interface{}{
  18132. "patient": patient,
  18133. "number": basNumber,
  18134. })
  18135. }
  18136. } else {
  18137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  18138. return
  18139. }
  18140. }
  18141. func (c *HisApiController) TestGetHnBasBaseInit() {
  18142. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18143. Iinit := DllDef.MustFindProc("Init")
  18144. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18145. //http://10.77.211.236/CSB/hsa-fsi-1303
  18146. //ret, _, err := Iinit.Call(StrPtr("https://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  18147. //ret, _, err := Iinit.Call(StrPtr("https://scr.hun.hsip.gov.cn/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|scr.hun.hsip.gov.cn"))
  18148. // 调用 Init 函数
  18149. 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"))))
  18150. //if ret != 0 {
  18151. fmt.Println("SSCard的报错原因:", err)
  18152. fmt.Println("SSCard的运算结果为:", ret)
  18153. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18154. // return
  18155. //}
  18156. result := int(ret)
  18157. fmt.Println("SSCard的运算结果为1:", result)
  18158. initFlag = 1
  18159. return
  18160. }
  18161. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  18162. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18163. Iinit := DllDef.MustFindProc("Init")
  18164. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18165. //http://10.77.211.236/CSB/hsa-fsi-1303
  18166. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360302"))
  18167. if ret != 0 {
  18168. fmt.Println("SSCard的报错原因:", err)
  18169. fmt.Println("SSCard的运算结果为:", ret)
  18170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18171. return
  18172. }
  18173. result := int(ret)
  18174. fmt.Println("SSCard的运算结果为1:", result)
  18175. initFlag = 1
  18176. return
  18177. }
  18178. func (c *HisApiController) TestGetJiangXiBasBaseInittwo() {
  18179. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18180. Iinit := DllDef.MustFindProc("Init")
  18181. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18182. //http://10.77.211.236/CSB/hsa-fsi-1303
  18183. ret, _, err := Iinit.Call(StrPtr("http://10.77.211.236/1.0.0/agent-card-init"), StrPtr("360100"))
  18184. if ret != 0 {
  18185. fmt.Println("SSCard的报错原因:", err)
  18186. fmt.Println("SSCard的运算结果为:", ret)
  18187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  18188. return
  18189. }
  18190. result := int(ret)
  18191. fmt.Println("SSCard的运算结果为1:", result)
  18192. initFlag = 1
  18193. return
  18194. }
  18195. func (c *HisApiController) GetSFZBaseInfo() string {
  18196. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18197. readCard := DllDef.MustFindProc("ReadSFZ")
  18198. if readCard == nil {
  18199. fmt.Println("readcard is nil")
  18200. readCard = DllDef.MustFindProc("ReadSFZ")
  18201. }
  18202. str := make([]byte, 8096)
  18203. str1 := make([]byte, 8096)
  18204. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  18205. fmt.Println(r)
  18206. return Remove0000(string(str))
  18207. }
  18208. func (c *HisApiController) GetEleBaseInfo() string {
  18209. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18210. readCard := DllDef.MustFindProc("GetQRBase")
  18211. fmt.Println(readCard)
  18212. if readCard == nil {
  18213. fmt.Println("readcard is nil")
  18214. readCard = DllDef.MustFindProc("GetQRBase")
  18215. }
  18216. str := make([]byte, 1024)
  18217. str1 := make([]byte, 1024)
  18218. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  18219. fmt.Println(ret2)
  18220. fmt.Println(string(str1))
  18221. fmt.Println(string(str))
  18222. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18223. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18224. if ret2 != 0 {
  18225. return ""
  18226. }
  18227. return string(str)
  18228. }
  18229. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  18230. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18231. readCard := DllDef.MustFindProc("NationEcTrans")
  18232. fmt.Println(readCard)
  18233. fmt.Println("!!!!!")
  18234. pBusiCardInfo := make([]byte, 2048)
  18235. input := make(map[string]interface{})
  18236. inputData := make(map[string]interface{})
  18237. inputData["orgId"] = code
  18238. inputData["businessType"] = "01101"
  18239. inputData["operatorId"] = "1"
  18240. inputData["operatorName"] = "admin"
  18241. inputData["officeId"] = "001"
  18242. inputData["officeName"] = "血透室"
  18243. inputData["deviceType"] = ""
  18244. input["data"] = inputData
  18245. input["orgId"] = code
  18246. input["transType"] = "ec.query"
  18247. bytesData, _ := json.Marshal(input)
  18248. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  18249. fmt.Println(ret2)
  18250. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18251. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18252. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  18253. }
  18254. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  18255. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18256. readCard := DllDef.MustFindProc("NationEcTrans")
  18257. fmt.Println(readCard)
  18258. fmt.Println("!!!!!")
  18259. pBusiCardInfo := make([]byte, 2048)
  18260. input := make(map[string]interface{})
  18261. inputData := make(map[string]interface{})
  18262. inputData["orgId"] = code
  18263. inputData["businessType"] = "01101"
  18264. inputData["operatorId"] = "9"
  18265. inputData["operatorName"] = "admin"
  18266. inputData["officeId"] = "001"
  18267. inputData["officeName"] = "血透室"
  18268. inputData["deviceType"] = ""
  18269. input["data"] = inputData
  18270. input["orgId"] = code
  18271. input["transType"] = "ec.query"
  18272. bytesData, _ := json.Marshal(input)
  18273. 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])))
  18274. fmt.Println(ret2)
  18275. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18276. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18277. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  18278. }
  18279. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  18280. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  18281. readCard := DllDef.MustFindProc("NationEcTrans")
  18282. fmt.Println(readCard)
  18283. fmt.Println("!!!!!")
  18284. pBusiCardInfo := make([]byte, 2048)
  18285. input := make(map[string]interface{})
  18286. inputData := make(map[string]interface{})
  18287. inputData["orgId"] = code
  18288. inputData["businessType"] = "01301"
  18289. inputData["operatorId"] = "9"
  18290. inputData["operatorName"] = "admin"
  18291. inputData["officeId"] = "001"
  18292. inputData["officeName"] = "血透室"
  18293. inputData["deviceType"] = ""
  18294. input["data"] = inputData
  18295. input["orgId"] = code
  18296. input["transType"] = "ec.query"
  18297. bytesData, _ := json.Marshal(input)
  18298. 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])))
  18299. fmt.Println(ret2)
  18300. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  18301. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  18302. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  18303. }
  18304. func GetJxEleBaseInfo(org_id int64) string {
  18305. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18306. readCard := DllDef.MustFindProc("NationEcTrans")
  18307. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18308. if readCard == nil {
  18309. fmt.Println("readcard is nil")
  18310. readCard = DllDef.MustFindProc("NationEcTrans")
  18311. }
  18312. str1 := make([]byte, 1024)
  18313. data := make(map[string]interface{})
  18314. inputData := make(map[string]interface{})
  18315. inputData["orgId"] = miConfig.Code
  18316. inputData["businessType"] = "01101"
  18317. inputData["operatorId"] = "test001"
  18318. inputData["operatorName"] = "cn"
  18319. inputData["officeId"] = "32760"
  18320. inputData["officeName"] = "waike"
  18321. inputData["deviceType"] = ""
  18322. data["data"] = inputData
  18323. data["transType"] = "ec.query"
  18324. data["extra "] = ""
  18325. data["orgId"] = miConfig.Code
  18326. bytesData, _ := json.Marshal(data)
  18327. //bytesData, _ := json.Marshal(data)
  18328. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18329. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18330. fmt.Println(ret2)
  18331. fmt.Println(string(str1))
  18332. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18333. if ret2 != 0 {
  18334. return ""
  18335. }
  18336. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18337. }
  18338. //func GetJxEleBaseInfoTWO(org_id int64) string {
  18339. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  18340. // readCard := DllDef.MustFindProc("NationEcTrans")
  18341. // miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18342. //
  18343. // if readCard == nil {
  18344. // fmt.Println("readcard is nil")
  18345. // readCard = DllDef.MustFindProc("NationEcTrans")
  18346. // }
  18347. // str1 := make([]byte, 1024)
  18348. //
  18349. // data := make(map[string]interface{})
  18350. //
  18351. // inputData := make(map[string]interface{})
  18352. // inputData["orgId"] = miConfig.Code
  18353. // inputData["businessType"] = "01101"
  18354. // inputData["operatorId"] = "test001"
  18355. // inputData["operatorName"] = "cn"
  18356. // inputData["officeId"] = "32760"
  18357. // inputData["officeName"] = "waike"
  18358. // inputData["deviceType"] = ""
  18359. //
  18360. // data["data"] = inputData
  18361. // data["transType"] = "ec.query"
  18362. // data["extra "] = ""
  18363. // data["orgId"] = miConfig.Code
  18364. // bytesData, _ := json.Marshal(data)
  18365. // //bytesData, _ := json.Marshal(data)
  18366. //
  18367. // //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18368. //
  18369. // ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18370. // fmt.Println(ret2)
  18371. // fmt.Println(string(str1))
  18372. // fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18373. //
  18374. // if ret2 != 0 {
  18375. // return ""
  18376. // }
  18377. // return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18378. //}
  18379. func GetJxEleBaseInitInfo(org_id int64) string {
  18380. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18381. readCard := DllDef.MustFindProc("NationEcTrans")
  18382. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  18383. if readCard == nil {
  18384. fmt.Println("readcard is nil")
  18385. readCard = DllDef.MustFindProc("NationEcTrans")
  18386. }
  18387. str1 := make([]byte, 2048)
  18388. data := make(map[string]interface{})
  18389. inputData := make(map[string]interface{})
  18390. inputData["orgId"] = miConfig.Code
  18391. inputData["businessType"] = "01101"
  18392. inputData["operatorId"] = "1"
  18393. inputData["operatorName"] = "huangchuang"
  18394. inputData["officeId"] = "101"
  18395. inputData["officeName"] = "xuetou"
  18396. inputData["deviceType"] = ""
  18397. data["data"] = inputData
  18398. data["transType"] = "ec.query"
  18399. data["orgId"] = miConfig.Code
  18400. bytesData, _ := json.Marshal(data)
  18401. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  18402. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18403. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  18404. fmt.Println(ret2)
  18405. fmt.Println(string(str1))
  18406. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18407. if ret2 != 0 {
  18408. return ""
  18409. }
  18410. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  18411. initEleFlag = 1
  18412. }
  18413. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  18414. }
  18415. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  18416. // // 构建命令
  18417. // cmd := exec.Command("python", "b.py")
  18418. //
  18419. // // 执行命令并等待完成
  18420. // output, err := cmd.CombinedOutput()
  18421. // if err != nil {
  18422. // fmt.Println("Error executing Python script:", err)
  18423. // return
  18424. // }
  18425. //
  18426. // // 打印Python脚本的输出
  18427. // fmt.Println(string(output))
  18428. //}
  18429. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  18430. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  18431. readCard := DllDef.MustFindProc("gxyb_call")
  18432. if readCard == nil {
  18433. fmt.Println("readcard is nil")
  18434. readCard = DllDef.MustFindProc("gxyb_call")
  18435. }
  18436. str := make([]byte, 1024)
  18437. str1 := make([]byte, 1024)
  18438. //data := make(map[string]interface{})
  18439. currentTime := time.Now()
  18440. // 格式化时间为 "YYYYMMDDHH24MISS"
  18441. formattedTime := currentTime.Format("20060102150405")
  18442. inputData := make(map[string]interface{})
  18443. inputData2 := make(map[string]interface{})
  18444. inputData["transNo"] = "1401"
  18445. inputData["transType"] = "passwordCheck"
  18446. inputData["timestamp"] = formattedTime
  18447. inputData2["fixmedinsCode"] = code
  18448. inputData2["psnNo"] = ""
  18449. inputData["data"] = inputData2
  18450. jsonBytes, err := json.Marshal(inputData)
  18451. if err != nil {
  18452. fmt.Println("Error encoding map to JSON:", err)
  18453. }
  18454. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18455. fmt.Println(string(str1))
  18456. fmt.Println(string(str))
  18457. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18458. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18459. if ret2 != 0 {
  18460. return ""
  18461. }
  18462. return string(str)
  18463. }
  18464. func (c *HisApiController) GetoleInfo() Response {
  18465. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  18466. defer ole.CoUninitialize()
  18467. // Replace with the ProgID or CLSID of your COM object
  18468. progID := "YinHai.XJ.Actual.Interface.New"
  18469. // Create COM object
  18470. unknown, err := oleutil.CreateObject(progID)
  18471. if err != nil {
  18472. fmt.Println("Unable to create COM object:", err)
  18473. }
  18474. defer unknown.Release()
  18475. // Query for the IDispatch interface
  18476. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  18477. if err != nil {
  18478. fmt.Println("Unable to get IDispatch interface:", err)
  18479. }
  18480. defer dispatch.Release()
  18481. // Prepare parameters
  18482. transNo := "1401"
  18483. transType := "passwordCheck"
  18484. timestamp := time.Now().Unix()
  18485. fixmedinsCode := "H45072101171"
  18486. psnNo := ""
  18487. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  18488. result2 := ""
  18489. // Call COM object's method using the IDispatch interface
  18490. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  18491. fmt.Println(resulr)
  18492. fmt.Println(result2)
  18493. if err != nil {
  18494. fmt.Println("调用COM对象方法失败:", err)
  18495. }
  18496. var response Response
  18497. err2 := json.Unmarshal([]byte(result2), &response)
  18498. if err2 != nil {
  18499. fmt.Println("解析JSON失败:", err)
  18500. }
  18501. return response
  18502. }
  18503. func (c *HisApiController) GetBasBaseInfo() string {
  18504. DllDef := syscall.MustLoadDLL("SSCard.dll")
  18505. readCard := DllDef.MustFindProc("ReadCardBas")
  18506. if readCard == nil {
  18507. fmt.Println("readcard is nil")
  18508. readCard = DllDef.MustFindProc("ReadCardBas")
  18509. }
  18510. str := make([]byte, 1024)
  18511. str1 := make([]byte, 1024)
  18512. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  18513. fmt.Println(string(str1))
  18514. fmt.Println(string(str))
  18515. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18516. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18517. if ret2 != 0 {
  18518. return ""
  18519. }
  18520. return string(str)
  18521. }
  18522. type Program struct {
  18523. FunctionID string `xml:"function_id"`
  18524. CardInfo string `xml:"cardinfo"`
  18525. User string `xml:"user"`
  18526. }
  18527. func (c *HisApiController) GetBasBaseInfo1111() string {
  18528. DllDef := syscall.MustLoadDLL("HealthyCarder.dll")
  18529. readCard := DllDef.MustFindProc("ReadSICardInfo")
  18530. readCard2 := DllDef.MustFindProc("ReadCardInfo")
  18531. if readCard == nil {
  18532. fmt.Println("readcard is nil")
  18533. readCard = DllDef.MustFindProc("ReadSICardInfo")
  18534. }
  18535. if readCard2 == nil {
  18536. fmt.Println("readcard is nil")
  18537. readCard2 = DllDef.MustFindProc("ReadCardInfo")
  18538. }
  18539. str := make([]byte, 1024)
  18540. str1 := make([]byte, 1024)
  18541. readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  18542. str3 := make([]byte, 1024)
  18543. str4 := make([]byte, 1024)
  18544. readCard.Call((uintptr)(unsafe.Pointer(&str[3])), (uintptr)(unsafe.Pointer(&str1[4])))
  18545. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18546. //if err != nil {
  18547. // fmt.Println("Error opening file:", err)
  18548. //}
  18549. //defer file.Close()
  18550. //
  18551. //var lastProgram Program
  18552. //scanner := bufio.NewScanner(file)
  18553. //inProgram := false
  18554. //
  18555. //for scanner.Scan() {
  18556. // line := scanner.Text()
  18557. // if strings.Contains(line, "<program>") {
  18558. // inProgram = true
  18559. // programXML := "<program>"
  18560. // for scanner.Scan() {
  18561. // line = scanner.Text()
  18562. // programXML += line
  18563. // if strings.Contains(line, "</program>") {
  18564. // programXML += "</program>"
  18565. // break
  18566. // }
  18567. // }
  18568. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18569. // // 解析成功,更新最后的 Program
  18570. // }
  18571. // inProgram = false
  18572. // }
  18573. //}
  18574. //
  18575. // fmt.Println("Error reading file:", inProgram)
  18576. //
  18577. //if err := scanner.Err(); err != nil {
  18578. // fmt.Println("Error reading file:", err)
  18579. //}
  18580. // 输出最后一次的 Program
  18581. //fmt.Printf("最后一次的 <program>:\n")
  18582. //fmt.Printf("<program>\n")
  18583. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18584. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18585. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18586. //fmt.Printf("</program>\n")
  18587. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18588. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18589. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  18590. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  18591. return ConvertToString(string(str), "gbk", "utf-8")
  18592. }
  18593. func (c *HisApiController) GetBasBaseInfo22222() string {
  18594. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  18595. readCard := DllDef.MustFindProc("iReadCardUnclassifiedBas")
  18596. if readCard == nil {
  18597. fmt.Println("readcard is nil")
  18598. readCard = DllDef.MustFindProc("iReadCardUnclassifiedBas")
  18599. }
  18600. str := make([]byte, 1024)
  18601. str1 := make([]byte, 1024)
  18602. readCard.Call(uintptr(1), (uintptr)(unsafe.Pointer(&str1[0])))
  18603. //ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  18604. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18605. //if err != nil {
  18606. // fmt.Println("Error opening file:", err)
  18607. //}
  18608. //defer file.Close()
  18609. //
  18610. //var lastProgram Program
  18611. //scanner := bufio.NewScanner(file)
  18612. //inProgram := false
  18613. //
  18614. //for scanner.Scan() {
  18615. // line := scanner.Text()
  18616. // if strings.Contains(line, "<program>") {
  18617. // inProgram = true
  18618. // programXML := "<program>"
  18619. // for scanner.Scan() {
  18620. // line = scanner.Text()
  18621. // programXML += line
  18622. // if strings.Contains(line, "</program>") {
  18623. // programXML += "</program>"
  18624. // break
  18625. // }
  18626. // }
  18627. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18628. // // 解析成功,更新最后的 Program
  18629. // }
  18630. // inProgram = false
  18631. // }
  18632. //}
  18633. //
  18634. // fmt.Println("Error reading file:", inProgram)
  18635. //
  18636. //if err := scanner.Err(); err != nil {
  18637. // fmt.Println("Error reading file:", err)
  18638. //}
  18639. // 输出最后一次的 Program
  18640. //fmt.Printf("最后一次的 <program>:\n")
  18641. //fmt.Printf("<program>\n")
  18642. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18643. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18644. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18645. //fmt.Printf("</program>\n")
  18646. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18647. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18648. return ConvertToString(string(str1), "gbk", "utf-8")
  18649. }
  18650. func (c *HisApiController) GetahBasBaseInfo() string {
  18651. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  18652. readCard := DllDef.MustFindProc("iReadCardBas")
  18653. if readCard == nil {
  18654. fmt.Println("readcard is nil")
  18655. readCard = DllDef.MustFindProc("iReadCardBas")
  18656. }
  18657. //str := make([]byte, 1024)
  18658. str1 := make([]byte, 1024)
  18659. ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&str1[0])))
  18660. //file, err := os.Open("C:\\Users\\Administrator\\Desktop\\11\\Power-Card\\SSCardDriver\\api.log")
  18661. //if err != nil {
  18662. // fmt.Println("Error opening file:", err)
  18663. //}
  18664. //defer file.Close()
  18665. //
  18666. //var lastProgram Program
  18667. //scanner := bufio.NewScanner(file)
  18668. //inProgram := false
  18669. //
  18670. //for scanner.Scan() {
  18671. // line := scanner.Text()
  18672. // if strings.Contains(line, "<program>") {
  18673. // inProgram = true
  18674. // programXML := "<program>"
  18675. // for scanner.Scan() {
  18676. // line = scanner.Text()
  18677. // programXML += line
  18678. // if strings.Contains(line, "</program>") {
  18679. // programXML += "</program>"
  18680. // break
  18681. // }
  18682. // }
  18683. // if err := xml.Unmarshal([]byte(programXML), &lastProgram); err == nil {
  18684. // // 解析成功,更新最后的 Program
  18685. // }
  18686. // inProgram = false
  18687. // }
  18688. //}
  18689. //
  18690. // fmt.Println("Error reading file:", inProgram)
  18691. //
  18692. //if err := scanner.Err(); err != nil {
  18693. // fmt.Println("Error reading file:", err)
  18694. //}
  18695. // 输出最后一次的 Program
  18696. //fmt.Printf("最后一次的 <program>:\n")
  18697. //fmt.Printf("<program>\n")
  18698. //fmt.Printf(" <function_id>%s</function_id>\n", lastProgram.FunctionID)
  18699. //fmt.Printf(" <cardinfo>%s</cardinfo>\n", lastProgram.CardInfo)
  18700. //fmt.Printf(" <user>%s</user>\n", lastProgram.User)
  18701. //fmt.Printf("</program>\n")
  18702. fmt.Println(string(str1))
  18703. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18704. if ret2 != 0 {
  18705. return ""
  18706. }
  18707. return string(str1)
  18708. }
  18709. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  18710. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  18711. readCard := DllDef.MustFindProc("read_cardinfo")
  18712. if readCard == nil {
  18713. fmt.Println("readcard is nil")
  18714. readCard = DllDef.MustFindProc("read_cardinfo")
  18715. }
  18716. str := make([]byte, 1024) //卡号
  18717. str1 := make([]byte, 1024) //卡识别码
  18718. str2 := make([]byte, 1024) //身份证号
  18719. str3 := make([]byte, 1024) //姓名
  18720. str4 := make([]byte, 1024) //错误信息
  18721. 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])))
  18722. fmt.Println(string(str1))
  18723. fmt.Println(string(str))
  18724. fmt.Println(string(str2))
  18725. fmt.Println(string(str3))
  18726. fmt.Println(string(str4))
  18727. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  18728. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  18729. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  18730. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  18731. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  18732. if ret2 != 0 {
  18733. return "", "", "", "", ""
  18734. }
  18735. return string(str), string(str1), string(str2), string(str3), string(str4)
  18736. }
  18737. type CustomFundPay struct {
  18738. FundPayType string `json:"fund_pay_type"`
  18739. FundPayamt float64 `json:"fund_payamt"`
  18740. InscpScpAmt float64 `json:"inscp_scp_amt"`
  18741. }
  18742. //func (c *HisApiController) GetBatchSettleList() {
  18743. // start_time_str := c.GetString("start_time")
  18744. // //end_time_str := c.GetString("end_time")
  18745. // admin_user_id, _ := c.GetInt64("admin_user_id")
  18746. //
  18747. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  18748. //
  18749. // for _, item := range orders {
  18750. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  18751. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  18752. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  18753. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  18754. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  18755. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  18756. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  18757. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  18758. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  18759. //
  18760. // if order.ID == 0 {
  18761. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  18762. // return
  18763. // }
  18764. //
  18765. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  18766. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  18767. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  18768. // //fmt.Println(count)
  18769. // //var zero string
  18770. // //number := count + 1
  18771. // //if number >= 1000 {
  18772. // // zero = "0000" + strconv.FormatInt(number, 10)
  18773. // //} else if number >= 10000 {
  18774. // // zero = "000" + strconv.FormatInt(number, 10)
  18775. // //} else if number >= 100000 {
  18776. // // zero = "00" + strconv.FormatInt(number, 10)
  18777. // //} else if number >= 1000000 {
  18778. // // zero = "0" + strconv.FormatInt(number, 10)
  18779. // //} else {
  18780. // // zero = strconv.FormatInt(number, 10)
  18781. // //}
  18782. // //fmt.Println(zero)
  18783. //
  18784. // struct4101 := service.Struct4101{
  18785. // PsnNo: order.PsnNo,
  18786. // MdtrtId: order.MdtrtId,
  18787. // SetlId: order.SetlId,
  18788. // PsnName: order.PsnName,
  18789. // Gend: order.Gend,
  18790. // Brdy: his.Brdy,
  18791. // Age: his.Age,
  18792. // Naty: order.Naty,
  18793. // PatnCertType: "01",
  18794. // Certno: order.Certno,
  18795. // Prfs: "90",
  18796. // ConerName: roles[0].UserName,
  18797. // PatnRlts: "99",
  18798. // ConerAddr: miConfig.OrgName,
  18799. // ConerTel: admin.Mobile,
  18800. // HiType: order.Insutype,
  18801. // Insuplc: miConfig.InsuplcAdmdvs,
  18802. // MaindiagFlag: "1",
  18803. // BillCode: order.SetlId,
  18804. // BillNo: order.SetlId,
  18805. // BizSn: order.Number,
  18806. // PsnSelfPay: order.PsnPartAmt,
  18807. // PsnOwnPay: order.PsnPartAmt,
  18808. // AcctPay: order.AcctPay,
  18809. // PsnCashpay: order.PsnCashPay,
  18810. // HiPaymtd: "1",
  18811. // Hsorg: miConfig.InsuplcAdmdvs,
  18812. // HsorgOpter: miConfig.InsuplcAdmdvs,
  18813. // MedinsFillPsn: curRoles.UserName,
  18814. // MedinsFillDept: miConfig.OrgName,
  18815. // IptMedType: "2",
  18816. // }
  18817. // struct4101.SetlBegnDate = order.SetlTime
  18818. // struct4101.SetlEndDate = order.SetlTime
  18819. // time_arr := strings.Split(order.SetlTime, " ")
  18820. // struct4101.AdmTime = time_arr[0]
  18821. // struct4101.AdmEndTime = time_arr[0]
  18822. //
  18823. // var rf []CustomFundPay
  18824. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  18825. //
  18826. // var tempFunPays []service.CustomStruct
  18827. // for _, item := range rf {
  18828. // var tempFunPay service.CustomStruct
  18829. // tempFunPay.FundPayamt = item.FundPayamt
  18830. // tempFunPay.FundPayType = item.FundPayType
  18831. // tempFunPays = append(tempFunPays, tempFunPay)
  18832. // }
  18833. // struct4101.CustomStruct = tempFunPays
  18834. //
  18835. // var tempDiaginfos []service.DiaginfoStructTwo
  18836. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  18837. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  18838. //
  18839. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  18840. // var config []*models.HisXtDiagnoseConfig
  18841. // for _, item := range diagnosis_ids {
  18842. // id, _ := strconv.ParseInt(item, 10, 64)
  18843. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  18844. // config = append(config, &diagnosisConfig)
  18845. // }
  18846. //
  18847. // for index, item := range config {
  18848. // if index == 0 {
  18849. // var tempDiaginfo service.DiaginfoStructTwo
  18850. // tempDiaginfo.DiagCode = item.CountryCode
  18851. // tempDiaginfo.DiagName = item.CountryContentName
  18852. // tempDiaginfo.DiagType = "1"
  18853. // tempDiaginfo.MaindiagFlag = "1"
  18854. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18855. // } else {
  18856. // var tempDiaginfo service.DiaginfoStructTwo
  18857. // tempDiaginfo.DiagCode = item.CountryCode
  18858. // tempDiaginfo.DiagName = item.CountryContentName
  18859. // tempDiaginfo.DiagType = "1"
  18860. // tempDiaginfo.MaindiagFlag = "0"
  18861. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  18862. // }
  18863. // }
  18864. // struct4101.Diseinfo = tempDiaginfos
  18865. //
  18866. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  18867. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  18868. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  18869. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  18870. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  18871. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  18872. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  18873. //
  18874. // var iteminfo service.IteminfoStruct
  18875. //
  18876. // var bedCostTotal float64 = 0 //床位总费
  18877. // var bedCostSelfTotal float64 = 0 //床位自费
  18878. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  18879. //
  18880. // var operationCostTotal float64 = 0 //手术费
  18881. // var operationCostSelfTotal float64 = 0 //手术费
  18882. // var operationCostPartSelfTotal float64 = 0 //手术费
  18883. //
  18884. // var otherCostTotal float64 = 0 //其他费用
  18885. // var otherCostSelfTotal float64 = 0 //其他费用
  18886. // var otherCostPartSelfTotal float64 = 0 //其他费用
  18887. //
  18888. // var materialCostTotal float64 = 0 //材料费
  18889. // var materialCostSelfTotal float64 = 0 //材料费
  18890. // var materialCostPartSelfTotal float64 = 0 //材料费
  18891. //
  18892. // var westernMedicineCostTotal float64 = 0 //西药费
  18893. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  18894. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  18895. //
  18896. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  18897. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  18898. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  18899. //
  18900. // var checkCostTotal float64 = 0 //检查费
  18901. // var checkCostSelfTotal float64 = 0 //检查费
  18902. // var checkCostPartSelfTotal float64 = 0 //检查费
  18903. //
  18904. // var laboratoryCostTotal float64 = 0 //化验费
  18905. // var laboratoryCostSelfTotal float64 = 0 //化验费
  18906. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  18907. //
  18908. // var treatCostTotal float64 = 0 //治疗费用
  18909. // var treatCostSelfTotal float64 = 0 //治疗费用
  18910. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  18911. //
  18912. // decimal.DivisionPrecision = 2
  18913. //
  18914. // var bed_fulamt_ownpay_amt float64 = 0
  18915. // var operation_fulamt_ownpay_amt float64 = 0
  18916. // var other_fulamt_ownpay_amt float64 = 0
  18917. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  18918. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  18919. // var check_fulamt_ownpay_amt float64 = 0
  18920. // var material_fulamt_ownpay_amt float64 = 0
  18921. // var laboratory_fulamt_ownpay_amt float64 = 0
  18922. // var treat_fulamt_ownpay_amt float64 = 0
  18923. //
  18924. // var bed_claa_sunmfee float64 = 0
  18925. // var bed_clab_amt float64 = 0
  18926. // var bed_other_amt float64 = 0
  18927. //
  18928. // var operation_claa_sunmfee float64 = 0
  18929. // var operation_clab_amt float64 = 0
  18930. // var operation_other_amt float64 = 0
  18931. //
  18932. // var other_claa_sunmfee float64 = 0
  18933. // var other_clab_amt float64 = 0
  18934. // var other_other_amt float64 = 0
  18935. //
  18936. // var westernMedicine_claa_sunmfee float64 = 0
  18937. // var westernMedicine_clab_amt float64 = 0
  18938. // var westernMedicine_other_amt float64 = 0
  18939. //
  18940. // var chineseTraditional_claa_sunmfee float64 = 0
  18941. // var chineseTraditional_clab_amt float64 = 0
  18942. // var chineseTraditional_other_amt float64 = 0
  18943. //
  18944. // var check_claa_sunmfee float64 = 0
  18945. // var check_clab_amt float64 = 0
  18946. // var check_other_amt float64 = 0
  18947. //
  18948. // var material_claa_sunmfee float64 = 0
  18949. // var material_clab_amt float64 = 0
  18950. // var material_other_amt float64 = 0
  18951. //
  18952. // var laboratory_claa_sunmfee float64 = 0
  18953. // var laboratory_clab_amt float64 = 0
  18954. // var laboratory_other_amt float64 = 0
  18955. //
  18956. // var treat_claa_sunmfee float64 = 0
  18957. // var treat_clab_amt float64 = 0
  18958. // var treat_other_amt float64 = 0
  18959. //
  18960. // for _, item := range order.HisOrderInfo {
  18961. // if item.MedChrgitmType == "01" { //床位费
  18962. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18963. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18964. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18965. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18966. // if item.ChrgitmLv == "1" {
  18967. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18968. // }
  18969. // if item.ChrgitmLv == "2" {
  18970. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18971. //
  18972. // }
  18973. // if item.ChrgitmLv == "3" {
  18974. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18975. // }
  18976. //
  18977. // }
  18978. //
  18979. // if item.MedChrgitmType == "03" { //检查费
  18980. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18981. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18982. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18983. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  18984. // if item.ChrgitmLv == "1" {
  18985. //
  18986. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  18987. //
  18988. // }
  18989. // if item.ChrgitmLv == "2" {
  18990. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  18991. //
  18992. // }
  18993. // if item.ChrgitmLv == "3" {
  18994. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  18995. // }
  18996. // }
  18997. //
  18998. // if item.MedChrgitmType == "04" { //化验费
  18999. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19000. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19001. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19002. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19003. // if item.ChrgitmLv == "1" {
  19004. //
  19005. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19006. //
  19007. // }
  19008. // if item.ChrgitmLv == "2" {
  19009. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19010. //
  19011. // }
  19012. // if item.ChrgitmLv == "3" {
  19013. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19014. // }
  19015. // }
  19016. //
  19017. // if item.MedChrgitmType == "05" { //治疗费
  19018. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19019. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19020. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19021. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19022. // if item.ChrgitmLv == "1" {
  19023. //
  19024. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19025. //
  19026. // }
  19027. // if item.ChrgitmLv == "2" {
  19028. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19029. //
  19030. // }
  19031. // if item.ChrgitmLv == "3" {
  19032. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19033. // }
  19034. // }
  19035. //
  19036. // if item.MedChrgitmType == "06" { //手术费
  19037. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19038. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19039. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19040. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19041. //
  19042. // if item.ChrgitmLv == "1" {
  19043. //
  19044. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19045. //
  19046. // }
  19047. // if item.ChrgitmLv == "2" {
  19048. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19049. //
  19050. // }
  19051. // if item.ChrgitmLv == "3" {
  19052. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19053. // }
  19054. // }
  19055. //
  19056. // if item.MedChrgitmType == "08" { //材料费
  19057. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19058. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19059. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19060. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19061. // if item.ChrgitmLv == "1" {
  19062. //
  19063. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19064. //
  19065. // }
  19066. // if item.ChrgitmLv == "2" {
  19067. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19068. //
  19069. // }
  19070. // if item.ChrgitmLv == "3" {
  19071. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19072. // }
  19073. // }
  19074. //
  19075. // if item.MedChrgitmType == "09" { //西药费
  19076. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19077. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19078. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19079. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19080. // if item.ChrgitmLv == "1" {
  19081. //
  19082. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19083. //
  19084. // }
  19085. // if item.ChrgitmLv == "2" {
  19086. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19087. //
  19088. // }
  19089. // if item.ChrgitmLv == "3" {
  19090. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19091. // }
  19092. // }
  19093. //
  19094. // if item.MedChrgitmType == "11" { //中成费
  19095. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19096. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19097. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19098. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19099. // if item.ChrgitmLv == "1" {
  19100. //
  19101. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19102. //
  19103. // }
  19104. // if item.ChrgitmLv == "2" {
  19105. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19106. //
  19107. // }
  19108. // if item.ChrgitmLv == "3" {
  19109. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19110. // }
  19111. // }
  19112. //
  19113. // if item.MedChrgitmType == "14" { //其他费
  19114. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19115. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19116. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19117. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19118. // if item.ChrgitmLv == "1" {
  19119. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19120. //
  19121. // }
  19122. // if item.ChrgitmLv == "2" {
  19123. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19124. //
  19125. // }
  19126. // if item.ChrgitmLv == "3" {
  19127. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19128. // }
  19129. // }
  19130. //
  19131. // }
  19132. //
  19133. // var iteminfoStructs []service.IteminfoStruct
  19134. //
  19135. // if bedCostTotal != 0 {
  19136. // iteminfo.MedChrgitm = "01"
  19137. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19138. // iteminfo.Amt = bedCostTotal
  19139. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  19140. // iteminfo.ClabAmt = bed_clab_amt
  19141. // iteminfo.OthAmt = bed_other_amt
  19142. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19143. // }
  19144. //
  19145. // if checkCostTotal != 0 {
  19146. // iteminfo.MedChrgitm = "03"
  19147. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19148. // iteminfo.Amt = checkCostTotal
  19149. // iteminfo.ClaaSumfee = check_claa_sunmfee
  19150. // iteminfo.ClabAmt = check_clab_amt
  19151. // iteminfo.OthAmt = check_other_amt
  19152. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19153. //
  19154. // }
  19155. //
  19156. // if laboratoryCostTotal != 0 {
  19157. // iteminfo.MedChrgitm = "04"
  19158. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19159. // iteminfo.Amt = laboratoryCostTotal
  19160. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19161. // iteminfo.ClabAmt = laboratory_clab_amt
  19162. // iteminfo.OthAmt = laboratory_other_amt
  19163. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19164. //
  19165. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19166. //
  19167. // }
  19168. //
  19169. // if treatCostTotal != 0 {
  19170. // iteminfo.MedChrgitm = "05"
  19171. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19172. // iteminfo.Amt = treatCostTotal
  19173. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  19174. // iteminfo.ClabAmt = treat_clab_amt
  19175. // iteminfo.OthAmt = treat_other_amt
  19176. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19177. // //(struct4101.IteminfoStruct, iteminfo)
  19178. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19179. // }
  19180. //
  19181. // if operationCostTotal != 0 {
  19182. // iteminfo.MedChrgitm = "06"
  19183. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19184. // iteminfo.Amt = operationCostTotal
  19185. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  19186. // iteminfo.ClabAmt = operation_clab_amt
  19187. // iteminfo.OthAmt = operation_other_amt
  19188. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19189. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19190. // }
  19191. //
  19192. // if materialCostTotal != 0 {
  19193. // iteminfo.MedChrgitm = "08"
  19194. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19195. // iteminfo.Amt = materialCostTotal
  19196. // iteminfo.ClaaSumfee = material_claa_sunmfee
  19197. // iteminfo.ClabAmt = material_clab_amt
  19198. // iteminfo.OthAmt = material_other_amt
  19199. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19200. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19201. // }
  19202. //
  19203. // if westernMedicineCostTotal != 0 {
  19204. // iteminfo.MedChrgitm = "09"
  19205. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19206. // iteminfo.Amt = westernMedicineCostTotal
  19207. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19208. // iteminfo.ClabAmt = westernMedicine_clab_amt
  19209. // iteminfo.OthAmt = westernMedicine_other_amt
  19210. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19211. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19212. //
  19213. // }
  19214. // if chineseTraditionalMedicineCostTotal != 0 {
  19215. // iteminfo.MedChrgitm = "11"
  19216. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19217. // iteminfo.Amt = westernMedicineCostTotal
  19218. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19219. // iteminfo.ClabAmt = westernMedicine_clab_amt
  19220. // iteminfo.OthAmt = westernMedicine_other_amt
  19221. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19222. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19223. //
  19224. // }
  19225. // if otherCostTotal != 0 {
  19226. // iteminfo.MedChrgitm = "14"
  19227. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19228. // iteminfo.Amt = otherCostTotal
  19229. // iteminfo.ClaaSumfee = other_claa_sunmfee
  19230. // iteminfo.ClabAmt = other_clab_amt
  19231. // iteminfo.OthAmt = other_other_amt
  19232. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19233. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  19234. //
  19235. // }
  19236. // struct4101.IteminfoStruct = iteminfoStructs
  19237. // struct4101.Ntly = "中国"
  19238. // struct4101.AdmCaty = "A03.06"
  19239. //
  19240. // struct4101.DoctorName = doctor.UserName
  19241. // struct4101.DoctorCode = doctor.DoctorNumber
  19242. //
  19243. // var res ResultSeventeen
  19244. //
  19245. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19246. // struct4101.BillCode = order.Number
  19247. // struct4101.BillNo = order.SetlId
  19248. // var resOther ResultSeventeenOther
  19249. // var pp models.PublicParams
  19250. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19251. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19252. // pp.FixmedinsName = miConfig.OrgName
  19253. // pp.FixmedinsCode = miConfig.Code
  19254. // pp.RequestUrl = miConfig.Url
  19255. // pp.Cainfo = miConfig.Cainfo
  19256. // pp.SecretKey = miConfig.SecretKey
  19257. // pp.AccessKey = miConfig.AccessKey
  19258. // pp.OpterName = curRoles.UserName
  19259. //
  19260. // client := &http.Client{}
  19261. // var req *http.Request
  19262. // data := make(map[string]interface{})
  19263. // data["struct4101"] = struct4101
  19264. // data["pp"] = pp
  19265. // bytesData, _ := json.Marshal(data)
  19266. // if miConfig.MdtrtareaAdmvs == "320921" {
  19267. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19268. // } else {
  19269. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19270. // }
  19271. // resp, _ := client.Do(req)
  19272. // defer resp.Body.Close()
  19273. // body, ioErr := ioutil.ReadAll(resp.Body)
  19274. // if ioErr != nil {
  19275. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19276. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19277. // return
  19278. // }
  19279. // var respJSON map[string]interface{}
  19280. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19281. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19282. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19283. // return
  19284. // }
  19285. //
  19286. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19287. // userJSONBytes, _ := json.Marshal(respJSON)
  19288. // fmt.Println("log")
  19289. // fmt.Println(string(userJSONBytes))
  19290. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19291. // utils.ErrorLog("解析失败:%v", err)
  19292. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19293. // return
  19294. // }
  19295. // res.InfRefmsgid = resOther.InfRefmsgid
  19296. // res.Output = resOther.Output
  19297. // res.ErrMsg = resOther.ErrMsg
  19298. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19299. // res.Infcode = infocode
  19300. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  19301. //
  19302. // var pp models.PublicParams
  19303. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19304. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19305. // pp.FixmedinsName = miConfig.OrgName
  19306. // pp.FixmedinsCode = miConfig.Code
  19307. // pp.RequestUrl = miConfig.Url
  19308. // pp.Cainfo = miConfig.Cainfo
  19309. // pp.SecretKey = miConfig.SecretKey
  19310. // pp.AccessKey = miConfig.AccessKey
  19311. // pp.OpterName = curRoles.UserName
  19312. // result, _ := service.Jxyb4101(struct4101, pp)
  19313. // var dat map[string]interface{}
  19314. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19315. // fmt.Println(dat)
  19316. // } else {
  19317. // fmt.Println(err)
  19318. // }
  19319. // userJSONBytes, _ := json.Marshal(dat)
  19320. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19321. // utils.ErrorLog("解析失败:%v", err)
  19322. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19323. // return
  19324. // }
  19325. //
  19326. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  19327. // var pp models.PublicParams
  19328. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19329. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19330. // pp.FixmedinsName = miConfig.OrgName
  19331. // pp.FixmedinsCode = miConfig.Code
  19332. // pp.RequestUrl = miConfig.Url
  19333. // pp.Cainfo = miConfig.Cainfo
  19334. // pp.SecretKey = miConfig.SecretKey
  19335. // pp.AccessKey = miConfig.AccessKey
  19336. // pp.OpterName = curRoles.UserName
  19337. // result, _ := service.Hnyb4101(struct4101, pp)
  19338. // var dat map[string]interface{}
  19339. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19340. // fmt.Println(dat)
  19341. // } else {
  19342. // fmt.Println(err)
  19343. // }
  19344. // userJSONBytes, _ := json.Marshal(dat)
  19345. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19346. // utils.ErrorLog("解析失败:%v", err)
  19347. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19348. // return
  19349. // }
  19350. //
  19351. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  19352. // var resOther ResultSeventeenOther
  19353. //
  19354. // var pp models.PublicParams
  19355. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19356. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19357. // pp.FixmedinsName = miConfig.OrgName
  19358. // pp.FixmedinsCode = miConfig.Code
  19359. // pp.RequestUrl = miConfig.Url
  19360. // pp.Cainfo = miConfig.Cainfo
  19361. // pp.SecretKey = miConfig.SecretKey
  19362. // pp.AccessKey = miConfig.AccessKey
  19363. // pp.OpterName = curRoles.UserName
  19364. // client := &http.Client{}
  19365. // var req *http.Request
  19366. // data := make(map[string]interface{})
  19367. // data["struct4101"] = struct4101
  19368. // data["pp"] = pp
  19369. // bytesData, _ := json.Marshal(data)
  19370. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  19371. // resp, _ := client.Do(req)
  19372. // defer resp.Body.Close()
  19373. // body, ioErr := ioutil.ReadAll(resp.Body)
  19374. // if ioErr != nil {
  19375. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19376. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19377. // return
  19378. // }
  19379. // var respJSON map[string]interface{}
  19380. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19381. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19382. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19383. // return
  19384. // }
  19385. //
  19386. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19387. // userJSONBytes, _ := json.Marshal(respJSON)
  19388. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19389. // utils.ErrorLog("解析失败:%v", err)
  19390. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19391. // return
  19392. // }
  19393. // res.InfRefmsgid = resOther.InfRefmsgid
  19394. // res.Output = resOther.Output
  19395. // res.ErrMsg = resOther.ErrMsg
  19396. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19397. // res.Infcode = infocode
  19398. //
  19399. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  19400. // var pp models.PublicParams
  19401. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19402. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19403. // pp.FixmedinsName = miConfig.OrgName
  19404. // pp.FixmedinsCode = miConfig.Code
  19405. // pp.RequestUrl = miConfig.Url
  19406. // pp.Cainfo = miConfig.Cainfo
  19407. // pp.SecretKey = miConfig.SecretKey
  19408. // pp.AccessKey = miConfig.AccessKey
  19409. // pp.OpterName = curRoles.UserName
  19410. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  19411. // fmt.Println(requestLog)
  19412. // fmt.Println(errMsgLog)
  19413. //
  19414. // saveLog(result, requestLog, "4101a", "上传清单")
  19415. //
  19416. // var dat map[string]interface{}
  19417. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19418. // fmt.Println(dat)
  19419. // } else {
  19420. // fmt.Println(err)
  19421. // }
  19422. // userJSONBytes, _ := json.Marshal(dat)
  19423. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19424. // utils.ErrorLog("解析失败:%v", err)
  19425. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19426. // return
  19427. // }
  19428. //
  19429. // } else {
  19430. //
  19431. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  19432. // var dat map[string]interface{}
  19433. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19434. // fmt.Println(dat)
  19435. // } else {
  19436. // fmt.Println(err)
  19437. // }
  19438. // userJSONBytes, _ := json.Marshal(dat)
  19439. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19440. // utils.ErrorLog("解析失败:%v", err)
  19441. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19442. // return
  19443. // }
  19444. // }
  19445. //
  19446. // if res.Infcode != 0 {
  19447. // adminUser := c.GetAdminUserInfo()
  19448. // errlog := &models.HisOrderError{
  19449. // UserOrgId: adminUser.CurrentOrgId,
  19450. // Ctime: time.Now().Unix(),
  19451. // Mtime: time.Now().Unix(),
  19452. // ErrMsg: res.ErrMsg,
  19453. // Status: 1,
  19454. // PatientId: order.ID,
  19455. // Stage: 10265,
  19456. // }
  19457. // service.CreateErrMsgLog(errlog)
  19458. // continue
  19459. // } else {
  19460. // //order.FaPiaoNumber = zero
  19461. // //order.FaPiaoCode = last_order.FaPiaoCode
  19462. // //service.UpdateOrder(order)
  19463. // hisFundSettleListResult := &models.HisFundSettleListResult{
  19464. // Number: res.Output.SetlListId,
  19465. // Status: 1,
  19466. // Ctime: time.Now().Unix(),
  19467. // Mtime: time.Now().Unix(),
  19468. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19469. // IsUpload: 1,
  19470. // OrderId: order.ID,
  19471. // }
  19472. // service.CreateUploadRecord(hisFundSettleListResult)
  19473. // c.ServeSuccessJSON(map[string]interface{}{
  19474. // "msg": "上传成功",
  19475. // "result": hisFundSettleListResult,
  19476. // })
  19477. // continue
  19478. // }
  19479. // }
  19480. //}
  19481. func (c *HisApiController) GetbatchSettleList() {
  19482. //order_id, _ := c.GetInt64("order_id")
  19483. admin_user_id, _ := c.GetInt64("admin_user_id")
  19484. orders, _ := service.GetAllHisOrderTwo10485()
  19485. for _, item := range orders {
  19486. order, _ := service.GetHisOrderByIDTwo(item.ID)
  19487. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  19488. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  19489. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  19490. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  19491. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  19492. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  19493. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  19494. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  19495. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  19496. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  19497. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  19498. //fmt.Println(count)
  19499. //var zero string
  19500. //number := count + 1
  19501. //if number >= 1000 {
  19502. // zero = "0000" + strconv.FormatInt(number, 10)
  19503. //} else if number >= 10000 {
  19504. // zero = "000" + strconv.FormatInt(number, 10)
  19505. //} else if number >= 100000 {
  19506. // zero = "00" + strconv.FormatInt(number, 10)
  19507. //} else if number >= 1000000 {
  19508. // zero = "0" + strconv.FormatInt(number, 10)
  19509. //} else {
  19510. // zero = strconv.FormatInt(number, 10)
  19511. //}
  19512. //fmt.Println(zero)
  19513. struct4101 := service.Struct4101{
  19514. PsnNo: order.PsnNo,
  19515. MdtrtId: order.MdtrtId,
  19516. SetlId: order.SetlId,
  19517. PsnName: order.PsnName,
  19518. Gend: order.Gend,
  19519. Brdy: his.Brdy,
  19520. Age: his.Age,
  19521. Naty: order.Naty,
  19522. PatnCertType: "01",
  19523. Certno: order.Certno,
  19524. Prfs: "90",
  19525. ConerName: roles[0].UserName,
  19526. PatnRlts: "99",
  19527. ConerAddr: miConfig.OrgName,
  19528. ConerTel: admin.Mobile,
  19529. HiType: order.Insutype,
  19530. Insuplc: miConfig.InsuplcAdmdvs,
  19531. MaindiagFlag: "1",
  19532. BillCode: order.SetlId,
  19533. BillNo: order.SetlId,
  19534. BizSn: order.Number,
  19535. PsnSelfPay: order.PsnPartAmt,
  19536. PsnOwnPay: order.PsnPartAmt,
  19537. AcctPay: order.AcctPay,
  19538. PsnCashpay: order.PsnCashPay,
  19539. HiPaymtd: "1",
  19540. Hsorg: miConfig.InsuplcAdmdvs,
  19541. HsorgOpter: miConfig.InsuplcAdmdvs,
  19542. MedinsFillPsn: curRoles.UserName,
  19543. MedinsFillDept: miConfig.OrgName,
  19544. IptMedType: "2",
  19545. }
  19546. struct4101.SetlBegnDate = order.SetlTime
  19547. struct4101.SetlEndDate = order.SetlTime
  19548. time_arr := strings.Split(order.SetlTime, " ")
  19549. struct4101.AdmTime = time_arr[0]
  19550. struct4101.AdmEndTime = time_arr[0]
  19551. //var rf []CustomFundPay
  19552. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  19553. //
  19554. //var tempFunPays []service.CustomStruct
  19555. //for _, item := range rf {
  19556. // var tempFunPay service.CustomStruct
  19557. // tempFunPay.FundPayamt = item.FundPayamt
  19558. // tempFunPay.FundPayType = item.FundPayType
  19559. // tempFunPays = append(tempFunPays, tempFunPay)
  19560. //}
  19561. //struct4101.CustomStruct = tempFunPays
  19562. var tempDiaginfos []service.DiaginfoStructTwo
  19563. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  19564. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  19565. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  19566. var config []*models.HisXtDiagnoseConfig
  19567. for _, item := range diagnosis_ids {
  19568. id, _ := strconv.ParseInt(item, 10, 64)
  19569. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19570. config = append(config, &diagnosisConfig)
  19571. }
  19572. for index, item := range config {
  19573. if index == 0 {
  19574. var tempDiaginfo service.DiaginfoStructTwo
  19575. tempDiaginfo.DiagCode = item.CountryCode
  19576. tempDiaginfo.DiagName = item.CountryContentName
  19577. tempDiaginfo.DiagType = "1"
  19578. tempDiaginfo.MaindiagFlag = "1"
  19579. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19580. } else {
  19581. var tempDiaginfo service.DiaginfoStructTwo
  19582. tempDiaginfo.DiagCode = item.CountryCode
  19583. tempDiaginfo.DiagName = item.CountryContentName
  19584. tempDiaginfo.DiagType = "1"
  19585. tempDiaginfo.MaindiagFlag = "0"
  19586. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  19587. }
  19588. }
  19589. struct4101.Diseinfo = tempDiaginfos
  19590. sickConfigTwo, _ := service.FindSickById(his.SickType)
  19591. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  19592. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  19593. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  19594. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  19595. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  19596. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  19597. var iteminfo service.IteminfoStruct
  19598. var bedCostTotal float64 = 0 //床位总费
  19599. var bedCostSelfTotal float64 = 0 //床位自费
  19600. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  19601. var operationCostTotal float64 = 0 //手术费
  19602. var operationCostSelfTotal float64 = 0 //手术费
  19603. var operationCostPartSelfTotal float64 = 0 //手术费
  19604. var otherCostTotal float64 = 0 //其他费用
  19605. var otherCostSelfTotal float64 = 0 //其他费用
  19606. var otherCostPartSelfTotal float64 = 0 //其他费用
  19607. var materialCostTotal float64 = 0 //材料费
  19608. var materialCostSelfTotal float64 = 0 //材料费
  19609. var materialCostPartSelfTotal float64 = 0 //材料费
  19610. var westernMedicineCostTotal float64 = 0 //西药费
  19611. var westernMedicineCostSelfTotal float64 = 0 //西药费
  19612. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  19613. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  19614. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  19615. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  19616. var checkCostTotal float64 = 0 //检查费
  19617. var checkCostSelfTotal float64 = 0 //检查费
  19618. var checkCostPartSelfTotal float64 = 0 //检查费
  19619. var laboratoryCostTotal float64 = 0 //化验费
  19620. var laboratoryCostSelfTotal float64 = 0 //化验费
  19621. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  19622. var treatCostTotal float64 = 0 //治疗费用
  19623. var treatCostSelfTotal float64 = 0 //治疗费用
  19624. var treatCostPartSelfTotal float64 = 0 //治疗费用
  19625. decimal.DivisionPrecision = 2
  19626. var bed_fulamt_ownpay_amt float64 = 0
  19627. var operation_fulamt_ownpay_amt float64 = 0
  19628. var other_fulamt_ownpay_amt float64 = 0
  19629. var westernMedicine_fulamt_ownpay_amt float64 = 0
  19630. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  19631. var check_fulamt_ownpay_amt float64 = 0
  19632. var material_fulamt_ownpay_amt float64 = 0
  19633. var laboratory_fulamt_ownpay_amt float64 = 0
  19634. var treat_fulamt_ownpay_amt float64 = 0
  19635. var bed_claa_sunmfee float64 = 0
  19636. var bed_clab_amt float64 = 0
  19637. var bed_other_amt float64 = 0
  19638. var operation_claa_sunmfee float64 = 0
  19639. var operation_clab_amt float64 = 0
  19640. var operation_other_amt float64 = 0
  19641. var other_claa_sunmfee float64 = 0
  19642. var other_clab_amt float64 = 0
  19643. var other_other_amt float64 = 0
  19644. var westernMedicine_claa_sunmfee float64 = 0
  19645. var westernMedicine_clab_amt float64 = 0
  19646. var westernMedicine_other_amt float64 = 0
  19647. var chineseTraditional_claa_sunmfee float64 = 0
  19648. var chineseTraditional_clab_amt float64 = 0
  19649. var chineseTraditional_other_amt float64 = 0
  19650. var check_claa_sunmfee float64 = 0
  19651. var check_clab_amt float64 = 0
  19652. var check_other_amt float64 = 0
  19653. var material_claa_sunmfee float64 = 0
  19654. var material_clab_amt float64 = 0
  19655. var material_other_amt float64 = 0
  19656. var laboratory_claa_sunmfee float64 = 0
  19657. var laboratory_clab_amt float64 = 0
  19658. var laboratory_other_amt float64 = 0
  19659. var treat_claa_sunmfee float64 = 0
  19660. var treat_clab_amt float64 = 0
  19661. var treat_other_amt float64 = 0
  19662. for _, item := range order.HisOrderInfo {
  19663. if item.MedChrgitmType == "01" { //床位费
  19664. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19665. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19666. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19667. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19668. if item.ChrgitmLv == "1" {
  19669. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19670. }
  19671. if item.ChrgitmLv == "2" {
  19672. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19673. }
  19674. if item.ChrgitmLv == "3" {
  19675. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19676. }
  19677. }
  19678. if item.MedChrgitmType == "03" { //检查费
  19679. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19680. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19681. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19682. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19683. if item.ChrgitmLv == "1" {
  19684. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19685. }
  19686. if item.ChrgitmLv == "2" {
  19687. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19688. }
  19689. if item.ChrgitmLv == "3" {
  19690. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19691. }
  19692. }
  19693. if item.MedChrgitmType == "04" { //化验费
  19694. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19695. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19696. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19697. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19698. if item.ChrgitmLv == "1" {
  19699. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19700. }
  19701. if item.ChrgitmLv == "2" {
  19702. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19703. }
  19704. if item.ChrgitmLv == "3" {
  19705. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19706. }
  19707. }
  19708. if item.MedChrgitmType == "05" { //治疗费
  19709. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19710. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19711. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19712. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19713. if item.ChrgitmLv == "1" {
  19714. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19715. }
  19716. if item.ChrgitmLv == "2" {
  19717. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19718. }
  19719. if item.ChrgitmLv == "3" {
  19720. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19721. }
  19722. }
  19723. if item.MedChrgitmType == "06" { //手术费
  19724. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19725. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19726. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19727. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19728. if item.ChrgitmLv == "1" {
  19729. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19730. }
  19731. if item.ChrgitmLv == "2" {
  19732. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19733. }
  19734. if item.ChrgitmLv == "3" {
  19735. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19736. }
  19737. }
  19738. if item.MedChrgitmType == "08" { //材料费
  19739. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19740. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19741. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19742. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19743. if item.ChrgitmLv == "1" {
  19744. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19745. }
  19746. if item.ChrgitmLv == "2" {
  19747. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19748. }
  19749. if item.ChrgitmLv == "3" {
  19750. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19751. }
  19752. }
  19753. if item.MedChrgitmType == "09" { //西药费
  19754. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19755. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19756. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19757. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19758. if item.ChrgitmLv == "1" {
  19759. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19760. }
  19761. if item.ChrgitmLv == "2" {
  19762. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19763. }
  19764. if item.ChrgitmLv == "3" {
  19765. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19766. }
  19767. }
  19768. if item.MedChrgitmType == "11" { //中成费
  19769. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19770. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19771. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19772. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19773. if item.ChrgitmLv == "1" {
  19774. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19775. }
  19776. if item.ChrgitmLv == "2" {
  19777. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19778. }
  19779. if item.ChrgitmLv == "3" {
  19780. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19781. }
  19782. }
  19783. if item.MedChrgitmType == "14" { //其他费
  19784. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19785. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19786. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19787. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  19788. if item.ChrgitmLv == "1" {
  19789. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  19790. }
  19791. if item.ChrgitmLv == "2" {
  19792. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  19793. }
  19794. if item.ChrgitmLv == "3" {
  19795. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  19796. }
  19797. }
  19798. }
  19799. var iteminfoStructs []service.IteminfoStruct
  19800. if bedCostTotal != 0 {
  19801. iteminfo.MedChrgitm = "01"
  19802. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19803. iteminfo.Amt = bedCostTotal
  19804. iteminfo.ClaaSumfee = bed_claa_sunmfee
  19805. iteminfo.ClabAmt = bed_clab_amt
  19806. iteminfo.OthAmt = bed_other_amt
  19807. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19808. }
  19809. if checkCostTotal != 0 {
  19810. iteminfo.MedChrgitm = "03"
  19811. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  19812. iteminfo.Amt = checkCostTotal
  19813. iteminfo.ClaaSumfee = check_claa_sunmfee
  19814. iteminfo.ClabAmt = check_clab_amt
  19815. iteminfo.OthAmt = check_other_amt
  19816. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19817. }
  19818. if laboratoryCostTotal != 0 {
  19819. iteminfo.MedChrgitm = "04"
  19820. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  19821. iteminfo.Amt = laboratoryCostTotal
  19822. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  19823. iteminfo.ClabAmt = laboratory_clab_amt
  19824. iteminfo.OthAmt = laboratory_other_amt
  19825. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19826. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19827. }
  19828. if treatCostTotal != 0 {
  19829. iteminfo.MedChrgitm = "05"
  19830. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  19831. iteminfo.Amt = treatCostTotal
  19832. iteminfo.ClaaSumfee = treat_claa_sunmfee
  19833. iteminfo.ClabAmt = treat_clab_amt
  19834. iteminfo.OthAmt = treat_other_amt
  19835. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19836. //(struct4101.IteminfoStruct, iteminfo)
  19837. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19838. }
  19839. if operationCostTotal != 0 {
  19840. iteminfo.MedChrgitm = "06"
  19841. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  19842. iteminfo.Amt = operationCostTotal
  19843. iteminfo.ClaaSumfee = operation_claa_sunmfee
  19844. iteminfo.ClabAmt = operation_clab_amt
  19845. iteminfo.OthAmt = operation_other_amt
  19846. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19847. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19848. }
  19849. if materialCostTotal != 0 {
  19850. iteminfo.MedChrgitm = "08"
  19851. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  19852. iteminfo.Amt = materialCostTotal
  19853. iteminfo.ClaaSumfee = material_claa_sunmfee
  19854. iteminfo.ClabAmt = material_clab_amt
  19855. iteminfo.OthAmt = material_other_amt
  19856. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19857. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19858. }
  19859. if westernMedicineCostTotal != 0 {
  19860. iteminfo.MedChrgitm = "09"
  19861. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19862. iteminfo.Amt = westernMedicineCostTotal
  19863. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19864. iteminfo.ClabAmt = westernMedicine_clab_amt
  19865. iteminfo.OthAmt = westernMedicine_other_amt
  19866. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19867. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19868. }
  19869. if chineseTraditionalMedicineCostTotal != 0 {
  19870. iteminfo.MedChrgitm = "11"
  19871. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  19872. iteminfo.Amt = westernMedicineCostTotal
  19873. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  19874. iteminfo.ClabAmt = westernMedicine_clab_amt
  19875. iteminfo.OthAmt = westernMedicine_other_amt
  19876. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19877. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19878. }
  19879. if otherCostTotal != 0 {
  19880. iteminfo.MedChrgitm = "14"
  19881. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  19882. iteminfo.Amt = otherCostTotal
  19883. iteminfo.ClaaSumfee = other_claa_sunmfee
  19884. iteminfo.ClabAmt = other_clab_amt
  19885. iteminfo.OthAmt = other_other_amt
  19886. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  19887. iteminfoStructs = append(iteminfoStructs, iteminfo)
  19888. }
  19889. struct4101.IteminfoStruct = iteminfoStructs
  19890. struct4101.Ntly = "中国"
  19891. struct4101.AdmCaty = "A03.06"
  19892. struct4101.DoctorName = doctor.UserName
  19893. struct4101.DoctorCode = doctor.DoctorNumber
  19894. var res ResultSeventeen
  19895. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  19896. struct4101.BillCode = order.Number
  19897. struct4101.BillNo = order.SetlId
  19898. var resOther ResultSeventeenOther
  19899. var pp models.PublicParams
  19900. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  19901. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19902. pp.FixmedinsName = miConfig.OrgName
  19903. pp.FixmedinsCode = miConfig.Code
  19904. pp.RequestUrl = miConfig.Url
  19905. pp.Cainfo = miConfig.Cainfo
  19906. pp.SecretKey = miConfig.SecretKey
  19907. pp.AccessKey = miConfig.AccessKey
  19908. pp.OpterName = curRoles.UserName
  19909. client := &http.Client{}
  19910. var req *http.Request
  19911. data := make(map[string]interface{})
  19912. data["struct4101"] = struct4101
  19913. data["pp"] = pp
  19914. bytesData, _ := json.Marshal(data)
  19915. if miConfig.MdtrtareaAdmvs == "320830" {
  19916. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/4101", bytes.NewReader(bytesData))
  19917. } else if miConfig.MdtrtareaAdmvs == "320921" {
  19918. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19919. } else {
  19920. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  19921. }
  19922. resp, _ := client.Do(req)
  19923. defer resp.Body.Close()
  19924. body, ioErr := ioutil.ReadAll(resp.Body)
  19925. if ioErr != nil {
  19926. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19928. return
  19929. }
  19930. var respJSON map[string]interface{}
  19931. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19932. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19934. return
  19935. }
  19936. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  19937. userJSONBytes, _ := json.Marshal(respJSON)
  19938. fmt.Println("log")
  19939. fmt.Println(string(userJSONBytes))
  19940. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  19941. utils.ErrorLog("解析失败:%v", err)
  19942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19943. return
  19944. }
  19945. res.InfRefmsgid = resOther.InfRefmsgid
  19946. res.Output = resOther.Output
  19947. res.ErrMsg = resOther.ErrMsg
  19948. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  19949. res.Infcode = infocode
  19950. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19951. var pp models.PublicParams
  19952. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19953. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19954. pp.FixmedinsName = miConfig.OrgName
  19955. pp.FixmedinsCode = miConfig.Code
  19956. pp.RequestUrl = miConfig.Url
  19957. pp.Cainfo = miConfig.Cainfo
  19958. pp.SecretKey = miConfig.SecretKey
  19959. pp.AccessKey = miConfig.AccessKey
  19960. pp.OpterName = curRoles.UserName
  19961. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  19962. result, _ := service.Jxyb4101(struct4101, pp)
  19963. var dat map[string]interface{}
  19964. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19965. fmt.Println(dat)
  19966. } else {
  19967. fmt.Println(err)
  19968. }
  19969. userJSONBytes, _ := json.Marshal(dat)
  19970. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19971. utils.ErrorLog("解析失败:%v", err)
  19972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19973. return
  19974. }
  19975. } else if miConfig.MdtrtareaAdmvs == "361025" {
  19976. var pp models.PublicParams
  19977. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  19978. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  19979. pp.FixmedinsName = miConfig.OrgName
  19980. pp.FixmedinsCode = miConfig.Code
  19981. pp.RequestUrl = miConfig.Url
  19982. pp.Cainfo = miConfig.Cainfo
  19983. pp.SecretKey = miConfig.SecretKey
  19984. pp.AccessKey = miConfig.AccessKey
  19985. pp.OpterName = curRoles.UserName
  19986. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  19987. result, _ := service.Jxyb4101(struct4101, pp)
  19988. var dat map[string]interface{}
  19989. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19990. fmt.Println(dat)
  19991. } else {
  19992. fmt.Println(err)
  19993. }
  19994. userJSONBytes, _ := json.Marshal(dat)
  19995. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19996. utils.ErrorLog("解析失败:%v", err)
  19997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19998. return
  19999. }
  20000. } else if miConfig.MdtrtareaAdmvs == "360100" {
  20001. var pp models.PublicParams
  20002. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20003. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20004. pp.FixmedinsName = miConfig.OrgName
  20005. pp.FixmedinsCode = miConfig.Code
  20006. pp.RequestUrl = miConfig.Url
  20007. pp.Cainfo = miConfig.Cainfo
  20008. pp.SecretKey = miConfig.SecretKey
  20009. pp.AccessKey = miConfig.AccessKey
  20010. pp.OpterName = curRoles.UserName
  20011. utils.ErrorLog("解析失败:%v", his.InsuplcAdmdvs)
  20012. result, _ := service.Jxyb4101(struct4101, pp)
  20013. var dat map[string]interface{}
  20014. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20015. fmt.Println(dat)
  20016. } else {
  20017. fmt.Println(err)
  20018. }
  20019. userJSONBytes, _ := json.Marshal(dat)
  20020. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20021. utils.ErrorLog("解析失败:%v", err)
  20022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20023. return
  20024. }
  20025. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20026. var pp models.PublicParams
  20027. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20028. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20029. pp.FixmedinsName = miConfig.OrgName
  20030. pp.FixmedinsCode = miConfig.Code
  20031. pp.RequestUrl = miConfig.Url
  20032. pp.Cainfo = miConfig.Cainfo
  20033. pp.SecretKey = miConfig.SecretKey
  20034. pp.AccessKey = miConfig.AccessKey
  20035. pp.OpterName = curRoles.UserName
  20036. result, _ := service.Hnyb4101(struct4101, pp)
  20037. var dat map[string]interface{}
  20038. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20039. fmt.Println(dat)
  20040. } else {
  20041. fmt.Println(err)
  20042. }
  20043. userJSONBytes, _ := json.Marshal(dat)
  20044. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20045. utils.ErrorLog("解析失败:%v", err)
  20046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20047. return
  20048. }
  20049. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20050. var resOther ResultSeventeenOther
  20051. var pp models.PublicParams
  20052. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20053. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20054. pp.FixmedinsName = miConfig.OrgName
  20055. pp.FixmedinsCode = miConfig.Code
  20056. pp.RequestUrl = miConfig.Url
  20057. pp.Cainfo = miConfig.Cainfo
  20058. pp.SecretKey = miConfig.SecretKey
  20059. pp.AccessKey = miConfig.AccessKey
  20060. pp.OpterName = curRoles.UserName
  20061. client := &http.Client{}
  20062. var req *http.Request
  20063. data := make(map[string]interface{})
  20064. data["struct4101"] = struct4101
  20065. data["pp"] = pp
  20066. bytesData, _ := json.Marshal(data)
  20067. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20068. resp, _ := client.Do(req)
  20069. defer resp.Body.Close()
  20070. body, ioErr := ioutil.ReadAll(resp.Body)
  20071. if ioErr != nil {
  20072. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20074. return
  20075. }
  20076. var respJSON map[string]interface{}
  20077. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20078. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20080. return
  20081. }
  20082. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20083. userJSONBytes, _ := json.Marshal(respJSON)
  20084. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20085. utils.ErrorLog("解析失败:%v", err)
  20086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20087. return
  20088. }
  20089. res.InfRefmsgid = resOther.InfRefmsgid
  20090. res.Output = resOther.Output
  20091. res.ErrMsg = resOther.ErrMsg
  20092. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20093. res.Infcode = infocode
  20094. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20095. var pp models.PublicParams
  20096. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20097. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20098. pp.FixmedinsName = miConfig.OrgName
  20099. pp.FixmedinsCode = miConfig.Code
  20100. pp.RequestUrl = miConfig.Url
  20101. pp.Cainfo = miConfig.Cainfo
  20102. pp.SecretKey = miConfig.SecretKey
  20103. pp.AccessKey = miConfig.AccessKey
  20104. pp.OpterName = curRoles.UserName
  20105. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  20106. fmt.Println(requestLog)
  20107. fmt.Println(errMsgLog)
  20108. saveLog(result, requestLog, "4101a", "上传清单")
  20109. var dat map[string]interface{}
  20110. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20111. fmt.Println(dat)
  20112. } else {
  20113. fmt.Println(err)
  20114. }
  20115. userJSONBytes, _ := json.Marshal(dat)
  20116. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20117. utils.ErrorLog("解析失败:%v", err)
  20118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20119. return
  20120. }
  20121. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20122. var pp models.PublicParams
  20123. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20124. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20125. pp.FixmedinsName = miConfig.OrgName
  20126. pp.FixmedinsCode = miConfig.Code
  20127. pp.RequestUrl = miConfig.Url
  20128. pp.Cainfo = miConfig.Cainfo
  20129. pp.SecretKey = miConfig.SecretKey
  20130. pp.AccessKey = miConfig.AccessKey
  20131. pp.OpterName = curRoles.UserName
  20132. client := &http.Client{}
  20133. var req *http.Request
  20134. data := make(map[string]interface{})
  20135. data["struct4101"] = struct4101
  20136. data["pp"] = pp
  20137. bytesData, _ := json.Marshal(data)
  20138. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  20139. resp, _ := client.Do(req)
  20140. defer resp.Body.Close()
  20141. body, ioErr := ioutil.ReadAll(resp.Body)
  20142. if ioErr != nil {
  20143. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20145. return
  20146. }
  20147. var respJSON map[string]interface{}
  20148. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20149. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20151. return
  20152. }
  20153. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20154. userJSONBytes, _ := json.Marshal(respJSON)
  20155. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20156. utils.ErrorLog("解析失败:%v", err)
  20157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20158. return
  20159. }
  20160. } else {
  20161. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20162. var dat map[string]interface{}
  20163. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20164. fmt.Println(dat)
  20165. } else {
  20166. fmt.Println(err)
  20167. }
  20168. userJSONBytes, _ := json.Marshal(dat)
  20169. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20170. utils.ErrorLog("解析失败:%v", err)
  20171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20172. return
  20173. }
  20174. }
  20175. if res.Infcode != 0 {
  20176. errlog := &models.HisOrderError{
  20177. UserOrgId: order.UserOrgId,
  20178. Ctime: time.Now().Unix(),
  20179. Mtime: time.Now().Unix(),
  20180. ErrMsg: res.ErrMsg + "解析失败",
  20181. Status: 1,
  20182. PatientId: order.ID,
  20183. Stage: 10485,
  20184. }
  20185. service.CreateErrMsgLog(errlog)
  20186. continue
  20187. //c.ServeSuccessJSON(map[string]interface{}{
  20188. // "failed_code": -10,
  20189. // "msg": res.ErrMsg,
  20190. //})
  20191. } else {
  20192. //order.FaPiaoNumber = zero
  20193. //order.FaPiaoCode = last_order.FaPiaoCode
  20194. //service.UpdateOrder(order)
  20195. hisFundSettleListResult := &models.HisFundSettleListResult{
  20196. Number: res.Output.SetlListId,
  20197. Status: 1,
  20198. Ctime: time.Now().Unix(),
  20199. Mtime: time.Now().Unix(),
  20200. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20201. IsUpload: 1,
  20202. OrderId: order.ID,
  20203. }
  20204. service.CreateUploadRecord(hisFundSettleListResult)
  20205. continue
  20206. }
  20207. }
  20208. }
  20209. func (c *HisApiController) GetSettleList() {
  20210. order_id, _ := c.GetInt64("order_id")
  20211. admin_user_id, _ := c.GetInt64("admin_user_id")
  20212. order, _ := service.GetHisOrderByIDTwo(order_id)
  20213. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20214. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  20215. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20216. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  20217. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20218. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20219. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  20220. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  20221. if order.ID == 0 {
  20222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20223. return
  20224. }
  20225. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  20226. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  20227. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  20228. //fmt.Println(count)
  20229. //var zero string
  20230. //number := count + 1
  20231. //if number >= 1000 {
  20232. // zero = "0000" + strconv.FormatInt(number, 10)
  20233. //} else if number >= 10000 {
  20234. // zero = "000" + strconv.FormatInt(number, 10)
  20235. //} else if number >= 100000 {
  20236. // zero = "00" + strconv.FormatInt(number, 10)
  20237. //} else if number >= 1000000 {
  20238. // zero = "0" + strconv.FormatInt(number, 10)
  20239. //} else {
  20240. // zero = strconv.FormatInt(number, 10)
  20241. //}
  20242. //fmt.Println(zero)
  20243. struct4101 := service.Struct4101{
  20244. PsnNo: order.PsnNo,
  20245. MdtrtId: order.MdtrtId,
  20246. SetlId: order.SetlId,
  20247. PsnName: order.PsnName,
  20248. Gend: order.Gend,
  20249. Brdy: his.Brdy,
  20250. Age: his.Age,
  20251. Naty: order.Naty,
  20252. PatnCertType: "01",
  20253. Certno: order.Certno,
  20254. Prfs: "90",
  20255. ConerName: roles[0].UserName,
  20256. PatnRlts: "99",
  20257. ConerAddr: miConfig.OrgName,
  20258. ConerTel: admin.Mobile,
  20259. HiType: order.Insutype,
  20260. Insuplc: miConfig.InsuplcAdmdvs,
  20261. MaindiagFlag: "1",
  20262. BillCode: order.SetlId,
  20263. BillNo: order.SetlId,
  20264. BizSn: order.Number,
  20265. PsnSelfPay: order.PsnPartAmt,
  20266. PsnOwnPay: order.PsnPartAmt,
  20267. AcctPay: order.AcctPay,
  20268. PsnCashpay: order.PsnCashPay,
  20269. HiPaymtd: "1",
  20270. Hsorg: miConfig.InsuplcAdmdvs,
  20271. HsorgOpter: miConfig.InsuplcAdmdvs,
  20272. MedinsFillPsn: curRoles.UserName,
  20273. MedinsFillDept: miConfig.OrgName,
  20274. IptMedType: "2",
  20275. }
  20276. struct4101.SetlBegnDate = order.SetlTime
  20277. struct4101.SetlEndDate = order.SetlTime
  20278. time_arr := strings.Split(order.SetlTime, " ")
  20279. struct4101.AdmTime = time_arr[0]
  20280. struct4101.AdmEndTime = time_arr[0]
  20281. //
  20282. //var rf []CustomFundPay
  20283. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  20284. //
  20285. //var tempFunPays []service.CustomStruct
  20286. //for _, item := range rf {
  20287. // var tempFunPay service.CustomStruct
  20288. // tempFunPay.FundPayamt = item.FundPayamt
  20289. // tempFunPay.FundPayType = item.FundPayType
  20290. // tempFunPays = append(tempFunPays, tempFunPay)
  20291. //}
  20292. //struct4101.CustomStruct = tempFunPays
  20293. var tempDiaginfos []service.DiaginfoStructTwo
  20294. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  20295. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  20296. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  20297. var config []*models.HisXtDiagnoseConfig
  20298. for _, item := range diagnosis_ids {
  20299. id, _ := strconv.ParseInt(item, 10, 64)
  20300. diagnosisConfig, _ := service.FindDiagnoseById(id)
  20301. config = append(config, &diagnosisConfig)
  20302. }
  20303. if miConfig.Code == "H15049901371" {
  20304. //for _, item := range config {
  20305. // if item.ID == 138 {
  20306. diagnosisConfig, _ := service.FindDiagnoseById(138)
  20307. var tempDiaginfo service.DiaginfoStructTwo
  20308. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  20309. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  20310. tempDiaginfo.DiagType = "1"
  20311. tempDiaginfo.MaindiagFlag = "1"
  20312. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20313. //}
  20314. //}
  20315. for _, item := range config {
  20316. if item.ID != 138 {
  20317. var tempDiaginfo service.DiaginfoStructTwo
  20318. tempDiaginfo.DiagCode = item.CountryCode
  20319. tempDiaginfo.DiagName = item.CountryContentName
  20320. tempDiaginfo.DiagType = "1"
  20321. tempDiaginfo.MaindiagFlag = "0"
  20322. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20323. }
  20324. }
  20325. } else {
  20326. for index, item := range config {
  20327. if index == 0 {
  20328. var tempDiaginfo service.DiaginfoStructTwo
  20329. tempDiaginfo.DiagCode = item.CountryCode
  20330. tempDiaginfo.DiagName = item.CountryContentName
  20331. tempDiaginfo.DiagType = "1"
  20332. tempDiaginfo.MaindiagFlag = "1"
  20333. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20334. } else {
  20335. var tempDiaginfo service.DiaginfoStructTwo
  20336. tempDiaginfo.DiagCode = item.CountryCode
  20337. tempDiaginfo.DiagName = item.CountryContentName
  20338. tempDiaginfo.DiagType = "1"
  20339. tempDiaginfo.MaindiagFlag = "0"
  20340. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  20341. }
  20342. }
  20343. }
  20344. struct4101.Diseinfo = tempDiaginfos
  20345. sickConfigTwo, _ := service.FindSickById(his.SickType)
  20346. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  20347. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  20348. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  20349. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  20350. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  20351. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  20352. var iteminfo service.IteminfoStruct
  20353. var bedCostTotal float64 = 0 //床位总费
  20354. var bedCostSelfTotal float64 = 0 //床位自费
  20355. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  20356. var operationCostTotal float64 = 0 //手术费
  20357. var operationCostSelfTotal float64 = 0 //手术费
  20358. var operationCostPartSelfTotal float64 = 0 //手术费
  20359. var otherCostTotal float64 = 0 //其他费用
  20360. var otherCostSelfTotal float64 = 0 //其他费用
  20361. var otherCostPartSelfTotal float64 = 0 //其他费用
  20362. var materialCostTotal float64 = 0 //材料费
  20363. var materialCostSelfTotal float64 = 0 //材料费
  20364. var materialCostPartSelfTotal float64 = 0 //材料费
  20365. var westernMedicineCostTotal float64 = 0 //西药费
  20366. var westernMedicineCostSelfTotal float64 = 0 //西药费
  20367. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  20368. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  20369. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  20370. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  20371. var checkCostTotal float64 = 0 //检查费
  20372. var checkCostSelfTotal float64 = 0 //检查费
  20373. var checkCostPartSelfTotal float64 = 0 //检查费
  20374. var laboratoryCostTotal float64 = 0 //化验费
  20375. var laboratoryCostSelfTotal float64 = 0 //化验费
  20376. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  20377. var treatCostTotal float64 = 0 //治疗费用
  20378. var treatCostSelfTotal float64 = 0 //治疗费用
  20379. var treatCostPartSelfTotal float64 = 0 //治疗费用
  20380. decimal.DivisionPrecision = 2
  20381. var bed_fulamt_ownpay_amt float64 = 0
  20382. var operation_fulamt_ownpay_amt float64 = 0
  20383. var other_fulamt_ownpay_amt float64 = 0
  20384. var westernMedicine_fulamt_ownpay_amt float64 = 0
  20385. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  20386. var check_fulamt_ownpay_amt float64 = 0
  20387. var material_fulamt_ownpay_amt float64 = 0
  20388. var laboratory_fulamt_ownpay_amt float64 = 0
  20389. var treat_fulamt_ownpay_amt float64 = 0
  20390. var bed_claa_sunmfee float64 = 0
  20391. var bed_clab_amt float64 = 0
  20392. var bed_other_amt float64 = 0
  20393. var operation_claa_sunmfee float64 = 0
  20394. var operation_clab_amt float64 = 0
  20395. var operation_other_amt float64 = 0
  20396. var other_claa_sunmfee float64 = 0
  20397. var other_clab_amt float64 = 0
  20398. var other_other_amt float64 = 0
  20399. var westernMedicine_claa_sunmfee float64 = 0
  20400. var westernMedicine_clab_amt float64 = 0
  20401. var westernMedicine_other_amt float64 = 0
  20402. var chineseTraditional_claa_sunmfee float64 = 0
  20403. var chineseTraditional_clab_amt float64 = 0
  20404. var chineseTraditional_other_amt float64 = 0
  20405. var check_claa_sunmfee float64 = 0
  20406. var check_clab_amt float64 = 0
  20407. var check_other_amt float64 = 0
  20408. var material_claa_sunmfee float64 = 0
  20409. var material_clab_amt float64 = 0
  20410. var material_other_amt float64 = 0
  20411. var laboratory_claa_sunmfee float64 = 0
  20412. var laboratory_clab_amt float64 = 0
  20413. var laboratory_other_amt float64 = 0
  20414. var treat_claa_sunmfee float64 = 0
  20415. var treat_clab_amt float64 = 0
  20416. var treat_other_amt float64 = 0
  20417. for _, item := range order.HisOrderInfo {
  20418. if item.MedChrgitmType == "01" { //床位费
  20419. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20420. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20421. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20422. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20423. if item.ChrgitmLv == "1" {
  20424. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20425. }
  20426. if item.ChrgitmLv == "2" {
  20427. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20428. }
  20429. if item.ChrgitmLv == "3" {
  20430. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20431. }
  20432. }
  20433. if item.MedChrgitmType == "03" { //检查费
  20434. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20435. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20436. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20437. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20438. if item.ChrgitmLv == "1" {
  20439. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20440. }
  20441. if item.ChrgitmLv == "2" {
  20442. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20443. }
  20444. if item.ChrgitmLv == "3" {
  20445. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20446. }
  20447. }
  20448. if item.MedChrgitmType == "04" { //化验费
  20449. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20450. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20451. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20452. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20453. if item.ChrgitmLv == "1" {
  20454. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20455. }
  20456. if item.ChrgitmLv == "2" {
  20457. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20458. }
  20459. if item.ChrgitmLv == "3" {
  20460. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20461. }
  20462. }
  20463. if item.MedChrgitmType == "05" { //治疗费
  20464. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20465. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20466. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20467. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20468. if item.ChrgitmLv == "1" {
  20469. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20470. }
  20471. if item.ChrgitmLv == "2" {
  20472. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20473. }
  20474. if item.ChrgitmLv == "3" {
  20475. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20476. }
  20477. }
  20478. if item.MedChrgitmType == "06" { //手术费
  20479. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20480. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20481. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20482. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20483. if item.ChrgitmLv == "1" {
  20484. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20485. }
  20486. if item.ChrgitmLv == "2" {
  20487. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20488. }
  20489. if item.ChrgitmLv == "3" {
  20490. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20491. }
  20492. }
  20493. if item.MedChrgitmType == "08" { //材料费
  20494. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20495. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20496. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20497. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20498. if item.ChrgitmLv == "1" {
  20499. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20500. }
  20501. if item.ChrgitmLv == "2" {
  20502. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20503. }
  20504. if item.ChrgitmLv == "3" {
  20505. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20506. }
  20507. }
  20508. if item.MedChrgitmType == "09" { //西药费
  20509. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20510. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20511. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20512. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20513. if item.ChrgitmLv == "1" {
  20514. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20515. }
  20516. if item.ChrgitmLv == "2" {
  20517. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20518. }
  20519. if item.ChrgitmLv == "3" {
  20520. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20521. }
  20522. }
  20523. if item.MedChrgitmType == "11" { //中成费
  20524. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20525. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20526. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20527. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20528. if item.ChrgitmLv == "1" {
  20529. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20530. }
  20531. if item.ChrgitmLv == "2" {
  20532. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20533. }
  20534. if item.ChrgitmLv == "3" {
  20535. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20536. }
  20537. }
  20538. if item.MedChrgitmType == "14" { //其他费
  20539. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20540. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20541. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20542. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  20543. if item.ChrgitmLv == "1" {
  20544. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  20545. }
  20546. if item.ChrgitmLv == "2" {
  20547. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  20548. }
  20549. if item.ChrgitmLv == "3" {
  20550. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  20551. }
  20552. }
  20553. }
  20554. var iteminfoStructs []service.IteminfoStruct
  20555. if bedCostTotal != 0 {
  20556. iteminfo.MedChrgitm = "01"
  20557. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20558. iteminfo.Amt = bedCostTotal
  20559. iteminfo.ClaaSumfee = bed_claa_sunmfee
  20560. iteminfo.ClabAmt = bed_clab_amt
  20561. iteminfo.OthAmt = bed_other_amt
  20562. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20563. }
  20564. if checkCostTotal != 0 {
  20565. iteminfo.MedChrgitm = "03"
  20566. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  20567. iteminfo.Amt = checkCostTotal
  20568. iteminfo.ClaaSumfee = check_claa_sunmfee
  20569. iteminfo.ClabAmt = check_clab_amt
  20570. iteminfo.OthAmt = check_other_amt
  20571. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20572. }
  20573. if laboratoryCostTotal != 0 {
  20574. iteminfo.MedChrgitm = "04"
  20575. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  20576. iteminfo.Amt = laboratoryCostTotal
  20577. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  20578. iteminfo.ClabAmt = laboratory_clab_amt
  20579. iteminfo.OthAmt = laboratory_other_amt
  20580. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20581. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20582. }
  20583. if treatCostTotal != 0 {
  20584. iteminfo.MedChrgitm = "05"
  20585. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  20586. iteminfo.Amt = treatCostTotal
  20587. iteminfo.ClaaSumfee = treat_claa_sunmfee
  20588. iteminfo.ClabAmt = treat_clab_amt
  20589. iteminfo.OthAmt = treat_other_amt
  20590. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20591. //(struct4101.IteminfoStruct, iteminfo)
  20592. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20593. }
  20594. if operationCostTotal != 0 {
  20595. iteminfo.MedChrgitm = "06"
  20596. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  20597. iteminfo.Amt = operationCostTotal
  20598. iteminfo.ClaaSumfee = operation_claa_sunmfee
  20599. iteminfo.ClabAmt = operation_clab_amt
  20600. iteminfo.OthAmt = operation_other_amt
  20601. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20602. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20603. }
  20604. if materialCostTotal != 0 {
  20605. iteminfo.MedChrgitm = "08"
  20606. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  20607. iteminfo.Amt = materialCostTotal
  20608. iteminfo.ClaaSumfee = material_claa_sunmfee
  20609. iteminfo.ClabAmt = material_clab_amt
  20610. iteminfo.OthAmt = material_other_amt
  20611. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20612. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20613. }
  20614. if westernMedicineCostTotal != 0 {
  20615. iteminfo.MedChrgitm = "09"
  20616. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20617. iteminfo.Amt = westernMedicineCostTotal
  20618. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20619. iteminfo.ClabAmt = westernMedicine_clab_amt
  20620. iteminfo.OthAmt = westernMedicine_other_amt
  20621. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20622. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20623. }
  20624. if chineseTraditionalMedicineCostTotal != 0 {
  20625. iteminfo.MedChrgitm = "11"
  20626. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  20627. iteminfo.Amt = westernMedicineCostTotal
  20628. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  20629. iteminfo.ClabAmt = westernMedicine_clab_amt
  20630. iteminfo.OthAmt = westernMedicine_other_amt
  20631. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20632. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20633. }
  20634. if otherCostTotal != 0 {
  20635. iteminfo.MedChrgitm = "14"
  20636. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  20637. iteminfo.Amt = otherCostTotal
  20638. iteminfo.ClaaSumfee = other_claa_sunmfee
  20639. iteminfo.ClabAmt = other_clab_amt
  20640. iteminfo.OthAmt = other_other_amt
  20641. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  20642. iteminfoStructs = append(iteminfoStructs, iteminfo)
  20643. }
  20644. struct4101.IteminfoStruct = iteminfoStructs
  20645. struct4101.Ntly = "中国"
  20646. struct4101.AdmCaty = "A03.06"
  20647. struct4101.DoctorName = doctor.UserName
  20648. struct4101.DoctorCode = doctor.DoctorNumber
  20649. var res ResultSeventeen
  20650. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  20651. struct4101.BillCode = order.Number
  20652. struct4101.BillNo = order.SetlId
  20653. var resOther ResultSeventeenOther
  20654. var pp models.PublicParams
  20655. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20656. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20657. pp.FixmedinsName = miConfig.OrgName
  20658. pp.FixmedinsCode = miConfig.Code
  20659. pp.RequestUrl = miConfig.Url
  20660. pp.Cainfo = miConfig.Cainfo
  20661. pp.SecretKey = miConfig.SecretKey
  20662. pp.AccessKey = miConfig.AccessKey
  20663. pp.OpterName = curRoles.UserName
  20664. client := &http.Client{}
  20665. var req *http.Request
  20666. data := make(map[string]interface{})
  20667. data["struct4101"] = struct4101
  20668. data["pp"] = pp
  20669. bytesData, _ := json.Marshal(data)
  20670. if miConfig.MdtrtareaAdmvs == "320830" {
  20671. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/4101", bytes.NewReader(bytesData))
  20672. } else if miConfig.MdtrtareaAdmvs == "320921" {
  20673. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  20674. } else {
  20675. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  20676. }
  20677. resp, _ := client.Do(req)
  20678. defer resp.Body.Close()
  20679. body, ioErr := ioutil.ReadAll(resp.Body)
  20680. if ioErr != nil {
  20681. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20683. return
  20684. }
  20685. var respJSON map[string]interface{}
  20686. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20687. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20689. return
  20690. }
  20691. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  20692. userJSONBytes, _ := json.Marshal(respJSON)
  20693. fmt.Println("log")
  20694. fmt.Println(string(userJSONBytes))
  20695. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20696. utils.ErrorLog("解析失败:%v", err)
  20697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20698. return
  20699. }
  20700. res.InfRefmsgid = resOther.InfRefmsgid
  20701. res.Output = resOther.Output
  20702. res.ErrMsg = resOther.ErrMsg
  20703. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20704. res.Infcode = infocode
  20705. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20706. var pp models.PublicParams
  20707. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20708. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20709. pp.FixmedinsName = miConfig.OrgName
  20710. pp.FixmedinsCode = miConfig.Code
  20711. pp.RequestUrl = miConfig.Url
  20712. pp.Cainfo = miConfig.Cainfo
  20713. pp.SecretKey = miConfig.SecretKey
  20714. pp.AccessKey = miConfig.AccessKey
  20715. pp.OpterName = curRoles.UserName
  20716. result, _ := service.Jxyb4101(struct4101, pp)
  20717. var dat map[string]interface{}
  20718. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20719. fmt.Println(dat)
  20720. } else {
  20721. fmt.Println(err)
  20722. }
  20723. userJSONBytes, _ := json.Marshal(dat)
  20724. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20725. utils.ErrorLog("解析失败:%v", err)
  20726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20727. return
  20728. }
  20729. } else if miConfig.MdtrtareaAdmvs == "361025" {
  20730. var pp models.PublicParams
  20731. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20732. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20733. pp.FixmedinsName = miConfig.OrgName
  20734. pp.FixmedinsCode = miConfig.Code
  20735. pp.RequestUrl = miConfig.Url
  20736. pp.Cainfo = miConfig.Cainfo
  20737. pp.SecretKey = miConfig.SecretKey
  20738. pp.AccessKey = miConfig.AccessKey
  20739. pp.OpterName = curRoles.UserName
  20740. result, _ := service.Jxyb4101(struct4101, pp)
  20741. var dat map[string]interface{}
  20742. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20743. fmt.Println(dat)
  20744. } else {
  20745. fmt.Println(err)
  20746. }
  20747. userJSONBytes, _ := json.Marshal(dat)
  20748. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20749. utils.ErrorLog("解析失败:%v", err)
  20750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20751. return
  20752. }
  20753. } else if miConfig.MdtrtareaAdmvs == "360100" {
  20754. var pp models.PublicParams
  20755. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  20756. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20757. pp.FixmedinsName = miConfig.OrgName
  20758. pp.FixmedinsCode = miConfig.Code
  20759. pp.RequestUrl = miConfig.Url
  20760. pp.Cainfo = miConfig.Cainfo
  20761. pp.SecretKey = miConfig.SecretKey
  20762. pp.AccessKey = miConfig.AccessKey
  20763. pp.OpterName = curRoles.UserName
  20764. result, _ := service.Jxyb4101(struct4101, pp)
  20765. var dat map[string]interface{}
  20766. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20767. fmt.Println(dat)
  20768. } else {
  20769. fmt.Println(err)
  20770. }
  20771. userJSONBytes, _ := json.Marshal(dat)
  20772. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20773. utils.ErrorLog("解析失败:%v", err)
  20774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20775. return
  20776. }
  20777. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20778. var pp models.PublicParams
  20779. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20780. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20781. pp.FixmedinsName = miConfig.OrgName
  20782. pp.FixmedinsCode = miConfig.Code
  20783. pp.RequestUrl = miConfig.Url
  20784. pp.Cainfo = miConfig.Cainfo
  20785. pp.SecretKey = miConfig.SecretKey
  20786. pp.AccessKey = miConfig.AccessKey
  20787. pp.OpterName = curRoles.UserName
  20788. result, _ := service.Hnyb4101(struct4101, pp)
  20789. var dat map[string]interface{}
  20790. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20791. fmt.Println(dat)
  20792. } else {
  20793. fmt.Println(err)
  20794. }
  20795. userJSONBytes, _ := json.Marshal(dat)
  20796. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20797. utils.ErrorLog("解析失败:%v", err)
  20798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20799. return
  20800. }
  20801. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20802. var resOther ResultSeventeenOther
  20803. var pp models.PublicParams
  20804. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20805. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20806. pp.FixmedinsName = miConfig.OrgName
  20807. pp.FixmedinsCode = miConfig.Code
  20808. pp.RequestUrl = miConfig.Url
  20809. pp.Cainfo = miConfig.Cainfo
  20810. pp.SecretKey = miConfig.SecretKey
  20811. pp.AccessKey = miConfig.AccessKey
  20812. pp.OpterName = curRoles.UserName
  20813. client := &http.Client{}
  20814. var req *http.Request
  20815. data := make(map[string]interface{})
  20816. data["struct4101"] = struct4101
  20817. data["pp"] = pp
  20818. bytesData, _ := json.Marshal(data)
  20819. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  20820. resp, _ := client.Do(req)
  20821. defer resp.Body.Close()
  20822. body, ioErr := ioutil.ReadAll(resp.Body)
  20823. if ioErr != nil {
  20824. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20826. return
  20827. }
  20828. var respJSON map[string]interface{}
  20829. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20830. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20832. return
  20833. }
  20834. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20835. userJSONBytes, _ := json.Marshal(respJSON)
  20836. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  20837. utils.ErrorLog("解析失败:%v", err)
  20838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20839. return
  20840. }
  20841. res.InfRefmsgid = resOther.InfRefmsgid
  20842. res.Output = resOther.Output
  20843. res.ErrMsg = resOther.ErrMsg
  20844. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  20845. res.Infcode = infocode
  20846. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20847. var pp models.PublicParams
  20848. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20849. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20850. pp.FixmedinsName = miConfig.OrgName
  20851. pp.FixmedinsCode = miConfig.Code
  20852. pp.RequestUrl = miConfig.Url
  20853. pp.Cainfo = miConfig.Cainfo
  20854. pp.SecretKey = miConfig.SecretKey
  20855. pp.AccessKey = miConfig.AccessKey
  20856. pp.OpterName = curRoles.UserName
  20857. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  20858. fmt.Println(requestLog)
  20859. fmt.Println(errMsgLog)
  20860. saveLog(result, requestLog, "4101a", "上传清单")
  20861. var dat map[string]interface{}
  20862. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20863. fmt.Println(dat)
  20864. } else {
  20865. fmt.Println(err)
  20866. }
  20867. userJSONBytes, _ := json.Marshal(dat)
  20868. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20869. utils.ErrorLog("解析失败:%v", err)
  20870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20871. return
  20872. }
  20873. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20874. var pp models.PublicParams
  20875. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  20876. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  20877. pp.FixmedinsName = miConfig.OrgName
  20878. pp.FixmedinsCode = miConfig.Code
  20879. pp.RequestUrl = miConfig.Url
  20880. pp.Cainfo = miConfig.Cainfo
  20881. pp.SecretKey = miConfig.SecretKey
  20882. pp.AccessKey = miConfig.AccessKey
  20883. pp.OpterName = curRoles.UserName
  20884. client := &http.Client{}
  20885. var req *http.Request
  20886. data := make(map[string]interface{})
  20887. data["struct4101"] = struct4101
  20888. data["pp"] = pp
  20889. bytesData, _ := json.Marshal(data)
  20890. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  20891. resp, _ := client.Do(req)
  20892. defer resp.Body.Close()
  20893. body, ioErr := ioutil.ReadAll(resp.Body)
  20894. if ioErr != nil {
  20895. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20897. return
  20898. }
  20899. var respJSON map[string]interface{}
  20900. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20901. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20903. return
  20904. }
  20905. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20906. userJSONBytes, _ := json.Marshal(respJSON)
  20907. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20908. utils.ErrorLog("解析失败:%v", err)
  20909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20910. return
  20911. }
  20912. } else {
  20913. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  20914. var dat map[string]interface{}
  20915. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20916. fmt.Println(dat)
  20917. } else {
  20918. fmt.Println(err)
  20919. }
  20920. userJSONBytes, _ := json.Marshal(dat)
  20921. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20922. utils.ErrorLog("解析失败:%v", err)
  20923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20924. return
  20925. }
  20926. }
  20927. if res.Infcode != 0 {
  20928. c.ServeSuccessJSON(map[string]interface{}{
  20929. "failed_code": -10,
  20930. "msg": res.ErrMsg,
  20931. })
  20932. return
  20933. } else {
  20934. //order.FaPiaoNumber = zero
  20935. //order.FaPiaoCode = last_order.FaPiaoCode
  20936. //service.UpdateOrder(order)
  20937. hisFundSettleListResult := &models.HisFundSettleListResult{
  20938. Number: res.Output.SetlListId,
  20939. Status: 1,
  20940. Ctime: time.Now().Unix(),
  20941. Mtime: time.Now().Unix(),
  20942. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20943. IsUpload: 1,
  20944. OrderId: order_id,
  20945. }
  20946. service.CreateUploadRecord(hisFundSettleListResult)
  20947. c.ServeSuccessJSON(map[string]interface{}{
  20948. "msg": "上传成功",
  20949. "result": hisFundSettleListResult,
  20950. })
  20951. return
  20952. }
  20953. }
  20954. func (c *HisApiController) GetSettleListHospital() {
  20955. order_id, _ := c.GetInt64("order_id")
  20956. admin_user_id, _ := c.GetInt64("admin_user_id")
  20957. order, _ := service.GetHisOrderByIDTwo(order_id)
  20958. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  20959. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  20960. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  20961. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  20962. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  20963. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  20964. if order.ID == 0 {
  20965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  20966. return
  20967. }
  20968. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  20969. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  20970. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  20971. fmt.Println(count)
  20972. var zero string
  20973. number := count + 1
  20974. if number >= 1000 {
  20975. zero = "0000" + strconv.FormatInt(number, 10)
  20976. } else if number >= 10000 {
  20977. zero = "000" + strconv.FormatInt(number, 10)
  20978. } else if number >= 100000 {
  20979. zero = "00" + strconv.FormatInt(number, 10)
  20980. } else if number >= 1000000 {
  20981. zero = "0" + strconv.FormatInt(number, 10)
  20982. } else {
  20983. zero = strconv.FormatInt(number, 10)
  20984. }
  20985. fmt.Println(zero)
  20986. struct4101 := service.Struct4101{
  20987. PsnNo: order.PsnNo,
  20988. MdtrtId: order.MdtrtId,
  20989. SetlId: order.SetlId,
  20990. PsnName: order.PsnName,
  20991. Gend: order.Gend,
  20992. Brdy: his.Brdy,
  20993. Age: int64(order.Age),
  20994. Naty: order.Naty,
  20995. PatnCertType: "01",
  20996. Certno: order.Certno,
  20997. Prfs: "90",
  20998. ConerName: roles[0].UserName,
  20999. PatnRlts: "99",
  21000. ConerAddr: miConfig.OrgName,
  21001. ConerTel: admin.Mobile,
  21002. HiType: order.Insutype,
  21003. Insuplc: miConfig.InsuplcAdmdvs,
  21004. MaindiagFlag: "1",
  21005. BillCode: order.SetlId,
  21006. BillNo: order.SetlId,
  21007. BizSn: order.Number,
  21008. PsnSelfPay: order.PsnPartAmt,
  21009. PsnOwnPay: order.PsnPartAmt,
  21010. AcctPay: order.AcctPay,
  21011. PsnCashpay: order.PsnCashPay,
  21012. HiPaymtd: "1",
  21013. Hsorg: miConfig.InsuplcAdmdvs,
  21014. HsorgOpter: miConfig.InsuplcAdmdvs,
  21015. MedinsFillPsn: curRoles.UserName,
  21016. MedinsFillDept: depart.Name,
  21017. IptMedType: "2",
  21018. AdmTime: his.InHosptialTime,
  21019. AdmEndTime: his.OutHosptialTime,
  21020. }
  21021. struct4101.SetlBegnDate = order.SetlTime
  21022. struct4101.SetlEndDate = order.SetlTime
  21023. //var rf []CustomFundPay
  21024. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  21025. //
  21026. //var tempFunPays []service.CustomStruct
  21027. //for _, item := range rf {
  21028. // var tempFunPay service.CustomStruct
  21029. // tempFunPay.FundPayamt = item.FundPayamt
  21030. // tempFunPay.FundPayType = item.FundPayType
  21031. // tempFunPays = append(tempFunPays, tempFunPay)
  21032. //}
  21033. //struct4101.CustomStruct = tempFunPays
  21034. var tempDiaginfos []service.DiaginfoStructTwo
  21035. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  21036. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  21037. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  21038. //for _, item := range infos {
  21039. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  21040. //}
  21041. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  21042. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  21043. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  21044. fmt.Println(diagnosis_ids_arr)
  21045. if order.UserOrgId == 10210 {
  21046. var diagnosis_ids_arr_two []int64
  21047. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  21048. var config []*models.HisXtDiagnoseConfig
  21049. for _, id := range diagnosis_ids_arr_two {
  21050. //id, _ := strconv.ParseInt(item, 10, 64)
  21051. diagnosisConfig, _ := service.FindDiagnoseById(id)
  21052. if diagnosisConfig.ID > 0 {
  21053. config = append(config, &diagnosisConfig)
  21054. }
  21055. }
  21056. for index, item := range config {
  21057. if item.ID > 0 {
  21058. if index == 0 {
  21059. var tempDiaginfo service.DiaginfoStructTwo
  21060. tempDiaginfo.DiagCode = item.CountryCode
  21061. tempDiaginfo.DiagName = item.CountryContentName
  21062. tempDiaginfo.DiagType = "1"
  21063. tempDiaginfo.MaindiagFlag = "1"
  21064. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21065. } else {
  21066. var tempDiaginfo service.DiaginfoStructTwo
  21067. tempDiaginfo.DiagCode = item.CountryCode
  21068. tempDiaginfo.DiagName = item.CountryContentName
  21069. tempDiaginfo.DiagType = "1"
  21070. tempDiaginfo.MaindiagFlag = "0"
  21071. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21072. }
  21073. }
  21074. }
  21075. struct4101.Diseinfo = tempDiaginfos
  21076. } else {
  21077. var config []*models.HisXtDiagnoseConfig
  21078. for _, item := range diagnosis_ids_arr {
  21079. id, _ := strconv.ParseInt(item, 10, 64)
  21080. diagnosisConfig, _ := service.FindDiagnoseById(id)
  21081. if diagnosisConfig.ID > 0 {
  21082. config = append(config, &diagnosisConfig)
  21083. }
  21084. }
  21085. for index, item := range config {
  21086. if item.ID > 0 {
  21087. if index == 0 {
  21088. var tempDiaginfo service.DiaginfoStructTwo
  21089. tempDiaginfo.DiagCode = item.CountryCode
  21090. tempDiaginfo.DiagName = item.CountryContentName
  21091. tempDiaginfo.DiagType = "1"
  21092. tempDiaginfo.MaindiagFlag = "1"
  21093. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21094. } else {
  21095. var tempDiaginfo service.DiaginfoStructTwo
  21096. tempDiaginfo.DiagCode = item.CountryCode
  21097. tempDiaginfo.DiagName = item.CountryContentName
  21098. tempDiaginfo.DiagType = "1"
  21099. tempDiaginfo.MaindiagFlag = "0"
  21100. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21101. }
  21102. }
  21103. }
  21104. struct4101.Diseinfo = tempDiaginfos
  21105. }
  21106. sickConfigTwo, _ := service.FindSickById(his.SickType)
  21107. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  21108. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  21109. tempOpspdiseinfo2.OprnOprtCode = ""
  21110. tempOpspdiseinfo2.OprnOprtName = ""
  21111. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  21112. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  21113. var iteminfo service.IteminfoStruct
  21114. var bedCostTotal float64 = 0 //床位总费
  21115. var bedCostSelfTotal float64 = 0 //床位自费
  21116. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  21117. var operationCostTotal float64 = 0 //手术费
  21118. var operationCostSelfTotal float64 = 0 //手术费
  21119. var operationCostPartSelfTotal float64 = 0 //手术费
  21120. var otherCostTotal float64 = 0 //其他费用
  21121. var otherCostSelfTotal float64 = 0 //其他费用
  21122. var otherCostPartSelfTotal float64 = 0 //其他费用
  21123. var materialCostTotal float64 = 0 //材料费
  21124. var materialCostSelfTotal float64 = 0 //材料费
  21125. var materialCostPartSelfTotal float64 = 0 //材料费
  21126. var westernMedicineCostTotal float64 = 0 //西药费
  21127. var westernMedicineCostSelfTotal float64 = 0 //西药费
  21128. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  21129. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  21130. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  21131. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  21132. var checkCostTotal float64 = 0 //检查费
  21133. var checkCostSelfTotal float64 = 0 //检查费
  21134. var checkCostPartSelfTotal float64 = 0 //检查费
  21135. var laboratoryCostTotal float64 = 0 //化验费
  21136. var laboratoryCostSelfTotal float64 = 0 //化验费
  21137. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  21138. var treatCostTotal float64 = 0 //治疗费用
  21139. var treatCostSelfTotal float64 = 0 //治疗费用
  21140. var treatCostPartSelfTotal float64 = 0 //治疗费用
  21141. decimal.DivisionPrecision = 2
  21142. var bed_fulamt_ownpay_amt float64 = 0
  21143. var operation_fulamt_ownpay_amt float64 = 0
  21144. var other_fulamt_ownpay_amt float64 = 0
  21145. var westernMedicine_fulamt_ownpay_amt float64 = 0
  21146. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  21147. var check_fulamt_ownpay_amt float64 = 0
  21148. var material_fulamt_ownpay_amt float64 = 0
  21149. var laboratory_fulamt_ownpay_amt float64 = 0
  21150. var treat_fulamt_ownpay_amt float64 = 0
  21151. var bed_claa_sunmfee float64 = 0
  21152. var bed_clab_amt float64 = 0
  21153. var bed_other_amt float64 = 0
  21154. var operation_claa_sunmfee float64 = 0
  21155. var operation_clab_amt float64 = 0
  21156. var operation_other_amt float64 = 0
  21157. var other_claa_sunmfee float64 = 0
  21158. var other_clab_amt float64 = 0
  21159. var other_other_amt float64 = 0
  21160. var westernMedicine_claa_sunmfee float64 = 0
  21161. var westernMedicine_clab_amt float64 = 0
  21162. var westernMedicine_other_amt float64 = 0
  21163. var chineseTraditional_claa_sunmfee float64 = 0
  21164. var chineseTraditional_clab_amt float64 = 0
  21165. var chineseTraditional_other_amt float64 = 0
  21166. var check_claa_sunmfee float64 = 0
  21167. var check_clab_amt float64 = 0
  21168. var check_other_amt float64 = 0
  21169. var material_claa_sunmfee float64 = 0
  21170. var material_clab_amt float64 = 0
  21171. var material_other_amt float64 = 0
  21172. var laboratory_claa_sunmfee float64 = 0
  21173. var laboratory_clab_amt float64 = 0
  21174. var laboratory_other_amt float64 = 0
  21175. var treat_claa_sunmfee float64 = 0
  21176. var treat_clab_amt float64 = 0
  21177. var treat_other_amt float64 = 0
  21178. for _, item := range order.HisOrderInfo {
  21179. if item.MedChrgitmType == "01" { //床位费
  21180. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21181. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21182. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21183. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21184. if item.ChrgitmLv == "1" {
  21185. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21186. }
  21187. if item.ChrgitmLv == "2" {
  21188. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21189. }
  21190. if item.ChrgitmLv == "3" {
  21191. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21192. }
  21193. }
  21194. if item.MedChrgitmType == "03" { //检查费
  21195. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21196. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21197. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21198. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21199. if item.ChrgitmLv == "1" {
  21200. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21201. }
  21202. if item.ChrgitmLv == "2" {
  21203. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21204. }
  21205. if item.ChrgitmLv == "3" {
  21206. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21207. }
  21208. }
  21209. if item.MedChrgitmType == "04" { //化验费
  21210. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21211. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21212. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21213. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21214. if item.ChrgitmLv == "1" {
  21215. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21216. }
  21217. if item.ChrgitmLv == "2" {
  21218. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21219. }
  21220. if item.ChrgitmLv == "3" {
  21221. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21222. }
  21223. }
  21224. if item.MedChrgitmType == "05" { //治疗费
  21225. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21226. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21227. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21228. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21229. if item.ChrgitmLv == "1" {
  21230. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21231. }
  21232. if item.ChrgitmLv == "2" {
  21233. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21234. }
  21235. if item.ChrgitmLv == "3" {
  21236. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21237. }
  21238. }
  21239. if item.MedChrgitmType == "06" { //手术费
  21240. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21241. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21242. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21243. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21244. if item.ChrgitmLv == "1" {
  21245. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21246. }
  21247. if item.ChrgitmLv == "2" {
  21248. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21249. }
  21250. if item.ChrgitmLv == "3" {
  21251. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21252. }
  21253. }
  21254. if item.MedChrgitmType == "08" { //材料费
  21255. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21256. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21257. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21258. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21259. if item.ChrgitmLv == "1" {
  21260. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21261. }
  21262. if item.ChrgitmLv == "2" {
  21263. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21264. }
  21265. if item.ChrgitmLv == "3" {
  21266. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21267. }
  21268. }
  21269. if item.MedChrgitmType == "09" { //西药费
  21270. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21271. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21272. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21273. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21274. if item.ChrgitmLv == "1" {
  21275. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21276. }
  21277. if item.ChrgitmLv == "2" {
  21278. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21279. }
  21280. if item.ChrgitmLv == "3" {
  21281. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21282. }
  21283. }
  21284. if item.MedChrgitmType == "11" { //中成费
  21285. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21286. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21287. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21288. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21289. if item.ChrgitmLv == "1" {
  21290. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21291. }
  21292. if item.ChrgitmLv == "2" {
  21293. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21294. }
  21295. if item.ChrgitmLv == "3" {
  21296. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21297. }
  21298. }
  21299. if item.MedChrgitmType == "14" { //其他费
  21300. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21301. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21302. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21303. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21304. if item.ChrgitmLv == "1" {
  21305. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21306. }
  21307. if item.ChrgitmLv == "2" {
  21308. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21309. }
  21310. if item.ChrgitmLv == "3" {
  21311. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21312. }
  21313. }
  21314. }
  21315. var iteminfoStructs []service.IteminfoStruct
  21316. if bedCostTotal != 0 {
  21317. iteminfo.MedChrgitm = "01"
  21318. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21319. iteminfo.Amt = bedCostTotal
  21320. iteminfo.ClaaSumfee = bed_claa_sunmfee
  21321. iteminfo.ClabAmt = bed_clab_amt
  21322. iteminfo.OthAmt = bed_other_amt
  21323. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21324. }
  21325. if checkCostTotal != 0 {
  21326. iteminfo.MedChrgitm = "03"
  21327. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  21328. iteminfo.Amt = checkCostTotal
  21329. iteminfo.ClaaSumfee = check_claa_sunmfee
  21330. iteminfo.ClabAmt = check_clab_amt
  21331. iteminfo.OthAmt = check_other_amt
  21332. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21333. }
  21334. if laboratoryCostTotal != 0 {
  21335. iteminfo.MedChrgitm = "04"
  21336. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  21337. iteminfo.Amt = laboratoryCostTotal
  21338. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  21339. iteminfo.ClabAmt = laboratory_clab_amt
  21340. iteminfo.OthAmt = laboratory_other_amt
  21341. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21342. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21343. }
  21344. if treatCostTotal != 0 {
  21345. iteminfo.MedChrgitm = "05"
  21346. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  21347. iteminfo.Amt = treatCostTotal
  21348. iteminfo.ClaaSumfee = treat_claa_sunmfee
  21349. iteminfo.ClabAmt = treat_clab_amt
  21350. iteminfo.OthAmt = treat_other_amt
  21351. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21352. //(struct4101.IteminfoStruct, iteminfo)
  21353. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21354. }
  21355. if operationCostTotal != 0 {
  21356. iteminfo.MedChrgitm = "06"
  21357. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  21358. iteminfo.Amt = operationCostTotal
  21359. iteminfo.ClaaSumfee = operation_claa_sunmfee
  21360. iteminfo.ClabAmt = operation_clab_amt
  21361. iteminfo.OthAmt = operation_other_amt
  21362. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21363. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21364. }
  21365. if materialCostTotal != 0 {
  21366. iteminfo.MedChrgitm = "08"
  21367. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  21368. iteminfo.Amt = materialCostTotal
  21369. iteminfo.ClaaSumfee = material_claa_sunmfee
  21370. iteminfo.ClabAmt = material_clab_amt
  21371. iteminfo.OthAmt = material_other_amt
  21372. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21373. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21374. }
  21375. if westernMedicineCostTotal != 0 {
  21376. iteminfo.MedChrgitm = "09"
  21377. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21378. iteminfo.Amt = westernMedicineCostTotal
  21379. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21380. iteminfo.ClabAmt = westernMedicine_clab_amt
  21381. iteminfo.OthAmt = westernMedicine_other_amt
  21382. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21383. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21384. }
  21385. if chineseTraditionalMedicineCostTotal != 0 {
  21386. iteminfo.MedChrgitm = "11"
  21387. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  21388. iteminfo.Amt = westernMedicineCostTotal
  21389. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  21390. iteminfo.ClabAmt = westernMedicine_clab_amt
  21391. iteminfo.OthAmt = westernMedicine_other_amt
  21392. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21393. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21394. }
  21395. if otherCostTotal != 0 {
  21396. iteminfo.MedChrgitm = "14"
  21397. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  21398. iteminfo.Amt = otherCostTotal
  21399. iteminfo.ClaaSumfee = other_claa_sunmfee
  21400. iteminfo.ClabAmt = other_clab_amt
  21401. iteminfo.OthAmt = other_other_amt
  21402. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  21403. iteminfoStructs = append(iteminfoStructs, iteminfo)
  21404. }
  21405. struct4101.IteminfoStruct = iteminfoStructs
  21406. struct4101.Ntly = "中国"
  21407. struct4101.AdmCaty = "A03.06"
  21408. var resOther ResultSeventeenOther
  21409. var res ResultSeventeen
  21410. if miConfig.MdtrtareaAdmvs == "150499" {
  21411. var pp models.PublicParams
  21412. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  21413. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21414. pp.FixmedinsName = miConfig.OrgName
  21415. pp.FixmedinsCode = miConfig.Code
  21416. pp.RequestUrl = miConfig.Url
  21417. pp.Cainfo = miConfig.Cainfo
  21418. pp.SecretKey = miConfig.SecretKey
  21419. pp.AccessKey = miConfig.AccessKey
  21420. pp.OpterName = curRoles.UserName
  21421. client := &http.Client{}
  21422. var req *http.Request
  21423. data := make(map[string]interface{})
  21424. data["struct4101"] = struct4101
  21425. data["pp"] = pp
  21426. bytesData, _ := json.Marshal(data)
  21427. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  21428. resp, _ := client.Do(req)
  21429. defer resp.Body.Close()
  21430. body, ioErr := ioutil.ReadAll(resp.Body)
  21431. if ioErr != nil {
  21432. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21434. return
  21435. }
  21436. var respJSON map[string]interface{}
  21437. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21438. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21440. return
  21441. }
  21442. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21443. userJSONBytes, _ := json.Marshal(respJSON)
  21444. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  21445. utils.ErrorLog("解析失败:%v", err)
  21446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21447. return
  21448. }
  21449. res.InfRefmsgid = resOther.InfRefmsgid
  21450. res.Output = resOther.Output
  21451. res.ErrMsg = resOther.ErrMsg
  21452. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  21453. res.Infcode = infocode
  21454. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21455. var pp models.PublicParams
  21456. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21457. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21458. pp.FixmedinsName = miConfig.OrgName
  21459. pp.FixmedinsCode = miConfig.Code
  21460. pp.RequestUrl = miConfig.Url
  21461. pp.Cainfo = miConfig.Cainfo
  21462. pp.SecretKey = miConfig.SecretKey
  21463. pp.AccessKey = miConfig.AccessKey
  21464. pp.OpterName = curRoles.UserName
  21465. result, _ := service.Jxyb4101(struct4101, pp)
  21466. var dat map[string]interface{}
  21467. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21468. fmt.Println(dat)
  21469. } else {
  21470. fmt.Println(err)
  21471. }
  21472. userJSONBytes, _ := json.Marshal(dat)
  21473. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21474. utils.ErrorLog("解析失败:%v", err)
  21475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21476. return
  21477. }
  21478. } else if miConfig.MdtrtareaAdmvs == "361025" {
  21479. var pp models.PublicParams
  21480. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21481. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21482. pp.FixmedinsName = miConfig.OrgName
  21483. pp.FixmedinsCode = miConfig.Code
  21484. pp.RequestUrl = miConfig.Url
  21485. pp.Cainfo = miConfig.Cainfo
  21486. pp.SecretKey = miConfig.SecretKey
  21487. pp.AccessKey = miConfig.AccessKey
  21488. pp.OpterName = curRoles.UserName
  21489. result, _ := service.Jxyb4101(struct4101, pp)
  21490. var dat map[string]interface{}
  21491. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21492. fmt.Println(dat)
  21493. } else {
  21494. fmt.Println(err)
  21495. }
  21496. userJSONBytes, _ := json.Marshal(dat)
  21497. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21498. utils.ErrorLog("解析失败:%v", err)
  21499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21500. return
  21501. }
  21502. } else if miConfig.MdtrtareaAdmvs == "360100" {
  21503. var pp models.PublicParams
  21504. pp.InsuplcAdmdvs = his.InsuplcAdmdvs
  21505. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  21506. pp.FixmedinsName = miConfig.OrgName
  21507. pp.FixmedinsCode = miConfig.Code
  21508. pp.RequestUrl = miConfig.Url
  21509. pp.Cainfo = miConfig.Cainfo
  21510. pp.SecretKey = miConfig.SecretKey
  21511. pp.AccessKey = miConfig.AccessKey
  21512. pp.OpterName = curRoles.UserName
  21513. result, _ := service.Jxyb4101(struct4101, pp)
  21514. var dat map[string]interface{}
  21515. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21516. fmt.Println(dat)
  21517. } else {
  21518. fmt.Println(err)
  21519. }
  21520. userJSONBytes, _ := json.Marshal(dat)
  21521. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21522. utils.ErrorLog("解析失败:%v", err)
  21523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21524. return
  21525. }
  21526. } else {
  21527. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  21528. var dat map[string]interface{}
  21529. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21530. fmt.Println(dat)
  21531. } else {
  21532. fmt.Println(err)
  21533. }
  21534. userJSONBytes, _ := json.Marshal(dat)
  21535. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21536. utils.ErrorLog("解析失败:%v", err)
  21537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21538. return
  21539. }
  21540. }
  21541. if res.Infcode != 0 {
  21542. c.ServeSuccessJSON(map[string]interface{}{
  21543. "failed_code": -10,
  21544. "msg": res.ErrMsg,
  21545. })
  21546. return
  21547. } else {
  21548. if miConfig.MdtrtareaAdmvs != "150499" {
  21549. order.FaPiaoNumber = zero
  21550. order.FaPiaoCode = last_order.FaPiaoCode
  21551. service.UpdateOrder(order)
  21552. }
  21553. hisFundSettleListResult := &models.HisFundSettleListResult{
  21554. Number: res.Output.SetlListId,
  21555. Status: 1,
  21556. Ctime: time.Now().Unix(),
  21557. Mtime: time.Now().Unix(),
  21558. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21559. IsUpload: 1,
  21560. OrderId: order_id,
  21561. }
  21562. service.CreateUploadRecord(hisFundSettleListResult)
  21563. c.ServeSuccessJSON(map[string]interface{}{
  21564. "msg": "上传成功",
  21565. "result": hisFundSettleListResult,
  21566. })
  21567. return
  21568. }
  21569. }
  21570. //func (c *HisApiController) GetBatchSettleList() {
  21571. // orders, _ := service.GetAllHisOrder(10106)
  21572. // for _, item := range orders {
  21573. // order_id := item.ID
  21574. // order, _ := service.GetHisOrderByIDTwo(order_id)
  21575. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  21576. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  21577. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  21578. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  21579. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  21580. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  21581. //
  21582. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  21583. //
  21584. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  21585. //
  21586. // if order.ID == 0 {
  21587. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  21588. // return
  21589. // }
  21590. // if his.BalanceAccountsType == 2 {
  21591. // continue
  21592. // }
  21593. // struct4101 := service.Struct4101{
  21594. // PsnNo: order.PsnNo,
  21595. // MdtrtId: order.MdtrtId,
  21596. // SetlId: order.SetlId,
  21597. // PsnName: order.PsnName,
  21598. // Gend: order.Gend,
  21599. // Brdy: his.Brdy,
  21600. // Age: his.Age,
  21601. // Naty: order.Naty,
  21602. // PatnCertType: "01",
  21603. // Certno: order.Certno,
  21604. // Prfs: "90",
  21605. // ConerName: roles[0].UserName,
  21606. // PatnRlts: "99",
  21607. // ConerAddr: miConfig.OrgName,
  21608. // ConerTel: admin.Mobile,
  21609. // HiType: order.Insutype,
  21610. // Insuplc: his.InsuplcAdmdvs,
  21611. // MaindiagFlag: "1",
  21612. // BillCode: order.SetlId,
  21613. // BillNo: order.SetlId,
  21614. // BizSn: order.Number,
  21615. // PsnSelfPay: order.PsnPartAmt,
  21616. // PsnOwnPay: order.PsnPartAmt,
  21617. // AcctPay: order.AcctPay,
  21618. // PsnCashpay: order.PsnCashPay,
  21619. // HiPaymtd: "1",
  21620. // Hsorg: his.InsuplcAdmdvs,
  21621. // HsorgOpter: his.InsuplcAdmdvs,
  21622. // MedinsFillPsn: curRoles.UserName,
  21623. // MedinsFillDept: depart.Name,
  21624. // IptMedType: "2",
  21625. // }
  21626. // struct4101.SetlBegnDate = order.SetlTime
  21627. // struct4101.SetlEndDate = order.SetlTime
  21628. // //if order.SettleType == 1 {
  21629. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  21630. // // dateStr := t.Format("2006-01-02")
  21631. // // struct4101.SetlBegnDate = dateStr
  21632. // // struct4101.SetlEndDate = dateStr
  21633. // //} else {
  21634. // // t := time.Unix(int64(order.SettleStartTime), 0)
  21635. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  21636. // // dateStartStr := t.Format("2006-01-02")
  21637. // // dateEndStr := t2.Format("2006-01-02")
  21638. // // struct4101.SetlBegnDate = dateStartStr
  21639. // // struct4101.SetlEndDate = dateEndStr
  21640. // //}
  21641. //
  21642. // var rf []CustomFundPay
  21643. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  21644. //
  21645. // var tempFunPays []service.CustomStruct
  21646. // var tempFunPay610100 service.CustomStruct
  21647. //
  21648. // for _, item := range rf {
  21649. // if item.FundPayType == "610100" {
  21650. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  21651. // tempFunPay610100.FundPayType = item.FundPayType
  21652. // } else {
  21653. // var tempFunPay service.CustomStruct
  21654. // tempFunPay.FundPayamt = item.FundPayamt
  21655. // tempFunPay.FundPayType = item.FundPayType
  21656. // tempFunPays = append(tempFunPays, tempFunPay)
  21657. // }
  21658. // }
  21659. // tempFunPays = append(tempFunPays, tempFunPay610100)
  21660. // struct4101.CustomStruct = tempFunPays
  21661. //
  21662. // var tempDiaginfos []service.DiaginfoStructTwo
  21663. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  21664. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  21665. //
  21666. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  21667. // var config []*models.HisXtDiagnoseConfig
  21668. // for _, item := range diagnosis_ids {
  21669. // id, _ := strconv.ParseInt(item, 10, 64)
  21670. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  21671. // config = append(config, &diagnosisConfig)
  21672. // }
  21673. //
  21674. // for index, item := range config {
  21675. // if index == 0 {
  21676. // var tempDiaginfo service.DiaginfoStructTwo
  21677. // tempDiaginfo.DiagCode = item.CountryCode
  21678. // tempDiaginfo.DiagName = item.CountryContentName
  21679. // tempDiaginfo.DiagType = "1"
  21680. // tempDiaginfo.MaindiagFlag = "1"
  21681. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21682. // } else {
  21683. //
  21684. // var tempDiaginfo service.DiaginfoStructTwo
  21685. // tempDiaginfo.DiagCode = item.CountryCode
  21686. // tempDiaginfo.DiagName = item.CountryContentName
  21687. // tempDiaginfo.DiagType = "2"
  21688. // tempDiaginfo.MaindiagFlag = "0"
  21689. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  21690. // }
  21691. // }
  21692. // struct4101.Diseinfo = tempDiaginfos
  21693. //
  21694. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  21695. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  21696. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  21697. // tempOpspdiseinfo2.OprnOprtCode = ""
  21698. // tempOpspdiseinfo2.OprnOprtName = ""
  21699. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  21700. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  21701. //
  21702. // var iteminfo service.IteminfoStruct
  21703. //
  21704. // var bedCostTotal float64 = 0 //床位总费
  21705. // var bedCostSelfTotal float64 = 0 //床位自费
  21706. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  21707. //
  21708. // var examineCostTotal float64 = 0 //诊查总费
  21709. // var examineCostSelfTotal float64 = 0 //诊查自费
  21710. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  21711. //
  21712. // var nursingCostTotal float64 = 0 //护理总费
  21713. // var nursingCostSelfTotal float64 = 0 //护理自费
  21714. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  21715. //
  21716. // var chineseMedicineCostTotal float64 = 0 //中成药
  21717. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  21718. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  21719. //
  21720. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  21721. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  21722. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  21723. //
  21724. // var registerCostTotal float64 = 0 //一般诊疗费
  21725. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  21726. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  21727. //
  21728. // var operationCostTotal float64 = 0 //手术费
  21729. // var operationCostSelfTotal float64 = 0 //手术费
  21730. // var operationCostPartSelfTotal float64 = 0 //手术费
  21731. //
  21732. // var otherCostTotal float64 = 0 //其他费用
  21733. // var otherCostSelfTotal float64 = 0 //其他费用
  21734. // var otherCostPartSelfTotal float64 = 0 //其他费用
  21735. //
  21736. // var materialCostTotal float64 = 0 //材料费
  21737. // var materialCostSelfTotal float64 = 0 //材料费
  21738. // var materialCostPartSelfTotal float64 = 0 //材料费
  21739. //
  21740. // var westernMedicineCostTotal float64 = 0 //西药费
  21741. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  21742. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  21743. //
  21744. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  21745. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  21746. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  21747. //
  21748. // var checkCostTotal float64 = 0 //检查费
  21749. // var checkCostSelfTotal float64 = 0 //检查费
  21750. // var checkCostPartSelfTotal float64 = 0 //检查费
  21751. //
  21752. // var laboratoryCostTotal float64 = 0 //化验费
  21753. // var laboratoryCostSelfTotal float64 = 0 //化验费
  21754. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  21755. //
  21756. // var treatCostTotal float64 = 0 //治疗费用
  21757. // var treatCostSelfTotal float64 = 0 //治疗费用
  21758. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  21759. //
  21760. // decimal.DivisionPrecision = 2
  21761. //
  21762. // var bed_fulamt_ownpay_amt float64 = 0
  21763. //
  21764. // var examine_fulamt_ownpay_amt float64 = 0
  21765. //
  21766. // var nursing_fulamt_ownpay_amt float64 = 0
  21767. //
  21768. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  21769. //
  21770. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  21771. //
  21772. // var register_fulamt_ownpay_amt float64 = 0
  21773. //
  21774. // var operation_fulamt_ownpay_amt float64 = 0
  21775. // var other_fulamt_ownpay_amt float64 = 0
  21776. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  21777. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  21778. // var check_fulamt_ownpay_amt float64 = 0
  21779. // var material_fulamt_ownpay_amt float64 = 0
  21780. // var laboratory_fulamt_ownpay_amt float64 = 0
  21781. // var treat_fulamt_ownpay_amt float64 = 0
  21782. //
  21783. // var bed_claa_sunmfee float64 = 0
  21784. // var bed_clab_amt float64 = 0
  21785. // var bed_other_amt float64 = 0
  21786. //
  21787. // var examine_claa_sunmfee float64 = 0
  21788. // var examine_clab_amt float64 = 0
  21789. // var examine_other_amt float64 = 0
  21790. //
  21791. // var nursing_claa_sunmfee float64 = 0
  21792. // var nursing_clab_amt float64 = 0
  21793. // var nursing_other_amt float64 = 0
  21794. //
  21795. // var chinese_medicine_claa_sunmfee float64 = 0
  21796. // var chinese_medicine_clab_amt float64 = 0
  21797. // var chinese_medicine_other_amt float64 = 0
  21798. //
  21799. // var commonly_treatment_claa_sunmfee float64 = 0
  21800. // var commonly_treatment_clab_amt float64 = 0
  21801. // var commonly_treatment_other_amt float64 = 0
  21802. //
  21803. // var operation_claa_sunmfee float64 = 0
  21804. // var operation_clab_amt float64 = 0
  21805. // var operation_other_amt float64 = 0
  21806. //
  21807. // var other_claa_sunmfee float64 = 0
  21808. // var other_clab_amt float64 = 0
  21809. // var other_other_amt float64 = 0
  21810. //
  21811. // var westernMedicine_claa_sunmfee float64 = 0
  21812. // var westernMedicine_clab_amt float64 = 0
  21813. // var westernMedicine_other_amt float64 = 0
  21814. //
  21815. // var chineseTraditional_claa_sunmfee float64 = 0
  21816. // var chineseTraditional_clab_amt float64 = 0
  21817. // var chineseTraditional_other_amt float64 = 0
  21818. //
  21819. // var check_claa_sunmfee float64 = 0
  21820. // var check_clab_amt float64 = 0
  21821. // var check_other_amt float64 = 0
  21822. //
  21823. // var material_claa_sunmfee float64 = 0
  21824. // var material_clab_amt float64 = 0
  21825. // var material_other_amt float64 = 0
  21826. //
  21827. // var laboratory_claa_sunmfee float64 = 0
  21828. // var laboratory_clab_amt float64 = 0
  21829. // var laboratory_other_amt float64 = 0
  21830. //
  21831. // var treat_claa_sunmfee float64 = 0
  21832. // var treat_clab_amt float64 = 0
  21833. // var treat_other_amt float64 = 0
  21834. //
  21835. // var register_claa_sunmfee float64 = 0
  21836. // var register_clab_amt float64 = 0
  21837. // var register_other_amt float64 = 0
  21838. //
  21839. // for _, item := range order.HisOrderInfo {
  21840. // if item.MedChrgitmType == "01" { //床位费
  21841. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21842. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21843. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21844. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21845. // if item.ChrgitmLv == "1" {
  21846. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21847. // }
  21848. // if item.ChrgitmLv == "2" {
  21849. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21850. //
  21851. // }
  21852. // if item.ChrgitmLv == "3" {
  21853. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21854. // }
  21855. //
  21856. // }
  21857. //
  21858. // if item.MedChrgitmType == "02" { //诊查
  21859. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21860. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21861. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21862. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21863. // if item.ChrgitmLv == "1" {
  21864. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21865. // }
  21866. // if item.ChrgitmLv == "2" {
  21867. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21868. //
  21869. // }
  21870. // if item.ChrgitmLv == "3" {
  21871. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21872. // }
  21873. //
  21874. // }
  21875. //
  21876. // if item.MedChrgitmType == "03" { //检查费
  21877. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21878. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21879. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21880. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21881. // if item.ChrgitmLv == "1" {
  21882. //
  21883. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21884. //
  21885. // }
  21886. // if item.ChrgitmLv == "2" {
  21887. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21888. //
  21889. // }
  21890. // if item.ChrgitmLv == "3" {
  21891. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21892. // }
  21893. // }
  21894. //
  21895. // if item.MedChrgitmType == "04" { //化验费
  21896. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21897. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21898. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21899. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21900. // if item.ChrgitmLv == "1" {
  21901. //
  21902. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21903. //
  21904. // }
  21905. // if item.ChrgitmLv == "2" {
  21906. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21907. //
  21908. // }
  21909. // if item.ChrgitmLv == "3" {
  21910. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21911. // }
  21912. // }
  21913. //
  21914. // if item.MedChrgitmType == "05" { //治疗费
  21915. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21916. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21917. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21918. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21919. // if item.ChrgitmLv == "1" {
  21920. //
  21921. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21922. //
  21923. // }
  21924. // if item.ChrgitmLv == "2" {
  21925. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21926. //
  21927. // }
  21928. // if item.ChrgitmLv == "3" {
  21929. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21930. // }
  21931. // }
  21932. //
  21933. // if item.MedChrgitmType == "06" { //手术费
  21934. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21935. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21936. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21937. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21938. //
  21939. // if item.ChrgitmLv == "1" {
  21940. //
  21941. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21942. //
  21943. // }
  21944. // if item.ChrgitmLv == "2" {
  21945. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21946. //
  21947. // }
  21948. // if item.ChrgitmLv == "3" {
  21949. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21950. // }
  21951. // }
  21952. //
  21953. // if item.MedChrgitmType == "07" { //手术费
  21954. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21955. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21956. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21957. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21958. //
  21959. // if item.ChrgitmLv == "1" {
  21960. //
  21961. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21962. //
  21963. // }
  21964. // if item.ChrgitmLv == "2" {
  21965. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21966. //
  21967. // }
  21968. // if item.ChrgitmLv == "3" {
  21969. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21970. // }
  21971. // }
  21972. //
  21973. // if item.MedChrgitmType == "08" { //材料费
  21974. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21975. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21976. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21977. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21978. // if item.ChrgitmLv == "1" {
  21979. //
  21980. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21981. //
  21982. // }
  21983. // if item.ChrgitmLv == "2" {
  21984. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21985. //
  21986. // }
  21987. // if item.ChrgitmLv == "3" {
  21988. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21989. // }
  21990. // }
  21991. // if item.MedChrgitmType == "09" { //西药费
  21992. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21993. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  21994. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  21995. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  21996. // if item.ChrgitmLv == "1" {
  21997. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  21998. // }
  21999. // if item.ChrgitmLv == "2" {
  22000. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22001. // }
  22002. // if item.ChrgitmLv == "3" {
  22003. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22004. // }
  22005. // }
  22006. // if item.MedChrgitmType == "10" { //中药饮片
  22007. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22008. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22009. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22010. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22011. // if item.ChrgitmLv == "1" {
  22012. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22013. // }
  22014. // if item.ChrgitmLv == "2" {
  22015. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22016. // }
  22017. // if item.ChrgitmLv == "3" {
  22018. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22019. // }
  22020. // }
  22021. //
  22022. // if item.MedChrgitmType == "11" { //中成费
  22023. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22024. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22025. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22026. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22027. // if item.ChrgitmLv == "1" {
  22028. //
  22029. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22030. //
  22031. // }
  22032. // if item.ChrgitmLv == "2" {
  22033. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22034. //
  22035. // }
  22036. // if item.ChrgitmLv == "3" {
  22037. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22038. // }
  22039. // }
  22040. //
  22041. // if item.MedChrgitmType == "12" { //中成费
  22042. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22043. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22044. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22045. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22046. // if item.ChrgitmLv == "1" {
  22047. //
  22048. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22049. //
  22050. // }
  22051. // if item.ChrgitmLv == "2" {
  22052. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22053. //
  22054. // }
  22055. // if item.ChrgitmLv == "3" {
  22056. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22057. // }
  22058. // }
  22059. //
  22060. // if item.MedChrgitmType == "13" { //中成费
  22061. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22062. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22063. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22064. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22065. // if item.ChrgitmLv == "1" {
  22066. //
  22067. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22068. //
  22069. // }
  22070. // if item.ChrgitmLv == "2" {
  22071. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22072. //
  22073. // }
  22074. // if item.ChrgitmLv == "3" {
  22075. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22076. // }
  22077. // }
  22078. //
  22079. // if item.MedChrgitmType == "14" { //其他费
  22080. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22081. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22082. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22083. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  22084. // if item.ChrgitmLv == "1" {
  22085. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  22086. //
  22087. // }
  22088. // if item.ChrgitmLv == "2" {
  22089. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  22090. //
  22091. // }
  22092. // if item.ChrgitmLv == "3" {
  22093. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  22094. // }
  22095. // }
  22096. //
  22097. // }
  22098. //
  22099. // var iteminfoStructs []service.IteminfoStruct
  22100. //
  22101. // if bedCostTotal != 0 {
  22102. // iteminfo.MedChrgitm = "01"
  22103. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  22104. // iteminfo.Amt = bedCostTotal
  22105. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  22106. // iteminfo.ClabAmt = bed_clab_amt
  22107. // iteminfo.OthAmt = bed_other_amt
  22108. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22109. // }
  22110. //
  22111. // if examineCostTotal != 0 {
  22112. // iteminfo.MedChrgitm = "02"
  22113. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  22114. // iteminfo.Amt = examineCostTotal
  22115. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  22116. // iteminfo.ClabAmt = examine_clab_amt
  22117. // iteminfo.OthAmt = examine_other_amt
  22118. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22119. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22120. // }
  22121. //
  22122. // if checkCostTotal != 0 {
  22123. // iteminfo.MedChrgitm = "03"
  22124. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  22125. // iteminfo.Amt = checkCostTotal
  22126. // iteminfo.ClaaSumfee = check_claa_sunmfee
  22127. // iteminfo.ClabAmt = check_clab_amt
  22128. // iteminfo.OthAmt = check_other_amt
  22129. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22130. //
  22131. // }
  22132. //
  22133. // if laboratoryCostTotal != 0 {
  22134. // iteminfo.MedChrgitm = "04"
  22135. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  22136. // iteminfo.Amt = laboratoryCostTotal
  22137. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  22138. // iteminfo.ClabAmt = laboratory_clab_amt
  22139. // iteminfo.OthAmt = laboratory_other_amt
  22140. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22141. //
  22142. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22143. //
  22144. // }
  22145. //
  22146. // if treatCostTotal != 0 {
  22147. // iteminfo.MedChrgitm = "05"
  22148. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  22149. // iteminfo.Amt = treatCostTotal
  22150. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  22151. // iteminfo.ClabAmt = treat_clab_amt
  22152. // iteminfo.OthAmt = treat_other_amt
  22153. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22154. // //(struct4101.IteminfoStruct, iteminfo)
  22155. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22156. // }
  22157. //
  22158. // if operationCostTotal != 0 {
  22159. // iteminfo.MedChrgitm = "06"
  22160. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  22161. // iteminfo.Amt = operationCostTotal
  22162. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  22163. // iteminfo.ClabAmt = operation_clab_amt
  22164. // iteminfo.OthAmt = operation_other_amt
  22165. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22166. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22167. // }
  22168. //
  22169. // if nursingCostTotal != 0 {
  22170. // iteminfo.MedChrgitm = "07"
  22171. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  22172. // iteminfo.Amt = nursingCostTotal
  22173. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  22174. // iteminfo.ClabAmt = nursing_clab_amt
  22175. // iteminfo.OthAmt = nursing_other_amt
  22176. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22177. // }
  22178. //
  22179. // if materialCostTotal != 0 {
  22180. // iteminfo.MedChrgitm = "08"
  22181. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  22182. // iteminfo.Amt = materialCostTotal
  22183. // iteminfo.ClaaSumfee = material_claa_sunmfee
  22184. // iteminfo.ClabAmt = material_clab_amt
  22185. // iteminfo.OthAmt = material_other_amt
  22186. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22187. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22188. // }
  22189. //
  22190. // if westernMedicineCostTotal != 0 {
  22191. // iteminfo.MedChrgitm = "09"
  22192. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  22193. // iteminfo.Amt = westernMedicineCostTotal
  22194. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  22195. // iteminfo.ClabAmt = westernMedicine_clab_amt
  22196. // iteminfo.OthAmt = westernMedicine_other_amt
  22197. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22198. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22199. //
  22200. // }
  22201. //
  22202. // if chineseMedicineCostTotal != 0 {
  22203. // iteminfo.MedChrgitm = "10"
  22204. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  22205. // iteminfo.Amt = chineseMedicineCostTotal
  22206. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  22207. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  22208. // iteminfo.OthAmt = chinese_medicine_other_amt
  22209. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22210. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22211. //
  22212. // }
  22213. //
  22214. // if chineseTraditionalMedicineCostTotal != 0 {
  22215. // iteminfo.MedChrgitm = "11"
  22216. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  22217. // iteminfo.Amt = westernMedicineCostTotal
  22218. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  22219. // iteminfo.ClabAmt = westernMedicine_clab_amt
  22220. // iteminfo.OthAmt = westernMedicine_other_amt
  22221. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22222. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22223. //
  22224. // }
  22225. //
  22226. // if commonlyTreatmentCostTotal != 0 {
  22227. // iteminfo.MedChrgitm = "12"
  22228. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  22229. // iteminfo.Amt = commonlyTreatmentCostTotal
  22230. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  22231. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  22232. // iteminfo.OthAmt = commonly_treatment_other_amt
  22233. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22234. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22235. //
  22236. // }
  22237. //
  22238. // if registerCostTotal != 0 {
  22239. // iteminfo.MedChrgitm = "13"
  22240. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  22241. // iteminfo.Amt = registerCostTotal
  22242. // iteminfo.ClaaSumfee = register_claa_sunmfee
  22243. // iteminfo.ClabAmt = register_clab_amt
  22244. // iteminfo.OthAmt = register_other_amt
  22245. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22246. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22247. //
  22248. // }
  22249. //
  22250. // if otherCostTotal != 0 {
  22251. // iteminfo.MedChrgitm = "14"
  22252. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  22253. // iteminfo.Amt = otherCostTotal
  22254. // iteminfo.ClaaSumfee = other_claa_sunmfee
  22255. // iteminfo.ClabAmt = other_clab_amt
  22256. // iteminfo.OthAmt = other_other_amt
  22257. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  22258. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  22259. //
  22260. // }
  22261. // struct4101.IteminfoStruct = iteminfoStructs
  22262. // time_arr := strings.Split(order.SetlTime, " ")
  22263. // struct4101.AdmTime = time_arr[0]
  22264. // struct4101.AdmEndTime = time_arr[0]
  22265. //
  22266. // struct4101.DoctorName = doctor.UserName
  22267. // struct4101.DoctorCode = doctor.DoctorNumber
  22268. //
  22269. // struct4101.Ntly = "中国"
  22270. // struct4101.AdmCaty = "A03.06"
  22271. // var res ResultSeventeen
  22272. // if miConfig.MdtrtareaAdmvs == "421300" {
  22273. // data := make(map[string]interface{})
  22274. // data["struct4101"] = struct4101
  22275. // data["secret_key"] = miConfig.SecretKey
  22276. // data["org_name"] = miConfig.OrgName
  22277. // data["opera"] = curRoles.UserName
  22278. // data["code"] = miConfig.Code
  22279. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  22280. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22281. //
  22282. // client := &http.Client{}
  22283. // bytesData, _ := json.Marshal(data)
  22284. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  22285. // resp, _ := client.Do(req)
  22286. // defer resp.Body.Close()
  22287. // body, ioErr := ioutil.ReadAll(resp.Body)
  22288. // if ioErr != nil {
  22289. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22290. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22291. // return
  22292. // }
  22293. // var respJSON map[string]interface{}
  22294. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22295. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22296. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22297. // return
  22298. // }
  22299. //
  22300. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22301. // userJSONBytes, _ := json.Marshal(respJSON)
  22302. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22303. // utils.ErrorLog("解析失败:%v", err)
  22304. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22305. // adminUser := c.GetAdminUserInfo()
  22306. // errlog := &models.HisOrderError{
  22307. // UserOrgId: adminUser.CurrentOrgId,
  22308. // Ctime: time.Now().Unix(),
  22309. // Mtime: time.Now().Unix(),
  22310. // ErrMsg: res.ErrMsg + "解析失败",
  22311. // Status: 1,
  22312. // PatientId: order_id,
  22313. // Stage: 10088,
  22314. // }
  22315. // service.CreateErrMsgLog(errlog)
  22316. // continue
  22317. // }
  22318. //
  22319. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  22320. // data := make(map[string]interface{})
  22321. // data["struct4101"] = struct4101
  22322. // data["secret_key"] = miConfig.SecretKey
  22323. // data["org_name"] = miConfig.OrgName
  22324. // data["opera"] = curRoles.UserName
  22325. // data["code"] = miConfig.Code
  22326. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  22327. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22328. //
  22329. // client := &http.Client{}
  22330. // bytesData, _ := json.Marshal(data)
  22331. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  22332. // resp, _ := client.Do(req)
  22333. // defer resp.Body.Close()
  22334. // body, ioErr := ioutil.ReadAll(resp.Body)
  22335. // if ioErr != nil {
  22336. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22337. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22338. // return
  22339. // }
  22340. // var respJSON map[string]interface{}
  22341. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22342. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22343. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22344. // return
  22345. // }
  22346. //
  22347. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22348. // userJSONBytes, _ := json.Marshal(respJSON)
  22349. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22350. // utils.ErrorLog("解析失败:%v", err)
  22351. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22352. // adminUser := c.GetAdminUserInfo()
  22353. // errlog := &models.HisOrderError{
  22354. // UserOrgId: adminUser.CurrentOrgId,
  22355. // Ctime: time.Now().Unix(),
  22356. // Mtime: time.Now().Unix(),
  22357. // ErrMsg: res.ErrMsg + "解析失败",
  22358. // Status: 1,
  22359. // PatientId: order_id,
  22360. // Stage: 10088,
  22361. // }
  22362. // service.CreateErrMsgLog(errlog)
  22363. // continue
  22364. // }
  22365. //
  22366. // } else {
  22367. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  22368. // fmt.Println(result)
  22369. //
  22370. // var dat map[string]interface{}
  22371. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22372. // fmt.Println(dat)
  22373. // } else {
  22374. // fmt.Println(err)
  22375. // }
  22376. // userJSONBytes, _ := json.Marshal(dat)
  22377. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22378. // utils.ErrorLog("解析失败:%v", err)
  22379. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22380. // adminUser := c.GetAdminUserInfo()
  22381. // errlog := &models.HisOrderError{
  22382. // UserOrgId: adminUser.CurrentOrgId,
  22383. // Ctime: time.Now().Unix(),
  22384. // Mtime: time.Now().Unix(),
  22385. // ErrMsg: res.ErrMsg + "解析失败",
  22386. // Status: 1,
  22387. // PatientId: order_id,
  22388. // Stage: 10106,
  22389. // }
  22390. // service.CreateErrMsgLog(errlog)
  22391. // continue
  22392. // }
  22393. // }
  22394. //
  22395. // if res.Infcode != 0 {
  22396. // adminUser := c.GetAdminUserInfo()
  22397. // errlog := &models.HisOrderError{
  22398. // UserOrgId: adminUser.CurrentOrgId,
  22399. // Ctime: time.Now().Unix(),
  22400. // Mtime: time.Now().Unix(),
  22401. // ErrMsg: res.ErrMsg,
  22402. // Status: 1,
  22403. // PatientId: order_id,
  22404. // Stage: 10106,
  22405. // }
  22406. // service.CreateErrMsgLog(errlog)
  22407. // continue
  22408. // } else {
  22409. // hisFundSettleListResult := &models.HisFundSettleListResult{
  22410. // Number: res.Output.SetlListId,
  22411. // Status: 1,
  22412. // Ctime: time.Now().Unix(),
  22413. // Mtime: time.Now().Unix(),
  22414. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  22415. // IsUpload: 1,
  22416. // OrderId: order_id,
  22417. // }
  22418. // service.CreateUploadRecord(hisFundSettleListResult)
  22419. // continue
  22420. // }
  22421. // }
  22422. //}
  22423. func (c *HisApiController) GetOrgInfo() {
  22424. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  22425. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  22426. }
  22427. func (c *HisApiController) GetHisPatientInfo() {
  22428. medical_insurance_card := c.GetString("medical_insurance_card")
  22429. id_card_type, _ := c.GetInt64("id_card_type")
  22430. id_card := c.GetString("id_card")
  22431. adminInfo := c.GetAdminUserInfo()
  22432. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  22433. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  22434. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  22435. IdCardNo := ""
  22436. if id_card_type == 1 {
  22437. IdCardNo = medical_insurance_card
  22438. } else if id_card_type == 2 {
  22439. IdCardNo = id_card
  22440. }
  22441. if config.IsOpen == 1 {
  22442. 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
  22443. resp, requestErr := http.Get(api)
  22444. if requestErr != nil {
  22445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22446. return
  22447. }
  22448. defer resp.Body.Close()
  22449. body, ioErr := ioutil.ReadAll(resp.Body)
  22450. if ioErr != nil {
  22451. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22453. return
  22454. }
  22455. var respJSON map[string]interface{}
  22456. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22457. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22459. return
  22460. }
  22461. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22462. userJSONBytes, _ := json.Marshal(userJSON)
  22463. var res ResultTwo
  22464. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22465. utils.ErrorLog("解析失败:%v", err)
  22466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22467. return
  22468. }
  22469. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  22470. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  22471. infoStr := string(Iinfos)
  22472. idetinfoStr := string(Idetinfos)
  22473. if res.Infcode == 0 {
  22474. his := models.VMHisPatient{
  22475. Status: 1,
  22476. Ctime: time.Now().Unix(),
  22477. Mtime: time.Now().Unix(),
  22478. PsnNo: res.Output.Baseinfo.PsnNo,
  22479. PsnCertType: res.Output.Baseinfo.PsnCertType,
  22480. Certno: res.Output.Baseinfo.Certno,
  22481. PsnName: res.Output.Baseinfo.PsnName,
  22482. Gend: res.Output.Baseinfo.Gend,
  22483. Naty: res.Output.Baseinfo.Naty,
  22484. Iinfo: infoStr,
  22485. Idetinfo: idetinfoStr,
  22486. UserOrgId: adminInfo.CurrentOrgId,
  22487. IsReturn: 1,
  22488. IdCardType: id_card_type,
  22489. }
  22490. c.ServeSuccessJSON(map[string]interface{}{
  22491. "info": his,
  22492. })
  22493. } else {
  22494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  22495. return
  22496. }
  22497. }
  22498. }
  22499. //func GetBasBaseInfo() (jsonStr string, err error) {
  22500. //
  22501. // handle := syscall.NewLazyDLL("SSCard.dll")
  22502. // add := handle.NewProc("ReadCardBas")
  22503. // str := make([]byte, 1024)
  22504. // str1 := make([]byte, 1024)
  22505. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  22506. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  22507. //
  22508. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  22509. //
  22510. // fmt.Println("> Add(4,5)的结果为:", ret)
  22511. // handle.Release()
  22512. //
  22513. // return "", nil
  22514. //
  22515. //}
  22516. //func GetQRBaseInfo() (jsonStr string, err error) {
  22517. // handle := syscall.LoadDLL("SSCard.dll")
  22518. // ReadCardBas := handle.FindProc("GetQRBase")
  22519. //
  22520. // str := make([]byte, 256)
  22521. // str1 := make([]byte, 256)
  22522. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  22523. //
  22524. // fmt.Println(string(str))
  22525. // fmt.Println(r)
  22526. // return string(str), nil
  22527. //}
  22528. //func CardInit() int {
  22529. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  22530. // add := DllTestDef.MustFindProc("Init")
  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. // result := int(ret)
  22536. // return result
  22537. //}
  22538. //func CardInit() int {
  22539. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  22540. // if err != nil {
  22541. // fmt.Println("SSCard的运算结果为:", ret)
  22542. // }
  22543. // fmt.Println(err)
  22544. // result := int(ret)
  22545. // return result
  22546. //}
  22547. func IntPtr(n int) uintptr {
  22548. return uintptr(n)
  22549. }
  22550. func StrPtr(s string) uintptr {
  22551. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  22552. }
  22553. type Result2001 struct {
  22554. Cainfo interface{} `json:"cainfo"`
  22555. ErrMsg string `json:"err_msg"`
  22556. InfRefmsgid string `json:"inf_refmsgid"`
  22557. Infcode int64 `json:"infcode"`
  22558. Output struct {
  22559. Trtinfo struct {
  22560. PsnNo string `json:"psn_no"`
  22561. TrtChkType string `json:"trt_chk_type"`
  22562. FundPayType string `json:"fund_pay_type"`
  22563. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  22564. Begndate string `json:"begndate"`
  22565. Enddate string `json:"enddate"`
  22566. TrtChkRslt string `json:"trt_chk_rslt"`
  22567. } `json:"trtinfo"`
  22568. } `json:"output"`
  22569. RefmsgTime string `json:"refmsg_time"`
  22570. RespondTime string `json:"respond_time"`
  22571. Signtype interface{} `json:"signtype"`
  22572. WarnMsg interface{} `json:"warn_msg"`
  22573. }
  22574. type Result2001Org10265 struct {
  22575. Cainfo interface{} `json:"cainfo"`
  22576. ErrMsg string `json:"err_msg"`
  22577. InfRefmsgid string `json:"inf_refmsgid"`
  22578. Infcode string `json:"infcode"`
  22579. Output struct {
  22580. Trtinfo struct {
  22581. PsnNo string `json:"psn_no"`
  22582. TrtChkType string `json:"trt_chk_type"`
  22583. FundPayType string `json:"fund_pay_type"`
  22584. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  22585. Begndate string `json:"begndate"`
  22586. Enddate string `json:"enddate"`
  22587. TrtChkRslt string `json:"trt_chk_rslt"`
  22588. } `json:"trtinfo"`
  22589. } `json:"output"`
  22590. RefmsgTime string `json:"refmsg_time"`
  22591. RespondTime string `json:"respond_time"`
  22592. Signtype interface{} `json:"signtype"`
  22593. WarnMsg interface{} `json:"warn_msg"`
  22594. }
  22595. type ResultTwo struct {
  22596. ErrMsg string `json:"err_msg"`
  22597. InfRefmsgid string `json:"inf_refmsgid"`
  22598. Infcode int64 `json:"infcode"`
  22599. Output struct {
  22600. Baseinfo struct {
  22601. //Brdy string `json:"brdy"`
  22602. Certno string `json:"certno"`
  22603. Gend string `json:"gend"`
  22604. Naty string `json:"naty"`
  22605. PsnCertType string `json:"psn_cert_type"`
  22606. PsnName string `json:"psn_name"`
  22607. PsnNo string `json:"psn_no"`
  22608. } `json:"baseinfo"`
  22609. Idetinfo []interface{} `json:"idetinfo"`
  22610. Iinfo []struct {
  22611. Balc float64 `json:"balc"`
  22612. CvlservFlag string `json:"cvlserv_flag"`
  22613. EmpName string `json:"emp_name"`
  22614. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22615. Insutype string `json:"insutype"`
  22616. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22617. //PausInsuDate string `json:"paus_insu_date"`
  22618. //PsnInsuDate string `json:"psn_insu_date"`
  22619. PsnInsuStas string `json:"psn_insu_stas"`
  22620. PsnType string `json:"psn_type"`
  22621. } `json:"insuinfo"`
  22622. } `json:"output"`
  22623. RefmsgTime string `json:"refmsg_time"`
  22624. RespondTime string `json:"respond_time"`
  22625. Signtype interface{} `json:"signtype"`
  22626. WarnInfo interface{} `json:"warn_info"`
  22627. }
  22628. type ResultTwo10265 struct {
  22629. ErrMsg string `json:"err_msg"`
  22630. InfRefmsgid string `json:"inf_refmsgid"`
  22631. Infcode string `json:"infcode"`
  22632. Output struct {
  22633. Baseinfo struct {
  22634. //Brdy string `json:"brdy"`
  22635. Certno string `json:"certno"`
  22636. Gend string `json:"gend"`
  22637. Naty string `json:"naty"`
  22638. PsnCertType string `json:"psn_cert_type"`
  22639. PsnName string `json:"psn_name"`
  22640. PsnNo string `json:"psn_no"`
  22641. } `json:"baseinfo"`
  22642. Idetinfo []interface{} `json:"idetinfo"`
  22643. Iinfo []struct {
  22644. Balc float64 `json:"balc"`
  22645. CvlservFlag string `json:"cvlserv_flag"`
  22646. EmpName string `json:"emp_name"`
  22647. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22648. Insutype string `json:"insutype"`
  22649. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22650. PsnInsuStas string `json:"psn_insu_stas"`
  22651. PsnType string `json:"psn_type"`
  22652. } `json:"insuinfo"`
  22653. } `json:"output"`
  22654. RefmsgTime string `json:"refmsg_time"`
  22655. RespondTime string `json:"respond_time"`
  22656. Signtype interface{} `json:"signtype"`
  22657. WarnInfo interface{} `json:"warn_info"`
  22658. }
  22659. type ResultThree struct {
  22660. Cainfo interface{} `json:"cainfo"`
  22661. ErrMsg string `json:"err_msg"`
  22662. InfRefmsgid string `json:"inf_refmsgid"`
  22663. Infcode int64 `json:"infcode"`
  22664. Output struct {
  22665. Data struct {
  22666. IptOtpNo string `json:"ipt_otp_no"`
  22667. MdtrtID string `json:"mdtrt_id"`
  22668. PsnNo string `json:"psn_no"`
  22669. } `json:"data"`
  22670. } `json:"output"`
  22671. RefmsgTime string `json:"refmsg_time"`
  22672. RespondTime string `json:"respond_time"`
  22673. Signtype interface{} `json:"signtype"`
  22674. WarnMsg interface{} `json:"warn_msg"`
  22675. }
  22676. type ResultThree10265 struct {
  22677. Cainfo interface{} `json:"cainfo"`
  22678. ErrMsg string `json:"err_msg"`
  22679. InfRefmsgid string `json:"inf_refmsgid"`
  22680. Infcode string `json:"infcode"`
  22681. Output struct {
  22682. Data struct {
  22683. IptOtpNo string `json:"ipt_otp_no"`
  22684. MdtrtID string `json:"mdtrt_id"`
  22685. PsnNo string `json:"psn_no"`
  22686. } `json:"data"`
  22687. } `json:"output"`
  22688. RefmsgTime string `json:"refmsg_time"`
  22689. RespondTime string `json:"respond_time"`
  22690. Signtype interface{} `json:"signtype"`
  22691. WarnMsg interface{} `json:"warn_msg"`
  22692. }
  22693. type ResultFour struct {
  22694. Cainfo string `json:"cainfo"`
  22695. ErrMsg string `json:"err_msg"`
  22696. InfRefmsgid string `json:"inf_refmsgid"`
  22697. Infcode int64 `json:"infcode"`
  22698. Output struct {
  22699. Result []struct {
  22700. BasMednFlag string `json:"bas_medn_flag"`
  22701. ChldMedcFlag string `json:"chld_medc_flag"`
  22702. ChrgitmLv string `json:"chrgitm_lv"`
  22703. Cnt float64 `json:"cnt"`
  22704. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  22705. DrtReimFlag string `json:"drt_reim_flag"`
  22706. FeedetlSn string `json:"feedetl_sn"`
  22707. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22708. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  22709. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22710. ListSpItemFlag string `json:"list_sp_item_flag"`
  22711. LmtUsedFlag string `json:"lmt_used_flag"`
  22712. MedChrgitmType string `json:"med_chrgitm_type"`
  22713. Memo string `json:"memo"`
  22714. OverlmtAmt float64 `json:"overlmt_amt"`
  22715. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22716. Pric float64 `json:"pric"`
  22717. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  22718. SelfpayProp float64 `json:"selfpay_prop"`
  22719. } `json:"result"`
  22720. } `json:"output"`
  22721. RefmsgTime string `json:"refmsg_time"`
  22722. RespondTime string `json:"respond_time"`
  22723. Signtype string `json:"signtype"`
  22724. WarnMsg string `json:"warn_msg"`
  22725. }
  22726. type ResultFour10265 struct {
  22727. Cainfo string `json:"cainfo"`
  22728. ErrMsg string `json:"err_msg"`
  22729. InfRefmsgid string `json:"inf_refmsgid"`
  22730. Infcode string `json:"infcode"`
  22731. Output struct {
  22732. Result []struct {
  22733. BasMednFlag string `json:"bas_medn_flag"`
  22734. ChldMedcFlag string `json:"chld_medc_flag"`
  22735. ChrgitmLv string `json:"chrgitm_lv"`
  22736. Cnt float64 `json:"cnt"`
  22737. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  22738. DrtReimFlag string `json:"drt_reim_flag"`
  22739. FeedetlSn string `json:"feedetl_sn"`
  22740. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22741. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  22742. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22743. ListSpItemFlag string `json:"list_sp_item_flag"`
  22744. LmtUsedFlag string `json:"lmt_used_flag"`
  22745. MedChrgitmType string `json:"med_chrgitm_type"`
  22746. Memo string `json:"memo"`
  22747. OverlmtAmt float64 `json:"overlmt_amt"`
  22748. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22749. Pric float64 `json:"pric"`
  22750. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  22751. SelfpayProp float64 `json:"selfpay_prop"`
  22752. } `json:"result"`
  22753. } `json:"output"`
  22754. RefmsgTime string `json:"refmsg_time"`
  22755. RespondTime string `json:"respond_time"`
  22756. Signtype string `json:"signtype"`
  22757. WarnMsg string `json:"warn_msg"`
  22758. }
  22759. type ResultMemo struct {
  22760. InsuAdmdvs string `json:"insuAdmdvs"`
  22761. }
  22762. // [{"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}]
  22763. type ResultIDInfo struct {
  22764. Begntime string `json:"begntime"`
  22765. Endtime string `json:"endtime"`
  22766. Memo string `json:"memo"`
  22767. }
  22768. type ResultFive struct {
  22769. Balc float64 `json:"balc"`
  22770. CvlservFlag string `json:"cvlserv_flag"`
  22771. EmpName string `json:"emp_name"`
  22772. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  22773. Insutype string `json:"insutype"`
  22774. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  22775. PausInsuDate string `json:"paus_insu_date"`
  22776. PsnInsuDate string `json:"psn_insu_date"`
  22777. PsnInsuStas string `json:"psn_insu_stas"`
  22778. PsnType string `json:"psn_type"`
  22779. }
  22780. type ResultSix struct {
  22781. Cainfo interface{} `json:"cainfo"`
  22782. ErrMsg string `json:"err_msg"`
  22783. InfRefmsgid string `json:"inf_refmsgid"`
  22784. Infcode int64 `json:"infcode"`
  22785. Output struct {
  22786. } `json:"output"`
  22787. RefmsgTime string `json:"refmsg_time"`
  22788. RespondTime string `json:"respond_time"`
  22789. Signtype interface{} `json:"signtype"`
  22790. WarnMsg interface{} `json:"warn_msg"`
  22791. }
  22792. type ResultSix3103 struct {
  22793. Cainfo interface{} `json:"cainfo"`
  22794. ErrMsg string `json:"err_msg"`
  22795. InfRefmsgid string `json:"inf_refmsgid"`
  22796. Infcode int64 `json:"infcode"`
  22797. RefmsgTime string `json:"refmsg_time"`
  22798. RespondTime string `json:"respond_time"`
  22799. Signtype interface{} `json:"signtype"`
  22800. WarnMsg interface{} `json:"warn_msg"`
  22801. }
  22802. type FJ3507Result struct {
  22803. Cainfo interface{} `json:"cainfo"`
  22804. ErrMsg string `json:"err_msg"`
  22805. InfRefmsgid string `json:"inf_refmsgid"`
  22806. Infcode int64 `json:"infcode"`
  22807. Output struct {
  22808. retRslt string `json:"retRslt"`
  22809. msgRslt string `json:"msgRslt"`
  22810. } `json:"output"`
  22811. RefmsgTime string `json:"refmsg_time"`
  22812. RespondTime string `json:"respond_time"`
  22813. Signtype interface{} `json:"signtype"`
  22814. WarnMsg interface{} `json:"warn_msg"`
  22815. }
  22816. type FJ3507ResultFor10188 struct {
  22817. Cainfo interface{} `json:"cainfo"`
  22818. ErrMsg string `json:"err_msg"`
  22819. InfRefmsgid string `json:"inf_refmsgid"`
  22820. Infcode string `json:"infcode"`
  22821. RefmsgTime string `json:"refmsg_time"`
  22822. RespondTime string `json:"respond_time"`
  22823. Signtype interface{} `json:"signtype"`
  22824. WarnMsg interface{} `json:"warn_msg"`
  22825. }
  22826. type Result2406 struct {
  22827. Cainfo interface{} `json:"cainfo"`
  22828. ErrMsg string `json:"err_msg"`
  22829. InfRefmsgid string `json:"inf_refmsgid"`
  22830. Infcode int64 `json:"infcode"`
  22831. Output struct {
  22832. Result struct {
  22833. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  22834. } `json:"result"`
  22835. } `json:"output"`
  22836. RefmsgTime string `json:"refmsg_time"`
  22837. RespondTime string `json:"respond_time"`
  22838. Signtype interface{} `json:"signtype"`
  22839. WarnMsg interface{} `json:"warn_msg"`
  22840. }
  22841. type GZResultSix struct {
  22842. Cainfo interface{} `json:"cainfo"`
  22843. ErrMsg string `json:"err_msg"`
  22844. InfRefmsgid string `json:"inf_refmsgid"`
  22845. Infcode int64 `json:"infcode"`
  22846. Output string `json:"output"`
  22847. RefmsgTime string `json:"refmsg_time"`
  22848. RespondTime string `json:"respond_time"`
  22849. Signtype interface{} `json:"signtype"`
  22850. WarnMsg interface{} `json:"warn_msg"`
  22851. }
  22852. type ResultSix10265 struct {
  22853. Cainfo interface{} `json:"cainfo"`
  22854. ErrMsg string `json:"err_msg"`
  22855. InfRefmsgid string `json:"inf_refmsgid"`
  22856. Infcode string `json:"infcode"`
  22857. Output struct {
  22858. } `json:"output"`
  22859. RefmsgTime string `json:"refmsg_time"`
  22860. RespondTime string `json:"respond_time"`
  22861. Signtype interface{} `json:"signtype"`
  22862. WarnMsg interface{} `json:"warn_msg"`
  22863. }
  22864. type ResultSeven struct {
  22865. Cainfo string `json:"cainfo"`
  22866. ErrMsg string `json:"err_msg"`
  22867. InfRefmsgid string `json:"inf_refmsgid"`
  22868. Infcode int64 `json:"infcode"`
  22869. Output struct {
  22870. Setlinfo struct {
  22871. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22872. AcctPay float64 `json:"acct_pay"`
  22873. ActPayDedc float64 `json:"act_pay_dedc"`
  22874. Age float64 `json:"age"`
  22875. Balc float64 `json:"balc"`
  22876. Certno string `json:"certno"`
  22877. ClrOptins string `json:"clr_optins"`
  22878. ClrType string `json:"clr_type"`
  22879. ClrWay string `json:"clr_way"`
  22880. CvlservFlag string `json:"cvlserv_flag"`
  22881. CvlservPay float64 `json:"cvlserv_pay"`
  22882. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22883. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22884. Gend string `json:"gend"`
  22885. HifesPay float64 `json:"hifes_pay"`
  22886. HifmiPay float64 `json:"hifmi_pay"`
  22887. HifpPay float64 `json:"hifp_pay"`
  22888. HospPartAmt float64 `json:"hosp_part_amt"`
  22889. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22890. Insutype string `json:"insutype"`
  22891. MafPay float64 `json:"maf_pay"`
  22892. MdtrtCertType string `json:"mdtrt_cert_type"`
  22893. HifobPay float64 `json:"hifob_pay"`
  22894. MdtrtID string `json:"mdtrt_id"`
  22895. MedType string `json:"med_type"`
  22896. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22897. MedinsSetlID string `json:"medins_setl_id"`
  22898. Naty string `json:"naty"`
  22899. OthPay float64 `json:"oth_pay"`
  22900. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22901. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22902. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22903. PsnCashPay float64 `json:"psn_cash_pay"`
  22904. PsnCertType string `json:"psn_cert_type"`
  22905. PsnName string `json:"psn_name"`
  22906. PsnNo string `json:"psn_no"`
  22907. PsnPartAmt float64 `json:"psn_part_amt"`
  22908. PsnType string `json:"psn_type"`
  22909. SetlID string `json:"setl_id"`
  22910. SetlTime string `json:"setl_time"`
  22911. } `json:"setlinfo"`
  22912. Setldetail interface{} `json:"setldetail"`
  22913. } `json:"output"`
  22914. RefmsgTime string `json:"refmsg_time"`
  22915. RespondTime string `json:"respond_time"`
  22916. Signtype interface{} `json:"signtype"`
  22917. WarnMsg interface{} `json:"warn_msg"`
  22918. }
  22919. type ResultSevenAH struct {
  22920. Cainfo string `json:"cainfo"`
  22921. ErrMsg string `json:"err_msg"`
  22922. InfRefmsgid string `json:"inf_refmsgid"`
  22923. Infcode int64 `json:"infcode"`
  22924. Output struct {
  22925. Setlinfo struct {
  22926. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22927. AcctPay float64 `json:"acct_pay"`
  22928. ActPayDedc float64 `json:"act_pay_dedc"`
  22929. Age float64 `json:"age"`
  22930. Balc float64 `json:"balc"`
  22931. Certno string `json:"certno"`
  22932. ClrOptins string `json:"clr_optins"`
  22933. ClrType string `json:"clr_type"`
  22934. ClrWay string `json:"clr_way"`
  22935. CvlservFlag string `json:"cvlserv_flag"`
  22936. CvlservPay float64 `json:"cvlserv_pay"`
  22937. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22938. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22939. Gend string `json:"gend"`
  22940. HifesPay float64 `json:"hifes_pay"`
  22941. HifmiPay float64 `json:"hifmi_pay"`
  22942. HifpPay float64 `json:"hifp_pay"`
  22943. HospPartAmt float64 `json:"hosp_part_amt"`
  22944. InscpScpAmt float64 `json:"inscp_scp_amt"`
  22945. Insutype string `json:"insutype"`
  22946. MafPay float64 `json:"maf_pay"`
  22947. MdtrtCertType string `json:"mdtrt_cert_type"`
  22948. HifobPay float64 `json:"hifob_pay"`
  22949. MdtrtID string `json:"mdtrt_id"`
  22950. MedType string `json:"med_type"`
  22951. MedfeeSumamt float64 `json:"medfee_sumamt"`
  22952. MedinsSetlID string `json:"medins_setl_id"`
  22953. Naty string `json:"naty"`
  22954. OthPay float64 `json:"oth_pay"`
  22955. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  22956. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  22957. PreselfpayAmt float64 `json:"preselfpay_amt"`
  22958. PsnCashPay float64 `json:"psn_cash_pay"`
  22959. PsnCertType string `json:"psn_cert_type"`
  22960. PsnName string `json:"psn_name"`
  22961. PsnNo string `json:"psn_no"`
  22962. PsnPartAmt float64 `json:"psn_part_amt"`
  22963. PsnType string `json:"psn_type"`
  22964. SetlID string `json:"setl_id"`
  22965. SetlTime int64 `json:"setl_time"`
  22966. } `json:"setlinfo"`
  22967. Setldetail interface{} `json:"setldetail"`
  22968. } `json:"output"`
  22969. RefmsgTime string `json:"refmsg_time"`
  22970. RespondTime string `json:"respond_time"`
  22971. Signtype interface{} `json:"signtype"`
  22972. WarnMsg interface{} `json:"warn_msg"`
  22973. }
  22974. type ResultSeven10265 struct {
  22975. Cainfo string `json:"cainfo"`
  22976. ErrMsg string `json:"err_msg"`
  22977. InfRefmsgid string `json:"inf_refmsgid"`
  22978. Infcode string `json:"infcode"`
  22979. Output struct {
  22980. Setlinfo struct {
  22981. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  22982. AcctPay float64 `json:"acct_pay"`
  22983. ActPayDedc float64 `json:"act_pay_dedc"`
  22984. Age float64 `json:"age"`
  22985. Balc float64 `json:"balc"`
  22986. Certno string `json:"certno"`
  22987. ClrOptins string `json:"clr_optins"`
  22988. ClrType string `json:"clr_type"`
  22989. ClrWay string `json:"clr_way"`
  22990. CvlservFlag string `json:"cvlserv_flag"`
  22991. CvlservPay float64 `json:"cvlserv_pay"`
  22992. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  22993. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  22994. Gend string `json:"gend"`
  22995. HifesPay float64 `json:"hifes_pay"`
  22996. HifmiPay float64 `json:"hifmi_pay"`
  22997. HifpPay float64 `json:"hifp_pay"`
  22998. HospPartAmt float64 `json:"hosp_part_amt"`
  22999. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23000. Insutype string `json:"insutype"`
  23001. MafPay float64 `json:"maf_pay"`
  23002. MdtrtCertType string `json:"mdtrt_cert_type"`
  23003. HifobPay float64 `json:"hifob_pay"`
  23004. MdtrtID string `json:"mdtrt_id"`
  23005. MedType string `json:"med_type"`
  23006. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23007. MedinsSetlID string `json:"medins_setl_id"`
  23008. Naty string `json:"naty"`
  23009. OthPay float64 `json:"oth_pay"`
  23010. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23011. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23012. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23013. PsnCashPay float64 `json:"psn_cash_pay"`
  23014. PsnCertType string `json:"psn_cert_type"`
  23015. PsnName string `json:"psn_name"`
  23016. PsnNo string `json:"psn_no"`
  23017. PsnPartAmt float64 `json:"psn_part_amt"`
  23018. PsnType string `json:"psn_type"`
  23019. SetlID string `json:"setl_id"`
  23020. SetlTime string `json:"setl_time"`
  23021. } `json:"setlinfo"`
  23022. Setldetail interface{} `json:"setldetail"`
  23023. } `json:"output"`
  23024. RefmsgTime string `json:"refmsg_time"`
  23025. RespondTime string `json:"respond_time"`
  23026. Signtype interface{} `json:"signtype"`
  23027. WarnMsg interface{} `json:"warn_msg"`
  23028. }
  23029. type ResultSeven10265Two struct {
  23030. Cainfo string `json:"cainfo"`
  23031. ErrMsg string `json:"err_msg"`
  23032. InfRefmsgid string `json:"inf_refmsgid"`
  23033. Infcode string `json:"infcode"`
  23034. Output struct {
  23035. Setlinfo struct {
  23036. AcctMulaidPay string `json:"acct_mulaid_pay"`
  23037. AcctPay float64 `json:"acct_pay"`
  23038. ActPayDedc float64 `json:"act_pay_dedc"`
  23039. Age float64 `json:"age"`
  23040. Balc float64 `json:"balc"`
  23041. Certno string `json:"certno"`
  23042. ClrOptins string `json:"clr_optins"`
  23043. ClrType string `json:"clr_type"`
  23044. ClrWay string `json:"clr_way"`
  23045. CvlservFlag string `json:"cvlserv_flag"`
  23046. CvlservPay float64 `json:"cvlserv_pay"`
  23047. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23048. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23049. Gend string `json:"gend"`
  23050. HifesPay float64 `json:"hifes_pay"`
  23051. HifmiPay float64 `json:"hifmi_pay"`
  23052. HifpPay float64 `json:"hifp_pay"`
  23053. HospPartAmt string `json:"hosp_part_amt"`
  23054. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23055. Insutype string `json:"insutype"`
  23056. MafPay float64 `json:"maf_pay"`
  23057. MdtrtCertType string `json:"mdtrt_cert_type"`
  23058. HifobPay float64 `json:"hifob_pay"`
  23059. MdtrtID string `json:"mdtrt_id"`
  23060. MedType string `json:"med_type"`
  23061. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23062. MedinsSetlID string `json:"medins_setl_id"`
  23063. Naty string `json:"naty"`
  23064. OthPay float64 `json:"oth_pay"`
  23065. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23066. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  23067. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23068. PsnCashPay float64 `json:"psn_cash_pay"`
  23069. PsnCertType string `json:"psn_cert_type"`
  23070. PsnName string `json:"psn_name"`
  23071. PsnNo string `json:"psn_no"`
  23072. PsnPartAmt float64 `json:"psn_part_amt"`
  23073. PsnType string `json:"psn_type"`
  23074. SetlID string `json:"setl_id"`
  23075. SetlTime string `json:"setl_time"`
  23076. } `json:"setlinfo"`
  23077. Setldetail interface{} `json:"setldetail"`
  23078. } `json:"output"`
  23079. RefmsgTime string `json:"refmsg_time"`
  23080. RespondTime string `json:"respond_time"`
  23081. Signtype interface{} `json:"signtype"`
  23082. WarnMsg interface{} `json:"warn_msg"`
  23083. }
  23084. type ResultSeven10633Two struct {
  23085. Cainfo string `json:"cainfo"`
  23086. ErrMsg string `json:"err_msg"`
  23087. InfRefmsgid string `json:"inf_refmsgid"`
  23088. Infcode string `json:"infcode"`
  23089. Output struct {
  23090. Setlinfo struct {
  23091. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23092. AcctPay float64 `json:"acct_pay"`
  23093. ActPayDedc float64 `json:"act_pay_dedc"`
  23094. Age float64 `json:"age"`
  23095. Balc float64 `json:"balc"`
  23096. Certno string `json:"certno"`
  23097. ClrOptins string `json:"clr_optins"`
  23098. ClrType string `json:"clr_type"`
  23099. ClrWay string `json:"clr_way"`
  23100. CvlservFlag string `json:"cvlserv_flag"`
  23101. CvlservPay float64 `json:"cvlserv_pay"`
  23102. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23103. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23104. Gend string `json:"gend"`
  23105. HifesPay float64 `json:"hifes_pay"`
  23106. HifmiPay float64 `json:"hifmi_pay"`
  23107. HifpPay float64 `json:"hifp_pay"`
  23108. HospPartAmt float64 `json:"hosp_part_amt"`
  23109. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23110. Insutype string `json:"insutype"`
  23111. MafPay float64 `json:"maf_pay"`
  23112. MdtrtCertType string `json:"mdtrt_cert_type"`
  23113. HifobPay float64 `json:"hifob_pay"`
  23114. MdtrtID string `json:"mdtrt_id"`
  23115. MedType string `json:"med_type"`
  23116. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23117. MedinsSetlID string `json:"medins_setl_id"`
  23118. Naty string `json:"naty"`
  23119. OthPay float64 `json:"oth_pay"`
  23120. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23121. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23122. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23123. PsnCashPay float64 `json:"psn_cash_pay"`
  23124. PsnCertType string `json:"psn_cert_type"`
  23125. PsnName string `json:"psn_name"`
  23126. PsnNo string `json:"psn_no"`
  23127. PsnPartAmt float64 `json:"psn_part_amt"`
  23128. PsnType string `json:"psn_type"`
  23129. SetlID string `json:"setl_id"`
  23130. SetlTime string `json:"setl_time"`
  23131. } `json:"setlinfo"`
  23132. Setldetail interface{} `json:"setldetail"`
  23133. } `json:"output"`
  23134. RefmsgTime string `json:"refmsg_time"`
  23135. RespondTime string `json:"respond_time"`
  23136. Signtype interface{} `json:"signtype"`
  23137. WarnMsg interface{} `json:"warn_msg"`
  23138. }
  23139. type ResultSeven10633Three struct {
  23140. Cainfo string `json:"cainfo"`
  23141. ErrMsg string `json:"err_msg"`
  23142. InfRefmsgid string `json:"inf_refmsgid"`
  23143. Infcode string `json:"infcode"`
  23144. Output struct {
  23145. Setlinfo struct {
  23146. AcctMulaidPay string `json:"acct_mulaid_pay"`
  23147. AcctPay float64 `json:"acct_pay"`
  23148. ActPayDedc float64 `json:"act_pay_dedc"`
  23149. Age float64 `json:"age"`
  23150. Balc float64 `json:"balc"`
  23151. Certno string `json:"certno"`
  23152. ClrOptins string `json:"clr_optins"`
  23153. ClrType string `json:"clr_type"`
  23154. ClrWay string `json:"clr_way"`
  23155. CvlservFlag string `json:"cvlserv_flag"`
  23156. CvlservPay float64 `json:"cvlserv_pay"`
  23157. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23158. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23159. Gend string `json:"gend"`
  23160. HifesPay float64 `json:"hifes_pay"`
  23161. HifmiPay float64 `json:"hifmi_pay"`
  23162. HifpPay float64 `json:"hifp_pay"`
  23163. HospPartAmt string `json:"hosp_part_amt"`
  23164. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23165. Insutype string `json:"insutype"`
  23166. MafPay float64 `json:"maf_pay"`
  23167. MdtrtCertType string `json:"mdtrt_cert_type"`
  23168. HifobPay float64 `json:"hifob_pay"`
  23169. MdtrtID string `json:"mdtrt_id"`
  23170. MedType string `json:"med_type"`
  23171. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23172. MedinsSetlID string `json:"medins_setl_id"`
  23173. Naty string `json:"naty"`
  23174. OthPay float64 `json:"oth_pay"`
  23175. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23176. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  23177. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23178. PsnCashPay float64 `json:"psn_cash_pay"`
  23179. PsnCertType string `json:"psn_cert_type"`
  23180. PsnName string `json:"psn_name"`
  23181. PsnNo string `json:"psn_no"`
  23182. PsnPartAmt float64 `json:"psn_part_amt"`
  23183. PsnType string `json:"psn_type"`
  23184. SetlID string `json:"setl_id"`
  23185. SetlTime string `json:"setl_time"`
  23186. } `json:"setlinfo"`
  23187. Setldetail interface{} `json:"setldetail"`
  23188. } `json:"output"`
  23189. RefmsgTime string `json:"refmsg_time"`
  23190. RespondTime string `json:"respond_time"`
  23191. Signtype interface{} `json:"signtype"`
  23192. WarnMsg interface{} `json:"warn_msg"`
  23193. }
  23194. type GZResultSeven10265Two struct {
  23195. Cainfo string `json:"cainfo"`
  23196. ErrMsg string `json:"err_msg"`
  23197. InfRefmsgid string `json:"inf_refmsgid"`
  23198. Infcode int64 `json:"infcode"`
  23199. Output struct {
  23200. Setlinfo struct {
  23201. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  23202. AcctPay float64 `json:"acct_pay"`
  23203. ActPayDedc float64 `json:"act_pay_dedc"`
  23204. Age float64 `json:"age"`
  23205. Balc float64 `json:"balc"`
  23206. Certno string `json:"certno"`
  23207. ClrOptins string `json:"clr_optins"`
  23208. ClrType string `json:"clr_type"`
  23209. ClrWay string `json:"clr_way"`
  23210. CvlservFlag string `json:"cvlserv_flag"`
  23211. CvlservPay float64 `json:"cvlserv_pay"`
  23212. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23213. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23214. Gend string `json:"gend"`
  23215. HifesPay float64 `json:"hifes_pay"`
  23216. HifmiPay float64 `json:"hifmi_pay"`
  23217. HifpPay float64 `json:"hifp_pay"`
  23218. HospPartAmt float64 `json:"hosp_part_amt"`
  23219. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23220. Insutype string `json:"insutype"`
  23221. MafPay float64 `json:"maf_pay"`
  23222. MdtrtCertType string `json:"mdtrt_cert_type"`
  23223. HifobPay float64 `json:"hifob_pay"`
  23224. MdtrtID string `json:"mdtrt_id"`
  23225. MedType string `json:"med_type"`
  23226. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23227. MedinsSetlID string `json:"medins_setl_id"`
  23228. Naty string `json:"naty"`
  23229. OthPay float64 `json:"oth_pay"`
  23230. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23231. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  23232. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23233. PsnCashPay float64 `json:"psn_cash_pay"`
  23234. PsnCertType string `json:"psn_cert_type"`
  23235. PsnName string `json:"psn_name"`
  23236. PsnNo string `json:"psn_no"`
  23237. PsnPartAmt float64 `json:"psn_part_amt"`
  23238. PsnType string `json:"psn_type"`
  23239. SetlID string `json:"setl_id"`
  23240. SetlTime string `json:"setl_time"`
  23241. } `json:"setlinfo"`
  23242. Setldetail interface{} `json:"setldetail"`
  23243. } `json:"output"`
  23244. RefmsgTime string `json:"refmsg_time"`
  23245. RespondTime string `json:"respond_time"`
  23246. Signtype interface{} `json:"signtype"`
  23247. WarnMsg interface{} `json:"warn_msg"`
  23248. }
  23249. type ResultEight struct {
  23250. Cainfo string `json:"cainfo"`
  23251. ErrMsg string `json:"err_msg"`
  23252. InfRefmsgid string `json:"inf_refmsgid"`
  23253. Infcode int64 `json:"infcode"`
  23254. Output struct {
  23255. Stmtinfo struct {
  23256. SetlOptins string `json:"setl_optins"`
  23257. StmtRslt string `json:"stmt_rslt"`
  23258. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  23259. } `json:"stmtinfo"`
  23260. } `json:"output"`
  23261. RefmsgTime string `json:"refmsg_time"`
  23262. RespondTime string `json:"respond_time"`
  23263. Signtype interface{} `json:"signtype"`
  23264. WarnMsg interface{} `json:"warn_msg"`
  23265. }
  23266. type ResultEightFor10188 struct {
  23267. Cainfo string `json:"cainfo"`
  23268. ErrMsg string `json:"err_msg"`
  23269. InfRefmsgid string `json:"inf_refmsgid"`
  23270. Infcode string `json:"infcode"`
  23271. Output struct {
  23272. Stmtinfo struct {
  23273. SetlOptins string `json:"setl_optins"`
  23274. StmtRslt string `json:"stmt_rslt"`
  23275. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  23276. } `json:"stmtinfo"`
  23277. } `json:"output"`
  23278. RefmsgTime string `json:"refmsg_time"`
  23279. RespondTime string `json:"respond_time"`
  23280. Signtype interface{} `json:"signtype"`
  23281. WarnMsg interface{} `json:"warn_msg"`
  23282. }
  23283. type ResultNine struct {
  23284. Cainfo string `json:"cainfo"`
  23285. ErrMsg string `json:"err_msg"`
  23286. InfRefmsgid string `json:"inf_refmsgid"`
  23287. Infcode int64 `json:"infcode"`
  23288. Output struct {
  23289. FileQuryNo string `json:"file_qury_no"`
  23290. } `json:"output"`
  23291. RefmsgTime string `json:"refmsg_time"`
  23292. RespondTime string `json:"respond_time"`
  23293. Signtype interface{} `json:"signtype"`
  23294. WarnMsg interface{} `json:"warn_msg"`
  23295. }
  23296. type ResultTen struct {
  23297. Cainfo string `json:"cainfo"`
  23298. ErrMsg string `json:"err_msg"`
  23299. InfRefmsgid string `json:"inf_refmsgid"`
  23300. Infcode int64 `json:"infcode"`
  23301. Output struct {
  23302. Fileinfo struct {
  23303. DldEndtime string `json:"dld_endtime"`
  23304. FileQuryNo string `json:"file_qury_no"`
  23305. Filename string `json:"filename"`
  23306. } `json:"fileinfo"`
  23307. } `json:"output"`
  23308. RefmsgTime string `json:"refmsg_time"`
  23309. RespondTime string `json:"respond_time"`
  23310. Signtype interface{} `json:"signtype"`
  23311. WarnMsg interface{} `json:"warn_msg"`
  23312. }
  23313. type Result5262 struct {
  23314. ErrMsg string `json:"err_msg"`
  23315. InfRefmsgid string `json:"inf_refmsgid"`
  23316. Infcode int64 `json:"infcode"`
  23317. Output struct {
  23318. PageInfo struct {
  23319. Size int `json:"size"`
  23320. RecordCounts int `json:"record_counts"`
  23321. } `json:"page_info"`
  23322. Idetinfo []interface{} `json:"idetinfo"`
  23323. Result []struct {
  23324. SetlID string `json:"setl_id"`
  23325. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  23326. MdtrtID string `json:"mdtrt_id"`
  23327. InitSetlID string `json:"init_setl_id,omitempty"`
  23328. PsnNo string `json:"psn_no"`
  23329. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  23330. PsnName string `json:"psn_name"`
  23331. PsnCertType string `json:"psn_cert_type"`
  23332. Certno string `json:"certno"`
  23333. Gend string `json:"gend,omitempty"`
  23334. Naty string `json:"naty,omitempty"`
  23335. Brdy string `json:"brdy,omitempty"`
  23336. Age float64 `json:"age,omitempty"`
  23337. Insutype string `json:"insutype,omitempty"`
  23338. PsnType string `json:"psn_type"`
  23339. CvlservFlag string `json:"cvlserv_flag"`
  23340. CvlservLv string `json:"cvlserv_lv,omitempty"`
  23341. SpPsnType string `json:"sp_psn_type,omitempty"`
  23342. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  23343. ClctGrde string `json:"clct_grde,omitempty"`
  23344. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  23345. NwbFlag string `json:"nwb_flag,omitempty"`
  23346. InsuAdmdvs string `json:"insu_admdvs"`
  23347. EmpNo string `json:"emp_no,omitempty"`
  23348. EmpName string `json:"emp_name,omitempty"`
  23349. EmpType string `json:"emp_type,omitempty"`
  23350. EconType string `json:"econ_type,omitempty"`
  23351. AfilIndu string `json:"afil_indu,omitempty"`
  23352. AfilRlts string `json:"afil_rlts,omitempty"`
  23353. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  23354. PayLoc string `json:"pay_loc,omitempty"`
  23355. FixmedinsCode string `json:"fixmedins_code"`
  23356. FixmedinsName string `json:"fixmedins_name"`
  23357. HospLv string `json:"hosp_lv,omitempty"`
  23358. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  23359. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  23360. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  23361. Begndate string `json:"begndate"`
  23362. Enddate string `json:"enddate"`
  23363. SetlTime string `json:"setl_time"`
  23364. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  23365. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  23366. MedType string `json:"med_type"`
  23367. SetlType string `json:"setl_type,omitempty"`
  23368. ClrType string `json:"clr_type,omitempty"`
  23369. ClrWay string `json:"clr_way,omitempty"`
  23370. PsnSetlway string `json:"psn_setlway,omitempty"`
  23371. ClrOptins string `json:"clr_optins,omitempty"`
  23372. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  23373. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  23374. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  23375. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  23376. InscpAmt float64 `json:"inscp_amt,omitempty"`
  23377. DedcStd float64 `json:"dedc_std,omitempty"`
  23378. CrtDedc float64 `json:"crt_dedc,omitempty"`
  23379. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  23380. HifpPay float64 `json:"hifp_pay,omitempty"`
  23381. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  23382. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  23383. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  23384. HifesPay float64 `json:"hifes_pay,omitempty"`
  23385. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  23386. HifobPay float64 `json:"hifob_pay,omitempty"`
  23387. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  23388. MafPay float64 `json:"maf_pay,omitempty"`
  23389. OthfundPay float64 `json:"othfund_pay,omitempty"`
  23390. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  23391. PsnPay float64 `json:"psn_pay,omitempty"`
  23392. AcctPay float64 `json:"acct_pay,omitempty"`
  23393. CashPayamt float64 `json:"cash_payamt,omitempty"`
  23394. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  23395. Balc float64 `json:"balc,omitempty"`
  23396. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  23397. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  23398. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  23399. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  23400. Year string `json:"year,omitempty"`
  23401. DiseNo string `json:"dise_no,omitempty"`
  23402. DiseName string `json:"dise_name,omitempty"`
  23403. Invono string `json:"invono,omitempty"`
  23404. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  23405. ValiFlag string `json:"vali_flag,omitempty"`
  23406. Memo string `json:"memo,omitempty"`
  23407. Rid string `json:"rid"`
  23408. UpdtTime string `json:"updt_time,omitempty"`
  23409. CrterID string `json:"crter_id,omitempty"`
  23410. CrterName string `json:"crter_name,omitempty"`
  23411. CrteTime string `json:"crte_time,omitempty"`
  23412. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  23413. OpterID string `json:"opter_id,omitempty"`
  23414. OpterName string `json:"opter_name,omitempty"`
  23415. OptTime string `json:"opt_time,omitempty"`
  23416. OptinsNo string `json:"optins_no,omitempty"`
  23417. PoolareaNo string `json:"poolarea_no,omitempty"`
  23418. } `json:"result"`
  23419. } `json:"output"`
  23420. RefmsgTime string `json:"refmsg_time"`
  23421. RespondTime string `json:"respond_time"`
  23422. Signtype interface{} `json:"signtype"`
  23423. WarnInfo interface{} `json:"warn_info"`
  23424. }
  23425. type Result5267 struct {
  23426. ErrMsg string `json:"err_msg"`
  23427. InfRefmsgid string `json:"inf_refmsgid"`
  23428. Infcode int64 `json:"infcode"`
  23429. Output struct {
  23430. PageInfo struct {
  23431. Size int `json:"size"`
  23432. RecordCounts int `json:"record_counts"`
  23433. } `json:"pageinfo"`
  23434. Result []struct {
  23435. SetlID string `json:"setl_id"`
  23436. ClrOptins string `json:"clr_optins"`
  23437. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  23438. MdtrtID string `json:"mdtrt_id"`
  23439. InitSetlID string `json:"init_setl_id,omitempty"`
  23440. PsnNo string `json:"psn_no"`
  23441. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  23442. PsnName string `json:"psn_name"`
  23443. PsnCertType string `json:"psn_cert_type"`
  23444. Certno string `json:"certno"`
  23445. Gend string `json:"gend,omitempty"`
  23446. Naty string `json:"naty,omitempty"`
  23447. Brdy string `json:"brdy,omitempty"`
  23448. Age float64 `json:"age,omitempty"`
  23449. Insutype string `json:"insutype,omitempty"`
  23450. PsnType string `json:"psn_type"`
  23451. CvlservFlag string `json:"cvlserv_flag"`
  23452. CvlservLv string `json:"cvlserv_lv,omitempty"`
  23453. SpPsnType string `json:"sp_psn_type,omitempty"`
  23454. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  23455. ClctGrde string `json:"clct_grde,omitempty"`
  23456. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  23457. NwbFlag string `json:"nwb_flag,omitempty"`
  23458. InsuAdmdvs string `json:"insu_admdvs"`
  23459. EmpNo string `json:"emp_no,omitempty"`
  23460. EmpName string `json:"emp_name,omitempty"`
  23461. EmpType string `json:"emp_type,omitempty"`
  23462. EconType string `json:"econ_type,omitempty"`
  23463. AfilIndu string `json:"afil_indu,omitempty"`
  23464. AfilRlts string `json:"afil_rlts,omitempty"`
  23465. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  23466. PayLoc string `json:"pay_loc,omitempty"`
  23467. FixmedinsCode string `json:"fixmedins_code"`
  23468. FixmedinsName string `json:"fixmedins_name"`
  23469. HospLv string `json:"hosp_lv,omitempty"`
  23470. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  23471. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  23472. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  23473. Begndate string `json:"begndate,omitempty"`
  23474. Enddate string `json:"enddate,omitempty"`
  23475. SetlTime string `json:"setl_time,omitempty"`
  23476. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  23477. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  23478. MedType string `json:"med_type"`
  23479. SetlType string `json:"setl_type,omitempty"`
  23480. ClrType string `json:"clr_type,omitempty"`
  23481. ClrWay string `json:"clr_way,omitempty"`
  23482. PsnSetlway string `json:"psn_setlway,omitempty"`
  23483. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  23484. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  23485. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  23486. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  23487. InscpAmt float64 `json:"inscp_amt,omitempty"`
  23488. DedcStd float64 `json:"dedc_std,omitempty"`
  23489. CrtDedc float64 `json:"crt_dedc,omitempty"`
  23490. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  23491. HifpPay float64 `json:"hifp_pay,omitempty"`
  23492. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  23493. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  23494. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  23495. HifesPay float64 `json:"hifes_pay,omitempty"`
  23496. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  23497. HifobPay float64 `json:"hifob_pay,omitempty"`
  23498. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  23499. MafPay float64 `json:"maf_pay,omitempty"`
  23500. OthfundPay float64 `json:"othfund_pay,omitempty"`
  23501. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  23502. PsnPay float64 `json:"psn_pay,omitempty"`
  23503. AcctPay float64 `json:"acct_pay,omitempty"`
  23504. CashPayamt float64 `json:"cash_payamt,omitempty"`
  23505. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  23506. Balc float64 `json:"balc,omitempty"`
  23507. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  23508. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  23509. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  23510. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  23511. Year string `json:"year,omitempty"`
  23512. DiseNo string `json:"dise_no,omitempty"`
  23513. DiseName string `json:"dise_name,omitempty"`
  23514. Invono string `json:"invono,omitempty"`
  23515. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  23516. Memo string `json:"memo,omitempty"`
  23517. UpdtTime string `json:"updt_time,omitempty"`
  23518. OpterID string `json:"opter_id,omitempty"`
  23519. OpterName string `json:"opter_name,omitempty"`
  23520. OptTime string `json:"opt_time,omitempty"`
  23521. OptinsNo string `json:"optins_no,omitempty"`
  23522. PoolareaNo string `json:"poolarea_no,omitempty"`
  23523. } `json:"result"`
  23524. } `json:"output"`
  23525. RefmsgTime string `json:"refmsg_time"`
  23526. RespondTime string `json:"respond_time"`
  23527. Signtype interface{} `json:"signtype"`
  23528. WarnInfo interface{} `json:"warn_info"`
  23529. }
  23530. // type Autogenerated struct {
  23531. // Output struct {
  23532. // Setlinfo struct {
  23533. // SetlTime string `json:"setl_time"`
  23534. // CvlservPay float64 `json:"cvlserv_pay"`
  23535. // Year string `json:"year"`
  23536. // MedType string `json:"med_type"`
  23537. // PsnPay float64 `json:"psn_pay"`
  23538. // OpterID string `json:"opter_id"`
  23539. // Begndate string `json:"begndate"`
  23540. // FlxempeFlag string `json:"flxempe_flag"`
  23541. // HifmiPay float64 `json:"hifmi_pay"`
  23542. // PsnNo string `json:"psn_no"`
  23543. // ActPayDedc float64 `json:"act_pay_dedc"`
  23544. // MedinsSetlID interface{} `json:"medins_setl_id"`
  23545. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23546. // ClrWay string `json:"clr_way"`
  23547. // OthPay float64 `json:"oth_pay"`
  23548. // Gend string `json:"gend"`
  23549. // MdtrtID string `json:"mdtrt_id"`
  23550. // AcctPay float64 `json:"acct_pay"`
  23551. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  23552. // Insutype string `json:"insutype"`
  23553. // Invono interface{} `json:"invono"`
  23554. // Enddate string `json:"enddate"`
  23555. // CashPayamt float64 `json:"cash_payamt"`
  23556. // PsnType string `json:"psn_type"`
  23557. // FixmedinsName string `json:"fixmedins_name"`
  23558. // HifpPay float64 `json:"hifp_pay"`
  23559. // NewFlag interface{} `json:"new_flag"`
  23560. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23561. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  23562. // PayLoc string `json:"pay_loc"`
  23563. // ClrType string `json:"clr_type"`
  23564. // RefdSetlFlag string `json:"refd_setl_flag"`
  23565. // CvlservFlag string `json:"cvlserv_flag"`
  23566. // EmpName string `json:"emp_name"`
  23567. // Brdy string `json:"brdy"`
  23568. // Naty string `json:"naty"`
  23569. // Certno string `json:"certno"`
  23570. // DiseCode string `json:"dise_code"`
  23571. // FixmedinsCode string `json:"fixmedins_code"`
  23572. // DedcHospLv string `json:"dedc_hosp_lv"`
  23573. // OpterName string `json:"opter_name"`
  23574. // Balc float64 `json:"balc"`
  23575. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23576. // PsnCertType string `json:"psn_cert_type"`
  23577. // HifobPay float64 `json:"hifob_pay"`
  23578. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  23579. // HifesPay float64 `json:"hifes_pay"`
  23580. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23581. // OptTime string `json:"opt_time"`
  23582. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23583. // SetlID string `json:"setl_id"`
  23584. // MafPay float64 `json:"maf_pay"`
  23585. // PsnName string `json:"psn_name"`
  23586. // InsuOptins interface{} `json:"insu_optins"`
  23587. // PrefFundPay interface{} `json:"pref_fund_pay"`
  23588. // ClrOptins string `json:"clr_optins"`
  23589. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23590. // DiseName string `json:"dise_name"`
  23591. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23592. // Age float64 `json:"age"`
  23593. // DtrtCertType string `json:"dtrt_cert_type"`
  23594. // HospLv string `json:"hosp_lv"`
  23595. // } `json:"setlinfo"`
  23596. // Setldetail []struct {
  23597. // FundPayType string `json:"fund_pay_type"`
  23598. // FundPayamt float64 `json:"fund_payamt"`
  23599. // SetlProcInfo interface{} `json:"setl_proc_info"`
  23600. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  23601. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  23602. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  23603. // PrefFundPay interface{} `json:"pref_fund_pay"`
  23604. // } `json:"setldetail"`
  23605. // } `json:"output"`
  23606. // Infcode int `json:"infcode"`
  23607. // WarnMsg interface{} `json:"warn_msg"`
  23608. // Cainfo interface{} `json:"cainfo"`
  23609. // ErrMsg interface{} `json:"err_msg"`
  23610. // RefmsgTime string `json:"refmsg_time"`
  23611. // Signtype interface{} `json:"signtype"`
  23612. // RespondTime string `json:"respond_time"`
  23613. // InfRefmsgid string `json:"inf_refmsgid"`
  23614. // }
  23615. type Result002 struct {
  23616. Cainfo interface{} `json:"cainfo"`
  23617. ErrMsg string `json:"err_msg"`
  23618. InfRefmsgid string `json:"inf_refmsgid"`
  23619. Infcode int64 `json:"infcode"`
  23620. Output struct {
  23621. RxFile string `json:"rx_file"`
  23622. SignDigest string `json:"sign_digest"`
  23623. SignCertSn string `json:"sign_cert_sn"`
  23624. SignCertDn string `json:"sign_cert_dn"`
  23625. } `json:"output"`
  23626. RefmsgTime string `json:"refmsg_time"`
  23627. RespondTime string `json:"respond_time"`
  23628. Signtype interface{} `json:"signtype"`
  23629. WarnMsg interface{} `json:"warn_msg"`
  23630. }
  23631. type AhResult002 struct {
  23632. RxFile string `json:"rxFile"`
  23633. SignDigest string `json:"signDigest"`
  23634. SignCertSn string `json:"signCertSn"`
  23635. SignCertDn string `json:"signCertDn"`
  23636. }
  23637. type Result003 struct {
  23638. Cainfo interface{} `json:"cainfo"`
  23639. ErrMsg string `json:"err_msg"`
  23640. InfRefmsgid string `json:"inf_refmsgid"`
  23641. Infcode int64 `json:"infcode"`
  23642. Output struct {
  23643. HiRxno string `json:"hi_rxno"`
  23644. RxStasCodg string `json:"rx_stas_codg"`
  23645. RxStasName string `json:"rx_stas_name"`
  23646. } `json:"output"`
  23647. RefmsgTime string `json:"refmsg_time"`
  23648. RespondTime string `json:"respond_time"`
  23649. Signtype interface{} `json:"signtype"`
  23650. WarnMsg interface{} `json:"warn_msg"`
  23651. }
  23652. type AHResult003 struct {
  23653. HiRxno string `json:"hiRxno"`
  23654. RxStasCodg string `json:"rxStasCodg"`
  23655. RxStasName string `json:"rxStasName"`
  23656. }
  23657. type ResultEleven struct {
  23658. Cainfo string `json:"cainfo"`
  23659. ErrMsg string `json:"err_msg"`
  23660. InfRefmsgid string `json:"inf_refmsgid"`
  23661. Infcode int64 `json:"infcode"`
  23662. Output struct {
  23663. Setlinfo struct {
  23664. SetlTime string `json:"setl_time"`
  23665. CvlservPay float64 `json:"cvlserv_pay"`
  23666. Year string `json:"year"`
  23667. MedType string `json:"med_type"`
  23668. PsnPay float64 `json:"psn_pay"`
  23669. OpterID string `json:"opter_id"`
  23670. Begndate string `json:"begndate"`
  23671. FlxempeFlag string `json:"flxempe_flag"`
  23672. HifmiPay float64 `json:"hifmi_pay"`
  23673. PsnNo string `json:"psn_no"`
  23674. ActPayDedc float64 `json:"act_pay_dedc"`
  23675. MedinsSetlID interface{} `json:"medins_setl_id"`
  23676. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23677. ClrWay string `json:"clr_way"`
  23678. OthPay float64 `json:"oth_pay"`
  23679. Gend string `json:"gend"`
  23680. MdtrtID string `json:"mdtrt_id"`
  23681. AcctPay float64 `json:"acct_pay"`
  23682. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23683. Insutype string `json:"insutype"`
  23684. Invono interface{} `json:"invono"`
  23685. Enddate string `json:"enddate"`
  23686. CashPayamt float64 `json:"cash_payamt"`
  23687. PsnType string `json:"psn_type"`
  23688. FixmedinsName string `json:"fixmedins_name"`
  23689. HifpPay float64 `json:"hifp_pay"`
  23690. NewFlag interface{} `json:"new_flag"`
  23691. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23692. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23693. PayLoc string `json:"pay_loc"`
  23694. ClrType string `json:"clr_type"`
  23695. RefdSetlFlag string `json:"refd_setl_flag"`
  23696. CvlservFlag string `json:"cvlserv_flag"`
  23697. EmpName string `json:"emp_name"`
  23698. Brdy string `json:"brdy"`
  23699. Naty string `json:"naty"`
  23700. Certno string `json:"certno"`
  23701. DiseCode string `json:"dise_code"`
  23702. FixmedinsCode string `json:"fixmedins_code"`
  23703. DedcHospLv string `json:"dedc_hosp_lv"`
  23704. OpterName string `json:"opter_name"`
  23705. Balc float64 `json:"balc"`
  23706. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23707. PsnCertType string `json:"psn_cert_type"`
  23708. HifobPay float64 `json:"hifob_pay"`
  23709. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23710. HifesPay float64 `json:"hifes_pay"`
  23711. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23712. OptTime string `json:"opt_time"`
  23713. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23714. SetlID string `json:"setl_id"`
  23715. MafPay float64 `json:"maf_pay"`
  23716. PsnName string `json:"psn_name"`
  23717. InsuOptins interface{} `json:"insu_optins"`
  23718. PrefFundPay interface{} `json:"pref_fund_pay"`
  23719. ClrOptins string `json:"clr_optins"`
  23720. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23721. DiseName string `json:"dise_name"`
  23722. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23723. Age float64 `json:"age"`
  23724. DtrtCertType string `json:"dtrt_cert_type"`
  23725. HospLv string `json:"hosp_lv"`
  23726. PsnCashPay float64 `json:"psn_cash_pay"`
  23727. } `json:"setlinfo"`
  23728. } `json:"output"`
  23729. RefmsgTime string `json:"refmsg_time"`
  23730. RespondTime string `json:"respond_time"`
  23731. Signtype interface{} `json:"signtype"`
  23732. WarnMsg interface{} `json:"warn_msg"`
  23733. }
  23734. type ResultElevenah struct {
  23735. Cainfo string `json:"cainfo"`
  23736. ErrMsg string `json:"err_msg"`
  23737. InfRefmsgid string `json:"inf_refmsgid"`
  23738. Infcode int64 `json:"infcode"`
  23739. Output struct {
  23740. Setlinfo struct {
  23741. SetlTime int64 `json:"setl_time"`
  23742. CvlservPay float64 `json:"cvlserv_pay"`
  23743. Year string `json:"year"`
  23744. MedType string `json:"med_type"`
  23745. PsnPay float64 `json:"psn_pay"`
  23746. OpterID string `json:"opter_id"`
  23747. Begndate int64 `json:"begndate"`
  23748. FlxempeFlag string `json:"flxempe_flag"`
  23749. HifmiPay float64 `json:"hifmi_pay"`
  23750. PsnNo string `json:"psn_no"`
  23751. ActPayDedc float64 `json:"act_pay_dedc"`
  23752. MedinsSetlID interface{} `json:"medins_setl_id"`
  23753. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23754. ClrWay string `json:"clr_way"`
  23755. OthPay float64 `json:"oth_pay"`
  23756. Gend string `json:"gend"`
  23757. MdtrtID string `json:"mdtrt_id"`
  23758. AcctPay float64 `json:"acct_pay"`
  23759. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23760. Insutype string `json:"insutype"`
  23761. Invono interface{} `json:"invono"`
  23762. Enddate int64 `json:"enddate"`
  23763. CashPayamt float64 `json:"cash_payamt"`
  23764. PsnType string `json:"psn_type"`
  23765. FixmedinsName string `json:"fixmedins_name"`
  23766. HifpPay float64 `json:"hifp_pay"`
  23767. NewFlag interface{} `json:"new_flag"`
  23768. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23769. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23770. PayLoc string `json:"pay_loc"`
  23771. ClrType string `json:"clr_type"`
  23772. RefdSetlFlag string `json:"refd_setl_flag"`
  23773. CvlservFlag string `json:"cvlserv_flag"`
  23774. EmpName string `json:"emp_name"`
  23775. Brdy int64 `json:"brdy"`
  23776. Naty string `json:"naty"`
  23777. Certno string `json:"certno"`
  23778. DiseCode string `json:"dise_code"`
  23779. FixmedinsCode string `json:"fixmedins_code"`
  23780. DedcHospLv string `json:"dedc_hosp_lv"`
  23781. OpterName string `json:"opter_name"`
  23782. Balc float64 `json:"balc"`
  23783. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23784. PsnCertType string `json:"psn_cert_type"`
  23785. HifobPay float64 `json:"hifob_pay"`
  23786. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23787. HifesPay float64 `json:"hifes_pay"`
  23788. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23789. OptTime int64 `json:"opt_time"`
  23790. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23791. SetlID string `json:"setl_id"`
  23792. MafPay float64 `json:"maf_pay"`
  23793. PsnName string `json:"psn_name"`
  23794. InsuOptins interface{} `json:"insu_optins"`
  23795. PrefFundPay interface{} `json:"pref_fund_pay"`
  23796. ClrOptins string `json:"clr_optins"`
  23797. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23798. DiseName string `json:"dise_name"`
  23799. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23800. Age float64 `json:"age"`
  23801. DtrtCertType string `json:"dtrt_cert_type"`
  23802. HospLv string `json:"hosp_lv"`
  23803. PsnCashPay float64 `json:"psn_cash_pay"`
  23804. } `json:"setlinfo"`
  23805. } `json:"output"`
  23806. RefmsgTime string `json:"refmsg_time"`
  23807. RespondTime string `json:"respond_time"`
  23808. Signtype interface{} `json:"signtype"`
  23809. WarnMsg interface{} `json:"warn_msg"`
  23810. }
  23811. type ResultEleven10265 struct {
  23812. Cainfo string `json:"cainfo"`
  23813. ErrMsg string `json:"err_msg"`
  23814. InfRefmsgid string `json:"inf_refmsgid"`
  23815. Infcode string `json:"infcode"`
  23816. Output struct {
  23817. Setlinfo struct {
  23818. SetlTime string `json:"setl_time"`
  23819. CvlservPay float64 `json:"cvlserv_pay"`
  23820. Year string `json:"year"`
  23821. MedType string `json:"med_type"`
  23822. PsnPay float64 `json:"psn_pay"`
  23823. OpterID string `json:"opter_id"`
  23824. Begndate string `json:"begndate"`
  23825. FlxempeFlag string `json:"flxempe_flag"`
  23826. HifmiPay float64 `json:"hifmi_pay"`
  23827. PsnNo string `json:"psn_no"`
  23828. ActPayDedc float64 `json:"act_pay_dedc"`
  23829. MedinsSetlID interface{} `json:"medins_setl_id"`
  23830. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  23831. ClrWay string `json:"clr_way"`
  23832. OthPay float64 `json:"oth_pay"`
  23833. Gend string `json:"gend"`
  23834. MdtrtID string `json:"mdtrt_id"`
  23835. AcctPay float64 `json:"acct_pay"`
  23836. InscpScpAmt float64 `json:"inscp_scp_amt"`
  23837. Insutype string `json:"insutype"`
  23838. Invono interface{} `json:"invono"`
  23839. Enddate string `json:"enddate"`
  23840. CashPayamt float64 `json:"cash_payamt"`
  23841. PsnType string `json:"psn_type"`
  23842. FixmedinsName string `json:"fixmedins_name"`
  23843. HifpPay float64 `json:"hifp_pay"`
  23844. NewFlag interface{} `json:"new_flag"`
  23845. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  23846. PreselfpayAmt float64 `json:"preselfpay_amt"`
  23847. PayLoc string `json:"pay_loc"`
  23848. ClrType string `json:"clr_type"`
  23849. RefdSetlFlag string `json:"refd_setl_flag"`
  23850. CvlservFlag string `json:"cvlserv_flag"`
  23851. EmpName string `json:"emp_name"`
  23852. Brdy string `json:"brdy"`
  23853. Naty string `json:"naty"`
  23854. Certno string `json:"certno"`
  23855. DiseCode string `json:"dise_code"`
  23856. FixmedinsCode string `json:"fixmedins_code"`
  23857. DedcHospLv string `json:"dedc_hosp_lv"`
  23858. OpterName string `json:"opter_name"`
  23859. Balc float64 `json:"balc"`
  23860. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  23861. PsnCertType string `json:"psn_cert_type"`
  23862. HifobPay float64 `json:"hifob_pay"`
  23863. MedfeeSumamt float64 `json:"medfee_sumamt"`
  23864. HifesPay float64 `json:"hifes_pay"`
  23865. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  23866. OptTime string `json:"opt_time"`
  23867. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  23868. SetlID string `json:"setl_id"`
  23869. MafPay float64 `json:"maf_pay"`
  23870. PsnName string `json:"psn_name"`
  23871. InsuOptins interface{} `json:"insu_optins"`
  23872. PrefFundPay interface{} `json:"pref_fund_pay"`
  23873. ClrOptins string `json:"clr_optins"`
  23874. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  23875. DiseName string `json:"dise_name"`
  23876. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  23877. Age float64 `json:"age"`
  23878. DtrtCertType string `json:"dtrt_cert_type"`
  23879. HospLv string `json:"hosp_lv"`
  23880. PsnCashPay float64 `json:"psn_cash_pay"`
  23881. } `json:"setlinfo"`
  23882. } `json:"output"`
  23883. RefmsgTime string `json:"refmsg_time"`
  23884. RespondTime string `json:"respond_time"`
  23885. Signtype interface{} `json:"signtype"`
  23886. WarnMsg interface{} `json:"warn_msg"`
  23887. }
  23888. type ResultTwelve struct {
  23889. Cainfo string `json:"cainfo"`
  23890. ErrMsg string `json:"err_msg"`
  23891. InfRefmsgid string `json:"inf_refmsgid"`
  23892. Infcode int64 `json:"infcode"`
  23893. Output struct {
  23894. MdtrtId string `json:"mdtrt_id"`
  23895. ChrgBchno string `json:"chrg_bchno"`
  23896. PsnNo string `json:"psn_no"`
  23897. } `json:"output"`
  23898. RefmsgTime string `json:"refmsg_time"`
  23899. RespondTime string `json:"respond_time"`
  23900. Signtype interface{} `json:"signtype"`
  23901. WarnMsg interface{} `json:"warn_msg"`
  23902. }
  23903. type ResultThirteen struct {
  23904. ErrMsg string `json:"err_msg"`
  23905. InfRefmsgid string `json:"inf_refmsgid"`
  23906. Infcode int64 `json:"infcode"`
  23907. Output struct {
  23908. Result struct {
  23909. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  23910. } `json:"result"`
  23911. } `json:"output"`
  23912. RefmsgTime string `json:"refmsg_time"`
  23913. RespondTime string `json:"respond_time"`
  23914. Signtype interface{} `json:"signtype"`
  23915. WarnInfo interface{} `json:"warn_info"`
  23916. }
  23917. type ResultThirteen10265 struct {
  23918. ErrMsg string `json:"err_msg"`
  23919. InfRefmsgid string `json:"inf_refmsgid"`
  23920. Infcode string `json:"infcode"`
  23921. Output struct {
  23922. Result struct {
  23923. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  23924. } `json:"result"`
  23925. } `json:"output"`
  23926. RefmsgTime string `json:"refmsg_time"`
  23927. RespondTime string `json:"respond_time"`
  23928. Signtype interface{} `json:"signtype"`
  23929. WarnInfo interface{} `json:"warn_info"`
  23930. }
  23931. type ResultFourteen struct {
  23932. ErrMsg string `json:"err_msg"`
  23933. InfRefmsgid string `json:"inf_refmsgid"`
  23934. Infcode int64 `json:"infcode"`
  23935. Output struct {
  23936. } `json:"output"`
  23937. RefmsgTime string `json:"refmsg_time"`
  23938. RespondTime string `json:"respond_time"`
  23939. Signtype interface{} `json:"signtype"`
  23940. WarnInfo interface{} `json:"warn_info"`
  23941. }
  23942. type ResultCFYLJG001 struct {
  23943. ErrMsg string `json:"err_msg"`
  23944. InfRefmsgid string `json:"inf_refmsgid"`
  23945. Infcode int64 `json:"infcode"`
  23946. Output struct {
  23947. RxTraceCode string `json:"rx_trace_code"`
  23948. HiRxno string `json:"hi_rxno"`
  23949. } `json:"output"`
  23950. RefmsgTime string `json:"refmsg_time"`
  23951. RespondTime string `json:"respond_time"`
  23952. Signtype interface{} `json:"signtype"`
  23953. WarnInfo interface{} `json:"warn_info"`
  23954. }
  23955. type ResultCFYLJG001AH struct {
  23956. RxTraceCode string `json:"rxTraceCode"`
  23957. HiRxno string `json:"hiRxno"`
  23958. }
  23959. type ResultCFYLJG007 struct {
  23960. ErrMsg string `json:"err_msg"`
  23961. InfRefmsgid string `json:"inf_refmsgid"`
  23962. Infcode int64 `json:"infcode"`
  23963. Output struct {
  23964. HiRxno string `json:"hi_rxno"`
  23965. RxStasName string `json:"rx_stas_name"`
  23966. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  23967. Seltdelts []interface{} `json:"seltdelts"`
  23968. RxUsedStasName string `json:"rx_used_stas_name"`
  23969. RxStasCodg string `json:"rx_stas_codg"`
  23970. } `json:"output"`
  23971. RefmsgTime string `json:"refmsg_time"`
  23972. RespondTime string `json:"respond_time"`
  23973. Signtype interface{} `json:"signtype"`
  23974. WarnInfo interface{} `json:"warn_info"`
  23975. }
  23976. type ResultCFYLJG002 struct {
  23977. ErrMsg string `json:"err_msg"`
  23978. InfRefmsgid string `json:"inf_refmsgid"`
  23979. Infcode int64 `json:"infcode"`
  23980. Output struct {
  23981. RxFile string `json:"rx_file"`
  23982. SignDigest string `json:"sign_digest"`
  23983. SignCertSn string `json:"sign_cert_sn"`
  23984. SignCertDn string `json:"sign_cert_dn"`
  23985. } `json:"output"`
  23986. RefmsgTime string `json:"refmsg_time"`
  23987. RespondTime string `json:"respond_time"`
  23988. Signtype interface{} `json:"signtype"`
  23989. WarnInfo interface{} `json:"warn_info"`
  23990. }
  23991. type ResultCFYLJG003 struct {
  23992. ErrMsg string `json:"err_msg"`
  23993. InfRefmsgid string `json:"inf_refmsgid"`
  23994. Infcode int64 `json:"infcode"`
  23995. Output struct {
  23996. HiRxno string `json:"hi_rxno"`
  23997. RxStasCodg string `json:"rx_stas_codg"`
  23998. RxStasName string `json:"rx_stas_name"`
  23999. } `json:"output"`
  24000. RefmsgTime string `json:"refmsg_time"`
  24001. RespondTime string `json:"respond_time"`
  24002. Signtype interface{} `json:"signtype"`
  24003. WarnInfo interface{} `json:"warn_info"`
  24004. }
  24005. type ResultCFYLJG004 struct {
  24006. ErrMsg string `json:"err_msg"`
  24007. InfRefmsgid string `json:"inf_refmsgid"`
  24008. Infcode int64 `json:"infcode"`
  24009. Output struct {
  24010. HiRxno string `json:"hi_rxno"`
  24011. RxStasCodg string `json:"rx_stas_codg"`
  24012. RxStasName string `json:"rx_stas_name"`
  24013. } `json:"output"`
  24014. RefmsgTime string `json:"refmsg_time"`
  24015. RespondTime string `json:"respond_time"`
  24016. Signtype interface{} `json:"signtype"`
  24017. WarnInfo interface{} `json:"warn_info"`
  24018. }
  24019. type ResultCFYLJG008 struct {
  24020. ErrMsg string `json:"err_msg"`
  24021. InfRefmsgid string `json:"inf_refmsgid"`
  24022. Infcode int64 `json:"infcode"`
  24023. Output struct {
  24024. PoolareaNo string `json:"poolareaNo"`
  24025. AdmdvsName string `json:"admdvsName"`
  24026. Count string `json:"count"`
  24027. } `json:"output"`
  24028. RefmsgTime string `json:"refmsg_time"`
  24029. RespondTime string `json:"respond_time"`
  24030. Signtype interface{} `json:"signtype"`
  24031. WarnInfo interface{} `json:"warn_info"`
  24032. }
  24033. type ResultCFYLJG005 struct {
  24034. ErrMsg string `json:"err_msg"`
  24035. InfRefmsgid string `json:"inf_refmsgid"`
  24036. Infcode int64 `json:"infcode"`
  24037. Output struct {
  24038. HiRxNo string `json:"hi_rxno"`
  24039. FixMedinsCode string `json:"fixmedins_code"`
  24040. FixMedinsName string `json:"fixmedins_name"`
  24041. RxStasCodg string `json:"rx_stas_codg"`
  24042. RxStasName string `json:"rx_stas_name"`
  24043. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  24044. RxUserdStasName string `json:"rx_userd_stas_name"`
  24045. PrscTime string `json:"prsc_time"`
  24046. RxDrugCnt float64 `json:"rx_drug_cnt"`
  24047. RxUsedWayCodg string `json:"rx_used_way_codg"`
  24048. RxUsedWayName string `json:"rx_used_way_name"`
  24049. RxFrquCodg string `json:"rx_frqu_codg"`
  24050. RxFrquName string `json:"rx_frqu_name"`
  24051. RxDosunt string `json:"rx_dosunt"`
  24052. RxDoscnt float64 `json:"rx_doscnt"`
  24053. RxDrordDscr string `json:"rx_drord_dscr"`
  24054. ValiDays int64 `json:"vali_days"`
  24055. ValiEndTime string `json:"vali_end_time"`
  24056. ReptFlag string `json:"rept_flag"`
  24057. MaxReptCnt int64 `json:"max_rept_cnt"`
  24058. ReptdCnt int64 `json:"reptd_cnt"`
  24059. MinInrvDays int64 `json:"min_inrv_days"`
  24060. RxTypeCode string `json:"rx_type_code"`
  24061. RxTypeName string `json:"rx_type_name"`
  24062. LongRxFlag string `json:"long_rx_flag"`
  24063. RxDetlList []struct {
  24064. MedListCodg string `json:"med_list_codg"`
  24065. MedinsListCodg string `json:"medins_list_codg"`
  24066. HospPrepFlag string `json:"hosp_prep_flag"`
  24067. RxItemTypeCode string `json:"rx_item_type_code"`
  24068. RxItemTypeName string `json:"rx_item_type_name"`
  24069. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  24070. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  24071. TcmHerbFoote string `json:"tcmherb_foote"`
  24072. MednTypeCode string `json:"medn_type_code"`
  24073. MednTypeName string `json:"medn_type_name"`
  24074. MainMedcFlag string `json:"main_medc_flag"`
  24075. UrgtFlag string `json:"urgt_flag"`
  24076. BasMednFlag string `json:"bas_medn_flag"`
  24077. ImpDrugFlag string `json:"imp_drug_flag"`
  24078. ProdBarc string `json:"prod_barc"`
  24079. DrugProdname string `json:"drug_prodname"`
  24080. GennameCodg string `json:"genname_codg"`
  24081. DrugGenname string `json:"drug_genname"`
  24082. DrugDosform string `json:"drug_dosform"`
  24083. DrugSpec string `json:"drug_spec"`
  24084. PrdrName string `json:"prdr_name"`
  24085. MedcWayCodg string `json:"medc_way_codg"`
  24086. MedcWayDscr string `json:"medc_way_dscr"`
  24087. MedcBegntime string `json:"medc_begntime"`
  24088. MedcEndtime string `json:"medc_endtime"`
  24089. MedcDays float64 `json:"medc_days"`
  24090. DrugPric float64 `json:"drug_pric"`
  24091. DrugSumamt float64 `json:"drug_sumamt"`
  24092. DrugCnt float64 `json:"drug_cnt"`
  24093. DrugDosunt string `json:"drug_dosunt"`
  24094. SinDoscnt float64 `json:"sin_doscnt"`
  24095. SinDosunt string `json:"sin_dosunt"`
  24096. UsedFrquCodg string `json:"used_frqu_codg"`
  24097. UsedFrquName string `json:"used_frqu_name"`
  24098. DrugTotlcnt string `json:"drug_totlcnt"`
  24099. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  24100. DiseCodg string `json:"dise_codg"`
  24101. HospApprFlag string `json:"hosp_appr_flag"`
  24102. } `json:"rx_detl_list"`
  24103. RxOtpinfo struct {
  24104. MedType string `json:"med_type"`
  24105. IptOtpNo string `json:"ipt_otp_no"`
  24106. OtpIptFlag string `json:"otp_ipt_flag"`
  24107. PatnName string `json:"patn_name"`
  24108. PatnAge float64 `json:"patn_age"`
  24109. PatnHgt float64 `json:"patn_hgt"`
  24110. PatnWt float64 `json:"patn_wt"`
  24111. Gend string `json:"gend"`
  24112. GesoVal float64 `json:"geso_val"`
  24113. NwbFlag string `json:"nwb_flag"`
  24114. NwbAge string `json:"nwb_age"`
  24115. SuckPrdFlag string `json:"suck_prd_flag"`
  24116. AlgsHis string `json:"algs_his"`
  24117. Insutype string `json:"insutype"`
  24118. PrscDeptName string `json:"prsc_dept_name"`
  24119. PrscDrName string `json:"prsc_dr_name"`
  24120. PharName string `json:"phar_name"`
  24121. PharChkTime string `json:"phar_chk_time"`
  24122. MdtrtTime string `json:"mdtrt_time"`
  24123. DiseCodg string `json:"dise_codg"`
  24124. DiseName string `json:"dise_name"`
  24125. SpDiseFlag string `json:"sp_dise_flag"`
  24126. MaindiagCode string `json:"maindiag_code"`
  24127. MaindiagName string `json:"maindiag_name"`
  24128. DiseCondDscr string `json:"dise_cond_dscr"`
  24129. FstdiagFlag string `json:"fstdiag_flag"`
  24130. } `json:"rx_otpinfo"`
  24131. RxDiseList []struct {
  24132. DiagType string `json:"diag_type"`
  24133. MaindiagFlag string `json:"maindiag_flag"`
  24134. DiagSrtNo string `json:"diag_srt_no"`
  24135. DiagCode string `json:"diag_code"`
  24136. DiagName string `json:"diag_name"`
  24137. DiagDept string `json:"diag_dept"`
  24138. DiagDrNo string `json:"diag_dr_no"`
  24139. DiagDrName string `json:"diag_dr_name"`
  24140. DiagTime string `json:"diag_time"`
  24141. TcmDiseCode string `json:"tcm_dise_code"`
  24142. TcmDiseName string `json:"tcm_dise_name"`
  24143. TcmSympCode string `json:"tcmsymp_code"`
  24144. TcmSymp string `json:"tcmsymp"`
  24145. } `json:"rx_dise_list"`
  24146. } `json:"output"`
  24147. RefmsgTime string `json:"refmsg_time"`
  24148. RespondTime string `json:"respond_time"`
  24149. Signtype interface{} `json:"signtype"`
  24150. WarnInfo interface{} `json:"warn_info"`
  24151. }
  24152. type ResultCFYLJG006 struct {
  24153. ErrMsg string `json:"err_msg"`
  24154. InfRefmsgid string `json:"inf_refmsgid"`
  24155. Infcode int64 `json:"infcode"`
  24156. Output struct {
  24157. HiRxNo string `json:"hi_rxno"`
  24158. PharCode string `json:"phar_code"`
  24159. PharName string `json:"phar_name"`
  24160. RxChkOpnn string `json:"rx_chk_opnn"`
  24161. RxChkTime string `json:"rx_chk_time"`
  24162. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  24163. RxChkStasName string `json:"rx_chk_stas_name"`
  24164. RxStasCodg string `json:"rx_stas_codg"`
  24165. RxStasName string `json:"rx_stas_name"`
  24166. } `json:"output"`
  24167. RefmsgTime string `json:"refmsg_time"`
  24168. RespondTime string `json:"respond_time"`
  24169. Signtype interface{} `json:"signtype"`
  24170. WarnInfo interface{} `json:"warn_info"`
  24171. }
  24172. type ResultFourteen10265 struct {
  24173. ErrMsg string `json:"err_msg"`
  24174. InfRefmsgid string `json:"inf_refmsgid"`
  24175. Infcode string `json:"infcode"`
  24176. Output struct {
  24177. } `json:"output"`
  24178. RefmsgTime string `json:"refmsg_time"`
  24179. RespondTime string `json:"respond_time"`
  24180. Signtype interface{} `json:"signtype"`
  24181. WarnInfo interface{} `json:"warn_info"`
  24182. }
  24183. type ResultSixteen struct {
  24184. Cainfo string `json:"cainfo"`
  24185. ErrMsg string `json:"err_msg"`
  24186. InfRefmsgid string `json:"inf_refmsgid"`
  24187. Infcode int64 `json:"infcode"`
  24188. Output struct {
  24189. Setlinfo struct {
  24190. MdtrtID string `json:"mdtrt_id"`
  24191. SetlID string `json:"setl_id"`
  24192. ClrOptins string `json:"clr_optins"`
  24193. SetlTime string `json:"setl_time"`
  24194. MedfeeSumamt float64 `json:"medfee_sumamt"`
  24195. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  24196. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  24197. PreselfpayAmt float64 `json:"preselfpay_amt"`
  24198. InscpScpAmt float64 `json:"inscp_scp_amt"`
  24199. ActPayDedc float64 `json:"act_pay_dedc"`
  24200. HifpPay float64 `json:"hifp_pay"`
  24201. PoolPropSe float64 `json:"pool_prop_selfpay"`
  24202. Lfpay float64 `json:"selfpay"`
  24203. CvlservPay float64 `json:"cvlserv_pay"`
  24204. HifesPay float64 `json:"hifes_pay"`
  24205. HifmiPay float64 `json:"hifmi_pay"`
  24206. HifobPay float64 `json:"hifob_pay"`
  24207. MafPay float64 `json:"maf_pay"`
  24208. OthPay float64 `json:"oth_pay"`
  24209. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  24210. PsnPartAmt float64 `json:"psn_part_amt"`
  24211. AcctPay float64 `json:"acct_pay"`
  24212. Balc float64 `json:"balc"`
  24213. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  24214. HospPartAmt float64 `json:"hosp_part_amt"`
  24215. MedinsSetlID string `json:"medins_setl_id"`
  24216. PdnCashPay string `json:"pdn_cash_pay"`
  24217. } `json:"setlinfo"`
  24218. } `json:"output"`
  24219. RefmsgTime string `json:"refmsg_time"`
  24220. RespondTime string `json:"respond_time"`
  24221. Signtype interface{} `json:"signtype"`
  24222. WarnMsg interface{} `json:"warn_msg"`
  24223. }
  24224. type ResultSixteen10265 struct {
  24225. Cainfo string `json:"cainfo"`
  24226. ErrMsg string `json:"err_msg"`
  24227. InfRefmsgid string `json:"inf_refmsgid"`
  24228. Infcode string `json:"infcode"`
  24229. Output struct {
  24230. Setlinfo struct {
  24231. MdtrtID string `json:"mdtrt_id"`
  24232. SetlID string `json:"setl_id"`
  24233. ClrOptins string `json:"clr_optins"`
  24234. SetlTime string `json:"setl_time"`
  24235. MedfeeSumamt float64 `json:"medfee_sumamt"`
  24236. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  24237. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  24238. PreselfpayAmt float64 `json:"preselfpay_amt"`
  24239. InscpScpAmt float64 `json:"inscp_scp_amt"`
  24240. ActPayDedc float64 `json:"act_pay_dedc"`
  24241. HifpPay float64 `json:"hifp_pay"`
  24242. PoolPropSe float64 `json:"pool_prop_selfpay"`
  24243. Lfpay float64 `json:"selfpay"`
  24244. CvlservPay float64 `json:"cvlserv_pay"`
  24245. HifesPay float64 `json:"hifes_pay"`
  24246. HifmiPay float64 `json:"hifmi_pay"`
  24247. HifobPay float64 `json:"hifob_pay"`
  24248. MafPay float64 `json:"maf_pay"`
  24249. OthPay float64 `json:"oth_pay"`
  24250. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  24251. PsnPartAmt float64 `json:"psn_part_amt"`
  24252. AcctPay float64 `json:"acct_pay"`
  24253. Balc float64 `json:"balc"`
  24254. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  24255. HospPartAmt float64 `json:"hosp_part_amt"`
  24256. MedinsSetlID string `json:"medins_setl_id"`
  24257. PdnCashPay string `json:"pdn_cash_pay"`
  24258. } `json:"setlinfo"`
  24259. } `json:"output"`
  24260. RefmsgTime string `json:"refmsg_time"`
  24261. RespondTime string `json:"respond_time"`
  24262. Signtype interface{} `json:"signtype"`
  24263. WarnMsg interface{} `json:"warn_msg"`
  24264. }
  24265. type ResultSixteen10265Two struct {
  24266. Cainfo string `json:"cainfo"`
  24267. ErrMsg string `json:"err_msg"`
  24268. InfRefmsgid string `json:"inf_refmsgid"`
  24269. Infcode string `json:"infcode"`
  24270. Output struct {
  24271. Setlinfo interface{} `json:"setlinfo"`
  24272. } `json:"output"`
  24273. RefmsgTime string `json:"refmsg_time"`
  24274. RespondTime string `json:"respond_time"`
  24275. Signtype interface{} `json:"signtype"`
  24276. WarnMsg interface{} `json:"warn_msg"`
  24277. }
  24278. type ResultgzSixteen10265Two struct {
  24279. Cainfo string `json:"cainfo"`
  24280. ErrMsg string `json:"err_msg"`
  24281. InfRefmsgid string `json:"inf_refmsgid"`
  24282. Infcode int64 `json:"infcode"`
  24283. Output struct {
  24284. Setlinfo interface{} `json:"setlinfo"`
  24285. } `json:"output"`
  24286. RefmsgTime string `json:"refmsg_time"`
  24287. RespondTime string `json:"respond_time"`
  24288. Signtype interface{} `json:"signtype"`
  24289. WarnMsg interface{} `json:"warn_msg"`
  24290. }
  24291. type ResultSeventeen struct {
  24292. ErrMsg string `json:"err_msg"`
  24293. InfRefmsgid string `json:"inf_refmsgid"`
  24294. Infcode int64 `json:"infcode"`
  24295. Output struct {
  24296. SetlListId string `json:"setl_list_id"`
  24297. } `json:"output"`
  24298. RefmsgTime string `json:"refmsg_time"`
  24299. RespondTime string `json:"respond_time"`
  24300. Signtype string `json:"signtype"`
  24301. WarnInfo string `json:"warn_info"`
  24302. }
  24303. type ResultSeventeenOther struct {
  24304. ErrMsg string `json:"err_msg"`
  24305. InfRefmsgid string `json:"inf_refmsgid"`
  24306. Infcode string `json:"infcode"`
  24307. Output struct {
  24308. SetlListId string `json:"setl_list_id"`
  24309. } `json:"output"`
  24310. RefmsgTime string `json:"refmsg_time"`
  24311. RespondTime string `json:"respond_time"`
  24312. Signtype string `json:"signtype"`
  24313. WarnInfo string `json:"warn_info"`
  24314. }
  24315. type Result90991 struct {
  24316. ErrMsg string `json:"err_msg"`
  24317. InfRefmsgid string `json:"inf_refmsgid"`
  24318. Infcode int64 `json:"infcode"`
  24319. Output struct {
  24320. Result struct {
  24321. PsnNo string `json:"psn_no"`
  24322. CardStat string `json:"card_stat"`
  24323. Certno string `json:"certno"`
  24324. PsnName string `json:"psn_name"`
  24325. CheckStat string `json:"check_stat"`
  24326. SscnoCheckStat string `json:"sscno_check_stat"`
  24327. } `json:"result"`
  24328. } `json:"output"`
  24329. RefmsgTime string `json:"refmsg_time"`
  24330. RespondTime string `json:"respond_time"`
  24331. Signtype interface{} `json:"signtype"`
  24332. WarnInfo interface{} `json:"warn_info"`
  24333. }
  24334. type Result90100 struct {
  24335. ErrMsg string `json:"err_msg"`
  24336. InfRefmsgid string `json:"inf_refmsgid"`
  24337. Infcode int64 `json:"infcode"`
  24338. Output struct {
  24339. PoolareaNo string `json:"poolarea_no"`
  24340. PoolareaNoName string `json:"poolarea_no_name"`
  24341. Insutype string `json:"insutype"`
  24342. InsutypeName string `json:"insutype_name"`
  24343. ClctType string `json:"clct_type"`
  24344. ClctTypeName string `json:"clct_type_name"`
  24345. ClctFlag string `json:"clct_flag"`
  24346. ClctFlagName string `json:"clct_flag_name"`
  24347. AccrymBegn string `json:"accrym_begn"`
  24348. AccrymEnd string `json:"accrym_end"`
  24349. ClctTime string `json:"clct_time"`
  24350. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  24351. } `json:"output"`
  24352. RefmsgTime string `json:"refmsg_time"`
  24353. RespondTime string `json:"respond_time"`
  24354. Signtype interface{} `json:"signtype"`
  24355. WarnInfo interface{} `json:"warn_info"`
  24356. }
  24357. type Custom struct {
  24358. DetItemFeeSumamt string
  24359. Cut string
  24360. FeedetlSn string
  24361. Price string
  24362. MedListCodg string
  24363. Type int64
  24364. AdviceId int64
  24365. ProjectId int64
  24366. ItemId int64
  24367. }
  24368. type Result5301 struct {
  24369. ErrMsg string `json:"err_msg"`
  24370. InfRefmsgid string `json:"inf_refmsgid"`
  24371. Infcode int64 `json:"infcode"`
  24372. Output struct {
  24373. Result []struct {
  24374. OpspDiseCode string `json:"opsp_dise_code"`
  24375. OpspDiseName string `json:"opsp_dise_name"`
  24376. Begndate string `json:"begndate"`
  24377. Enddate string `json:"enddate"`
  24378. } `json:"feedetail"`
  24379. } `json:"output"`
  24380. RefmsgTime string `json:"refmsg_time"`
  24381. RespondTime string `json:"respond_time"`
  24382. Signtype interface{} `json:"signtype"`
  24383. WarnInfo interface{} `json:"warn_info"`
  24384. }
  24385. type Result5301For10265 struct {
  24386. ErrMsg string `json:"err_msg"`
  24387. InfRefmsgid string `json:"inf_refmsgid"`
  24388. Infcode string `json:"infcode"`
  24389. Output struct {
  24390. Result []struct {
  24391. OpspDiseCode string `json:"opsp_dise_code"`
  24392. OpspDiseName string `json:"opsp_dise_name"`
  24393. Begndate string `json:"begndate"`
  24394. Enddate string `json:"enddate"`
  24395. } `json:"feedetail"`
  24396. } `json:"output"`
  24397. RefmsgTime string `json:"refmsg_time"`
  24398. RespondTime string `json:"respond_time"`
  24399. Signtype interface{} `json:"signtype"`
  24400. WarnInfo interface{} `json:"warn_info"`
  24401. }
  24402. //获取个人信息----挂号-----上传就诊信息
  24403. func (c *HisApiController) GetRegisterInfo() {
  24404. id, _ := c.GetInt64("id")
  24405. record_time := c.GetString("record_time")
  24406. settlementValue, _ := c.GetInt64("settlement_value")
  24407. medical_insurance_card := c.GetString("medical_insurance_card")
  24408. name := c.GetString("name")
  24409. id_card_type, _ := c.GetInt64("id_card_type")
  24410. certificates, _ := c.GetInt64("certificates")
  24411. medical_care, _ := c.GetInt64("medical_care")
  24412. birthday := c.GetString("birthday")
  24413. id_card := c.GetString("id_card")
  24414. register_type, _ := c.GetInt64("register")
  24415. doctor, _ := c.GetInt64("doctor")
  24416. department, _ := c.GetInt64("department")
  24417. gender, _ := c.GetInt64("sex")
  24418. registration_fee, _ := c.GetFloat("registration_fee")
  24419. medical_expenses, _ := c.GetFloat("medical_expenses")
  24420. social_type, _ := c.GetInt64("social_type")
  24421. admin_user_id, _ := c.GetInt64("admin_user_id")
  24422. insuplc_admdvs := c.GetString("insuplc_admdvs")
  24423. insuplc_admdvs_tt := c.GetString("insuplc_admdvs")
  24424. mdtrt_type := c.GetString("mdtrt_type")
  24425. if id_card_type == 5 {
  24426. id_card_type = 4
  24427. }
  24428. timeLayout := "2006-01-02"
  24429. loc, _ := time.LoadLocation("Local")
  24430. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  24431. birthUnix := birthdays.Unix()
  24432. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24433. if err != nil {
  24434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24435. return
  24436. }
  24437. recordDateTime := theTime.Unix()
  24438. adminInfo := c.GetAdminUserInfo()
  24439. var patient service.Patients
  24440. if id == 0 {
  24441. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  24442. } else {
  24443. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  24444. }
  24445. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  24446. if patientPrescription.ID == 0 {
  24447. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  24448. }
  24449. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  24450. if patient.ID == 0 {
  24451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  24452. return
  24453. }
  24454. if len(patient.IdCardNo) == 0 {
  24455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  24456. return
  24457. }
  24458. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  24459. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  24460. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  24461. //就诊结算未完成,不能进行二次挂号
  24462. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  24463. if len(his) >= 1 {
  24464. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  24465. if len(his) >= 1 && order.ID == 0 {
  24466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  24467. return
  24468. }
  24469. }
  24470. var aaaa string
  24471. //var register_log string
  24472. if config.IsOpen == 1 {
  24473. var res ResultTwo
  24474. var res10265 ResultTwo10265
  24475. var PsnNo string
  24476. var PsnCertType string
  24477. var Certno string
  24478. var PsnName string
  24479. var Gend string
  24480. var Naty string
  24481. var Brdy string
  24482. var Age float64
  24483. var infoStr string
  24484. var idetinfoStr string
  24485. var infocode int64
  24486. var verify_number string
  24487. fmt.Println(verify_number)
  24488. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  24489. psn_info, _ := service.GetPsnByPatientId(id)
  24490. PsnNo = psn_info.PsnNo
  24491. PsnCertType = psn_info.PsnCertType
  24492. Certno = psn_info.Certno
  24493. PsnName = psn_info.PsnName
  24494. Gend = psn_info.Gend
  24495. Naty = psn_info.Naty
  24496. Brdy = psn_info.Brdy
  24497. Age = psn_info.Age
  24498. infoStr = psn_info.Insuinfo
  24499. idetinfoStr = psn_info.Idetinfo
  24500. infocode = 0
  24501. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  24502. psn_info, _ := service.GetPsnByPatientId(id)
  24503. PsnNo = psn_info.PsnNo
  24504. PsnCertType = psn_info.PsnCertType
  24505. Certno = psn_info.Certno
  24506. PsnName = psn_info.PsnName
  24507. Gend = psn_info.Gend
  24508. Naty = psn_info.Naty
  24509. Brdy = psn_info.Brdy
  24510. Age = psn_info.Age
  24511. infoStr = psn_info.Insuinfo
  24512. idetinfoStr = psn_info.Idetinfo
  24513. infocode = 0
  24514. verify_number = psn_info.VerifyNumber
  24515. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24516. if id_card_type == 2 {
  24517. //请求内网数据
  24518. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  24519. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24520. "&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
  24521. resp, requestErr := http.Get(api)
  24522. if requestErr != nil {
  24523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24524. return
  24525. }
  24526. body, ioErr := ioutil.ReadAll(resp.Body)
  24527. if ioErr != nil {
  24528. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24530. return
  24531. }
  24532. var respJSON map[string]interface{}
  24533. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24534. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24536. return
  24537. }
  24538. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24539. result_byte, _ := json.Marshal(respJSON)
  24540. result := string(result_byte)
  24541. var dat map[string]interface{}
  24542. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24543. fmt.Println(dat)
  24544. } else {
  24545. fmt.Println(err)
  24546. }
  24547. userJSONBytes, _ := json.Marshal(dat)
  24548. var res ResultTwo
  24549. var resTwo10265 ResultTwo10265
  24550. if miConfig.Code == "H15049901371" {
  24551. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  24552. utils.ErrorLog("解析失败:%v", err)
  24553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24554. return
  24555. }
  24556. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  24557. res.Infcode = Infcode
  24558. res.ErrMsg = resTwo10265.ErrMsg
  24559. res.Output = resTwo10265.Output
  24560. res.InfRefmsgid = resTwo10265.InfRefmsgid
  24561. res.RespondTime = resTwo10265.RespondTime
  24562. res.WarnInfo = resTwo10265.WarnInfo
  24563. } else {
  24564. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24565. utils.ErrorLog("解析失败:%v", err)
  24566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24567. return
  24568. }
  24569. }
  24570. //var insutypes []string
  24571. //var insutype string
  24572. //var is390 int = 0
  24573. //var is310 int = 0
  24574. //for _, item := range res.Output.Iinfo {
  24575. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  24576. // insutypes = append(insutypes, item.Insutype)
  24577. // }
  24578. //}
  24579. //if len(insutypes) == 1 {
  24580. // insutype = insutypes[0]
  24581. //} else {
  24582. // for _, i := range insutypes {
  24583. // if i == "390" {
  24584. // is390 = 1
  24585. // }
  24586. //
  24587. // if i == "310" {
  24588. // is310 = 1
  24589. // }
  24590. // }
  24591. //}
  24592. //if is390 == 1 {
  24593. // insutype = "390"
  24594. //}
  24595. //if is310 == 1 {
  24596. // insutype = "310"
  24597. //}
  24598. //if len(insutypes) == 0 {
  24599. // insutype = "310"
  24600. //}
  24601. PsnNo = res.Output.Baseinfo.PsnNo
  24602. PsnCertType = res.Output.Baseinfo.PsnCertType
  24603. Certno = res.Output.Baseinfo.Certno
  24604. PsnName = res.Output.Baseinfo.PsnName
  24605. Gend = res.Output.Baseinfo.Gend
  24606. Naty = res.Output.Baseinfo.Naty
  24607. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24608. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24609. infoStr = string(Iinfos)
  24610. idetinfoStr = string(Idetinfos)
  24611. infocode = res.Infcode
  24612. //infocode = 0
  24613. //verify_number = psn_info.VerifyNumber
  24614. } else {
  24615. psn_info, _ := service.GetPsnByPatientId(id)
  24616. PsnNo = psn_info.PsnNo
  24617. PsnCertType = psn_info.PsnCertType
  24618. Certno = psn_info.Certno
  24619. PsnName = psn_info.PsnName
  24620. Gend = psn_info.Gend
  24621. Naty = psn_info.Naty
  24622. Brdy = psn_info.Brdy
  24623. Age = psn_info.Age
  24624. infoStr = psn_info.Insuinfo
  24625. idetinfoStr = psn_info.Idetinfo
  24626. infocode = 0
  24627. verify_number = psn_info.VerifyNumber
  24628. }
  24629. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24630. if id_card_type == 1 {
  24631. psn_info, _ := service.GetPsnByPatientId(id)
  24632. PsnNo = psn_info.PsnNo
  24633. PsnCertType = psn_info.PsnCertType
  24634. Certno = psn_info.Certno
  24635. PsnName = psn_info.PsnName
  24636. Gend = psn_info.Gend
  24637. Naty = psn_info.Naty
  24638. Brdy = psn_info.Brdy
  24639. Age = psn_info.Age
  24640. infoStr = psn_info.Insuinfo
  24641. idetinfoStr = psn_info.Idetinfo
  24642. infocode = 0
  24643. verify_number = psn_info.VerifyNumber
  24644. } else if id_card_type == 2 {
  24645. 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)
  24646. fmt.Println(errMsgLog)
  24647. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24648. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24649. utils.ErrorLog("解析失败:%v", err)
  24650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24651. return
  24652. }
  24653. PsnNo = res.Output.Baseinfo.PsnNo
  24654. PsnCertType = res.Output.Baseinfo.PsnCertType
  24655. Certno = res.Output.Baseinfo.Certno
  24656. PsnName = res.Output.Baseinfo.PsnName
  24657. Gend = res.Output.Baseinfo.Gend
  24658. Naty = res.Output.Baseinfo.Naty
  24659. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24660. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24661. infoStr = string(Iinfos)
  24662. idetinfoStr = string(Idetinfos)
  24663. infocode = res.Infcode
  24664. }
  24665. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24666. if id_card_type == 1 {
  24667. psn_info, _ := service.GetPsnByPatientId(id)
  24668. PsnNo = psn_info.PsnNo
  24669. PsnCertType = psn_info.PsnCertType
  24670. Certno = psn_info.Certno
  24671. PsnName = psn_info.PsnName
  24672. Gend = psn_info.Gend
  24673. Naty = psn_info.Naty
  24674. Brdy = psn_info.Brdy
  24675. Age = psn_info.Age
  24676. infoStr = psn_info.Insuinfo
  24677. idetinfoStr = psn_info.Idetinfo
  24678. infocode = 0
  24679. verify_number = psn_info.VerifyNumber
  24680. } else if id_card_type == 2 {
  24681. 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, "")
  24682. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24683. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24684. utils.ErrorLog("解析失败:%v", err)
  24685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24686. return
  24687. }
  24688. PsnNo = res.Output.Baseinfo.PsnNo
  24689. PsnCertType = res.Output.Baseinfo.PsnCertType
  24690. Certno = res.Output.Baseinfo.Certno
  24691. PsnName = res.Output.Baseinfo.PsnName
  24692. Gend = res.Output.Baseinfo.Gend
  24693. Naty = res.Output.Baseinfo.Naty
  24694. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24695. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24696. infoStr = string(Iinfos)
  24697. idetinfoStr = string(Idetinfos)
  24698. infocode = res.Infcode
  24699. } else {
  24700. psn_info, _ := service.GetPsnByPatientId(id)
  24701. PsnNo = psn_info.PsnNo
  24702. PsnCertType = psn_info.PsnCertType
  24703. Certno = psn_info.Certno
  24704. PsnName = psn_info.PsnName
  24705. Gend = psn_info.Gend
  24706. Naty = psn_info.Naty
  24707. Brdy = psn_info.Brdy
  24708. Age = psn_info.Age
  24709. infoStr = psn_info.Insuinfo
  24710. idetinfoStr = psn_info.Idetinfo
  24711. infocode = 0
  24712. verify_number = psn_info.VerifyNumber
  24713. }
  24714. } else if miConfig.MdtrtareaAdmvs == "361025" {
  24715. if id_card_type == 1 {
  24716. psn_info, _ := service.GetPsnByPatientId(id)
  24717. PsnNo = psn_info.PsnNo
  24718. PsnCertType = psn_info.PsnCertType
  24719. Certno = psn_info.Certno
  24720. PsnName = psn_info.PsnName
  24721. Gend = psn_info.Gend
  24722. Naty = psn_info.Naty
  24723. Brdy = psn_info.Brdy
  24724. Age = psn_info.Age
  24725. infoStr = psn_info.Insuinfo
  24726. idetinfoStr = psn_info.Idetinfo
  24727. infocode = 0
  24728. verify_number = psn_info.VerifyNumber
  24729. } else if id_card_type == 2 {
  24730. psn_info, _ := service.GetPsnByPatientId(id)
  24731. PsnNo = psn_info.PsnNo
  24732. PsnCertType = psn_info.PsnCertType
  24733. Certno = psn_info.Certno
  24734. PsnName = psn_info.PsnName
  24735. Gend = psn_info.Gend
  24736. Naty = psn_info.Naty
  24737. Brdy = psn_info.Brdy
  24738. Age = psn_info.Age
  24739. infoStr = psn_info.Insuinfo
  24740. idetinfoStr = psn_info.Idetinfo
  24741. infocode = 0
  24742. verify_number = psn_info.VerifyNumber
  24743. } else {
  24744. psn_info, _ := service.GetPsnByPatientId(id)
  24745. PsnNo = psn_info.PsnNo
  24746. PsnCertType = psn_info.PsnCertType
  24747. Certno = psn_info.Certno
  24748. PsnName = psn_info.PsnName
  24749. Gend = psn_info.Gend
  24750. Naty = psn_info.Naty
  24751. Brdy = psn_info.Brdy
  24752. Age = psn_info.Age
  24753. infoStr = psn_info.Insuinfo
  24754. idetinfoStr = psn_info.Idetinfo
  24755. infocode = 0
  24756. verify_number = psn_info.VerifyNumber
  24757. }
  24758. } else if miConfig.MdtrtareaAdmvs == "360100" {
  24759. if id_card_type == 1 {
  24760. psn_info, _ := service.GetPsnByPatientId(id)
  24761. PsnNo = psn_info.PsnNo
  24762. PsnCertType = psn_info.PsnCertType
  24763. Certno = psn_info.Certno
  24764. PsnName = psn_info.PsnName
  24765. Gend = psn_info.Gend
  24766. Naty = psn_info.Naty
  24767. Brdy = psn_info.Brdy
  24768. Age = psn_info.Age
  24769. infoStr = psn_info.Insuinfo
  24770. idetinfoStr = psn_info.Idetinfo
  24771. infocode = 0
  24772. verify_number = psn_info.VerifyNumber
  24773. } else if id_card_type == 2 {
  24774. psn_info, _ := service.GetPsnByPatientId(id)
  24775. PsnNo = psn_info.PsnNo
  24776. PsnCertType = psn_info.PsnCertType
  24777. Certno = psn_info.Certno
  24778. PsnName = psn_info.PsnName
  24779. Gend = psn_info.Gend
  24780. Naty = psn_info.Naty
  24781. Brdy = psn_info.Brdy
  24782. Age = psn_info.Age
  24783. infoStr = psn_info.Insuinfo
  24784. idetinfoStr = psn_info.Idetinfo
  24785. infocode = 0
  24786. verify_number = psn_info.VerifyNumber
  24787. } else {
  24788. psn_info, _ := service.GetPsnByPatientId(id)
  24789. PsnNo = psn_info.PsnNo
  24790. PsnCertType = psn_info.PsnCertType
  24791. Certno = psn_info.Certno
  24792. PsnName = psn_info.PsnName
  24793. Gend = psn_info.Gend
  24794. Naty = psn_info.Naty
  24795. Brdy = psn_info.Brdy
  24796. Age = psn_info.Age
  24797. infoStr = psn_info.Insuinfo
  24798. idetinfoStr = psn_info.Idetinfo
  24799. infocode = 0
  24800. verify_number = psn_info.VerifyNumber
  24801. }
  24802. } else if miConfig.MdtrtareaAdmvs == "341203" || miConfig.MdtrtareaAdmvs == "340699" {
  24803. psn_info, _ := service.GetPsnByPatientId(id)
  24804. PsnNo = psn_info.PsnNo
  24805. PsnCertType = psn_info.PsnCertType
  24806. Certno = psn_info.Certno
  24807. PsnName = psn_info.PsnName
  24808. Gend = psn_info.Gend
  24809. Naty = psn_info.Naty
  24810. Brdy = psn_info.Brdy
  24811. Age = psn_info.Age
  24812. infoStr = psn_info.Insuinfo
  24813. idetinfoStr = psn_info.Idetinfo
  24814. infocode = 0
  24815. verify_number = psn_info.VerifyNumber
  24816. idetinfoStr = psn_info.Idetinfo
  24817. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24818. if id_card_type == 1 {
  24819. psn_info, _ := service.GetPsnByPatientId(id)
  24820. PsnNo = psn_info.PsnNo
  24821. PsnCertType = psn_info.PsnCertType
  24822. Certno = psn_info.Certno
  24823. PsnName = psn_info.PsnName
  24824. Gend = psn_info.Gend
  24825. Naty = psn_info.Naty
  24826. Brdy = psn_info.Brdy
  24827. Age = psn_info.Age
  24828. infoStr = psn_info.Insuinfo
  24829. idetinfoStr = psn_info.Idetinfo
  24830. infocode = 0
  24831. verify_number = psn_info.VerifyNumber
  24832. } else if id_card_type == 2 {
  24833. 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)
  24834. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24835. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24836. utils.ErrorLog("解析失败:%v", err)
  24837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24838. return
  24839. }
  24840. PsnNo = res.Output.Baseinfo.PsnNo
  24841. PsnCertType = res.Output.Baseinfo.PsnCertType
  24842. Certno = res.Output.Baseinfo.Certno
  24843. PsnName = res.Output.Baseinfo.PsnName
  24844. Gend = res.Output.Baseinfo.Gend
  24845. Naty = res.Output.Baseinfo.Naty
  24846. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24847. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24848. infoStr = string(Iinfos)
  24849. idetinfoStr = string(Idetinfos)
  24850. infocode = res.Infcode
  24851. } else if id_card_type == 4 {
  24852. psn_info, _ := service.GetPsnByPatientId(id)
  24853. PsnNo = psn_info.PsnNo
  24854. PsnCertType = psn_info.PsnCertType
  24855. Certno = psn_info.Certno
  24856. PsnName = psn_info.PsnName
  24857. Gend = psn_info.Gend
  24858. Naty = psn_info.Naty
  24859. Brdy = psn_info.Brdy
  24860. Age = psn_info.Age
  24861. infoStr = psn_info.Insuinfo
  24862. idetinfoStr = psn_info.Idetinfo
  24863. infocode = 0
  24864. verify_number = psn_info.VerifyNumber
  24865. }
  24866. } else if miConfig.MdtrtareaAdmvs == "131023" {
  24867. var result string
  24868. var requestLog string
  24869. 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), "")
  24870. if id_card_type == 4 {
  24871. psn_info, _ := service.GetPsnByPatientId(id)
  24872. PsnNo = psn_info.PsnNo
  24873. PsnCertType = psn_info.PsnCertType
  24874. Certno = psn_info.Certno
  24875. PsnName = psn_info.PsnName
  24876. Gend = psn_info.Gend
  24877. Naty = psn_info.Naty
  24878. Brdy = psn_info.Brdy
  24879. Age = psn_info.Age
  24880. infoStr = psn_info.Insuinfo
  24881. idetinfoStr = psn_info.Idetinfo
  24882. infocode = 0
  24883. verify_number = psn_info.VerifyNumber
  24884. } else {
  24885. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24886. if miConfig.Code == "H15049901371" {
  24887. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  24888. utils.ErrorLog("解析失败:%v", err)
  24889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24890. return
  24891. }
  24892. res.ErrMsg = res10265.ErrMsg
  24893. res.Output = res10265.Output
  24894. res.InfRefmsgid = res10265.InfRefmsgid
  24895. } else {
  24896. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24897. utils.ErrorLog("解析失败:%v", err)
  24898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24899. return
  24900. }
  24901. }
  24902. PsnNo = res.Output.Baseinfo.PsnNo
  24903. PsnCertType = res.Output.Baseinfo.PsnCertType
  24904. Certno = res.Output.Baseinfo.Certno
  24905. PsnName = res.Output.Baseinfo.PsnName
  24906. Gend = res.Output.Baseinfo.Gend
  24907. Naty = res.Output.Baseinfo.Naty
  24908. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  24909. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  24910. infoStr = string(Iinfos)
  24911. idetinfoStr = string(Idetinfos)
  24912. if miConfig.Code == "H15049901371" {
  24913. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  24914. } else {
  24915. infocode = res.Infcode
  24916. }
  24917. }
  24918. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24919. psn_info, _ := service.GetPsnByPatientId(id)
  24920. PsnNo = psn_info.PsnNo
  24921. PsnCertType = psn_info.PsnCertType
  24922. Certno = psn_info.Certno
  24923. PsnName = psn_info.PsnName
  24924. Gend = psn_info.Gend
  24925. Naty = psn_info.Naty
  24926. Brdy = psn_info.Brdy
  24927. Age = psn_info.Age
  24928. infoStr = psn_info.Insuinfo
  24929. idetinfoStr = psn_info.Idetinfo
  24930. infocode = 0
  24931. verify_number = psn_info.VerifyNumber
  24932. } else if miConfig.MdtrtareaAdmvs == "450721" {
  24933. psn_info, _ := service.GetPsnByPatientId(id)
  24934. PsnNo = psn_info.PsnNo
  24935. PsnCertType = psn_info.PsnCertType
  24936. Certno = psn_info.Certno
  24937. PsnName = psn_info.PsnName
  24938. Gend = psn_info.Gend
  24939. Naty = psn_info.Naty
  24940. Brdy = psn_info.Brdy
  24941. Age = psn_info.Age
  24942. infoStr = psn_info.Insuinfo
  24943. idetinfoStr = psn_info.Idetinfo
  24944. infocode = 0
  24945. verify_number = psn_info.VerifyNumber
  24946. } else {
  24947. var result string
  24948. var requestLog string
  24949. //if miConfig.UserOrgId == 10138 {
  24950. if id_card_type != 4 || id_card_type != 1 {
  24951. var insa string
  24952. if len(patient.InsuplcAdmdvs) > 0 {
  24953. insa = patient.InsuplcAdmdvs
  24954. } else {
  24955. insa = miConfig.InsuplcAdmdvs
  24956. }
  24957. //psn_info, _ := service.GetPsnByPatientId(id)
  24958. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  24959. 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)
  24960. }
  24961. //}
  24962. //else {
  24963. // var insa string
  24964. // if len(patient.InsuplcAdmdvs) > 0 {
  24965. // insa = patient.InsuplcAdmdvs
  24966. // } else {
  24967. // insa = miConfig.InsuplcAdmdvs
  24968. // }
  24969. // 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)
  24970. //}
  24971. if id_card_type == 4 || id_card_type == 1 {
  24972. psn_info, _ := service.GetPsnByPatientId(id)
  24973. PsnNo = psn_info.PsnNo
  24974. PsnCertType = psn_info.PsnCertType
  24975. Certno = psn_info.Certno
  24976. PsnName = psn_info.PsnName
  24977. Gend = psn_info.Gend
  24978. Naty = psn_info.Naty
  24979. Brdy = psn_info.Brdy
  24980. Age = psn_info.Age
  24981. infoStr = psn_info.Insuinfo
  24982. idetinfoStr = psn_info.Idetinfo
  24983. infocode = 0
  24984. verify_number = psn_info.VerifyNumber
  24985. } else {
  24986. saveLog(result, requestLog, "1101", "人员基本信息获取")
  24987. if miConfig.Code == "H15049901371" {
  24988. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  24989. utils.ErrorLog("解析失败:%v", err)
  24990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24991. return
  24992. }
  24993. res.ErrMsg = res10265.ErrMsg
  24994. res.Output = res10265.Output
  24995. res.InfRefmsgid = res10265.InfRefmsgid
  24996. } else {
  24997. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24998. utils.ErrorLog("解析失败:%v", err)
  24999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25000. return
  25001. }
  25002. }
  25003. PsnNo = res.Output.Baseinfo.PsnNo
  25004. PsnCertType = res.Output.Baseinfo.PsnCertType
  25005. Certno = res.Output.Baseinfo.Certno
  25006. PsnName = res.Output.Baseinfo.PsnName
  25007. Gend = res.Output.Baseinfo.Gend
  25008. Naty = res.Output.Baseinfo.Naty
  25009. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  25010. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  25011. infoStr = string(Iinfos)
  25012. idetinfoStr = string(Idetinfos)
  25013. if miConfig.Code == "H15049901371" {
  25014. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  25015. } else {
  25016. infocode = res.Infcode
  25017. }
  25018. }
  25019. }
  25020. if infocode == 0 {
  25021. his := models.VMHisPatient{
  25022. Name: name,
  25023. Gender: gender,
  25024. Birthday: birthUnix,
  25025. MedicalTreatmentType: medical_care,
  25026. IdType: certificates,
  25027. IdCardNo: id_card,
  25028. BalanceAccountsType: settlementValue,
  25029. SocialType: social_type,
  25030. MedicalInsuranceNumber: medical_insurance_card,
  25031. RegisterType: register_type,
  25032. RegisterCost: registration_fee,
  25033. TreatmentCost: medical_expenses,
  25034. Status: 1,
  25035. Ctime: time.Now().Unix(),
  25036. Mtime: time.Now().Unix(),
  25037. PsnNo: PsnNo,
  25038. PsnCertType: PsnCertType,
  25039. Certno: Certno,
  25040. PsnName: PsnName,
  25041. Gend: Gend,
  25042. Naty: Naty,
  25043. Brdy: Brdy,
  25044. Age: Age,
  25045. Iinfo: infoStr,
  25046. Idetinfo: idetinfoStr,
  25047. PatientId: patient.ID,
  25048. RecordDate: theTime.Unix(),
  25049. UserOrgId: adminInfo.CurrentOrgId,
  25050. AdminUserId: admin_user_id,
  25051. IsReturn: 1,
  25052. IdCardType: id_card_type,
  25053. Doctor: doctor,
  25054. Departments: department,
  25055. MdtrtGrpType: mdtrt_type,
  25056. }
  25057. timestamp := time.Now().Unix()
  25058. tempTime := time.Unix(timestamp, 0)
  25059. timeFormat := tempTime.Format("20060102150405")
  25060. chrgBchno := rand.Intn(100000) + 10000
  25061. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  25062. his.Number = ipt_otp_no
  25063. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  25064. department, _ := service.GetDepartMentDetail(department)
  25065. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  25066. IdCardNo := ""
  25067. if id_card_type == 1 {
  25068. // IdCardNo = medical_insurance_card
  25069. IdCardNo = patient.IdCardNo
  25070. } else {
  25071. IdCardNo = patient.IdCardNo
  25072. }
  25073. var rf []*ResultFive
  25074. json.Unmarshal([]byte(his.Iinfo), &rf)
  25075. var insutypes []*ResultFive
  25076. var insutype string
  25077. var insuplc_admdvs_temp string
  25078. var is390 int = 0
  25079. var is310 int = 0
  25080. for _, item := range rf {
  25081. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25082. insutypes = append(insutypes, item)
  25083. }
  25084. }
  25085. if len(insutypes) == 1 {
  25086. insutype = insutypes[0].Insutype
  25087. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  25088. if insutype == "390" {
  25089. is390 = 1
  25090. }
  25091. if insutype == "310" {
  25092. is310 = 1
  25093. }
  25094. } else {
  25095. for _, i := range insutypes {
  25096. if i.Insutype == "390" {
  25097. is390 = 1
  25098. }
  25099. if i.Insutype == "310" {
  25100. is310 = 1
  25101. }
  25102. }
  25103. }
  25104. if is390 == 1 {
  25105. insutype = "390"
  25106. }
  25107. if is310 == 1 {
  25108. insutype = "310"
  25109. }
  25110. fmt.Println(social_type)
  25111. if social_type > 0 {
  25112. insutype = strconv.FormatInt(social_type, 10)
  25113. }
  25114. var infocode int64
  25115. var resThree ResultThree
  25116. var resThree10265 ResultThree10265
  25117. if len(insuplc_admdvs) == 0 {
  25118. psn_info, _ := service.GetPsnByPatientId(id)
  25119. //if len(psn_info.InsuplcAdmdvs) > 0 {
  25120. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25121. //}
  25122. } else {
  25123. insuplc_admdvs_temp = insuplc_admdvs
  25124. }
  25125. if miConfig.MdtrtareaAdmvs == "421300" {
  25126. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25127. psn_info, _ := service.GetPsnByPatientId(id)
  25128. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25129. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25130. "&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
  25131. resp, requestErr := http.Get(api)
  25132. if requestErr != nil {
  25133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25134. return
  25135. }
  25136. body, ioErr := ioutil.ReadAll(resp.Body)
  25137. if ioErr != nil {
  25138. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25140. return
  25141. }
  25142. var respJSON map[string]interface{}
  25143. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25144. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25146. return
  25147. }
  25148. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25149. result, _ := json.Marshal(respJSON)
  25150. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25151. utils.ErrorLog("解析失败:%v", err)
  25152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25153. return
  25154. }
  25155. infocode = resThree.Infcode
  25156. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25157. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25158. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  25159. // insuplc_admdvs_temp =
  25160. //}
  25161. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  25162. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25163. //}
  25164. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25165. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25166. "&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
  25167. resp, requestErr := http.Get(api)
  25168. if requestErr != nil {
  25169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25170. return
  25171. }
  25172. body, ioErr := ioutil.ReadAll(resp.Body)
  25173. if ioErr != nil {
  25174. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25176. return
  25177. }
  25178. var respJSON map[string]interface{}
  25179. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25180. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25182. return
  25183. }
  25184. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25185. result, _ := json.Marshal(respJSON)
  25186. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25187. utils.ErrorLog("解析失败:%v", err)
  25188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25189. return
  25190. }
  25191. infocode = resThree.Infcode
  25192. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25193. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25194. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  25195. // insuplc_admdvs_temp =
  25196. //}
  25197. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  25198. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25199. //}
  25200. utils.ErrorLog("解析失败:%v", insutype)
  25201. utils.ErrorLog("解析失败:%v", PsnNo)
  25202. utils.ErrorLog("解析失败:%v", Certno)
  25203. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  25204. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  25205. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  25206. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  25207. utils.ErrorLog("解析失败:%v", PsnNo)
  25208. utils.ErrorLog("解析失败:%v", department.Number)
  25209. utils.ErrorLog("解析失败:%v", department.Name)
  25210. utils.ErrorLog("解析失败:%v", roles.UserName)
  25211. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25212. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25213. "&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
  25214. resp, requestErr := http.Get(api)
  25215. if requestErr != nil {
  25216. utils.ErrorLog("解析失败:%v", requestErr)
  25217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25218. return
  25219. }
  25220. body, ioErr := ioutil.ReadAll(resp.Body)
  25221. if ioErr != nil {
  25222. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25224. return
  25225. }
  25226. var respJSON map[string]interface{}
  25227. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25228. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25230. return
  25231. }
  25232. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25233. result, _ := json.Marshal(respJSON)
  25234. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25235. utils.ErrorLog("解析失败:%v", err)
  25236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25237. return
  25238. }
  25239. infocode = resThree.Infcode
  25240. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25241. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25242. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  25243. // insuplc_admdvs_temp =
  25244. //}
  25245. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  25246. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25247. //}
  25248. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25249. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25250. "&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
  25251. resp, requestErr := http.Get(api)
  25252. if requestErr != nil {
  25253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25254. return
  25255. }
  25256. body, ioErr := ioutil.ReadAll(resp.Body)
  25257. if ioErr != nil {
  25258. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25260. return
  25261. }
  25262. var respJSON map[string]interface{}
  25263. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25264. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25266. return
  25267. }
  25268. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25269. result, _ := json.Marshal(respJSON)
  25270. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25271. utils.ErrorLog("解析失败:%v", err)
  25272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25273. return
  25274. }
  25275. infocode = resThree.Infcode
  25276. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25277. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25278. psn_info, _ := service.GetPsnByPatientId(id)
  25279. var verify_number string
  25280. if id_card_type == 4 {
  25281. verify_number = psn_info.VerifyNumber
  25282. } else if id_card_type == 1 {
  25283. bas := strings.Split(psn_info.CardInfo, "|")
  25284. cardNumber := bas[2]
  25285. verify_number = cardNumber
  25286. }
  25287. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25288. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25289. "&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
  25290. resp, requestErr := http.Get(api)
  25291. if requestErr != nil {
  25292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25293. return
  25294. }
  25295. body, ioErr := ioutil.ReadAll(resp.Body)
  25296. if ioErr != nil {
  25297. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25299. return
  25300. }
  25301. var respJSON map[string]interface{}
  25302. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25303. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25305. return
  25306. }
  25307. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25308. result, _ := json.Marshal(respJSON)
  25309. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25310. // utils.ErrorLog("解析失败:%v", err)
  25311. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25312. // return
  25313. //}
  25314. //infocode = resThree.Infcode
  25315. //result, _ := json.Marshal(respJSON)
  25316. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25317. utils.ErrorLog("解析失败:%v", err)
  25318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25319. return
  25320. }
  25321. resThree.ErrMsg = resThree10265.ErrMsg
  25322. resThree.Output = resThree10265.Output
  25323. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25324. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25325. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  25326. psn_info, _ := service.GetPsnByPatientId(id)
  25327. his.PsnNo = psn_info.PsnNo
  25328. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25329. var cert_no string
  25330. if id_card_type == 3 {
  25331. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  25332. cert_no = IdCardNo
  25333. } else if id_card_type == 4 {
  25334. cert_no = IdCardNo
  25335. psn_info.VerifyNumber = psn_info.VerifyNumber
  25336. } else {
  25337. bas := strings.Split(psn_info.CardInfo, "|")
  25338. cert_no = bas[2]
  25339. }
  25340. var hisPrescription []*models.HisPrescription
  25341. fmt.Println(hisPrescription)
  25342. for _, item := range rf {
  25343. if item.Insutype == insutype {
  25344. //insuplc_admdvs = item.InsuplcAdmdvs
  25345. his.InsuplcAdmdvs = insuplc_admdvs
  25346. }
  25347. }
  25348. his.Insutype = insutype
  25349. var res3101 Result3101
  25350. res3101.Infcode = "0"
  25351. //res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25352. if res3101.Infcode == "0" {
  25353. fmt.Println("33333333")
  25354. if len(res3101.Output.Result) > 0 {
  25355. fmt.Println("222222")
  25356. for _, item := range res3101.Output.Result {
  25357. if len(res3101.ErrMsg) == 0 {
  25358. res3101.ErrMsg = item.VolaCont
  25359. } else {
  25360. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  25361. }
  25362. }
  25363. c.ServeSuccessJSON(map[string]interface{}{
  25364. "failed_code": -10,
  25365. "msg": res3101.ErrMsg,
  25366. })
  25367. return
  25368. } else {
  25369. fmt.Println("11111")
  25370. var api string
  25371. if miConfig.MdtrtareaAdmvs == "320830" {
  25372. ipt_otp_no = timeFormat
  25373. api = miConfig.AppSecret + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25374. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25375. "&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
  25376. } else if miConfig.MdtrtareaAdmvs == "320921" {
  25377. ipt_otp_no = timeFormat
  25378. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25379. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25380. "&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
  25381. } else {
  25382. ipt_otp_no = timeFormat
  25383. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  25384. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25385. "&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
  25386. }
  25387. resp, requestErr := http.Get(api)
  25388. if requestErr != nil {
  25389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25390. return
  25391. }
  25392. body, ioErr := ioutil.ReadAll(resp.Body)
  25393. if ioErr != nil {
  25394. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25396. return
  25397. }
  25398. var respJSON map[string]interface{}
  25399. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25400. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25402. return
  25403. }
  25404. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25405. result, _ := json.Marshal(respJSON)
  25406. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25407. utils.ErrorLog("解析失败:%v", err)
  25408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25409. return
  25410. }
  25411. resThree.ErrMsg = resThree10265.ErrMsg
  25412. resThree.Output = resThree10265.Output
  25413. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25414. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25415. }
  25416. } else if res3101.Infcode != "0" {
  25417. c.ServeSuccessJSON(map[string]interface{}{
  25418. "failed_code": -10,
  25419. "msg": res3101.ErrMsg,
  25420. })
  25421. return
  25422. }
  25423. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25424. psn_info, _ := service.GetPsnByPatientId(id)
  25425. var cert_no string
  25426. if id_card_type == 1 {
  25427. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  25428. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25429. } else if id_card_type == 4 {
  25430. cert_no = psn_info.VerifyNumber
  25431. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25432. } else {
  25433. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25434. cert_no = psn_info.VerifyNumber
  25435. }
  25436. 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)
  25437. saveLog(result, requestLog, "2201", "挂号")
  25438. if miConfig.Code == "H15049901371" {
  25439. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25440. utils.ErrorLog("解析失败:%v", err)
  25441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25442. return
  25443. }
  25444. resThree.ErrMsg = resThree10265.ErrMsg
  25445. resThree.Output = resThree10265.Output
  25446. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25447. } else {
  25448. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25449. utils.ErrorLog("解析失败:%v", err)
  25450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25451. return
  25452. }
  25453. }
  25454. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25455. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  25456. psn_info, _ := service.GetPsnByPatientId(id)
  25457. var result string
  25458. var requestLog string
  25459. if id_card_type == 1 {
  25460. bas := strings.Split(psn_info.CardInfo, "|")
  25461. basNumber := bas[2]
  25462. card_sn := bas[3]
  25463. 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)
  25464. saveLog(result, requestLog, "2201A", "挂号")
  25465. } else if id_card_type == 2 {
  25466. 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, "", "", "", "", "", "")
  25467. saveLog(result, requestLog, "2201A", "挂号")
  25468. } else {
  25469. 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)
  25470. saveLog(result, requestLog, "2201A", "挂号")
  25471. }
  25472. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25473. utils.ErrorLog("解析失败:%v", err)
  25474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25475. return
  25476. }
  25477. infocode = resThree.Infcode
  25478. } else if miConfig.MdtrtareaAdmvs == "361025" { //江西萍乡
  25479. psn_info, _ := service.GetPsnByPatientId(id)
  25480. var result string
  25481. var requestLog string
  25482. if id_card_type == 1 {
  25483. bas := strings.Split(psn_info.CardInfo, "|")
  25484. basNumber := bas[2]
  25485. card_sn := ""
  25486. 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)
  25487. saveLog(result, requestLog, "2201A", "挂号")
  25488. } else if id_card_type == 2 {
  25489. 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, "", "", "", "", "", "")
  25490. saveLog(result, requestLog, "2201A", "挂号")
  25491. } else {
  25492. 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)
  25493. saveLog(result, requestLog, "2201A", "挂号")
  25494. }
  25495. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25496. utils.ErrorLog("解析失败:%v", err)
  25497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25498. return
  25499. }
  25500. infocode = resThree.Infcode
  25501. } else if miConfig.MdtrtareaAdmvs == "360100" { //江西萍乡
  25502. psn_info, _ := service.GetPsnByPatientId(id)
  25503. var result string
  25504. var requestLog string
  25505. if id_card_type == 1 {
  25506. bas := strings.Split(psn_info.CardInfo, "|")
  25507. basNumber := bas[2]
  25508. card_sn := ""
  25509. 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)
  25510. saveLog(result, requestLog, "2201A", "挂号")
  25511. } else if id_card_type == 2 {
  25512. 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, "", "", "", "", "", "")
  25513. saveLog(result, requestLog, "2201A", "挂号")
  25514. } else {
  25515. 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)
  25516. saveLog(result, requestLog, "2201A", "挂号")
  25517. }
  25518. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25519. utils.ErrorLog("解析失败:%v", err)
  25520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25521. return
  25522. }
  25523. infocode = resThree.Infcode
  25524. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25525. psn_info, _ := service.GetPsnByPatientId(id)
  25526. his.PsnNo = psn_info.PsnNo
  25527. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25528. var cert_no string
  25529. if id_card_type == 1 {
  25530. bas := strings.Split(psn_info.CardInfo, "|")
  25531. cert_no = bas[2]
  25532. } else if id_card_type == 4 {
  25533. cert_no = psn_info.VerifyNumber
  25534. psn_info.VerifyNumber = psn_info.VerifyNumber
  25535. IdCardNo = psn_info.VerifyNumber
  25536. } else {
  25537. cert_no = IdCardNo
  25538. psn_info.VerifyNumber = cert_no
  25539. }
  25540. for _, item := range rf {
  25541. if item.Insutype == insutype {
  25542. his.InsuplcAdmdvs = insuplc_admdvs
  25543. }
  25544. }
  25545. his.Insutype = insutype
  25546. var api string
  25547. ipt_otp_no = timeFormat
  25548. 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 +
  25549. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25550. "&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
  25551. resp, requestErr := http.Get(api)
  25552. if requestErr != nil {
  25553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25554. return
  25555. }
  25556. body, ioErr := ioutil.ReadAll(resp.Body)
  25557. if ioErr != nil {
  25558. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25560. return
  25561. }
  25562. var respJSON map[string]interface{}
  25563. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25564. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25566. return
  25567. }
  25568. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25569. if status == "0" {
  25570. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25571. c.ServeSuccessJSON(map[string]interface{}{
  25572. "failed_code": -10,
  25573. "msg": err_msg,
  25574. })
  25575. return
  25576. }
  25577. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25578. result, _ := json.Marshal(respJSON)
  25579. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25580. utils.ErrorLog("解析失败:%v", err)
  25581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25582. return
  25583. }
  25584. infocode = resThree.Infcode
  25585. } else if miConfig.MdtrtareaAdmvs == "340699" {
  25586. psn_info, _ := service.GetPsnByPatientId(id)
  25587. his.PsnNo = psn_info.PsnNo
  25588. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  25589. var cert_no string
  25590. if id_card_type == 1 {
  25591. bas := strings.Split(psn_info.CardInfo, "|")
  25592. cert_no = bas[2]
  25593. } else if id_card_type == 4 {
  25594. cert_no = psn_info.VerifyNumber
  25595. psn_info.VerifyNumber = psn_info.VerifyNumber
  25596. IdCardNo = psn_info.VerifyNumber
  25597. } else {
  25598. cert_no = IdCardNo
  25599. psn_info.VerifyNumber = cert_no
  25600. }
  25601. for _, item := range rf {
  25602. if item.Insutype == insutype {
  25603. his.InsuplcAdmdvs = insuplc_admdvs
  25604. patient.InsuplcAdmdvs = insuplc_admdvs
  25605. }
  25606. }
  25607. his.Insutype = insutype
  25608. var api string
  25609. ipt_otp_no = timeFormat
  25610. 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 +
  25611. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25612. "&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
  25613. resp, requestErr := http.Get(api)
  25614. if requestErr != nil {
  25615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25616. return
  25617. }
  25618. body, ioErr := ioutil.ReadAll(resp.Body)
  25619. if ioErr != nil {
  25620. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25622. return
  25623. }
  25624. var respJSON map[string]interface{}
  25625. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25626. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25628. return
  25629. }
  25630. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25631. if status == "0" {
  25632. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25633. c.ServeSuccessJSON(map[string]interface{}{
  25634. "failed_code": -10,
  25635. "msg": err_msg,
  25636. })
  25637. return
  25638. }
  25639. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25640. result, _ := json.Marshal(respJSON)
  25641. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25642. utils.ErrorLog("解析失败:%v", err)
  25643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25644. return
  25645. }
  25646. infocode = resThree.Infcode
  25647. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25648. hour := time.Now().Format("15")
  25649. min := time.Now().Format("04")
  25650. sec := time.Now().Format("05")
  25651. begin := record_time + " " + hour + ":" + min + ":" + sec
  25652. psn_info, _ := service.GetPsnByPatientId(id)
  25653. var result string
  25654. var requestLog string
  25655. if id_card_type == 1 {
  25656. bas := strings.Split(psn_info.CardInfo, "|")
  25657. basNumber := bas[2]
  25658. card_sn := bas[3]
  25659. 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)
  25660. saveLog(result, requestLog, "2201A", "挂号")
  25661. } else if id_card_type == 2 {
  25662. 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)
  25663. saveLog(result, requestLog, "2201A", "挂号")
  25664. } else {
  25665. 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)
  25666. saveLog(result, requestLog, "2201A", "挂号")
  25667. }
  25668. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25669. utils.ErrorLog("解析失败:%v", err)
  25670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25671. return
  25672. }
  25673. infocode = resThree.Infcode
  25674. } else if miConfig.MdtrtareaAdmvs == "131023" {
  25675. psn_info, _ := service.GetPsnByPatientId(id)
  25676. 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)
  25677. saveLog(result, requestLog, "2201A", "挂号")
  25678. if miConfig.Code == "H15049901371" {
  25679. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25680. utils.ErrorLog("解析失败:%v", err)
  25681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25682. return
  25683. }
  25684. resThree.ErrMsg = resThree10265.ErrMsg
  25685. resThree.Output = resThree10265.Output
  25686. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25687. } else {
  25688. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25689. utils.ErrorLog("解析失败:%v", err)
  25690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25691. return
  25692. }
  25693. }
  25694. if miConfig.Code == "H15049901371" {
  25695. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25696. } else {
  25697. infocode = resThree.Infcode
  25698. }
  25699. } else {
  25700. psn_info, _ := service.GetPsnByPatientId(id)
  25701. if id_card_type == 4 || id_card_type == 1 {
  25702. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  25703. }
  25704. var rf []*ResultFive
  25705. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  25706. var insutypes []*ResultFive
  25707. var insutype string
  25708. var is390 int = 0
  25709. var is310 int = 0
  25710. for _, item := range rf {
  25711. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  25712. insutypes = append(insutypes, item)
  25713. }
  25714. }
  25715. if len(insutypes) == 1 {
  25716. insutype = insutypes[0].Insutype
  25717. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  25718. } else {
  25719. for _, i := range insutypes {
  25720. if i.Insutype == "390" {
  25721. is390 = 1
  25722. }
  25723. if i.Insutype == "310" {
  25724. is310 = 1
  25725. }
  25726. }
  25727. }
  25728. if is390 == 1 {
  25729. insutype = "390"
  25730. }
  25731. if is310 == 1 {
  25732. insutype = "310"
  25733. }
  25734. fmt.Println(len(insutypes))
  25735. if len(insutypes) == 0 {
  25736. for index, item := range rf {
  25737. if index == 0 {
  25738. insutype = item.Insutype
  25739. insuplc_admdvs = item.InsuplcAdmdvs
  25740. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25741. }
  25742. }
  25743. fmt.Println(insutype)
  25744. fmt.Println(insuplc_admdvs)
  25745. }
  25746. if social_type > 0 {
  25747. insutype = strconv.FormatInt(social_type, 10)
  25748. }
  25749. fmt.Println("--------")
  25750. fmt.Println(psn_info)
  25751. fmt.Println(psn_info.PsnNo)
  25752. for _, item := range rf {
  25753. if item.Insutype == insutype {
  25754. insutype = item.Insutype
  25755. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25756. }
  25757. }
  25758. if miConfig.MdtrtareaAdmvs == "441202" {
  25759. var hisPrescription []*models.HisPrescription
  25760. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25761. if res3101.Infcode == 0 {
  25762. fmt.Println("33333333")
  25763. if len(res3101.Output.Result) > 0 {
  25764. fmt.Println("222222")
  25765. for _, item := range res3101.Output.Result {
  25766. if len(res3101.ErrMsg) == 0 {
  25767. res3101.ErrMsg = item.VolaCont
  25768. } else {
  25769. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  25770. }
  25771. }
  25772. c.ServeSuccessJSON(map[string]interface{}{
  25773. "failed_code": -10,
  25774. "msg": res3101.ErrMsg,
  25775. })
  25776. return
  25777. } else {
  25778. hour := time.Now().Format("15")
  25779. min := time.Now().Format("04")
  25780. sec := time.Now().Format("05")
  25781. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25782. fmt.Println(record_time_two)
  25783. 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)
  25784. saveLog(result, requestLog, "2201A", "挂号")
  25785. if miConfig.Code == "H15049901371" {
  25786. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25787. utils.ErrorLog("解析失败:%v", err)
  25788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25789. return
  25790. }
  25791. resThree.ErrMsg = resThree10265.ErrMsg
  25792. resThree.Output = resThree10265.Output
  25793. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25794. } else {
  25795. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25796. utils.ErrorLog("解析失败:%v", err)
  25797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25798. return
  25799. }
  25800. }
  25801. if miConfig.Code == "H15049901371" {
  25802. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25803. } else {
  25804. infocode = resThree.Infcode
  25805. }
  25806. }
  25807. } else if res3101.Infcode != 0 {
  25808. c.ServeSuccessJSON(map[string]interface{}{
  25809. "failed_code": -10,
  25810. "msg": res3101.ErrMsg,
  25811. })
  25812. return
  25813. }
  25814. } else if miConfig.MdtrtareaAdmvs == "440205" {
  25815. var hisPrescription []*models.HisPrescription
  25816. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25817. if res3101.Infcode == 0 {
  25818. fmt.Println("33333333")
  25819. if len(res3101.Output.Result) > 0 {
  25820. fmt.Println("222222")
  25821. for _, item := range res3101.Output.Result {
  25822. if len(res3101.ErrMsg) == 0 {
  25823. res3101.ErrMsg = item.VolaCont
  25824. } else {
  25825. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  25826. }
  25827. }
  25828. c.ServeSuccessJSON(map[string]interface{}{
  25829. "failed_code": -10,
  25830. "msg": res3101.ErrMsg,
  25831. })
  25832. return
  25833. } else {
  25834. hour := time.Now().Format("15")
  25835. min := time.Now().Format("04")
  25836. sec := time.Now().Format("05")
  25837. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25838. fmt.Println(record_time_two)
  25839. 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)
  25840. saveLog(result, requestLog, "2201A", "挂号")
  25841. if miConfig.Code == "H15049901371" {
  25842. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25843. utils.ErrorLog("解析失败:%v", err)
  25844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25845. return
  25846. }
  25847. resThree.ErrMsg = resThree10265.ErrMsg
  25848. resThree.Output = resThree10265.Output
  25849. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25850. } else {
  25851. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25852. utils.ErrorLog("解析失败:%v", err)
  25853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25854. return
  25855. }
  25856. }
  25857. if miConfig.Code == "H15049901371" {
  25858. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  25859. } else {
  25860. infocode = resThree.Infcode
  25861. }
  25862. }
  25863. } else if res3101.Infcode != 0 {
  25864. c.ServeSuccessJSON(map[string]interface{}{
  25865. "failed_code": -10,
  25866. "msg": res3101.ErrMsg,
  25867. })
  25868. return
  25869. }
  25870. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25871. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  25872. psn_info, _ := service.GetPsnByPatientId(id)
  25873. var verify_number string
  25874. if id_card_type == 4 {
  25875. verify_number = psn_info.VerifyNumber
  25876. } else if id_card_type == 1 {
  25877. bas := strings.Split(psn_info.CardInfo, "|")
  25878. cardNumber := bas[2]
  25879. verify_number = cardNumber
  25880. } else {
  25881. verify_number = psn_info.Certno
  25882. }
  25883. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  25884. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  25885. "&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
  25886. resp, requestErr := http.Get(api)
  25887. if requestErr != nil {
  25888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25889. return
  25890. }
  25891. body, ioErr := ioutil.ReadAll(resp.Body)
  25892. if ioErr != nil {
  25893. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25895. return
  25896. }
  25897. var respJSON map[string]interface{}
  25898. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25899. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25901. return
  25902. }
  25903. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25904. result, _ := json.Marshal(respJSON)
  25905. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25906. utils.ErrorLog("解析失败:%v", err)
  25907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25908. return
  25909. }
  25910. infocode = resThree.Infcode
  25911. } else {
  25912. hour := time.Now().Format("15")
  25913. min := time.Now().Format("04")
  25914. sec := time.Now().Format("05")
  25915. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25916. if id_card_type == 1 {
  25917. for _, item := range rf {
  25918. if item.Insutype == strconv.FormatInt(social_type, 10) {
  25919. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  25920. insuplc_admdvs_temp = item.InsuplcAdmdvs
  25921. } else if strconv.FormatInt(social_type, 10) == "390" {
  25922. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25923. } else {
  25924. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25925. }
  25926. }
  25927. }
  25928. }
  25929. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  25930. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25931. }
  25932. if id_card_type == 1 {
  25933. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  25934. bas := strings.Split(psn_info.CardInfo, "|")
  25935. basNumber := bas[1]
  25936. IdCardNo = basNumber
  25937. }
  25938. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  25939. IdCardNo = psn_info.VerifyNumber
  25940. }
  25941. if len(insuplc_admdvs_temp) == 0 {
  25942. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  25943. }
  25944. var result string
  25945. var requestLog string
  25946. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" || miConfig.Code == "H44090200998"{
  25947. var hisPrescription []*models.HisPrescription
  25948. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription, department)
  25949. if res3101.Infcode == 0 {
  25950. if len(res3101.Output.Result) > 0 {
  25951. if len(res3101.Output.Result) > 0 {
  25952. c.ServeSuccessJSON(map[string]interface{}{
  25953. "failed_code": -10,
  25954. "failed_type": 100,
  25955. "warm_type": 1,
  25956. "msg": res3101,
  25957. })
  25958. return
  25959. } else {
  25960. c.ServeSuccessJSON(map[string]interface{}{
  25961. "failed_code": -10,
  25962. "msg": res3101.ErrMsg,
  25963. })
  25964. return
  25965. }
  25966. } else {
  25967. hour := time.Now().Format("15")
  25968. min := time.Now().Format("04")
  25969. sec := time.Now().Format("05")
  25970. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  25971. fmt.Println(record_time_two)
  25972. if his.IdCardType == 2 {
  25973. IdCardNo = psn_info.Certno
  25974. psn_info.VerifyNumber = psn_info.Certno
  25975. } else if his.IdCardType == 4 {
  25976. IdCardNo = psn_info.Certno
  25977. } else {
  25978. bas := strings.Split(psn_info.CardInfo, "|")
  25979. IdCardNo = bas[2]
  25980. }
  25981. aaaa = insutype
  25982. 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)
  25983. saveLog(result, requestLog, "2201A", "挂号")
  25984. if miConfig.Code == "H15049901371" {
  25985. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  25986. utils.ErrorLog("解析失败:%v", err)
  25987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25988. return
  25989. }
  25990. resThree.ErrMsg = resThree10265.ErrMsg
  25991. resThree.Output = resThree10265.Output
  25992. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  25993. } else {
  25994. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  25995. utils.ErrorLog("解析失败:%v", err)
  25996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25997. return
  25998. }
  25999. }
  26000. if miConfig.Code == "H15049901371" {
  26001. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  26002. } else {
  26003. infocode = resThree.Infcode
  26004. }
  26005. }
  26006. } else if res3101.Infcode != 0 {
  26007. c.ServeSuccessJSON(map[string]interface{}{
  26008. "failed_code": -10,
  26009. "msg": res3101.ErrMsg,
  26010. })
  26011. return
  26012. }
  26013. } else {
  26014. psn_info, _ := service.GetPsnByPatientId(id)
  26015. var rf []*ResultFive
  26016. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  26017. //var insutypes []*ResultFive
  26018. var insutype string
  26019. var insutypes []*ResultFive
  26020. var is390 int = 0
  26021. var is310 int = 0
  26022. for _, item := range rf {
  26023. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26024. insutypes = append(insutypes, item)
  26025. }
  26026. }
  26027. if len(insutypes) == 1 {
  26028. insutype = insutypes[0].Insutype
  26029. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  26030. } else {
  26031. for _, i := range insutypes {
  26032. if i.Insutype == "390" {
  26033. is390 = 1
  26034. }
  26035. if i.Insutype == "310" {
  26036. is310 = 1
  26037. }
  26038. }
  26039. }
  26040. if is390 == 1 {
  26041. insutype = "390"
  26042. }
  26043. if is310 == 1 {
  26044. insutype = "310"
  26045. }
  26046. if len(insutypes) == 0 {
  26047. insutype = "310"
  26048. }
  26049. if social_type > 0 {
  26050. insutype = strconv.FormatInt(social_type, 10)
  26051. }
  26052. for _, item := range rf {
  26053. if item.Insutype == insutype {
  26054. insuplc_admdvs_temp = item.InsuplcAdmdvs
  26055. }
  26056. }
  26057. if len(insuplc_admdvs_tt) > 0 {
  26058. insuplc_admdvs_temp = insuplc_admdvs_tt
  26059. }
  26060. 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)
  26061. saveLog(result, requestLog, "2201A", "挂号")
  26062. }
  26063. if miConfig.Code == "H15049901371" {
  26064. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  26065. utils.ErrorLog("解析失败:%v", err)
  26066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26067. return
  26068. }
  26069. resThree.ErrMsg = resThree10265.ErrMsg
  26070. resThree.Output = resThree10265.Output
  26071. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  26072. } else {
  26073. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  26074. utils.ErrorLog("解析失败:%v", err)
  26075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26076. return
  26077. }
  26078. }
  26079. if miConfig.Code == "H15049901371" {
  26080. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  26081. } else {
  26082. infocode = resThree.Infcode
  26083. }
  26084. }
  26085. }
  26086. if infocode == -1 {
  26087. adminUser := c.GetAdminUserInfo()
  26088. errlog := &models.HisOrderError{
  26089. UserOrgId: adminUser.CurrentOrgId,
  26090. Ctime: time.Now().Unix(),
  26091. Mtime: time.Now().Unix(),
  26092. ErrMsg: resThree.ErrMsg,
  26093. Status: 1,
  26094. PatientId: id,
  26095. RecordTime: recordDateTime,
  26096. Stage: 2,
  26097. }
  26098. service.CreateErrMsgLog(errlog)
  26099. c.ServeSuccessJSON(map[string]interface{}{
  26100. "failed_code": -10,
  26101. "msg": resThree.ErrMsg,
  26102. })
  26103. return
  26104. }
  26105. utils.ErrorLog("解析失败:%v", insutype)
  26106. his.Number = resThree.Output.Data.MdtrtID
  26107. his.PsnNo = resThree.Output.Data.PsnNo
  26108. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  26109. his.IdCardNo = patient.IdCardNo
  26110. his.PhoneNumber = patient.Phone
  26111. his.UserOrgId = adminInfo.CurrentOrgId
  26112. his.Insutype = insutype
  26113. if miConfig.Code == "H44030500255" {
  26114. his.Insutype = aaaa
  26115. }
  26116. his.Ctime = time.Now().Unix()
  26117. his.Mtime = time.Now().Unix()
  26118. his.InsuplcAdmdvs = insuplc_admdvs_temp
  26119. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  26120. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  26121. }
  26122. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  26123. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  26124. }
  26125. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  26126. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  26127. }
  26128. his.Status = 1
  26129. his.MdtrtGrpType = mdtrt_type
  26130. service.UpdateHisPatientStatus(&his)
  26131. service.UpdateHisPatient123(&patient)
  26132. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  26133. c.ServeSuccessJSON(map[string]interface{}{
  26134. "his_info": his,
  26135. })
  26136. } else {
  26137. adminUser := c.GetAdminUserInfo()
  26138. errlog := &models.HisOrderError{
  26139. UserOrgId: adminUser.CurrentOrgId,
  26140. Ctime: time.Now().Unix(),
  26141. Mtime: time.Now().Unix(),
  26142. ErrMsg: res.ErrMsg,
  26143. Status: 1,
  26144. PatientId: id,
  26145. RecordTime: recordDateTime,
  26146. Stage: 1,
  26147. }
  26148. service.CreateErrMsgLog(errlog)
  26149. c.ServeSuccessJSON(map[string]interface{}{
  26150. "failed_code": -10,
  26151. "msg": res.ErrMsg,
  26152. })
  26153. return
  26154. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  26155. }
  26156. }
  26157. }
  26158. func (c *HisApiController) GetUploadInfo() {
  26159. id, _ := c.GetInt64("id")
  26160. record_time := c.GetString("record_time")
  26161. his_patient_id, _ := c.GetInt64("his_patient_id")
  26162. order_id, _ := c.GetInt64("order_id")
  26163. pay_way, _ := c.GetInt64("pay_way")
  26164. pay_ways := c.GetString("pay_ways")
  26165. oth_desc := c.GetString("oth_desc")
  26166. pay_price, _ := c.GetFloat("pay_price")
  26167. pay_card_no := c.GetString("pay_card_no")
  26168. discount_price, _ := c.GetFloat("discount_price")
  26169. preferential_price, _ := c.GetFloat("preferential_price")
  26170. reality_price, _ := c.GetFloat("reality_price")
  26171. found_price, _ := c.GetFloat("found_price")
  26172. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  26173. private_price, _ := c.GetFloat("private_price")
  26174. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  26175. admin_user_id, _ := c.GetInt64("admin_user_id")
  26176. fapiao_code := c.GetString("fapiao_code")
  26177. fapiao_number := c.GetString("fapiao_number")
  26178. diagnosis_id := c.GetString("diagnosis")
  26179. sick_type, _ := c.GetInt64("sick_type")
  26180. reg_type, _ := c.GetInt64("p_type")
  26181. begin_time := c.GetString("begin_time")
  26182. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  26183. cash_pay := c.GetString("cash_pay")
  26184. band_card_pay := c.GetString("band_card_pay")
  26185. wechat_pay := c.GetString("wechat_pay")
  26186. ali_pay := c.GetString("ali_pay")
  26187. jifen_pay := c.GetString("jifen_pay")
  26188. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  26189. fmt.Println(acct_used_flag)
  26190. id_str := c.GetString("ids")
  26191. ids_arr := strings.Split(id_str, ",")
  26192. timeLayout := "2006-01-02"
  26193. loc, _ := time.LoadLocation("Local")
  26194. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  26195. if err != nil {
  26196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26197. return
  26198. }
  26199. recordDateTime := theTime.Unix()
  26200. adminUser := c.GetAdminUserInfo()
  26201. var tempOrder models.HisOrder
  26202. tempOrder, _ = service.GetHisOrderByID(order_id)
  26203. var prescriptions []*models.HisPrescription
  26204. var start_time int64
  26205. var end_time int64
  26206. //押金模块
  26207. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  26208. tmp_decimal := c.GetString("tmp_decimal")
  26209. var decimal float64 //本次使用的押金
  26210. var errmsg error
  26211. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  26212. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  26213. return
  26214. }
  26215. if len(tmp_decimal) > 0 {
  26216. if tmp_decimal[0] == 45 {
  26217. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  26218. return
  26219. }
  26220. }
  26221. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  26222. fmt.Println(errs)
  26223. decimal = tt
  26224. //if adminUser.CurrentOrgId == 10106{
  26225. // if len(fapiao_code) == 0{
  26226. // fapiao_code = "144072080589"
  26227. // }
  26228. // if len(fapiao_number) == 0{
  26229. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  26230. // if order.ID == 0{
  26231. // fapiao_number = "00001520"
  26232. // }else{
  26233. // //fapiao_code = "00001520"
  26234. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  26235. // var zero string
  26236. // if fpNumber >= 1000{
  26237. // zero = "0000" + strconv.Itoa(fpNumber)
  26238. // }else if fpNumber >= 10000{
  26239. // zero = "000" + strconv.Itoa(fpNumber)
  26240. // } else if fpNumber >= 100000{
  26241. // zero = "00" + strconv.Itoa(fpNumber)
  26242. // } else if fpNumber >= 1000000{
  26243. // zero = "0" + strconv.Itoa(fpNumber)
  26244. // }else {
  26245. // zero = strconv.Itoa(fpNumber)
  26246. // }
  26247. // fapiao_number = zero
  26248. // }
  26249. // }
  26250. //}
  26251. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26252. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  26253. var patientPrescription models.HisPrescriptionInfo
  26254. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  26255. if patientPrescription.ID == 0 {
  26256. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  26257. }
  26258. //if patientPrescription.Do
  26259. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26260. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  26261. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  26262. diagnosis_ids := strings.Split(diagnosis_id, ",")
  26263. var config []*models.HisXtDiagnoseConfig
  26264. for _, item := range diagnosis_ids {
  26265. id, _ := strconv.ParseInt(item, 10, 64)
  26266. diagnosisConfig, _ := service.FindDiagnoseById(id)
  26267. config = append(config, &diagnosisConfig)
  26268. }
  26269. sickConfig, _ := service.FindSickById(sick_type)
  26270. //if tempOrder.ID == 0 {
  26271. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  26272. //}
  26273. if tempOrder.ID == 0 {
  26274. var result string
  26275. var requestLog string
  26276. var res2 ResultSix
  26277. var res3 GZResultSix
  26278. var ressix10265 ResultSix10265
  26279. if miConfig.MdtrtareaAdmvs == "421300" {
  26280. data := make(map[string]interface{})
  26281. client := &http.Client{}
  26282. data["psn_no"] = his.PsnNo
  26283. data["mdtrt_id"] = his.Number
  26284. data["opter"] = roles.UserName
  26285. data["org_name"] = miConfig.OrgName
  26286. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26287. data["doctor_id"] = doctor_info.DoctorNumber
  26288. data["doctor_name"] = doctor_info.UserName
  26289. data["department"] = department.Name
  26290. data["fixmedins_code"] = miConfig.Code
  26291. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26292. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26293. data["secret_key"] = miConfig.SecretKey
  26294. data["sick_code"] = sickConfig.CountryCode
  26295. data["sick_name"] = sickConfig.ClassName
  26296. data["dept"] = strconv.FormatInt(department.ID, 10)
  26297. data["config"] = config
  26298. data["begin_time"] = begin_time
  26299. bytesData, _ := json.Marshal(data)
  26300. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  26301. resp, _ := client.Do(req)
  26302. defer resp.Body.Close()
  26303. body, ioErr := ioutil.ReadAll(resp.Body)
  26304. if ioErr != nil {
  26305. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26307. return
  26308. }
  26309. var respJSON map[string]interface{}
  26310. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26311. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26313. return
  26314. }
  26315. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26316. userJSONBytes, _ := json.Marshal(respJSON)
  26317. fmt.Println("log")
  26318. fmt.Println(string(userJSONBytes))
  26319. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26320. utils.ErrorLog("解析失败:%v", err)
  26321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26322. return
  26323. }
  26324. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26325. data := make(map[string]interface{})
  26326. client := &http.Client{}
  26327. data["psn_no"] = his.PsnNo
  26328. data["mdtrt_id"] = his.Number
  26329. data["opter"] = roles.UserName
  26330. data["org_name"] = miConfig.OrgName
  26331. if reg_type == 11 && his.Insutype == "390" {
  26332. data["med_type"] = "110104"
  26333. } else {
  26334. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26335. }
  26336. data["doctor_id"] = doctor_info.DoctorNumber
  26337. data["doctor_name"] = doctor_info.UserName
  26338. data["department"] = department.Name
  26339. data["fixmedins_code"] = miConfig.Code
  26340. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26341. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26342. data["secret_key"] = miConfig.SecretKey
  26343. data["sick_code"] = sickConfig.CountryCode
  26344. data["sick_name"] = sickConfig.ClassName
  26345. data["dept"] = strconv.FormatInt(department.ID, 10)
  26346. data["config"] = config
  26347. data["begin_time"] = begin_time
  26348. bytesData, _ := json.Marshal(data)
  26349. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  26350. resp, _ := client.Do(req)
  26351. defer resp.Body.Close()
  26352. body, ioErr := ioutil.ReadAll(resp.Body)
  26353. if ioErr != nil {
  26354. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26356. return
  26357. }
  26358. var respJSON map[string]interface{}
  26359. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26360. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26362. return
  26363. }
  26364. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26365. userJSONBytes, _ := json.Marshal(respJSON)
  26366. fmt.Println("log")
  26367. fmt.Println(string(userJSONBytes))
  26368. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26369. utils.ErrorLog("解析失败:%v", err)
  26370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26371. return
  26372. }
  26373. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26374. data := make(map[string]interface{})
  26375. client := &http.Client{}
  26376. data["psn_no"] = his.PsnNo
  26377. data["mdtrt_id"] = his.Number
  26378. data["opter"] = roles.UserName
  26379. data["org_name"] = miConfig.OrgName
  26380. if reg_type == 11 && his.Insutype == "390" {
  26381. data["med_type"] = "110104"
  26382. } else {
  26383. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26384. }
  26385. data["doctor_id"] = doctor_info.DoctorNumber
  26386. data["doctor_name"] = doctor_info.UserName
  26387. data["department"] = department.Name
  26388. data["fixmedins_code"] = miConfig.Code
  26389. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26390. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26391. data["secret_key"] = miConfig.SecretKey
  26392. data["sick_code"] = sickConfig.CountryCode
  26393. data["sick_name"] = sickConfig.ClassName
  26394. data["dept"] = strconv.FormatInt(department.ID, 10)
  26395. data["config"] = config
  26396. data["begin_time"] = begin_time
  26397. bytesData, _ := json.Marshal(data)
  26398. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  26399. resp, _ := client.Do(req)
  26400. defer resp.Body.Close()
  26401. body, ioErr := ioutil.ReadAll(resp.Body)
  26402. if ioErr != nil {
  26403. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26405. return
  26406. }
  26407. var respJSON map[string]interface{}
  26408. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26409. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26411. return
  26412. }
  26413. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26414. userJSONBytes, _ := json.Marshal(respJSON)
  26415. fmt.Println("log")
  26416. fmt.Println(string(userJSONBytes))
  26417. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26418. utils.ErrorLog("解析失败:%v", err)
  26419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26420. return
  26421. }
  26422. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26423. data := make(map[string]interface{})
  26424. client := &http.Client{}
  26425. data["psn_no"] = his.PsnNo
  26426. data["mdtrt_id"] = his.Number
  26427. data["opter"] = roles.UserName
  26428. data["org_name"] = miConfig.OrgName
  26429. if reg_type == 11 && his.Insutype == "390" {
  26430. data["med_type"] = "110104"
  26431. } else {
  26432. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26433. }
  26434. data["doctor_id"] = doctor_info.DoctorNumber
  26435. data["doctor_name"] = doctor_info.UserName
  26436. data["department"] = department.Name
  26437. data["fixmedins_code"] = miConfig.Code
  26438. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26439. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26440. data["secret_key"] = miConfig.SecretKey
  26441. data["sick_code"] = sickConfig.CountryCode
  26442. data["sick_name"] = sickConfig.ClassName
  26443. data["dept"] = strconv.FormatInt(department.ID, 10)
  26444. data["config"] = config
  26445. data["begin_time"] = begin_time
  26446. bytesData, _ := json.Marshal(data)
  26447. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  26448. resp, _ := client.Do(req)
  26449. defer resp.Body.Close()
  26450. body, ioErr := ioutil.ReadAll(resp.Body)
  26451. if ioErr != nil {
  26452. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26454. return
  26455. }
  26456. var respJSON map[string]interface{}
  26457. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26458. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26460. return
  26461. }
  26462. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26463. userJSONBytes, _ := json.Marshal(respJSON)
  26464. fmt.Println("log")
  26465. fmt.Println(string(userJSONBytes))
  26466. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26467. utils.ErrorLog("解析失败:%v", err)
  26468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26469. return
  26470. }
  26471. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  26472. utils.ErrorLog("解析失败:%v", doctor_info)
  26473. data := make(map[string]interface{})
  26474. client := &http.Client{}
  26475. data["psn_no"] = his.PsnNo
  26476. data["mdtrt_id"] = his.Number
  26477. data["doctor"] = roles.UserName
  26478. data["department"] = department.Name
  26479. data["org_name"] = miConfig.OrgName
  26480. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26481. data["doctor_id"] = doctor_info.DoctorNumber
  26482. data["new_doctor_name"] = doctor_info.UserName
  26483. data["fixmedins_code"] = miConfig.Code
  26484. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26485. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26486. data["secret_key"] = miConfig.SecretKey
  26487. data["sick_code"] = sickConfig.CountryCode
  26488. data["sick_name"] = sickConfig.ClassName
  26489. data["url"] = miConfig.Url
  26490. data["ak"] = miConfig.AccessKey
  26491. data["begin_time"] = begin_time
  26492. data["cainfo"] = miConfig.Cainfo
  26493. data["dept"] = strconv.FormatInt(department.ID, 10)
  26494. data["config"] = config
  26495. bytesData, _ := json.Marshal(data)
  26496. var req *http.Request
  26497. if miConfig.MdtrtareaAdmvs == "320830" {
  26498. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2203", bytes.NewReader(bytesData))
  26499. //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 +
  26500. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  26501. } else if miConfig.MdtrtareaAdmvs == "320921" {
  26502. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  26503. //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 +
  26504. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  26505. } else {
  26506. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  26507. }
  26508. resp, _ := client.Do(req)
  26509. defer resp.Body.Close()
  26510. body, ioErr := ioutil.ReadAll(resp.Body)
  26511. if ioErr != nil {
  26512. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26514. return
  26515. }
  26516. var respJSON map[string]interface{}
  26517. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26518. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26520. return
  26521. }
  26522. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26523. userJSONBytes, _ := json.Marshal(respJSON)
  26524. fmt.Println("log")
  26525. fmt.Println(string(userJSONBytes))
  26526. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  26527. utils.ErrorLog("解析失败:%v", err)
  26528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26529. return
  26530. }
  26531. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26532. res2.Output = ressix10265.Output
  26533. res2.ErrMsg = ressix10265.ErrMsg
  26534. res2.Cainfo = ressix10265.Cainfo
  26535. res2.WarnMsg = ressix10265.WarnMsg
  26536. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26537. res2.Infcode = infocode
  26538. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26539. data := make(map[string]interface{})
  26540. client := &http.Client{}
  26541. data["psn_no"] = his.PsnNo
  26542. data["mdtrt_id"] = his.Number
  26543. data["doctor"] = roles.UserName
  26544. data["department"] = department.Name
  26545. data["org_name"] = miConfig.OrgName
  26546. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26547. data["doctor_id"] = doctor_info.DoctorNumber
  26548. data["new_doctor_name"] = doctor_info.UserName
  26549. data["fixmedins_code"] = miConfig.Code
  26550. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26551. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26552. data["secret_key"] = miConfig.SecretKey
  26553. data["sick_code"] = sickConfig.CountryCode
  26554. data["sick_name"] = sickConfig.ClassName
  26555. data["url"] = miConfig.Url
  26556. data["ak"] = miConfig.AccessKey
  26557. data["begin_time"] = begin_time
  26558. data["cainfo"] = miConfig.Cainfo
  26559. data["dept"] = strconv.FormatInt(department.ID, 10)
  26560. data["config"] = config
  26561. bytesData, _ := json.Marshal(data)
  26562. var req *http.Request
  26563. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  26564. resp, _ := client.Do(req)
  26565. defer resp.Body.Close()
  26566. body, ioErr := ioutil.ReadAll(resp.Body)
  26567. if ioErr != nil {
  26568. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26570. return
  26571. }
  26572. var respJSON map[string]interface{}
  26573. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26574. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26576. return
  26577. }
  26578. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26579. userJSONBytes, _ := json.Marshal(respJSON)
  26580. fmt.Println("log")
  26581. fmt.Println(string(userJSONBytes))
  26582. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  26583. utils.ErrorLog("解析失败:%v", err)
  26584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26585. return
  26586. }
  26587. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26588. res2.Output = ressix10265.Output
  26589. res2.ErrMsg = ressix10265.ErrMsg
  26590. res2.Cainfo = ressix10265.Cainfo
  26591. res2.WarnMsg = ressix10265.WarnMsg
  26592. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26593. res2.Infcode = infocode
  26594. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26595. 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)
  26596. saveLog(result, requestLog, "2203", "上传就诊信息")
  26597. var respJSON2 map[string]interface{}
  26598. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26599. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26601. return
  26602. }
  26603. userJSONBytes2, _ := json.Marshal(respJSON2)
  26604. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26605. utils.ErrorLog("解析失败:%v", err)
  26606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26607. return
  26608. }
  26609. 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)
  26610. fmt.Println(result2)
  26611. fmt.Println(src_request)
  26612. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26613. data := make(map[string]interface{})
  26614. client := &http.Client{}
  26615. data["psn_no"] = his.PsnNo
  26616. data["mdtrt_id"] = his.Number
  26617. data["doctor"] = roles.UserName
  26618. data["department"] = department.Name
  26619. data["org_name"] = miConfig.OrgName
  26620. data["med_type"] = strconv.FormatInt(reg_type, 10)
  26621. data["doctor_id"] = doctor_info.DoctorNumber
  26622. data["new_doctor_name"] = doctor_info.UserName
  26623. data["fixmedins_code"] = miConfig.Code
  26624. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26625. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26626. data["secret_key"] = miConfig.SecretKey
  26627. data["sick_code"] = sickConfig.CountryCode
  26628. data["sick_name"] = sickConfig.ClassName
  26629. data["url"] = miConfig.Url
  26630. data["ak"] = miConfig.AccessKey
  26631. data["begin_time"] = begin_time
  26632. data["cainfo"] = miConfig.Cainfo
  26633. data["dept"] = strconv.FormatInt(department.ID, 10)
  26634. data["config"] = config
  26635. bytesData, _ := json.Marshal(data)
  26636. var req *http.Request
  26637. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  26638. resp, _ := client.Do(req)
  26639. defer resp.Body.Close()
  26640. body, ioErr := ioutil.ReadAll(resp.Body)
  26641. if ioErr != nil {
  26642. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26644. return
  26645. }
  26646. var respJSON map[string]interface{}
  26647. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26648. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26650. return
  26651. }
  26652. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26653. userJSONBytes, _ := json.Marshal(respJSON)
  26654. fmt.Println("log")
  26655. fmt.Println(string(userJSONBytes))
  26656. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26657. utils.ErrorLog("解析失败:%v", err)
  26658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26659. return
  26660. }
  26661. } else {
  26662. if miConfig.MdtrtareaAdmvs == "440781" { //
  26663. 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)
  26664. } else {
  26665. if miConfig.Code == "H15049901371" {
  26666. //赤峰地区国家医保医疗类别
  26667. //职工透析:医疗类别选特殊情况门诊990502
  26668. //居民定额血透门慢: 医疗类别选门诊慢病140104
  26669. var med_type string
  26670. if his.Insutype == "390" {
  26671. if reg_type == 14 {
  26672. med_type = "9933"
  26673. } else if reg_type == 11 {
  26674. med_type = "11"
  26675. }
  26676. } else if his.Insutype == "310" {
  26677. if reg_type == 14 {
  26678. med_type = "990502"
  26679. } else if reg_type == 11 {
  26680. med_type = "11"
  26681. }
  26682. }
  26683. 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)
  26684. } else {
  26685. 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)
  26686. }
  26687. }
  26688. saveLog(result, requestLog, "2203", "上传就诊信息")
  26689. var respJSON2 map[string]interface{}
  26690. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  26691. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26693. return
  26694. }
  26695. userJSONBytes2, _ := json.Marshal(respJSON2)
  26696. if miConfig.Code == "H15049901371" {
  26697. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  26698. utils.ErrorLog("解析失败:%v", err)
  26699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26700. return
  26701. }
  26702. res2.InfRefmsgid = ressix10265.InfRefmsgid
  26703. res2.Output = ressix10265.Output
  26704. res2.ErrMsg = ressix10265.ErrMsg
  26705. res2.Cainfo = ressix10265.Cainfo
  26706. res2.WarnMsg = ressix10265.WarnMsg
  26707. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  26708. res2.Infcode = infocode
  26709. } else {
  26710. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  26711. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  26712. utils.ErrorLog("解析失败:%v", err)
  26713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26714. return
  26715. }
  26716. res2.Infcode = res3.Infcode
  26717. } else {
  26718. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26719. utils.ErrorLog("解析失败:%v", err)
  26720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26721. return
  26722. }
  26723. }
  26724. }
  26725. }
  26726. if res2.Infcode == -1 {
  26727. adminUser := c.GetAdminUserInfo()
  26728. errlog := &models.HisOrderError{
  26729. UserOrgId: adminUser.CurrentOrgId,
  26730. Ctime: time.Now().Unix(),
  26731. Mtime: time.Now().Unix(),
  26732. ErrMsg: res2.ErrMsg,
  26733. Status: 1,
  26734. PatientId: id,
  26735. RecordTime: recordDateTime,
  26736. Stage: 3,
  26737. }
  26738. service.CreateErrMsgLog(errlog)
  26739. c.ServeSuccessJSON(map[string]interface{}{
  26740. "failed_code": -10,
  26741. "msg": res2.ErrMsg,
  26742. })
  26743. return
  26744. } else {
  26745. his.Diagnosis = diagnosis_id
  26746. his.SickType = sickConfig.ID
  26747. //var p_type int64
  26748. //if reg_type == 1111 || reg_type == 1112 {
  26749. // p_type = 11
  26750. //
  26751. //}
  26752. his.PType = fmt.Sprintf("%d", reg_type)
  26753. service.UpdateHisPatientThree(&his)
  26754. data := make(map[string]interface{})
  26755. if settle_accounts_type == 1 { //日结
  26756. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  26757. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  26758. } else {
  26759. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  26760. }
  26761. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  26762. data["pre"] = prescriptions
  26763. } else { //月结
  26764. start_time_str := c.GetString("start_time")
  26765. end_time_str := c.GetString("end_time")
  26766. timeLayout := "2006-01-02"
  26767. loc, _ := time.LoadLocation("Local")
  26768. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  26769. if err != nil {
  26770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26771. return
  26772. }
  26773. recordStartTime := theStartTime.Unix()
  26774. start_time = recordStartTime
  26775. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  26776. if err != nil {
  26777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26778. return
  26779. }
  26780. recordEndTime := theEndTime.Unix()
  26781. end_time = recordEndTime
  26782. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  26783. data["pre"] = prescriptions
  26784. }
  26785. timestamp := time.Now().Unix()
  26786. tempTime := time.Unix(timestamp, 0)
  26787. timeFormat := tempTime.Format("20060102150405")
  26788. chrgBchno := rand.Intn(100000) + 10000
  26789. new_chrg_bchno := ""
  26790. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  26791. new_chrg_bchno = chrg_bchno
  26792. strconv.FormatInt(his.PatientId, 10)
  26793. client := &http.Client{}
  26794. if adminUser.CurrentOrgId == 10265 {
  26795. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  26796. new_chrg_bchno = "0000"
  26797. }
  26798. }
  26799. data["psn_no"] = his.PsnNo
  26800. data["mdtrt_id"] = his.Number
  26801. data["chrg_bchno"] = new_chrg_bchno
  26802. data["org_name"] = miConfig.OrgName
  26803. data["doctor"] = doctor_info.UserName
  26804. data["doctor_id"] = doctor_info.DoctorNumber
  26805. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  26806. data["fixmedins_code"] = miConfig.Code
  26807. data["dept_code"] = department.Number
  26808. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  26809. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  26810. data["secret_key"] = miConfig.SecretKey
  26811. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  26812. data["url"] = miConfig.Url
  26813. data["ak"] = miConfig.AccessKey
  26814. data["new_doctor_name"] = patientPrescription.Doctor
  26815. data["diag_code"] = sickConfig.CountryCode
  26816. data["cainfo"] = miConfig.Cainfo
  26817. data["opter"] = roles.UserName
  26818. var ids []int64
  26819. for _, item := range prescriptions {
  26820. ids = append(ids, item.ID)
  26821. }
  26822. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26823. if config.IsOpen == 1 { //对接了医保,走医保流程
  26824. var res ResultFour
  26825. var resFour10265 ResultFour10265
  26826. if miConfig.MdtrtareaAdmvs == "421300" {
  26827. bytesData, _ := json.Marshal(data)
  26828. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  26829. resp, _ := client.Do(req)
  26830. defer resp.Body.Close()
  26831. body, ioErr := ioutil.ReadAll(resp.Body)
  26832. if ioErr != nil {
  26833. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26835. return
  26836. }
  26837. var respJSON map[string]interface{}
  26838. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26839. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26841. return
  26842. }
  26843. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26844. userJSONBytes, _ := json.Marshal(respJSON)
  26845. fmt.Println("log")
  26846. fmt.Println(string(userJSONBytes))
  26847. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26848. utils.ErrorLog("解析失败:%v", err)
  26849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26850. return
  26851. }
  26852. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26853. bytesData, _ := json.Marshal(data)
  26854. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  26855. resp, _ := client.Do(req)
  26856. defer resp.Body.Close()
  26857. body, ioErr := ioutil.ReadAll(resp.Body)
  26858. if ioErr != nil {
  26859. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26861. return
  26862. }
  26863. var respJSON map[string]interface{}
  26864. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26867. return
  26868. }
  26869. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26870. userJSONBytes, _ := json.Marshal(respJSON)
  26871. fmt.Println("log")
  26872. fmt.Println(string(userJSONBytes))
  26873. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26874. utils.ErrorLog("解析失败:%v", err)
  26875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26876. return
  26877. }
  26878. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26879. bytesData, _ := json.Marshal(data)
  26880. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  26881. resp, _ := client.Do(req)
  26882. defer resp.Body.Close()
  26883. body, ioErr := ioutil.ReadAll(resp.Body)
  26884. if ioErr != nil {
  26885. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26887. return
  26888. }
  26889. var respJSON map[string]interface{}
  26890. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26891. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26893. return
  26894. }
  26895. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26896. userJSONBytes, _ := json.Marshal(respJSON)
  26897. fmt.Println("log")
  26898. fmt.Println(string(userJSONBytes))
  26899. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26900. utils.ErrorLog("解析失败:%v", err)
  26901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26902. return
  26903. }
  26904. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26905. bytesData, _ := json.Marshal(data)
  26906. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  26907. resp, _ := client.Do(req)
  26908. defer resp.Body.Close()
  26909. body, ioErr := ioutil.ReadAll(resp.Body)
  26910. if ioErr != nil {
  26911. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26913. return
  26914. }
  26915. var respJSON map[string]interface{}
  26916. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26917. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26919. return
  26920. }
  26921. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26922. userJSONBytes, _ := json.Marshal(respJSON)
  26923. fmt.Println("log")
  26924. fmt.Println(string(userJSONBytes))
  26925. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26926. utils.ErrorLog("解析失败:%v", err)
  26927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26928. return
  26929. }
  26930. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  26931. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  26932. var result3101 Result3101
  26933. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  26934. result3101.Infcode = "0"
  26935. if result3101.Infcode == "0" {
  26936. if len(result3101.Output.Result) > 0 {
  26937. var errMsgs []string
  26938. for _, item := range result3101.Output.Result {
  26939. errMsgs = append(errMsgs, item.VolaCont)
  26940. }
  26941. c.ServeSuccessJSON(map[string]interface{}{
  26942. "failed_code": -10,
  26943. "msg": errMsgs,
  26944. })
  26945. return
  26946. }
  26947. }
  26948. bytesData, _ := json.Marshal(data)
  26949. var req *http.Request
  26950. if miConfig.MdtrtareaAdmvs == "320830" {
  26951. data["diag_code"] = sickConfig.CountryCode
  26952. fmt.Println(data)
  26953. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2204", bytes.NewReader(bytesData))
  26954. } else if miConfig.MdtrtareaAdmvs == "320921" {
  26955. data["diag_code"] = sickConfig.CountryCode
  26956. fmt.Println(data)
  26957. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26958. } else {
  26959. data["diag_code"] = sickConfig.CountryCode
  26960. fmt.Println(data)
  26961. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26962. }
  26963. resp, _ := client.Do(req)
  26964. defer resp.Body.Close()
  26965. body, ioErr := ioutil.ReadAll(resp.Body)
  26966. if ioErr != nil {
  26967. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26969. return
  26970. }
  26971. var respJSON map[string]interface{}
  26972. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  26973. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26975. return
  26976. }
  26977. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26978. userJSONBytes, _ := json.Marshal(respJSON)
  26979. fmt.Println("log")
  26980. fmt.Println(string(userJSONBytes))
  26981. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  26982. utils.ErrorLog("解析失败:%v", err)
  26983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26984. return
  26985. }
  26986. res.InfRefmsgid = resFour10265.InfRefmsgid
  26987. res.Output = resFour10265.Output
  26988. res.ErrMsg = resFour10265.ErrMsg
  26989. res.Cainfo = resFour10265.Cainfo
  26990. res.WarnMsg = resFour10265.WarnMsg
  26991. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  26992. res.Infcode = infocode
  26993. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26994. var pagesize int = 2
  26995. var start int = 1
  26996. var stop int
  26997. var pagecount int
  26998. var curpage int
  26999. var isSuccess bool = true
  27000. data["doctor_id"] = doctor_info.DoctorNumber
  27001. //总页数,向上取整,注意除之前要先转换类型为float64
  27002. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  27003. for curpage = 1; curpage <= pagecount; curpage++ {
  27004. if curpage == 1 {
  27005. start = 1
  27006. } else {
  27007. start = (curpage-1)*pagesize + 1
  27008. }
  27009. stop = curpage * pagesize
  27010. if stop > len(prescriptions) {
  27011. stop = len(prescriptions)
  27012. }
  27013. //var requestLog string
  27014. data["pre"] = prescriptions[start-1 : stop]
  27015. fmt.Println(data["pre"])
  27016. bytesData, _ := json.Marshal(data)
  27017. var req *http.Request
  27018. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  27019. resp, _ := client.Do(req)
  27020. defer resp.Body.Close()
  27021. body, ioErr := ioutil.ReadAll(resp.Body)
  27022. if ioErr != nil {
  27023. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27025. return
  27026. }
  27027. var respJSON map[string]interface{}
  27028. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27029. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27031. return
  27032. }
  27033. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27034. userJSONBytes, _ := json.Marshal(respJSON)
  27035. fmt.Println("log")
  27036. fmt.Println(string(userJSONBytes))
  27037. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27038. utils.ErrorLog("解析失败:%v", err)
  27039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27040. return
  27041. }
  27042. res.InfRefmsgid = resFour10265.InfRefmsgid
  27043. res.Output = resFour10265.Output
  27044. res.ErrMsg = resFour10265.ErrMsg
  27045. res.Cainfo = resFour10265.Cainfo
  27046. res.WarnMsg = resFour10265.WarnMsg
  27047. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27048. res.Infcode = infocode
  27049. if infocode == 0 {
  27050. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  27051. } else {
  27052. isSuccess = false
  27053. errlog := &models.HisOrderError{
  27054. UserOrgId: adminUser.CurrentOrgId,
  27055. Ctime: time.Now().Unix(),
  27056. Mtime: time.Now().Unix(),
  27057. Number: chrg_bchno,
  27058. ErrMsg: "",
  27059. Status: 1,
  27060. PatientId: id,
  27061. RecordTime: recordDateTime,
  27062. Stage: 4,
  27063. }
  27064. service.CreateErrMsgLog(errlog)
  27065. c.ServeSuccessJSON(map[string]interface{}{
  27066. "failed_code": -10,
  27067. "msg": res.ErrMsg,
  27068. })
  27069. return
  27070. }
  27071. }
  27072. if isSuccess {
  27073. res.Infcode = 0
  27074. }
  27075. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27076. 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)
  27077. var dat map[string]interface{}
  27078. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27079. fmt.Println(dat)
  27080. } else {
  27081. fmt.Println(err)
  27082. }
  27083. saveLog(result, request_log, "2204", "上传费用明细")
  27084. userJSONBytes, _ := json.Marshal(dat)
  27085. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27086. utils.ErrorLog("解析失败:%v", err)
  27087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27088. return
  27089. }
  27090. res.InfRefmsgid = resFour10265.InfRefmsgid
  27091. res.Output = resFour10265.Output
  27092. res.ErrMsg = resFour10265.ErrMsg
  27093. res.Cainfo = resFour10265.Cainfo
  27094. res.WarnMsg = resFour10265.WarnMsg
  27095. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27096. res.Infcode = infocode
  27097. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27098. bytesData, _ := json.Marshal(data)
  27099. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  27100. resp, _ := client.Do(req)
  27101. defer resp.Body.Close()
  27102. body, ioErr := ioutil.ReadAll(resp.Body)
  27103. if ioErr != nil {
  27104. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27106. return
  27107. }
  27108. var respJSON map[string]interface{}
  27109. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  27110. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27112. return
  27113. }
  27114. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27115. userJSONBytes, _ := json.Marshal(respJSON)
  27116. fmt.Println("log")
  27117. fmt.Println(string(userJSONBytes))
  27118. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27119. utils.ErrorLog("解析失败:%v", err)
  27120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27121. return
  27122. }
  27123. } else {
  27124. if miConfig.Code == "H15049901371" {
  27125. 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)
  27126. var dat map[string]interface{}
  27127. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27128. fmt.Println(dat)
  27129. } else {
  27130. fmt.Println(err)
  27131. }
  27132. saveLog(result, request_log, "2204", "上传费用明细")
  27133. userJSONBytes, _ := json.Marshal(dat)
  27134. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  27135. utils.ErrorLog("解析失败:%v", err)
  27136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27137. return
  27138. }
  27139. res.InfRefmsgid = resFour10265.InfRefmsgid
  27140. res.Output = resFour10265.Output
  27141. res.ErrMsg = resFour10265.ErrMsg
  27142. res.Cainfo = resFour10265.Cainfo
  27143. res.WarnMsg = resFour10265.WarnMsg
  27144. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  27145. res.Infcode = infocode
  27146. } else {
  27147. 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)
  27148. var dat map[string]interface{}
  27149. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27150. fmt.Println(dat)
  27151. } else {
  27152. fmt.Println(err)
  27153. }
  27154. saveLog(result, request_log, "2204", "上传费用明细")
  27155. userJSONBytes, _ := json.Marshal(dat)
  27156. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27157. utils.ErrorLog("解析失败:%v", err)
  27158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27159. return
  27160. }
  27161. }
  27162. }
  27163. if res.Infcode == 0 {
  27164. order := &models.HisOrder{
  27165. UserOrgId: adminUser.CurrentOrgId,
  27166. HisPatientId: his.ID,
  27167. PatientId: his.PatientId,
  27168. SettleAccountsDate: recordDateTime,
  27169. MdtrtId: his.Number,
  27170. PsnNo: his.PsnNo,
  27171. MedType: strconv.FormatInt(reg_type, 10),
  27172. Ctime: time.Now().Unix(),
  27173. Mtime: time.Now().Unix(),
  27174. Status: 1,
  27175. Number: chrg_bchno,
  27176. Infcode: res.Infcode,
  27177. WarnMsg: res.WarnMsg,
  27178. Cainfo: res.Cainfo,
  27179. ErrMsg: res.ErrMsg,
  27180. RespondTime: res.RefmsgTime,
  27181. InfRefmsgid: res.InfRefmsgid,
  27182. OrderStatus: 1,
  27183. PayWay: pay_way,
  27184. PayWays: pay_ways,
  27185. OthDesc: oth_desc,
  27186. PayPrice: pay_price,
  27187. PayCardNo: pay_card_no,
  27188. DiscountPrice: discount_price,
  27189. PreferentialPrice: preferential_price,
  27190. RealityPrice: reality_price,
  27191. FoundPrice: found_price,
  27192. MedicalInsurancePrice: medical_insurance_price,
  27193. PrivatePrice: private_price,
  27194. IsMedicineInsurance: 1,
  27195. SettleType: settle_accounts_type,
  27196. SettleStartTime: start_time,
  27197. SettleEndTime: end_time,
  27198. Creator: roles.AdminUserId,
  27199. Modify: roles.AdminUserId,
  27200. FaPiaoNumber: fapiao_number,
  27201. FaPiaoCode: fapiao_code,
  27202. PType: 2,
  27203. Diagnosis: diagnosis_id,
  27204. CashPay: cash_pay,
  27205. WechatPay: wechat_pay,
  27206. AliPay: ali_pay,
  27207. JifenPay: jifen_pay,
  27208. BandCardPay: band_card_pay,
  27209. }
  27210. err = service.CreateOrder(order)
  27211. if err != nil {
  27212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  27213. return
  27214. }
  27215. for _, item := range res.Output.Result {
  27216. temp := strings.Split(item.FeedetlSn, "-")
  27217. var advice_id int64 = 0
  27218. var project_id int64 = 0
  27219. var types int64 = 0
  27220. id, _ := strconv.ParseInt(temp[2], 10, 64)
  27221. types, _ = strconv.ParseInt(temp[1], 10, 64)
  27222. if temp[1] == "1" {
  27223. advice_id = id
  27224. project_id = 0
  27225. } else if temp[1] == "2" {
  27226. advice_id = 0
  27227. project_id = id
  27228. }
  27229. if item.MedChrgitmType == "9" {
  27230. item.MedChrgitmType = "09"
  27231. }
  27232. info := &models.HisOrderInfo{
  27233. OrderNumber: order.Number,
  27234. FeedetlSn: item.FeedetlSn,
  27235. UploadDate: time.Now().Unix(),
  27236. AdviceId: advice_id,
  27237. DetItemFeeSumamt: item.DetItemFeeSumamt,
  27238. Cnt: item.Cnt,
  27239. Pric: float64(item.Pric),
  27240. PatientId: his.PatientId,
  27241. PricUplmtAmt: item.PricUplmtAmt,
  27242. SelfpayProp: item.SelfpayProp,
  27243. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  27244. OverlmtAmt: item.OverlmtAmt,
  27245. PreselfpayAmt: item.PreselfpayAmt,
  27246. BasMednFlag: item.BasMednFlag,
  27247. MedChrgitmType: item.MedChrgitmType,
  27248. HiNegoDrugFlag: item.HiNegoDrugFlag,
  27249. Status: 1,
  27250. Memo: item.Memo,
  27251. Mtime: time.Now().Unix(),
  27252. InscpScpAmt: item.InscpScpAmt,
  27253. DrtReimFlag: item.DrtReimFlag,
  27254. Ctime: time.Now().Unix(),
  27255. ListSpItemFlag: item.ListSpItemFlag,
  27256. ChldMedcFlag: item.ChldMedcFlag,
  27257. LmtUsedFlag: item.LmtUsedFlag,
  27258. ChrgitmLv: item.ChrgitmLv,
  27259. UserOrgId: adminUser.CurrentOrgId,
  27260. HisPatientId: his.ID,
  27261. OrderId: order.ID,
  27262. ProjectId: project_id,
  27263. Type: types,
  27264. }
  27265. service.CreateOrderInfo(info)
  27266. }
  27267. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  27268. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  27269. var total float64
  27270. for _, item := range prescriptions {
  27271. if item.Type == 1 { //药品
  27272. for _, subItem := range item.HisDoctorAdviceInfo {
  27273. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  27274. total_one := price * subItem.PrescribingNumber
  27275. total = total + total_one
  27276. }
  27277. }
  27278. if item.Type == 2 { //项目
  27279. for _, subItem := range item.HisPrescriptionProject {
  27280. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  27281. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  27282. total_one := price * cnt
  27283. total = total + total_one
  27284. }
  27285. }
  27286. }
  27287. allTotal := fmt.Sprintf("%.2f", total)
  27288. //if adminUser.CurrentOrgId == 9919 {
  27289. //
  27290. // allTotal = fmt.Sprintf("%.2f", total)
  27291. //
  27292. //} else {
  27293. //
  27294. // allTotal = fmt.Sprintf("%.2f", total)
  27295. //
  27296. //}
  27297. if res.Infcode == 0 {
  27298. var rf []*ResultFive
  27299. json.Unmarshal([]byte(his.Iinfo), &rf)
  27300. chrg_bchno := chrg_bchno
  27301. cert_no := his.Certno
  27302. var insutypes []string
  27303. var insutype string
  27304. var is390 int = 0
  27305. var is310 int = 0
  27306. for _, item := range rf {
  27307. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27308. insutypes = append(insutypes, item.Insutype)
  27309. }
  27310. }
  27311. if len(insutypes) == 1 {
  27312. insutype = insutypes[0]
  27313. } else {
  27314. for _, i := range insutypes {
  27315. if i == "390" {
  27316. is390 = 1
  27317. }
  27318. if i == "310" {
  27319. is310 = 1
  27320. }
  27321. }
  27322. }
  27323. if is390 == 1 {
  27324. insutype = "390"
  27325. }
  27326. if is310 == 1 {
  27327. insutype = "310"
  27328. }
  27329. if len(insutypes) == 0 {
  27330. insutype = "310"
  27331. }
  27332. if len(insutypes) == 2 {
  27333. insutype = strconv.FormatInt(his.SocialType, 10)
  27334. }
  27335. insutype = strconv.FormatInt(his.SocialType, 10)
  27336. //insutype = "390"
  27337. if his.IdCardType == 1 {
  27338. // cert_no = his.MedicalInsuranceNumber
  27339. cert_no = his.Certno
  27340. } else {
  27341. cert_no = his.Certno
  27342. }
  27343. var res ResultSeven
  27344. var resSeven10265 ResultSeven10265
  27345. var gzresSeven10265Two GZResultSeven10265Two
  27346. var src_resquest string
  27347. var result2 string
  27348. if miConfig.MdtrtareaAdmvs == "421300" {
  27349. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27350. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27351. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27352. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27353. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27354. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27355. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27356. resp, requestErr := http.Get(api)
  27357. if requestErr != nil {
  27358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27359. return
  27360. }
  27361. body, ioErr := ioutil.ReadAll(resp.Body)
  27362. if ioErr != nil {
  27363. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27365. return
  27366. }
  27367. var respJSON map[string]interface{}
  27368. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27369. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27371. return
  27372. }
  27373. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27374. result, _ := json.Marshal(respJSON)
  27375. if miConfig.Code == "H15049901371" {
  27376. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27377. utils.ErrorLog("解析失败:%v", err)
  27378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27379. return
  27380. }
  27381. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27382. res.Output = resSeven10265.Output
  27383. res.ErrMsg = resSeven10265.ErrMsg
  27384. res.Cainfo = resSeven10265.Cainfo
  27385. res.WarnMsg = resSeven10265.WarnMsg
  27386. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27387. res.Infcode = infocode
  27388. } else {
  27389. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27390. utils.ErrorLog("解析失败:%v", err)
  27391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27392. return
  27393. }
  27394. }
  27395. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27396. if reg_type == 11 && his.Insutype == "390" {
  27397. reg_type = 110104
  27398. }
  27399. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27400. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27401. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27402. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27403. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27404. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27405. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27406. resp, requestErr := http.Get(api)
  27407. if requestErr != nil {
  27408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27409. return
  27410. }
  27411. body, ioErr := ioutil.ReadAll(resp.Body)
  27412. if ioErr != nil {
  27413. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27415. return
  27416. }
  27417. var respJSON map[string]interface{}
  27418. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27419. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27421. return
  27422. }
  27423. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27424. result, _ := json.Marshal(respJSON)
  27425. if miConfig.Code == "H15049901371" {
  27426. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27427. utils.ErrorLog("解析失败:%v", err)
  27428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27429. return
  27430. }
  27431. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27432. res.Output = resSeven10265.Output
  27433. res.ErrMsg = resSeven10265.ErrMsg
  27434. res.Cainfo = resSeven10265.Cainfo
  27435. res.WarnMsg = resSeven10265.WarnMsg
  27436. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27437. res.Infcode = infocode
  27438. } else {
  27439. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27440. utils.ErrorLog("解析失败:%v", err)
  27441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27442. return
  27443. }
  27444. }
  27445. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27446. if reg_type == 11 && his.Insutype == "390" {
  27447. reg_type = 110104
  27448. }
  27449. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27450. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27451. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27452. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27453. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27454. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27455. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27456. resp, requestErr := http.Get(api)
  27457. if requestErr != nil {
  27458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27459. return
  27460. }
  27461. body, ioErr := ioutil.ReadAll(resp.Body)
  27462. if ioErr != nil {
  27463. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27465. return
  27466. }
  27467. var respJSON map[string]interface{}
  27468. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27469. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27471. return
  27472. }
  27473. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27474. result, _ := json.Marshal(respJSON)
  27475. if miConfig.Code == "H15049901371" {
  27476. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27477. utils.ErrorLog("解析失败:%v", err)
  27478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27479. return
  27480. }
  27481. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27482. res.Output = resSeven10265.Output
  27483. res.ErrMsg = resSeven10265.ErrMsg
  27484. res.Cainfo = resSeven10265.Cainfo
  27485. res.WarnMsg = resSeven10265.WarnMsg
  27486. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27487. res.Infcode = infocode
  27488. } else {
  27489. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27490. utils.ErrorLog("解析失败:%v", err)
  27491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27492. return
  27493. }
  27494. }
  27495. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27496. if reg_type == 11 && his.Insutype == "390" {
  27497. reg_type = 110104
  27498. }
  27499. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27500. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27501. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27502. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27503. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27504. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27505. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  27506. resp, requestErr := http.Get(api)
  27507. if requestErr != nil {
  27508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27509. return
  27510. }
  27511. body, ioErr := ioutil.ReadAll(resp.Body)
  27512. if ioErr != nil {
  27513. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27515. return
  27516. }
  27517. var respJSON map[string]interface{}
  27518. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27519. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27521. return
  27522. }
  27523. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27524. result, _ := json.Marshal(respJSON)
  27525. if miConfig.Code == "H15049901371" {
  27526. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27527. utils.ErrorLog("解析失败:%v", err)
  27528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27529. return
  27530. }
  27531. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27532. res.Output = resSeven10265.Output
  27533. res.ErrMsg = resSeven10265.ErrMsg
  27534. res.Cainfo = resSeven10265.Cainfo
  27535. res.WarnMsg = resSeven10265.WarnMsg
  27536. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27537. res.Infcode = infocode
  27538. } else {
  27539. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27540. utils.ErrorLog("解析失败:%v", err)
  27541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27542. return
  27543. }
  27544. }
  27545. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  27546. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  27547. var result3101 Result3101
  27548. //utils.ErrorLog("解析失败:%v", result3101)
  27549. result3101.Infcode = "0"
  27550. if result3101.Infcode == "0" {
  27551. if len(result3101.Output.Result) > 0 {
  27552. var errMsgs []string
  27553. for _, item := range result3101.Output.Result {
  27554. errMsgs = append(errMsgs, item.VolaCont)
  27555. }
  27556. c.ServeSuccessJSON(map[string]interface{}{
  27557. "failed_code": -10,
  27558. "msg": errMsgs,
  27559. })
  27560. return
  27561. } else {
  27562. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27563. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  27564. bas := strings.Split(psn_info.CardInfo, "|")
  27565. if his.IdCardType == 1 {
  27566. cert_no = bas[2]
  27567. } else if his.IdCardType == 3 {
  27568. cert_no = his.Certno
  27569. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  27570. } else if his.IdCardType == 4 {
  27571. cert_no = his.Certno
  27572. psn_info.VerifyNumber = psn_info.VerifyNumber
  27573. }
  27574. var api string
  27575. if miConfig.MdtrtareaAdmvs == "320830" {
  27576. api = miConfig.AppSecret + "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 if miConfig.MdtrtareaAdmvs == "320921" {
  27584. api = "http://192.168.2.3: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. } else {
  27592. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27593. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27594. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27595. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27596. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27597. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27598. "&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
  27599. }
  27600. resp, requestErr := http.Get(api)
  27601. if requestErr != nil {
  27602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27603. return
  27604. }
  27605. body, ioErr := ioutil.ReadAll(resp.Body)
  27606. if ioErr != nil {
  27607. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27609. return
  27610. }
  27611. var respJSON map[string]interface{}
  27612. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27613. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27615. return
  27616. }
  27617. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27618. result, _ := json.Marshal(respJSON)
  27619. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27620. utils.ErrorLog("解析失败:%v", err)
  27621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27622. return
  27623. }
  27624. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27625. res.Output = resSeven10265.Output
  27626. res.ErrMsg = resSeven10265.ErrMsg
  27627. res.Cainfo = resSeven10265.Cainfo
  27628. res.WarnMsg = resSeven10265.WarnMsg
  27629. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27630. res.Infcode = infocode
  27631. }
  27632. }
  27633. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27634. psn_info, _ := service.GetPsnByPatientId(id)
  27635. var verify_number string
  27636. if psn_info.IdCardType == 4 {
  27637. verify_number = psn_info.VerifyNumber
  27638. } else if psn_info.IdCardType == 1 {
  27639. bas := strings.Split(psn_info.CardInfo, "|")
  27640. cardNumber := bas[2]
  27641. verify_number = cardNumber
  27642. } else {
  27643. psn_info.IdCardType = 2
  27644. verify_number = psn_info.Certno
  27645. }
  27646. var api string
  27647. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  27648. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  27649. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27650. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27651. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  27652. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  27653. "&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
  27654. resp, requestErr := http.Get(api)
  27655. if requestErr != nil {
  27656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27657. return
  27658. }
  27659. body, ioErr := ioutil.ReadAll(resp.Body)
  27660. if ioErr != nil {
  27661. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27663. return
  27664. }
  27665. var respJSON map[string]interface{}
  27666. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27669. return
  27670. }
  27671. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27672. result, _ := json.Marshal(respJSON)
  27673. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  27674. utils.ErrorLog("解析失败:%v", err)
  27675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27676. return
  27677. }
  27678. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27679. res.Output = resSeven10265.Output
  27680. res.ErrMsg = resSeven10265.ErrMsg
  27681. res.Cainfo = resSeven10265.Cainfo
  27682. res.WarnMsg = resSeven10265.WarnMsg
  27683. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27684. res.Infcode = infocode
  27685. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27686. var cert_no string
  27687. if his.IdCardType == 4 {
  27688. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27689. cert_no = psn_info.VerifyNumber
  27690. 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)
  27691. } else if his.IdCardType == 1 {
  27692. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27693. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  27694. 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)
  27695. }
  27696. //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)
  27697. var dat map[string]interface{}
  27698. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27699. fmt.Println(dat)
  27700. } else {
  27701. fmt.Println(err)
  27702. }
  27703. saveLog(result2, src_resquest, "2207", "结算")
  27704. userJSONBytes, _ := json.Marshal(dat)
  27705. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27706. utils.ErrorLog("解析失败:%v", err)
  27707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27708. return
  27709. }
  27710. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27711. res.Output = resSeven10265.Output
  27712. res.ErrMsg = resSeven10265.ErrMsg
  27713. res.Cainfo = resSeven10265.Cainfo
  27714. res.WarnMsg = resSeven10265.WarnMsg
  27715. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27716. res.Infcode = infocode
  27717. } else if miConfig.MdtrtareaAdmvs == "450721" {
  27718. res2 := c.GetoleInfo()
  27719. if res2.Infcode == 0 {
  27720. var result string
  27721. var request_log string
  27722. var result_log string
  27723. if res2.Output.MdtrtCertType == "02" {
  27724. 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)
  27725. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27726. } else if res2.Output.MdtrtCertType == "01" {
  27727. 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)
  27728. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27729. } else {
  27730. 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)
  27731. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  27732. }
  27733. var dat map[string]interface{}
  27734. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27735. fmt.Println(dat)
  27736. } else {
  27737. fmt.Println(err)
  27738. }
  27739. userJSONBytes, _ := json.Marshal(dat)
  27740. var res5 ResultTwo
  27741. //var resTwo10265 ResultTwo10265
  27742. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  27743. utils.ErrorLog("解析失败:%v", err)
  27744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27745. return
  27746. }
  27747. if res5.Infcode == -1 {
  27748. c.ServeSuccessJSON(map[string]interface{}{
  27749. "failed_code": -10,
  27750. "msg": res5.ErrMsg,
  27751. })
  27752. return
  27753. }
  27754. var insutypes []string
  27755. var insutype string
  27756. var is390 int = 0
  27757. var is310 int = 0
  27758. for _, item := range res5.Output.Iinfo {
  27759. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27760. insutypes = append(insutypes, item.Insutype)
  27761. }
  27762. }
  27763. if len(insutypes) == 1 {
  27764. insutype = insutypes[0]
  27765. } else {
  27766. for _, i := range insutypes {
  27767. if i == "390" {
  27768. is390 = 1
  27769. }
  27770. if i == "310" {
  27771. is310 = 1
  27772. }
  27773. }
  27774. }
  27775. if is390 == 1 {
  27776. insutype = "390"
  27777. }
  27778. if is310 == 1 {
  27779. insutype = "310"
  27780. }
  27781. if len(insutypes) == 0 {
  27782. insutype = "310"
  27783. }
  27784. fmt.Println(insutype)
  27785. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  27786. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  27787. infoStr := string(Iinfos)
  27788. idetinfoStr := string(Idetinfos)
  27789. psn := &models.HisPsn{
  27790. PsnNo: res5.Output.Baseinfo.PsnNo,
  27791. PatientId: id,
  27792. Certno: res5.Output.Baseinfo.Certno,
  27793. Gend: res5.Output.Baseinfo.Gend,
  27794. Naty: res5.Output.Baseinfo.Naty,
  27795. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  27796. PsnName: res5.Output.Baseinfo.PsnName,
  27797. Idetinfo: idetinfoStr,
  27798. Insuinfo: infoStr,
  27799. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  27800. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  27801. VerifyNumber: res2.Output.EcToken,
  27802. }
  27803. if res2.Output.MdtrtCertType == "01" {
  27804. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27805. psn.VerifyNumber = res2.Output.EcToken
  27806. } else if res2.Output.MdtrtCertType == "02" {
  27807. psn.VerifyNumber = res2.Output.CardNo
  27808. } else {
  27809. psn.VerifyNumber = res2.Output.MdtrtCertNo
  27810. }
  27811. service.CreateHisPsn(psn)
  27812. if res2.Output.MdtrtCertType == "01" {
  27813. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27814. token := res2.Output.EcToken
  27815. 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)
  27816. } else if res2.Output.MdtrtCertType == "02" {
  27817. 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)
  27818. } else {
  27819. 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)
  27820. }
  27821. var dat2 map[string]interface{}
  27822. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  27823. fmt.Println(dat2)
  27824. } else {
  27825. fmt.Println(err)
  27826. }
  27827. userJSONBytes3, _ := json.Marshal(dat2)
  27828. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  27829. utils.ErrorLog("解析失败:%v", err)
  27830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27831. return
  27832. }
  27833. saveLog(result2, src_resquest, "2207", "结算")
  27834. } else {
  27835. c.ServeSuccessJSON(map[string]interface{}{
  27836. "failed_code": -10,
  27837. "msg": res2.ErrMsg,
  27838. })
  27839. return
  27840. }
  27841. } else {
  27842. if miConfig.Code == "H15049901371" {
  27843. //赤峰地区国家医保医疗类别
  27844. //职工透析:医疗类别选特殊情况门诊990502
  27845. //居民定额血透门慢: 医疗类别选门诊慢病140104
  27846. var med_type string
  27847. if his.Insutype == "390" {
  27848. if reg_type == 14 {
  27849. med_type = "9933"
  27850. } else if reg_type == 11 {
  27851. med_type = "11"
  27852. }
  27853. } else if his.Insutype == "310" {
  27854. if reg_type == 14 {
  27855. med_type = "990502"
  27856. } else if reg_type == 11 {
  27857. med_type = "11"
  27858. }
  27859. }
  27860. 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)
  27861. } else {
  27862. if his.IdCardType == 4 {
  27863. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27864. var token string
  27865. token = psn_info.VerifyNumber
  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, token, admin_user_id)
  27867. } else {
  27868. if his.IdCardType == 1 {
  27869. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  27870. bas := strings.Split(psn_info.CardInfo, "|")
  27871. basNumber := bas[2]
  27872. cert_no = basNumber
  27873. }
  27874. 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)
  27875. }
  27876. }
  27877. //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)
  27878. var dat map[string]interface{}
  27879. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27880. fmt.Println(dat)
  27881. } else {
  27882. fmt.Println(err)
  27883. }
  27884. saveLog(result2, src_resquest, "2207", "结算")
  27885. userJSONBytes, _ := json.Marshal(dat)
  27886. if miConfig.Code == "H15049901371" {
  27887. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  27888. utils.ErrorLog("解析失败:%v", err)
  27889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27890. return
  27891. }
  27892. res.InfRefmsgid = resSeven10265.InfRefmsgid
  27893. res.Output = resSeven10265.Output
  27894. res.ErrMsg = resSeven10265.ErrMsg
  27895. res.Cainfo = resSeven10265.Cainfo
  27896. res.WarnMsg = resSeven10265.WarnMsg
  27897. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  27898. res.Infcode = infocode
  27899. } else {
  27900. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  27901. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  27902. utils.ErrorLog("解析失败:%v", err)
  27903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27904. return
  27905. }
  27906. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  27907. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  27908. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  27909. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27910. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  27911. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  27912. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  27913. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27914. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  27915. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27916. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27917. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27918. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27919. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  27920. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  27921. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  27922. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  27923. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  27924. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  27925. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  27926. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27927. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  27928. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  27929. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  27930. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  27931. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  27932. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  27933. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  27934. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  27935. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  27936. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  27937. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  27938. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  27939. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  27940. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  27941. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  27942. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  27943. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  27944. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  27945. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  27946. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  27947. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  27948. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  27949. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  27950. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  27951. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  27952. res.ErrMsg = gzresSeven10265Two.ErrMsg
  27953. res.Cainfo = gzresSeven10265Two.Cainfo
  27954. res.WarnMsg = gzresSeven10265Two.WarnMsg
  27955. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  27956. //res.Infcode = infocode
  27957. } else {
  27958. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27959. utils.ErrorLog("解析失败:%v", err)
  27960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27961. return
  27962. }
  27963. }
  27964. }
  27965. }
  27966. if res.Infcode == -1 {
  27967. errlog := &models.HisOrderError{
  27968. UserOrgId: adminUser.CurrentOrgId,
  27969. Ctime: time.Now().Unix(),
  27970. Mtime: time.Now().Unix(),
  27971. Number: chrg_bchno,
  27972. ErrMsg: res.ErrMsg,
  27973. Status: 1,
  27974. PatientId: id,
  27975. RecordTime: recordDateTime,
  27976. Stage: 6,
  27977. }
  27978. service.CreateErrMsgLog(errlog)
  27979. c.ServeSuccessJSON(map[string]interface{}{
  27980. "failed_code": -10,
  27981. "msg": res.ErrMsg,
  27982. })
  27983. return
  27984. } else {
  27985. sickConfig, _ := service.FindSickById(his.SickType)
  27986. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  27987. order.OrderStatus = 2
  27988. order.Status = 1
  27989. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  27990. order.SetlId = res.Output.Setlinfo.SetlID
  27991. order.PsnNo = res.Output.Setlinfo.PsnNo
  27992. order.PsnName = res.Output.Setlinfo.PsnName
  27993. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  27994. order.Certno = res.Output.Setlinfo.Certno
  27995. order.Gend = res.Output.Setlinfo.Gend
  27996. order.Naty = res.Output.Setlinfo.Naty
  27997. order.Age = res.Output.Setlinfo.Age
  27998. order.Insutype = res.Output.Setlinfo.Insutype
  27999. order.PsnType = res.Output.Setlinfo.PsnType
  28000. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  28001. order.SetlTime = res.Output.Setlinfo.SetlTime
  28002. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  28003. if res.Output.Setlinfo.MedType == "140101" {
  28004. order.MedType = "14"
  28005. } else {
  28006. if res.Output.Setlinfo.MedType == "110104" {
  28007. order.MedType = "11"
  28008. } else {
  28009. order.MedType = res.Output.Setlinfo.MedType
  28010. }
  28011. }
  28012. if reg_type == 1112 {
  28013. order.MedType = "1112"
  28014. }
  28015. if reg_type == 1111 {
  28016. order.MedType = "1111"
  28017. }
  28018. order.ClrType = res.Output.Setlinfo.ClrType
  28019. if adminUser.CurrentOrgId == 10480 {
  28020. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  28021. order.ClrType = "11"
  28022. } else {
  28023. order.ClrType = "9903"
  28024. }
  28025. }
  28026. if adminUser.CurrentOrgId == 10721 {
  28027. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  28028. order.ClrType = "11"
  28029. } else {
  28030. order.ClrType = "9903"
  28031. }
  28032. }
  28033. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  28034. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  28035. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  28036. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  28037. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  28038. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  28039. order.HifpPay = res.Output.Setlinfo.HifpPay
  28040. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  28041. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  28042. order.HifesPay = res.Output.Setlinfo.HifesPay
  28043. order.HifobPay = res.Output.Setlinfo.HifobPay
  28044. order.MafPay = res.Output.Setlinfo.MafPay
  28045. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  28046. order.OthPay = res.Output.Setlinfo.OthPay
  28047. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  28048. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  28049. order.AcctPay = res.Output.Setlinfo.AcctPay
  28050. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  28051. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  28052. order.Balc = res.Output.Setlinfo.Balc
  28053. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  28054. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  28055. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  28056. //order.ClrType = res.Output.Setlinfo.ClrType
  28057. order.ClrWay = res.Output.Setlinfo.ClrWay
  28058. order.Creator = order.Creator
  28059. order.Modify = roles.AdminUserId
  28060. order.RequestLog = src_resquest
  28061. order.FaPiaoNumber = fapiao_number
  28062. order.FaPiaoCode = fapiao_code
  28063. order.SickName = sickConfig.ClassName
  28064. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  28065. //detailStr := string(setlDetail)
  28066. //order.SetlDetail = detailStr
  28067. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  28068. err = service.UpDateOrder(order)
  28069. if err == nil {
  28070. //判断是否使用了押金
  28071. if dec_way == "true" {
  28072. tmpstring := strconv.FormatInt(order.ID, 10)
  28073. order.Decimal = decimal
  28074. service.UpDateOrder(order)
  28075. //扣押金
  28076. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  28077. if errmsg != nil {
  28078. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  28079. return
  28080. }
  28081. }
  28082. c.ServeSuccessJSON(map[string]interface{}{
  28083. "msg": "结算成功",
  28084. })
  28085. } else {
  28086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  28087. return
  28088. }
  28089. }
  28090. } else {
  28091. adminUser := c.GetAdminUserInfo()
  28092. errlog := &models.HisOrderError{
  28093. UserOrgId: adminUser.CurrentOrgId,
  28094. Ctime: time.Now().Unix(),
  28095. Mtime: time.Now().Unix(),
  28096. ErrMsg: res.ErrMsg,
  28097. Status: 1,
  28098. PatientId: id,
  28099. RecordTime: recordDateTime,
  28100. Stage: 4,
  28101. }
  28102. service.CreateErrMsgLog(errlog)
  28103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  28104. return
  28105. }
  28106. } else {
  28107. adminUser := c.GetAdminUserInfo()
  28108. errlog := &models.HisOrderError{
  28109. UserOrgId: adminUser.CurrentOrgId,
  28110. Ctime: time.Now().Unix(),
  28111. Mtime: time.Now().Unix(),
  28112. ErrMsg: res.ErrMsg,
  28113. Status: 1,
  28114. PatientId: id,
  28115. RecordTime: recordDateTime,
  28116. Stage: 4,
  28117. }
  28118. service.CreateErrMsgLog(errlog)
  28119. c.ServeSuccessJSON(map[string]interface{}{
  28120. "failed_code": -10,
  28121. "msg": res.ErrMsg,
  28122. })
  28123. return
  28124. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  28125. //return
  28126. }
  28127. }
  28128. }
  28129. } else if tempOrder.ID > 0 {
  28130. if tempOrder.IsPre == 1 {
  28131. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  28132. var rf []*ResultFive
  28133. json.Unmarshal([]byte(his.Iinfo), &rf)
  28134. chrg_bchno := tempOrder.Number
  28135. cert_no := his.Certno
  28136. var insutypes []string
  28137. var insutype string
  28138. var is390 int = 0
  28139. var is310 int = 0
  28140. for _, item := range rf {
  28141. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28142. insutypes = append(insutypes, item.Insutype)
  28143. }
  28144. }
  28145. if len(insutypes) == 1 {
  28146. insutype = insutypes[0]
  28147. } else {
  28148. for _, i := range insutypes {
  28149. if i == "390" {
  28150. is390 = 1
  28151. }
  28152. if i == "310" {
  28153. is310 = 1
  28154. }
  28155. }
  28156. }
  28157. if is390 == 1 {
  28158. insutype = "390"
  28159. }
  28160. if is310 == 1 {
  28161. insutype = "310"
  28162. }
  28163. if len(insutypes) == 0 {
  28164. insutype = "310"
  28165. }
  28166. if len(insutypes) == 2 {
  28167. insutype = strconv.FormatInt(his.SocialType, 10)
  28168. }
  28169. //insutype = "390"
  28170. if his.IdCardType == 1 {
  28171. // cert_no = his.MedicalInsuranceNumber
  28172. cert_no = his.Certno
  28173. } else {
  28174. cert_no = his.Certno
  28175. }
  28176. var res ResultSeven
  28177. var ahres ResultSevenAH
  28178. var resSeven10265 ResultSeven10265
  28179. var gzresSeven10265Two GZResultSeven10265Two
  28180. var src_resquest string
  28181. var result2 string
  28182. if miConfig.MdtrtareaAdmvs == "450721" {
  28183. res2 := c.GetoleInfo()
  28184. if res2.Infcode == 0 {
  28185. var result string
  28186. var request_log string
  28187. var result_log string
  28188. if res2.Output.MdtrtCertType == "02" {
  28189. 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)
  28190. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  28191. } else if res2.Output.MdtrtCertType == "01" {
  28192. 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)
  28193. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  28194. } else {
  28195. 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)
  28196. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  28197. }
  28198. var dat map[string]interface{}
  28199. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28200. fmt.Println(dat)
  28201. } else {
  28202. fmt.Println(err)
  28203. }
  28204. userJSONBytes, _ := json.Marshal(dat)
  28205. var res5 ResultTwo
  28206. //var resTwo10265 ResultTwo10265
  28207. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  28208. utils.ErrorLog("解析失败:%v", err)
  28209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28210. return
  28211. }
  28212. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  28213. if res5.Infcode == -1 {
  28214. c.ServeSuccessJSON(map[string]interface{}{
  28215. "failed_code": -10,
  28216. "msg": res5.ErrMsg,
  28217. })
  28218. return
  28219. }
  28220. var insutypes []string
  28221. var insutype string
  28222. var is390 int = 0
  28223. var is310 int = 0
  28224. for _, item := range res5.Output.Iinfo {
  28225. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28226. insutypes = append(insutypes, item.Insutype)
  28227. }
  28228. }
  28229. if len(insutypes) == 1 {
  28230. insutype = insutypes[0]
  28231. } else {
  28232. for _, i := range insutypes {
  28233. if i == "390" {
  28234. is390 = 1
  28235. }
  28236. if i == "310" {
  28237. is310 = 1
  28238. }
  28239. }
  28240. }
  28241. if is390 == 1 {
  28242. insutype = "390"
  28243. }
  28244. if is310 == 1 {
  28245. insutype = "310"
  28246. }
  28247. if len(insutypes) == 0 {
  28248. insutype = "310"
  28249. }
  28250. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  28251. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  28252. infoStr := string(Iinfos)
  28253. idetinfoStr := string(Idetinfos)
  28254. psn := &models.HisPsn{
  28255. PsnNo: res5.Output.Baseinfo.PsnNo,
  28256. PatientId: id,
  28257. Certno: res5.Output.Baseinfo.Certno,
  28258. Gend: res5.Output.Baseinfo.Gend,
  28259. Naty: res5.Output.Baseinfo.Naty,
  28260. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  28261. PsnName: res5.Output.Baseinfo.PsnName,
  28262. Idetinfo: idetinfoStr,
  28263. Insuinfo: infoStr,
  28264. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  28265. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  28266. VerifyNumber: res2.Output.EcToken,
  28267. }
  28268. service.CreateHisPsn(psn)
  28269. if res2.Output.MdtrtCertType == "01" {
  28270. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28271. token := res2.Output.EcToken
  28272. 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)
  28273. } else if res2.Output.MdtrtCertType == "02" {
  28274. 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)
  28275. } else {
  28276. 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)
  28277. }
  28278. var dat2 map[string]interface{}
  28279. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28280. fmt.Println(dat2)
  28281. } else {
  28282. fmt.Println(err)
  28283. }
  28284. userJSONBytes3, _ := json.Marshal(dat2)
  28285. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  28286. utils.ErrorLog("解析失败:%v", err)
  28287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28288. return
  28289. }
  28290. saveLog(result2, src_resquest, "2207", "结算")
  28291. } else {
  28292. c.ServeSuccessJSON(map[string]interface{}{
  28293. "failed_code": -10,
  28294. "msg": res2.ErrMsg,
  28295. })
  28296. return
  28297. }
  28298. } else if miConfig.MdtrtareaAdmvs == "421300" {
  28299. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28300. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28301. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28302. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28303. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28304. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28305. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28306. resp, requestErr := http.Get(api)
  28307. if requestErr != nil {
  28308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28309. return
  28310. }
  28311. body, ioErr := ioutil.ReadAll(resp.Body)
  28312. if ioErr != nil {
  28313. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28315. return
  28316. }
  28317. var respJSON map[string]interface{}
  28318. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28319. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28321. return
  28322. }
  28323. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28324. result, _ := json.Marshal(respJSON)
  28325. fmt.Println("log")
  28326. fmt.Println(string(result))
  28327. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28328. utils.ErrorLog("解析失败:%v", err)
  28329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28330. return
  28331. }
  28332. } else if miConfig.MdtrtareaAdmvs == "420200" {
  28333. if reg_type == 11 && his.Insutype == "390" {
  28334. reg_type = 110104
  28335. }
  28336. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28337. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28338. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28339. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28340. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28341. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28342. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28343. resp, requestErr := http.Get(api)
  28344. if requestErr != nil {
  28345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28346. return
  28347. }
  28348. body, ioErr := ioutil.ReadAll(resp.Body)
  28349. if ioErr != nil {
  28350. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28352. return
  28353. }
  28354. var respJSON map[string]interface{}
  28355. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28356. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28358. return
  28359. }
  28360. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28361. result, _ := json.Marshal(respJSON)
  28362. fmt.Println("log")
  28363. fmt.Println(string(result))
  28364. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28365. utils.ErrorLog("解析失败:%v", err)
  28366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28367. return
  28368. }
  28369. } else if miConfig.MdtrtareaAdmvs == "420902" {
  28370. if reg_type == 11 && his.Insutype == "390" {
  28371. reg_type = 110104
  28372. }
  28373. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28374. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28375. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28376. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28377. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28378. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28379. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28380. resp, requestErr := http.Get(api)
  28381. if requestErr != nil {
  28382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28383. return
  28384. }
  28385. body, ioErr := ioutil.ReadAll(resp.Body)
  28386. if ioErr != nil {
  28387. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28389. return
  28390. }
  28391. var respJSON map[string]interface{}
  28392. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28393. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28395. return
  28396. }
  28397. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28398. result, _ := json.Marshal(respJSON)
  28399. fmt.Println("log")
  28400. fmt.Println(string(result))
  28401. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28402. utils.ErrorLog("解析失败:%v", err)
  28403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28404. return
  28405. }
  28406. } else if miConfig.MdtrtareaAdmvs == "421182" {
  28407. if reg_type == 11 && his.Insutype == "390" {
  28408. reg_type = 110104
  28409. }
  28410. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28411. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28412. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28413. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28414. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28415. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28416. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  28417. resp, requestErr := http.Get(api)
  28418. if requestErr != nil {
  28419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28420. return
  28421. }
  28422. body, ioErr := ioutil.ReadAll(resp.Body)
  28423. if ioErr != nil {
  28424. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28426. return
  28427. }
  28428. var respJSON map[string]interface{}
  28429. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28430. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28432. return
  28433. }
  28434. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28435. result, _ := json.Marshal(respJSON)
  28436. fmt.Println("log")
  28437. fmt.Println(string(result))
  28438. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28439. utils.ErrorLog("解析失败:%v", err)
  28440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28441. return
  28442. }
  28443. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  28444. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  28445. var result3101 Result3101
  28446. //utils.ErrorLog("解析失败:%v", result3101)
  28447. result3101.Infcode = "0"
  28448. if result3101.Infcode == "0" {
  28449. if len(result3101.Output.Result) > 0 {
  28450. var errMsgs []string
  28451. for _, item := range result3101.Output.Result {
  28452. errMsgs = append(errMsgs, item.VolaCont)
  28453. }
  28454. c.ServeSuccessJSON(map[string]interface{}{
  28455. "failed_code": -10,
  28456. "msg": errMsgs,
  28457. })
  28458. return
  28459. } else {
  28460. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28461. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28462. bas := strings.Split(psn_info.CardInfo, "|")
  28463. if his.IdCardType == 1 {
  28464. cert_no = bas[2]
  28465. } else if his.IdCardType == 3 {
  28466. cert_no = his.Certno
  28467. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  28468. } else if his.IdCardType == 4 {
  28469. cert_no = his.Certno
  28470. psn_info.VerifyNumber = psn_info.VerifyNumber
  28471. }
  28472. //江苏地区国家医保医疗类别
  28473. //职工透析:医疗类别选特殊情况门诊9933
  28474. //居民血透门慢: 医疗类别选门诊慢病1402
  28475. //var med_type string
  28476. //if his.Insutype == "310" {
  28477. // if reg_type == 14 {
  28478. // med_type = "9933"
  28479. // } else if reg_type == 11 {
  28480. // med_type = "11"
  28481. //
  28482. // }
  28483. //} else if his.Insutype == "390" {
  28484. // if reg_type == 14 {
  28485. // med_type = "1402"
  28486. // } else if reg_type == 11 {
  28487. // med_type = "11"
  28488. // }
  28489. //}
  28490. var api string
  28491. if miConfig.MdtrtareaAdmvs == "320830" {
  28492. api = miConfig.AppSecret + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28493. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28494. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28495. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28496. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28497. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28498. "&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
  28499. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28500. } else if miConfig.MdtrtareaAdmvs == "320921" {
  28501. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28502. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28503. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28504. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28505. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28506. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28507. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + 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
  28508. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28509. } else {
  28510. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28511. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28512. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28513. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28514. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28515. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28516. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28517. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  28518. }
  28519. resp, requestErr := http.Get(api)
  28520. if requestErr != nil {
  28521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28522. return
  28523. }
  28524. body, ioErr := ioutil.ReadAll(resp.Body)
  28525. if ioErr != nil {
  28526. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28528. return
  28529. }
  28530. var respJSON map[string]interface{}
  28531. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28532. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28534. return
  28535. }
  28536. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28537. result, _ := json.Marshal(respJSON)
  28538. fmt.Println("log")
  28539. fmt.Println(string(result))
  28540. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  28541. utils.ErrorLog("解析失败:%v", err)
  28542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28543. return
  28544. }
  28545. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28546. res.Output = resSeven10265.Output
  28547. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28548. res.ErrMsg = resSeven10265.ErrMsg
  28549. res.Cainfo = resSeven10265.Cainfo
  28550. res.WarnMsg = resSeven10265.WarnMsg
  28551. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28552. res.Infcode = infocode
  28553. }
  28554. }
  28555. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28556. psn_info, _ := service.GetPsnByPatientId(id)
  28557. var verify_number string
  28558. if psn_info.IdCardType == 4 {
  28559. verify_number = psn_info.VerifyNumber
  28560. } else if psn_info.IdCardType == 1 {
  28561. bas := strings.Split(psn_info.CardInfo, "|")
  28562. cardNumber := bas[2]
  28563. verify_number = cardNumber
  28564. } else {
  28565. verify_number = psn_info.Certno
  28566. psn_info.IdCardType = 2
  28567. }
  28568. var api string
  28569. new_chrg_bchno := chrg_bchno
  28570. if adminUser.CurrentOrgId == 10265 {
  28571. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  28572. new_chrg_bchno = "0000"
  28573. }
  28574. }
  28575. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28576. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  28577. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28578. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28579. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  28580. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28581. "&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
  28582. resp, requestErr := http.Get(api)
  28583. if requestErr != nil {
  28584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28585. return
  28586. }
  28587. body, ioErr := ioutil.ReadAll(resp.Body)
  28588. if ioErr != nil {
  28589. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28591. return
  28592. }
  28593. var respJSON map[string]interface{}
  28594. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28595. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28597. return
  28598. }
  28599. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28600. result, _ := json.Marshal(respJSON)
  28601. fmt.Println("log")
  28602. fmt.Println(string(result))
  28603. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  28604. utils.ErrorLog("解析失败:%v", err)
  28605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28606. return
  28607. }
  28608. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28609. res.Output = resSeven10265.Output
  28610. res.InfRefmsgid = resSeven10265.InfRefmsgid
  28611. res.ErrMsg = resSeven10265.ErrMsg
  28612. res.Cainfo = resSeven10265.Cainfo
  28613. res.WarnMsg = resSeven10265.WarnMsg
  28614. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  28615. res.Infcode = infocode
  28616. } else if miConfig.MdtrtareaAdmvs == "350500" {
  28617. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28618. var cert_no string
  28619. if his.IdCardType == 1 {
  28620. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28621. } else {
  28622. cert_no = psn_info.VerifyNumber
  28623. }
  28624. 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)
  28625. var dat map[string]interface{}
  28626. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28627. fmt.Println(dat)
  28628. } else {
  28629. fmt.Println(err)
  28630. }
  28631. saveLog(result2, src_resquest, "2207", "结算")
  28632. userJSONBytes, _ := json.Marshal(dat)
  28633. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28634. utils.ErrorLog("解析失败:%v", err)
  28635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28636. return
  28637. }
  28638. } else if miConfig.MdtrtareaAdmvs == "360302" {
  28639. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28640. var cert_no string
  28641. var card_sn string
  28642. if his.IdCardType == 1 {
  28643. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28644. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28645. bas := strings.Split(psn_info.CardInfo, "|")
  28646. card_sn = bas[3]
  28647. } else if his.IdCardType == 2 {
  28648. cert_no = his.IdCardNo
  28649. } else {
  28650. cert_no = psn_info.VerifyNumber
  28651. }
  28652. var rf []*ResultFive
  28653. json.Unmarshal([]byte(his.Iinfo), &rf)
  28654. var psn_type string
  28655. for _, item := range rf {
  28656. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28657. psn_type = item.PsnType
  28658. }
  28659. }
  28660. 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)
  28661. var dat map[string]interface{}
  28662. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28663. fmt.Println(dat)
  28664. } else {
  28665. fmt.Println(err)
  28666. }
  28667. saveLog(result2, src_resquest, "2207", "结算")
  28668. userJSONBytes, _ := json.Marshal(dat)
  28669. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28670. utils.ErrorLog("解析失败:%v", err)
  28671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28672. return
  28673. }
  28674. } else if miConfig.MdtrtareaAdmvs == "361025" {
  28675. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28676. var cert_no string
  28677. var card_sn string
  28678. if his.IdCardType == 1 {
  28679. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28680. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28681. //bas := strings.Split(psn_info.CardInfo, "|")
  28682. card_sn = ""
  28683. } else if his.IdCardType == 2 {
  28684. cert_no = his.IdCardNo
  28685. } else {
  28686. cert_no = psn_info.VerifyNumber
  28687. }
  28688. var rf []*ResultFive
  28689. json.Unmarshal([]byte(his.Iinfo), &rf)
  28690. var psn_type string
  28691. for _, item := range rf {
  28692. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28693. psn_type = item.PsnType
  28694. }
  28695. }
  28696. 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)
  28697. var dat map[string]interface{}
  28698. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28699. fmt.Println(dat)
  28700. } else {
  28701. fmt.Println(err)
  28702. }
  28703. saveLog(result2, src_resquest, "2207", "结算")
  28704. userJSONBytes, _ := json.Marshal(dat)
  28705. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28706. utils.ErrorLog("解析失败:%v", err)
  28707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28708. return
  28709. }
  28710. } else if miConfig.MdtrtareaAdmvs == "360100" {
  28711. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28712. var cert_no string
  28713. var card_sn string
  28714. if his.IdCardType == 1 {
  28715. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  28716. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28717. //bas := strings.Split(psn_info.CardInfo, "|")
  28718. card_sn = ""
  28719. } else if his.IdCardType == 2 {
  28720. cert_no = his.IdCardNo
  28721. } else {
  28722. cert_no = psn_info.VerifyNumber
  28723. }
  28724. var rf []*ResultFive
  28725. json.Unmarshal([]byte(his.Iinfo), &rf)
  28726. var psn_type string
  28727. for _, item := range rf {
  28728. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  28729. psn_type = item.PsnType
  28730. }
  28731. }
  28732. 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)
  28733. var dat map[string]interface{}
  28734. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28735. fmt.Println(dat)
  28736. } else {
  28737. fmt.Println(err)
  28738. }
  28739. saveLog(result2, src_resquest, "2207", "结算")
  28740. userJSONBytes, _ := json.Marshal(dat)
  28741. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28742. utils.ErrorLog("解析失败:%v", err)
  28743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28744. return
  28745. }
  28746. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28747. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28748. if his.IdCardType == 1 {
  28749. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28750. bas := strings.Split(psn_info.CardInfo, "|")
  28751. cert_no = bas[2]
  28752. } else if his.IdCardType == 3 {
  28753. cert_no = his.Certno
  28754. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  28755. } else if his.IdCardType == 4 {
  28756. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28757. cert_no = psn_info.VerifyNumber
  28758. psn_info.VerifyNumber = psn_info.VerifyNumber
  28759. } else {
  28760. cert_no = his.Certno
  28761. psn_info.VerifyNumber = his.Certno
  28762. }
  28763. var api string
  28764. var med_type string
  28765. if his.Insutype == "390" {
  28766. if reg_type == 992102 {
  28767. med_type = "992102"
  28768. }
  28769. if reg_type == 1104 {
  28770. med_type = "1104"
  28771. }
  28772. if reg_type == 1104 {
  28773. med_type = "1104"
  28774. }
  28775. if reg_type == 140104 {
  28776. med_type = "140104"
  28777. }
  28778. if reg_type == 140201 {
  28779. med_type = "140201"
  28780. }
  28781. if reg_type == 14 {
  28782. med_type = "14"
  28783. }
  28784. } else if his.Insutype == "310" {
  28785. if reg_type == 1104 {
  28786. med_type = "1104"
  28787. }
  28788. if reg_type == 992102 {
  28789. med_type = "992102"
  28790. }
  28791. if reg_type == 140104 {
  28792. med_type = "140104"
  28793. }
  28794. if reg_type == 140201 {
  28795. med_type = "140201"
  28796. }
  28797. if reg_type == 14 {
  28798. med_type = "14"
  28799. }
  28800. }
  28801. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28802. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28803. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28804. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28805. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28806. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28807. "&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
  28808. resp, requestErr := http.Get(api)
  28809. if requestErr != nil {
  28810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28811. return
  28812. }
  28813. body, ioErr := ioutil.ReadAll(resp.Body)
  28814. if ioErr != nil {
  28815. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28817. return
  28818. }
  28819. var respJSON map[string]interface{}
  28820. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28821. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28823. return
  28824. }
  28825. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28826. if status == "0" {
  28827. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28828. c.ServeSuccessJSON(map[string]interface{}{
  28829. "failed_code": -10,
  28830. "msg": err_msg,
  28831. })
  28832. return
  28833. }
  28834. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28835. result, _ := json.Marshal(respJSON)
  28836. fmt.Println("log")
  28837. fmt.Println(string(result))
  28838. if err := json.Unmarshal(result, &ahres); err != nil {
  28839. utils.ErrorLog("解析失败:%v", err)
  28840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28841. return
  28842. }
  28843. res.InfRefmsgid = ahres.InfRefmsgid
  28844. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  28845. // 创建对应的Time类型
  28846. t := time.UnixMilli(timestamp)
  28847. // 格式化成指定的日期字符串
  28848. str := t.Format("2006-01-02 15:04:05")
  28849. res.Output.Setlinfo.SetlTime = str
  28850. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  28851. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  28852. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28853. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  28854. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  28855. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  28856. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28857. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  28858. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  28859. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  28860. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  28861. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  28862. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  28863. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  28864. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  28865. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  28866. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  28867. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  28868. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28869. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  28870. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  28871. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  28872. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  28873. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  28874. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  28875. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  28876. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  28877. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  28878. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  28879. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  28880. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  28881. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  28882. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  28883. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  28884. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  28885. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  28886. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  28887. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  28888. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  28889. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  28890. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  28891. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  28892. res.Output.Setldetail = ahres.Output.Setldetail
  28893. res.ErrMsg = ahres.ErrMsg
  28894. res.Cainfo = ahres.Cainfo
  28895. res.WarnMsg = ahres.WarnMsg
  28896. res.Infcode = ahres.Infcode
  28897. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  28898. res.Output.Setlinfo.ClrType = "11"
  28899. } else {
  28900. res.Output.Setlinfo.ClrType = "9903"
  28901. }
  28902. } else if miConfig.MdtrtareaAdmvs == "340699" {
  28903. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  28904. if his.IdCardType == 1 {
  28905. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28906. bas := strings.Split(psn_info.CardInfo, "|")
  28907. cert_no = bas[2]
  28908. } else if his.IdCardType == 3 {
  28909. cert_no = his.Certno
  28910. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  28911. } else if his.IdCardType == 4 {
  28912. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  28913. cert_no = his.Certno
  28914. psn_info.VerifyNumber = psn_info.VerifyNumber
  28915. } else {
  28916. cert_no = his.Certno
  28917. psn_info.VerifyNumber = his.Certno
  28918. }
  28919. var api string
  28920. var med_type string
  28921. if his.Insutype == "390" {
  28922. if reg_type == 1104 {
  28923. med_type = "1104"
  28924. }
  28925. if reg_type == 992102 {
  28926. med_type = "992102"
  28927. }
  28928. if reg_type == 140104 {
  28929. med_type = "140104"
  28930. }
  28931. if reg_type == 14 {
  28932. med_type = "14"
  28933. }
  28934. if reg_type == 140201 {
  28935. med_type = "140201"
  28936. }
  28937. } else if his.Insutype == "310" {
  28938. if reg_type == 1104 {
  28939. med_type = "1104"
  28940. }
  28941. if reg_type == 992102 {
  28942. med_type = "992102"
  28943. }
  28944. if reg_type == 14 {
  28945. med_type = "14"
  28946. }
  28947. if reg_type == 140104 {
  28948. med_type = "140104"
  28949. }
  28950. if reg_type == 140201 {
  28951. med_type = "140201"
  28952. }
  28953. }
  28954. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  28955. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  28956. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28957. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  28958. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  28959. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  28960. "&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
  28961. resp, requestErr := http.Get(api)
  28962. if requestErr != nil {
  28963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28964. return
  28965. }
  28966. body, ioErr := ioutil.ReadAll(resp.Body)
  28967. if ioErr != nil {
  28968. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28970. return
  28971. }
  28972. var respJSON map[string]interface{}
  28973. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28974. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28976. return
  28977. }
  28978. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28979. if status == "0" {
  28980. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28981. c.ServeSuccessJSON(map[string]interface{}{
  28982. "failed_code": -10,
  28983. "msg": err_msg,
  28984. })
  28985. return
  28986. }
  28987. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28988. result, _ := json.Marshal(respJSON)
  28989. fmt.Println("log")
  28990. fmt.Println(string(result))
  28991. if err := json.Unmarshal(result, &ahres); err != nil {
  28992. utils.ErrorLog("解析失败:%v", err)
  28993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28994. return
  28995. }
  28996. res.InfRefmsgid = ahres.InfRefmsgid
  28997. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  28998. // 创建对应的Time类型
  28999. t := time.UnixMilli(timestamp)
  29000. // 格式化成指定的日期字符串
  29001. str := t.Format("2006-01-02 15:04:05")
  29002. res.Output.Setlinfo.SetlTime = str
  29003. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  29004. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  29005. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29006. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  29007. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  29008. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  29009. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  29010. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  29011. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  29012. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  29013. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  29014. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  29015. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  29016. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  29017. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  29018. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  29019. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  29020. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  29021. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29022. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  29023. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  29024. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  29025. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  29026. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  29027. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  29028. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  29029. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  29030. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  29031. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  29032. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  29033. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  29034. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  29035. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  29036. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  29037. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  29038. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  29039. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  29040. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  29041. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  29042. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  29043. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  29044. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  29045. res.Output.Setldetail = ahres.Output.Setldetail
  29046. res.ErrMsg = ahres.ErrMsg
  29047. res.Cainfo = ahres.Cainfo
  29048. res.WarnMsg = ahres.WarnMsg
  29049. res.Infcode = ahres.Infcode
  29050. if strings.Contains(his.InsuplcAdmdvs, "3406") {
  29051. res.Output.Setlinfo.ClrType = "11"
  29052. } else {
  29053. res.Output.Setlinfo.ClrType = "9903"
  29054. }
  29055. } else if miConfig.MdtrtareaAdmvs == "430800" {
  29056. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29057. var cert_no string
  29058. if his.IdCardType == 1 {
  29059. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  29060. } else if his.IdCardType == 2 {
  29061. cert_no = his.IdCardNo
  29062. } else {
  29063. cert_no = psn_info.VerifyNumber
  29064. }
  29065. 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, "")
  29066. var dat map[string]interface{}
  29067. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29068. fmt.Println(dat)
  29069. } else {
  29070. fmt.Println(err)
  29071. }
  29072. saveLog(result2, src_resquest, "2207", "结算")
  29073. userJSONBytes, _ := json.Marshal(dat)
  29074. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29075. utils.ErrorLog("解析失败:%v", err)
  29076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29077. return
  29078. }
  29079. } else if miConfig.MdtrtareaAdmvs == "441799" {
  29080. psn_info, _ := service.GetPsnByPatientId(id)
  29081. var verify_number string
  29082. if psn_info.IdCardType == 4 {
  29083. verify_number = psn_info.VerifyNumber
  29084. } else if psn_info.IdCardType == 1 {
  29085. bas := strings.Split(psn_info.CardInfo, "|")
  29086. cardNumber := bas[2]
  29087. verify_number = cardNumber
  29088. } else {
  29089. verify_number = psn_info.Certno
  29090. psn_info.IdCardType = 2
  29091. }
  29092. var api string
  29093. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  29094. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  29095. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  29096. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  29097. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  29098. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  29099. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  29100. resp, requestErr := http.Get(api)
  29101. if requestErr != nil {
  29102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29103. return
  29104. }
  29105. body, ioErr := ioutil.ReadAll(resp.Body)
  29106. if ioErr != nil {
  29107. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29109. return
  29110. }
  29111. var respJSON map[string]interface{}
  29112. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29115. return
  29116. }
  29117. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29118. result, _ := json.Marshal(respJSON)
  29119. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29120. utils.ErrorLog("解析失败:%v", err)
  29121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29122. return
  29123. }
  29124. } else {
  29125. var src_resquest string
  29126. if miConfig.Code == "H15049901371" {
  29127. //赤峰地区国家医保医疗类别
  29128. //职工透析:医疗类别选特殊情况门诊990502
  29129. //居民定额血透门慢: 医疗类别选门诊慢病140104
  29130. var med_type string
  29131. if his.Insutype == "390" {
  29132. if reg_type == 14 {
  29133. med_type = "9933"
  29134. } else if reg_type == 11 {
  29135. med_type = "11"
  29136. }
  29137. } else if his.Insutype == "310" {
  29138. if reg_type == 14 {
  29139. med_type = "990502"
  29140. } else if reg_type == 11 {
  29141. med_type = "11"
  29142. }
  29143. }
  29144. 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)
  29145. } else {
  29146. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" || miConfig.Code == "H44090200998"{
  29147. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  29148. if result3101.Infcode == 0 {
  29149. if len(result3101.Output.Result) > 0 {
  29150. c.ServeSuccessJSON(map[string]interface{}{
  29151. "failed_code": -10,
  29152. "failed_type": 100,
  29153. "warm_type": 2,
  29154. "msg": result3101,
  29155. })
  29156. return
  29157. }
  29158. } else {
  29159. c.ServeSuccessJSON(map[string]interface{}{
  29160. "failed_code": -10,
  29161. "msg": result3101.ErrMsg,
  29162. })
  29163. return
  29164. }
  29165. }
  29166. if his.IdCardType == 4 {
  29167. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  29168. token := psn_info.VerifyNumber
  29169. 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)
  29170. } else {
  29171. 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)
  29172. }
  29173. }
  29174. var dat map[string]interface{}
  29175. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29176. fmt.Println(dat)
  29177. } else {
  29178. fmt.Println(err)
  29179. }
  29180. saveLog(result2, src_resquest, "2207", "结算")
  29181. userJSONBytes, _ := json.Marshal(dat)
  29182. if miConfig.Code == "H15049901371" {
  29183. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  29184. utils.ErrorLog("解析失败:%v", err)
  29185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29186. return
  29187. }
  29188. res.InfRefmsgid = resSeven10265.InfRefmsgid
  29189. res.Output = resSeven10265.Output
  29190. res.ErrMsg = resSeven10265.ErrMsg
  29191. res.Cainfo = resSeven10265.Cainfo
  29192. res.WarnMsg = resSeven10265.WarnMsg
  29193. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  29194. res.Infcode = infocode
  29195. } else {
  29196. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  29197. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  29198. utils.ErrorLog("解析失败:%v", err)
  29199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29200. return
  29201. }
  29202. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  29203. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  29204. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  29205. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  29206. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  29207. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  29208. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  29209. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  29210. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  29211. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29212. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29213. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29214. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29215. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  29216. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  29217. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  29218. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  29219. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  29220. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  29221. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  29222. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  29223. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  29224. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  29225. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  29226. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  29227. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  29228. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  29229. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  29230. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  29231. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  29232. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  29233. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  29234. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  29235. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  29236. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  29237. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  29238. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  29239. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  29240. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  29241. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  29242. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  29243. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  29244. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  29245. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  29246. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  29247. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  29248. res.ErrMsg = gzresSeven10265Two.ErrMsg
  29249. res.Cainfo = gzresSeven10265Two.Cainfo
  29250. res.WarnMsg = gzresSeven10265Two.WarnMsg
  29251. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  29252. //res.Infcode = infocode
  29253. } else {
  29254. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29255. utils.ErrorLog("解析失败:%v", err)
  29256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29257. return
  29258. }
  29259. }
  29260. }
  29261. }
  29262. if res.Infcode != 0 {
  29263. errlog := &models.HisOrderError{
  29264. UserOrgId: adminUser.CurrentOrgId,
  29265. Ctime: time.Now().Unix(),
  29266. Mtime: time.Now().Unix(),
  29267. Number: chrg_bchno,
  29268. ErrMsg: res.ErrMsg,
  29269. Status: 1,
  29270. PatientId: id,
  29271. RecordTime: recordDateTime,
  29272. Stage: 6,
  29273. }
  29274. service.CreateErrMsgLog(errlog)
  29275. c.ServeSuccessJSON(map[string]interface{}{
  29276. "failed_code": -10,
  29277. "msg": res.ErrMsg,
  29278. })
  29279. return
  29280. } else {
  29281. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  29282. order.OrderStatus = 2
  29283. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  29284. order.SetlId = res.Output.Setlinfo.SetlID
  29285. order.PsnNo = res.Output.Setlinfo.PsnNo
  29286. order.PsnName = res.Output.Setlinfo.PsnName
  29287. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  29288. order.Certno = res.Output.Setlinfo.Certno
  29289. order.Gend = res.Output.Setlinfo.Gend
  29290. order.Naty = res.Output.Setlinfo.Naty
  29291. order.Age = res.Output.Setlinfo.Age
  29292. order.Insutype = res.Output.Setlinfo.Insutype
  29293. order.PsnType = res.Output.Setlinfo.PsnType
  29294. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  29295. order.SetlTime = res.Output.Setlinfo.SetlTime
  29296. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  29297. order.PayWays = pay_ways
  29298. order.AcctUsedFlag = acct_used_flag
  29299. order.WechatPay = wechat_pay
  29300. order.AliPay = ali_pay
  29301. order.JifenPay = jifen_pay
  29302. order.BandCardPay = band_card_pay
  29303. order.CashPay = cash_pay
  29304. order.OthDesc = oth_desc
  29305. //order.MedType = res.Output.Setlinfo.MedType
  29306. if reg_type == 1112 {
  29307. order.MedType = "1112"
  29308. }
  29309. if reg_type == 1111 {
  29310. order.MedType = "1111"
  29311. }
  29312. order.ClrType = res.Output.Setlinfo.ClrType
  29313. if adminUser.CurrentOrgId == 10480 {
  29314. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  29315. order.ClrType = "11"
  29316. } else {
  29317. order.ClrType = "9903"
  29318. }
  29319. }
  29320. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  29321. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  29322. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  29323. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  29324. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  29325. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  29326. order.HifpPay = res.Output.Setlinfo.HifpPay
  29327. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  29328. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  29329. order.HifesPay = res.Output.Setlinfo.HifesPay
  29330. order.HifobPay = res.Output.Setlinfo.HifobPay
  29331. order.MafPay = res.Output.Setlinfo.MafPay
  29332. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  29333. order.OthPay = res.Output.Setlinfo.OthPay
  29334. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  29335. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  29336. order.AcctPay = res.Output.Setlinfo.AcctPay
  29337. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  29338. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  29339. order.Balc = res.Output.Setlinfo.Balc
  29340. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  29341. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  29342. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  29343. order.ClrWay = res.Output.Setlinfo.ClrWay
  29344. order.Creator = order.Creator
  29345. order.Modify = roles.AdminUserId
  29346. order.RequestLog = src_resquest
  29347. order.Diagnosis = diagnosis_id
  29348. order.FaPiaoNumber = fapiao_number
  29349. order.FaPiaoCode = fapiao_code
  29350. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  29351. detailStr := string(setlDetail)
  29352. order.SetlDetail = detailStr
  29353. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  29354. err = service.UpDateOrder(order)
  29355. if err == nil {
  29356. //判断是否使用了押金
  29357. if dec_way == "true" {
  29358. tmpstring := strconv.FormatInt(order.ID, 10)
  29359. //扣押金
  29360. order.Decimal = decimal
  29361. service.UpDateOrder(order)
  29362. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  29363. if errmsg != nil {
  29364. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  29365. return
  29366. }
  29367. }
  29368. c.ServeSuccessJSON(map[string]interface{}{
  29369. "msg": "结算成功",
  29370. })
  29371. } else {
  29372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  29373. return
  29374. }
  29375. }
  29376. }
  29377. }
  29378. }
  29379. // 上传明细-预结算-
  29380. func (c *HisApiController) GetPreUploadInfo() {
  29381. id, _ := c.GetInt64("id")
  29382. record_time := c.GetString("record_time")
  29383. his_patient_id, _ := c.GetInt64("his_patient_id")
  29384. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  29385. admin_user_id, _ := c.GetInt64("admin_user_id")
  29386. diagnosis_id := c.GetString("diagnosis")
  29387. sick_type, _ := c.GetInt64("sick_type")
  29388. reg_type, _ := c.GetInt64("p_type")
  29389. begin_time := c.GetString("begin_time")
  29390. acct_used_flag := c.GetString("acct_used_flag")
  29391. id_str := c.GetString("ids")
  29392. ids_arr := strings.Split(id_str, ",")
  29393. timeLayout := "2006-01-02"
  29394. loc, _ := time.LoadLocation("Local")
  29395. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  29396. if err != nil {
  29397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  29398. return
  29399. }
  29400. recordDateTime := theTime.Unix()
  29401. adminUser := c.GetAdminUserInfo()
  29402. diagnosis_ids := strings.Split(diagnosis_id, ",")
  29403. var config []*models.HisXtDiagnoseConfig
  29404. for _, item := range diagnosis_ids {
  29405. id, _ := strconv.ParseInt(item, 10, 64)
  29406. if id > 0 {
  29407. diagnosisConfig, _ := service.FindDiagnoseById(id)
  29408. config = append(config, &diagnosisConfig)
  29409. }
  29410. }
  29411. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  29412. sickConfig, _ := service.FindSickById(sick_type)
  29413. var prescriptions []*models.HisPrescription
  29414. var start_time int64
  29415. var end_time int64
  29416. var isSuccess bool = true
  29417. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29418. fmt.Println(his_patient_id)
  29419. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  29420. timestamp := time.Now().Unix()
  29421. tempTime := time.Unix(timestamp, 0)
  29422. timeFormat := tempTime.Format("20060102150405")
  29423. chrgBchno := rand.Intn(100000) + 10000
  29424. new_chrg_bchno := ""
  29425. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  29426. new_chrg_bchno = chrg_bchno
  29427. if adminUser.CurrentOrgId == 10265 {
  29428. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  29429. new_chrg_bchno = "0000"
  29430. }
  29431. }
  29432. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29433. var patientPrescription models.HisPrescriptionInfo
  29434. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  29435. if patientPrescription.ID == 0 {
  29436. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  29437. }
  29438. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29439. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  29440. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  29441. strconv.FormatInt(his.PatientId, 10)
  29442. var res2406 Result2406
  29443. //安徽单病种处理
  29444. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  29445. data := make(map[string]interface{})
  29446. client := &http.Client{}
  29447. data["psn_no"] = his.PsnNo
  29448. data["mdtrt_id"] = his.Number
  29449. data["operator"] = roles.UserName
  29450. data["cert_no"] = his.IdCardNo
  29451. data["org_name"] = miConfig.OrgName
  29452. data["psn_name"] = his.Name
  29453. data["ipt_otp_no"] = his.IptOtpNo
  29454. data["ipt_psn_sp_flag_type"] = "0901"
  29455. data["ipt_psn_sp_flag"] = "1"
  29456. data["fixmedins_code"] = miConfig.Code
  29457. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29458. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29459. data["url"] = miConfig.Url
  29460. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  29461. bytesData, _ := json.Marshal(data)
  29462. var req *http.Request
  29463. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  29464. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  29465. resp, _ := client.Do(req)
  29466. defer resp.Body.Close()
  29467. body, ioErr := ioutil.ReadAll(resp.Body)
  29468. if ioErr != nil {
  29469. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29471. return
  29472. }
  29473. var respJSON map[string]interface{}
  29474. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29475. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29477. return
  29478. }
  29479. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29480. if status == "0" {
  29481. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29482. c.ServeSuccessJSON(map[string]interface{}{
  29483. "failed_code": -10,
  29484. "msg": err_msg,
  29485. })
  29486. return
  29487. }
  29488. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29489. userJSONBytes, _ := json.Marshal(respJSON)
  29490. fmt.Println("log")
  29491. fmt.Println(string(userJSONBytes))
  29492. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  29493. utils.ErrorLog("解析失败:%v", err)
  29494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29495. return
  29496. }
  29497. } else if miConfig.MdtrtareaAdmvs == "340699" && reg_type == 992102 {
  29498. data := make(map[string]interface{})
  29499. client := &http.Client{}
  29500. data["psn_no"] = his.PsnNo
  29501. data["mdtrt_id"] = his.Number
  29502. data["operator"] = roles.UserName
  29503. data["cert_no"] = his.IdCardNo
  29504. data["org_name"] = miConfig.OrgName
  29505. data["psn_name"] = his.Name
  29506. data["ipt_otp_no"] = his.IptOtpNo
  29507. data["ipt_psn_sp_flag_type"] = "0901"
  29508. data["ipt_psn_sp_flag"] = "1"
  29509. data["fixmedins_code"] = miConfig.Code
  29510. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29511. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29512. data["url"] = miConfig.Url
  29513. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  29514. bytesData, _ := json.Marshal(data)
  29515. var req *http.Request
  29516. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  29517. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  29518. resp, _ := client.Do(req)
  29519. defer resp.Body.Close()
  29520. body, ioErr := ioutil.ReadAll(resp.Body)
  29521. if ioErr != nil {
  29522. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29524. return
  29525. }
  29526. var respJSON map[string]interface{}
  29527. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29528. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29530. return
  29531. }
  29532. status := respJSON["data"].(map[string]interface{})["status"].(string)
  29533. if status == "0" {
  29534. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  29535. c.ServeSuccessJSON(map[string]interface{}{
  29536. "failed_code": -10,
  29537. "msg": err_msg,
  29538. })
  29539. return
  29540. }
  29541. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29542. userJSONBytes, _ := json.Marshal(respJSON)
  29543. fmt.Println("log")
  29544. fmt.Println(string(userJSONBytes))
  29545. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  29546. utils.ErrorLog("解析失败:%v", err)
  29547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29548. return
  29549. }
  29550. }
  29551. if res2406.Infcode != 0 {
  29552. adminUser := c.GetAdminUserInfo()
  29553. errlog := &models.HisOrderError{
  29554. UserOrgId: adminUser.CurrentOrgId,
  29555. Ctime: time.Now().Unix(),
  29556. Mtime: time.Now().Unix(),
  29557. ErrMsg: res2406.ErrMsg,
  29558. Status: 1,
  29559. PatientId: id,
  29560. RecordTime: recordDateTime,
  29561. Stage: 3,
  29562. }
  29563. service.CreateErrMsgLog(errlog)
  29564. c.ServeSuccessJSON(map[string]interface{}{
  29565. "failed_code": -10,
  29566. "msg": res2406.ErrMsg,
  29567. })
  29568. return
  29569. }
  29570. var res2 ResultSix
  29571. var res3 GZResultSix
  29572. var resSix10265 ResultSix10265
  29573. //var time_stamp string
  29574. if miConfig.MdtrtareaAdmvs == "421300" {
  29575. data := make(map[string]interface{})
  29576. client := &http.Client{}
  29577. data["psn_no"] = his.PsnNo
  29578. data["mdtrt_id"] = his.Number
  29579. data["department"] = department.Name
  29580. data["org_name"] = miConfig.OrgName
  29581. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29582. data["doctor_id"] = doctor_info.DoctorNumber
  29583. data["doctor_name"] = roles.UserName
  29584. data["fixmedins_code"] = miConfig.Code
  29585. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29586. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29587. data["secret_key"] = miConfig.SecretKey
  29588. data["sick_code"] = sickConfig.CountryCode
  29589. data["sick_name"] = sickConfig.ClassName
  29590. data["begin_time"] = begin_time
  29591. data["dept"] = strconv.FormatInt(department.ID, 10)
  29592. data["config"] = config
  29593. data["opter"] = roles.UserName
  29594. fmt.Println(data)
  29595. bytesData, _ := json.Marshal(data)
  29596. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  29597. resp, _ := client.Do(req)
  29598. defer resp.Body.Close()
  29599. body, ioErr := ioutil.ReadAll(resp.Body)
  29600. if ioErr != nil {
  29601. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29603. return
  29604. }
  29605. var respJSON map[string]interface{}
  29606. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29607. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29609. return
  29610. }
  29611. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29612. userJSONBytes, _ := json.Marshal(respJSON)
  29613. fmt.Println("log")
  29614. fmt.Println(string(userJSONBytes))
  29615. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29616. utils.ErrorLog("解析失败:%v", err)
  29617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29618. return
  29619. }
  29620. } else if miConfig.MdtrtareaAdmvs == "420200" {
  29621. data := make(map[string]interface{})
  29622. client := &http.Client{}
  29623. data["psn_no"] = his.PsnNo
  29624. data["mdtrt_id"] = his.Number
  29625. data["department"] = department.Name
  29626. data["org_name"] = miConfig.OrgName
  29627. if reg_type == 11 && his.Insutype == "390" {
  29628. data["med_type"] = "110104"
  29629. } else {
  29630. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29631. }
  29632. data["doctor_id"] = doctor_info.DoctorNumber
  29633. data["doctor_name"] = roles.UserName
  29634. data["fixmedins_code"] = miConfig.Code
  29635. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29636. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29637. data["secret_key"] = miConfig.SecretKey
  29638. data["sick_code"] = sickConfig.CountryCode
  29639. data["sick_name"] = sickConfig.ClassName
  29640. data["begin_time"] = begin_time
  29641. data["dept"] = strconv.FormatInt(department.ID, 10)
  29642. data["config"] = config
  29643. data["opter"] = roles.UserName
  29644. fmt.Println(data)
  29645. bytesData, _ := json.Marshal(data)
  29646. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  29647. resp, _ := client.Do(req)
  29648. defer resp.Body.Close()
  29649. body, ioErr := ioutil.ReadAll(resp.Body)
  29650. if ioErr != nil {
  29651. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29653. return
  29654. }
  29655. var respJSON map[string]interface{}
  29656. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29659. return
  29660. }
  29661. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29662. userJSONBytes, _ := json.Marshal(respJSON)
  29663. fmt.Println("log")
  29664. fmt.Println(string(userJSONBytes))
  29665. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29666. utils.ErrorLog("解析失败:%v", err)
  29667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29668. return
  29669. }
  29670. } else if miConfig.MdtrtareaAdmvs == "420902" {
  29671. data := make(map[string]interface{})
  29672. client := &http.Client{}
  29673. data["psn_no"] = his.PsnNo
  29674. data["mdtrt_id"] = his.Number
  29675. data["department"] = department.Name
  29676. data["org_name"] = miConfig.OrgName
  29677. if reg_type == 11 && his.Insutype == "390" {
  29678. data["med_type"] = "110104"
  29679. } else {
  29680. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29681. }
  29682. data["doctor_id"] = doctor_info.DoctorNumber
  29683. data["doctor_name"] = roles.UserName
  29684. data["fixmedins_code"] = miConfig.Code
  29685. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29686. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29687. data["secret_key"] = miConfig.SecretKey
  29688. data["sick_code"] = sickConfig.CountryCode
  29689. data["sick_name"] = sickConfig.ClassName
  29690. data["begin_time"] = begin_time
  29691. data["dept"] = strconv.FormatInt(department.ID, 10)
  29692. data["config"] = config
  29693. data["opter"] = roles.UserName
  29694. fmt.Println(data)
  29695. bytesData, _ := json.Marshal(data)
  29696. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  29697. resp, _ := client.Do(req)
  29698. defer resp.Body.Close()
  29699. body, ioErr := ioutil.ReadAll(resp.Body)
  29700. if ioErr != nil {
  29701. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29703. return
  29704. }
  29705. var respJSON map[string]interface{}
  29706. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29707. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29709. return
  29710. }
  29711. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29712. userJSONBytes, _ := json.Marshal(respJSON)
  29713. fmt.Println("log")
  29714. fmt.Println(string(userJSONBytes))
  29715. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29716. utils.ErrorLog("解析失败:%v", err)
  29717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29718. return
  29719. }
  29720. } else if miConfig.MdtrtareaAdmvs == "421182" {
  29721. data := make(map[string]interface{})
  29722. client := &http.Client{}
  29723. data["psn_no"] = his.PsnNo
  29724. data["mdtrt_id"] = his.Number
  29725. data["department"] = department.Name
  29726. data["org_name"] = miConfig.OrgName
  29727. if reg_type == 11 && his.Insutype == "390" {
  29728. data["med_type"] = "110104"
  29729. } else {
  29730. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29731. }
  29732. data["doctor_id"] = doctor_info.DoctorNumber
  29733. data["doctor_name"] = roles.UserName
  29734. data["fixmedins_code"] = miConfig.Code
  29735. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29736. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29737. data["secret_key"] = miConfig.SecretKey
  29738. data["sick_code"] = sickConfig.CountryCode
  29739. data["sick_name"] = sickConfig.ClassName
  29740. data["begin_time"] = begin_time
  29741. data["dept"] = strconv.FormatInt(department.ID, 10)
  29742. data["config"] = config
  29743. data["opter"] = roles.UserName
  29744. fmt.Println(data)
  29745. bytesData, _ := json.Marshal(data)
  29746. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  29747. resp, _ := client.Do(req)
  29748. defer resp.Body.Close()
  29749. body, ioErr := ioutil.ReadAll(resp.Body)
  29750. if ioErr != nil {
  29751. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29753. return
  29754. }
  29755. var respJSON map[string]interface{}
  29756. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29757. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29759. return
  29760. }
  29761. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29762. userJSONBytes, _ := json.Marshal(respJSON)
  29763. fmt.Println("log")
  29764. fmt.Println(string(userJSONBytes))
  29765. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29766. utils.ErrorLog("解析失败:%v", err)
  29767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29768. return
  29769. }
  29770. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  29771. utils.ErrorLog("解析失败:%v", doctor_info)
  29772. data := make(map[string]interface{})
  29773. client := &http.Client{}
  29774. data["psn_no"] = his.PsnNo
  29775. data["mdtrt_id"] = his.Number
  29776. data["doctor"] = roles.UserName
  29777. data["department"] = department.Name
  29778. data["org_name"] = miConfig.OrgName
  29779. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29780. data["doctor_id"] = doctor_info.DoctorNumber
  29781. data["new_doctor_name"] = doctor_info.UserName
  29782. data["fixmedins_code"] = miConfig.Code
  29783. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29784. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29785. data["secret_key"] = miConfig.SecretKey
  29786. data["sick_code"] = sickConfig.CountryCode
  29787. data["sick_name"] = sickConfig.ClassName
  29788. data["url"] = miConfig.Url
  29789. data["ak"] = miConfig.AccessKey
  29790. data["begin_time"] = begin_time
  29791. data["cainfo"] = miConfig.Cainfo
  29792. data["dept"] = strconv.FormatInt(department.ID, 10)
  29793. data["config"] = config
  29794. bytesData, _ := json.Marshal(data)
  29795. var req *http.Request
  29796. if miConfig.MdtrtareaAdmvs == "320830" {
  29797. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2203", bytes.NewReader(bytesData))
  29798. } else if miConfig.MdtrtareaAdmvs == "320921" {
  29799. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  29800. } else {
  29801. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  29802. }
  29803. resp, _ := client.Do(req)
  29804. defer resp.Body.Close()
  29805. body, ioErr := ioutil.ReadAll(resp.Body)
  29806. if ioErr != nil {
  29807. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29809. return
  29810. }
  29811. var respJSON map[string]interface{}
  29812. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29813. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29815. return
  29816. }
  29817. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  29818. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  29819. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  29820. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29821. userJSONBytes, _ := json.Marshal(respJSON)
  29822. fmt.Println("log")
  29823. fmt.Println(string(userJSONBytes))
  29824. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  29825. utils.ErrorLog("解析失败:%v", err)
  29826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29827. return
  29828. }
  29829. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29830. res2.Output = resSix10265.Output
  29831. res2.ErrMsg = resSix10265.ErrMsg
  29832. res2.Cainfo = resSix10265.Cainfo
  29833. res2.WarnMsg = resSix10265.WarnMsg
  29834. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29835. res2.Infcode = infocode
  29836. } else if miConfig.MdtrtareaAdmvs == "150499" {
  29837. data := make(map[string]interface{})
  29838. client := &http.Client{}
  29839. data["psn_no"] = his.PsnNo
  29840. data["mdtrt_id"] = his.Number
  29841. data["doctor"] = roles.UserName
  29842. data["department"] = department.Name
  29843. data["org_name"] = miConfig.OrgName
  29844. data["med_type"] = strconv.FormatInt(reg_type, 10)
  29845. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  29846. data["fixmedins_code"] = miConfig.Code
  29847. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  29848. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29849. data["secret_key"] = miConfig.SecretKey
  29850. data["sick_code"] = sickConfig.CountryCode
  29851. data["sick_name"] = sickConfig.ClassName
  29852. data["begin_time"] = begin_time
  29853. data["dept"] = strconv.FormatInt(department.ID, 10)
  29854. data["config"] = config
  29855. //data["url"] = miConfig.Url
  29856. //data["ak"] = miConfig.AccessKey
  29857. data["cainfo"] = miConfig.Cainfo
  29858. fmt.Println(data)
  29859. bytesData, _ := json.Marshal(data)
  29860. var req *http.Request
  29861. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  29862. resp, _ := client.Do(req)
  29863. defer resp.Body.Close()
  29864. body, ioErr := ioutil.ReadAll(resp.Body)
  29865. if ioErr != nil {
  29866. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29868. return
  29869. }
  29870. var respJSON map[string]interface{}
  29871. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29872. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29874. return
  29875. }
  29876. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  29877. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  29878. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  29879. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29880. userJSONBytes, _ := json.Marshal(respJSON)
  29881. fmt.Println("log")
  29882. fmt.Println(string(userJSONBytes))
  29883. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  29884. utils.ErrorLog("解析失败:%v", err)
  29885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29886. return
  29887. }
  29888. res2.InfRefmsgid = resSix10265.InfRefmsgid
  29889. res2.Output = resSix10265.Output
  29890. res2.ErrMsg = resSix10265.ErrMsg
  29891. res2.Cainfo = resSix10265.Cainfo
  29892. res2.WarnMsg = resSix10265.WarnMsg
  29893. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29894. res2.Infcode = infocode
  29895. } else if miConfig.MdtrtareaAdmvs == "350500" {
  29896. 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)
  29897. saveLog(result, requestLog, "2203", "上传就诊信息")
  29898. var respJSON2 map[string]interface{}
  29899. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29900. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29902. return
  29903. }
  29904. userJSONBytes2, _ := json.Marshal(respJSON2)
  29905. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29906. utils.ErrorLog("解析失败:%v", err)
  29907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29908. return
  29909. }
  29910. } else if miConfig.MdtrtareaAdmvs == "360302" {
  29911. var result string
  29912. var requestLog string
  29913. 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, "")
  29914. saveLog(result, requestLog, "2203", "上传就诊信息")
  29915. var respJSON2 map[string]interface{}
  29916. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29917. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29919. return
  29920. }
  29921. userJSONBytes2, _ := json.Marshal(respJSON2)
  29922. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29923. utils.ErrorLog("解析失败:%v", err)
  29924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29925. return
  29926. }
  29927. } else if miConfig.MdtrtareaAdmvs == "361025" {
  29928. var result string
  29929. var requestLog string
  29930. 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, "")
  29931. saveLog(result, requestLog, "2203", "上传就诊信息")
  29932. var respJSON2 map[string]interface{}
  29933. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29934. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29936. return
  29937. }
  29938. userJSONBytes2, _ := json.Marshal(respJSON2)
  29939. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29940. utils.ErrorLog("解析失败:%v", err)
  29941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29942. return
  29943. }
  29944. } else if miConfig.MdtrtareaAdmvs == "360100" {
  29945. var result string
  29946. var requestLog string
  29947. 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, "")
  29948. saveLog(result, requestLog, "2203", "上传就诊信息")
  29949. var respJSON2 map[string]interface{}
  29950. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  29951. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29953. return
  29954. }
  29955. userJSONBytes2, _ := json.Marshal(respJSON2)
  29956. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29957. utils.ErrorLog("解析失败:%v", err)
  29958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29959. return
  29960. }
  29961. } else if miConfig.MdtrtareaAdmvs == "341203" {
  29962. data := make(map[string]interface{})
  29963. client := &http.Client{}
  29964. data["psn_no"] = his.PsnNo
  29965. data["mdtrt_id"] = his.Number
  29966. data["operator"] = roles.UserName
  29967. data["department"] = department.Name
  29968. data["org_name"] = miConfig.OrgName
  29969. var med_type string
  29970. if his.Insutype == "390" {
  29971. if reg_type == 992102 {
  29972. med_type = "992102"
  29973. data["sick_code"] = "ZDZ940"
  29974. data["sick_name"] = "慢性肾衰竭"
  29975. }
  29976. if reg_type == 140104 {
  29977. med_type = "140104"
  29978. data["sick_code"] = sickConfig.CountryCode
  29979. data["sick_name"] = sickConfig.ClassName
  29980. }
  29981. if reg_type == 14 {
  29982. med_type = "140104"
  29983. data["sick_code"] = sickConfig.CountryCode
  29984. data["sick_name"] = sickConfig.ClassName
  29985. }
  29986. if reg_type == 1104 {
  29987. med_type = "1104"
  29988. data["sick_code"] = sickConfig.CountryCode
  29989. data["sick_name"] = sickConfig.ClassName
  29990. }
  29991. } else if his.Insutype == "310" {
  29992. if reg_type == 992102 {
  29993. med_type = "992102"
  29994. data["sick_code"] = "ZDZ940"
  29995. data["sick_name"] = "慢性肾衰竭"
  29996. }
  29997. if reg_type == 140104 {
  29998. med_type = "140104"
  29999. data["sick_code"] = sickConfig.CountryCode
  30000. data["sick_name"] = sickConfig.ClassName
  30001. }
  30002. if reg_type == 14 {
  30003. med_type = "14"
  30004. data["sick_code"] = sickConfig.CountryCode
  30005. data["sick_name"] = sickConfig.ClassName
  30006. }
  30007. if reg_type == 1104 {
  30008. med_type = "1104"
  30009. data["sick_code"] = sickConfig.CountryCode
  30010. data["sick_name"] = sickConfig.ClassName
  30011. }
  30012. }
  30013. data["med_type"] = med_type
  30014. data["doctor_number"] = doctor_info.DoctorNumber
  30015. data["doctor_name"] = doctor_info.UserName
  30016. data["fixmedins_code"] = miConfig.Code
  30017. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30018. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30019. data["secret_key"] = miConfig.SecretKey
  30020. data["begin_time"] = begin_time
  30021. data["dept"] = strconv.FormatInt(department.ID, 10)
  30022. data["config"] = config
  30023. data["url"] = miConfig.Url
  30024. data["ak"] = miConfig.AccessKey
  30025. data["cainfo"] = miConfig.Cainfo
  30026. bytesData, _ := json.Marshal(data)
  30027. var req *http.Request
  30028. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  30029. resp, _ := client.Do(req)
  30030. defer resp.Body.Close()
  30031. body, ioErr := ioutil.ReadAll(resp.Body)
  30032. if ioErr != nil {
  30033. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30035. return
  30036. }
  30037. var respJSON map[string]interface{}
  30038. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30039. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30041. return
  30042. }
  30043. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30044. if status == "0" {
  30045. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30046. c.ServeSuccessJSON(map[string]interface{}{
  30047. "failed_code": -10,
  30048. "msg": err_msg,
  30049. })
  30050. return
  30051. }
  30052. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30053. userJSONBytes, _ := json.Marshal(respJSON)
  30054. fmt.Println("log")
  30055. fmt.Println(string(userJSONBytes))
  30056. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30057. utils.ErrorLog("解析失败:%v", err)
  30058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30059. return
  30060. }
  30061. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30062. data := make(map[string]interface{})
  30063. client := &http.Client{}
  30064. data["psn_no"] = his.PsnNo
  30065. data["mdtrt_id"] = his.Number
  30066. data["operator"] = roles.UserName
  30067. data["department"] = department.Name
  30068. data["org_name"] = miConfig.OrgName
  30069. var med_type string
  30070. if his.Insutype == "390" {
  30071. if reg_type == 992102 {
  30072. med_type = "992102"
  30073. data["sick_code"] = sickConfig.CountryCode
  30074. data["sick_name"] = sickConfig.ClassName
  30075. }
  30076. if reg_type == 140104 {
  30077. med_type = "140104"
  30078. data["sick_code"] = sickConfig.CountryCode
  30079. data["sick_name"] = sickConfig.ClassName
  30080. }
  30081. if reg_type == 140201 {
  30082. med_type = "140201"
  30083. data["sick_code"] = sickConfig.CountryCode
  30084. data["sick_name"] = sickConfig.ClassName
  30085. }
  30086. if reg_type == 14 {
  30087. med_type = "14"
  30088. data["sick_code"] = sickConfig.CountryCode
  30089. data["sick_name"] = sickConfig.ClassName
  30090. }
  30091. if reg_type == 11 {
  30092. med_type = "11"
  30093. data["sick_code"] = sickConfig.CountryCode
  30094. data["sick_name"] = sickConfig.ClassName
  30095. }
  30096. } else if his.Insutype == "310" {
  30097. if reg_type == 992102 {
  30098. med_type = "992102"
  30099. data["sick_code"] = sickConfig.CountryCode
  30100. data["sick_name"] = sickConfig.ClassName
  30101. }
  30102. if reg_type == 140104 {
  30103. med_type = "140104"
  30104. data["sick_code"] = sickConfig.CountryCode
  30105. data["sick_name"] = sickConfig.ClassName
  30106. }
  30107. if reg_type == 140201 {
  30108. med_type = "140201"
  30109. data["sick_code"] = sickConfig.CountryCode
  30110. data["sick_name"] = sickConfig.ClassName
  30111. }
  30112. if reg_type == 14 {
  30113. med_type = "14"
  30114. data["sick_code"] = sickConfig.CountryCode
  30115. data["sick_name"] = sickConfig.ClassName
  30116. }
  30117. if reg_type == 11 {
  30118. med_type = "11"
  30119. data["sick_code"] = sickConfig.CountryCode
  30120. data["sick_name"] = sickConfig.ClassName
  30121. }
  30122. }
  30123. data["med_type"] = med_type
  30124. data["doctor_number"] = doctor_info.DoctorNumber
  30125. data["doctor_name"] = doctor_info.UserName
  30126. data["fixmedins_code"] = miConfig.Code
  30127. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30128. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30129. data["secret_key"] = miConfig.SecretKey
  30130. data["begin_time"] = begin_time
  30131. data["dept"] = strconv.FormatInt(department.ID, 10)
  30132. data["config"] = config
  30133. data["url"] = miConfig.Url
  30134. data["ak"] = miConfig.AccessKey
  30135. data["cainfo"] = miConfig.Cainfo
  30136. bytesData, _ := json.Marshal(data)
  30137. var req *http.Request
  30138. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  30139. resp, _ := client.Do(req)
  30140. defer resp.Body.Close()
  30141. body, ioErr := ioutil.ReadAll(resp.Body)
  30142. if ioErr != nil {
  30143. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30145. return
  30146. }
  30147. var respJSON map[string]interface{}
  30148. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30149. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30151. return
  30152. }
  30153. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30154. if status == "0" {
  30155. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30156. c.ServeSuccessJSON(map[string]interface{}{
  30157. "failed_code": -10,
  30158. "msg": err_msg,
  30159. })
  30160. return
  30161. }
  30162. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30163. userJSONBytes, _ := json.Marshal(respJSON)
  30164. fmt.Println("log")
  30165. fmt.Println(string(userJSONBytes))
  30166. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30167. utils.ErrorLog("解析失败:%v", err)
  30168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30169. return
  30170. }
  30171. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30172. var result string
  30173. var requestLog string
  30174. 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)
  30175. saveLog(result, requestLog, "2203", "上传就诊信息")
  30176. var respJSON2 map[string]interface{}
  30177. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30178. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30180. return
  30181. }
  30182. userJSONBytes2, _ := json.Marshal(respJSON2)
  30183. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30184. utils.ErrorLog("解析失败:%v", err)
  30185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30186. return
  30187. }
  30188. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30189. data := make(map[string]interface{})
  30190. client := &http.Client{}
  30191. data["psn_no"] = his.PsnNo
  30192. data["mdtrt_id"] = his.Number
  30193. data["doctor"] = roles.UserName
  30194. data["department"] = department.Name
  30195. data["org_name"] = miConfig.OrgName
  30196. data["med_type"] = strconv.FormatInt(reg_type, 10)
  30197. data["doctor_id"] = doctor_info.DoctorNumber
  30198. data["fixmedins_code"] = miConfig.Code
  30199. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30200. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30201. data["secret_key"] = miConfig.SecretKey
  30202. data["sick_code"] = sickConfig.CountryCode
  30203. data["sick_name"] = sickConfig.ClassName
  30204. data["begin_time"] = begin_time
  30205. data["new_doctor_name"] = doctor_info.UserName
  30206. data["dept"] = strconv.FormatInt(department.ID, 10)
  30207. data["config"] = config
  30208. bytesData, _ := json.Marshal(data)
  30209. var req *http.Request
  30210. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  30211. resp, _ := client.Do(req)
  30212. defer resp.Body.Close()
  30213. body, ioErr := ioutil.ReadAll(resp.Body)
  30214. if ioErr != nil {
  30215. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30217. return
  30218. }
  30219. var respJSON map[string]interface{}
  30220. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30221. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30223. return
  30224. }
  30225. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30226. userJSONBytes, _ := json.Marshal(respJSON)
  30227. fmt.Println("log")
  30228. fmt.Println(string(userJSONBytes))
  30229. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  30230. utils.ErrorLog("解析失败:%v", err)
  30231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30232. return
  30233. }
  30234. } else {
  30235. var result string
  30236. var requestLog string
  30237. if miConfig.MdtrtareaAdmvs == "440781" { //
  30238. 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)
  30239. } else {
  30240. if miConfig.Code == "H15049901371" {
  30241. //赤峰地区国家医保医疗类别
  30242. //职工透析:医疗类别选特殊情况门诊990502
  30243. //居民定额血透门慢: 医疗类别选门诊慢病140104
  30244. var med_type string
  30245. if his.Insutype == "390" {
  30246. if reg_type == 14 {
  30247. med_type = "9933"
  30248. } else if reg_type == 11 {
  30249. med_type = "11"
  30250. }
  30251. } else if his.Insutype == "310" {
  30252. if reg_type == 14 {
  30253. med_type = "990502"
  30254. } else if reg_type == 11 {
  30255. med_type = "11"
  30256. }
  30257. }
  30258. 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)
  30259. } else {
  30260. 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)
  30261. }
  30262. saveLog(result, requestLog, "2203", "上传就诊信息")
  30263. var respJSON2 map[string]interface{}
  30264. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  30265. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30267. return
  30268. }
  30269. userJSONBytes2, _ := json.Marshal(respJSON2)
  30270. if miConfig.Code == "H15049901371" {
  30271. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  30272. utils.ErrorLog("解析失败:%v", err)
  30273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30274. return
  30275. }
  30276. res2.InfRefmsgid = resSix10265.InfRefmsgid
  30277. res2.Output = resSix10265.Output
  30278. res2.ErrMsg = resSix10265.ErrMsg
  30279. res2.Cainfo = resSix10265.Cainfo
  30280. res2.WarnMsg = resSix10265.WarnMsg
  30281. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30282. res2.Infcode = infocode
  30283. } else {
  30284. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  30285. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  30286. utils.ErrorLog("解析失败:%v", err)
  30287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30288. return
  30289. }
  30290. res2.Infcode = res3.Infcode
  30291. } else {
  30292. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30293. utils.ErrorLog("解析失败:%v", err)
  30294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30295. return
  30296. }
  30297. }
  30298. }
  30299. }
  30300. }
  30301. if res2.Infcode == -1 {
  30302. adminUser := c.GetAdminUserInfo()
  30303. errlog := &models.HisOrderError{
  30304. UserOrgId: adminUser.CurrentOrgId,
  30305. Ctime: time.Now().Unix(),
  30306. Mtime: time.Now().Unix(),
  30307. ErrMsg: res2.ErrMsg,
  30308. Status: 1,
  30309. PatientId: id,
  30310. RecordTime: recordDateTime,
  30311. Stage: 3,
  30312. }
  30313. service.CreateErrMsgLog(errlog)
  30314. c.ServeSuccessJSON(map[string]interface{}{
  30315. "failed_code": -10,
  30316. "msg": res2.ErrMsg,
  30317. })
  30318. return
  30319. }
  30320. if res2.Infcode != 0 {
  30321. adminUser := c.GetAdminUserInfo()
  30322. errlog := &models.HisOrderError{
  30323. UserOrgId: adminUser.CurrentOrgId,
  30324. Ctime: time.Now().Unix(),
  30325. Mtime: time.Now().Unix(),
  30326. ErrMsg: res2.ErrMsg,
  30327. Status: 1,
  30328. PatientId: id,
  30329. RecordTime: recordDateTime,
  30330. Stage: 3,
  30331. }
  30332. service.CreateErrMsgLog(errlog)
  30333. c.ServeSuccessJSON(map[string]interface{}{
  30334. "failed_code": -10,
  30335. "msg": res2.ErrMsg,
  30336. })
  30337. return
  30338. } else {
  30339. his.Diagnosis = diagnosis_id
  30340. his.SickType = sickConfig.ID
  30341. his.PType = fmt.Sprintf("%d", reg_type)
  30342. service.UpdateHisPatientThree(&his)
  30343. data := make(map[string]interface{})
  30344. if settle_accounts_type == 1 { //日结
  30345. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  30346. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  30347. } else {
  30348. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  30349. }
  30350. data["pre"] = prescriptions
  30351. } else { //月结
  30352. start_time_str := c.GetString("start_time")
  30353. end_time_str := c.GetString("end_time")
  30354. timeLayout := "2006-01-02"
  30355. loc, _ := time.LoadLocation("Local")
  30356. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  30357. if err != nil {
  30358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30359. return
  30360. }
  30361. recordStartTime := theStartTime.Unix()
  30362. start_time = recordStartTime
  30363. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  30364. if err != nil {
  30365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  30366. return
  30367. }
  30368. recordEndTime := theEndTime.Unix()
  30369. end_time = recordEndTime
  30370. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  30371. data["pre"] = prescriptions
  30372. }
  30373. client := &http.Client{}
  30374. data["psn_no"] = his.PsnNo
  30375. data["mdtrt_id"] = his.Number
  30376. data["chrg_bchno"] = new_chrg_bchno
  30377. data["org_name"] = miConfig.OrgName
  30378. data["doctor"] = doctor_info.UserName
  30379. data["doctor_id"] = doctor_info.DoctorNumber
  30380. data["dept"] = department.Name
  30381. data["fixmedins_code"] = miConfig.Code
  30382. data["opter"] = roles.UserName
  30383. data["dept_code"] = department.Number
  30384. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  30385. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30386. data["secret_key"] = miConfig.SecretKey
  30387. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  30388. data["url"] = miConfig.Url
  30389. data["ak"] = miConfig.AccessKey
  30390. data["new_doctor_name"] = patientPrescription.Doctor
  30391. if his.Insutype == "390" {
  30392. if reg_type == 992102 {
  30393. data["diag_code"] = "ZDZ940"
  30394. }
  30395. if reg_type == 140104 {
  30396. data["diag_code"] = sickConfig.CountryCode
  30397. }
  30398. if reg_type == 140201 {
  30399. data["diag_code"] = sickConfig.CountryCode
  30400. }
  30401. if reg_type == 14 {
  30402. data["diag_code"] = sickConfig.CountryCode
  30403. }
  30404. if reg_type == 1104 {
  30405. data["diag_code"] = sickConfig.CountryCode
  30406. }
  30407. } else if his.Insutype == "310" {
  30408. if miConfig.MdtrtareaAdmvs == "341203" {
  30409. if reg_type == 992102 {
  30410. data["diag_code"] = "ZDZ940"
  30411. }
  30412. if reg_type != 992102 {
  30413. data["diag_code"] = sickConfig.CountryCode
  30414. }
  30415. } else {
  30416. data["diag_code"] = sickConfig.CountryCode
  30417. }
  30418. }
  30419. data["cainfo"] = miConfig.Cainfo
  30420. data["opter"] = roles.UserName
  30421. var ids []int64
  30422. for _, item := range prescriptions {
  30423. ids = append(ids, item.ID)
  30424. }
  30425. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30426. if config.IsOpen == 1 { //对接了医保,走医保流程
  30427. var res ResultFour
  30428. var resFour10265 ResultFour10265
  30429. if miConfig.MdtrtareaAdmvs == "421300" {
  30430. bytesData, _ := json.Marshal(data)
  30431. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  30432. resp, _ := client.Do(req)
  30433. defer resp.Body.Close()
  30434. body, ioErr := ioutil.ReadAll(resp.Body)
  30435. if ioErr != nil {
  30436. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30438. return
  30439. }
  30440. var respJSON map[string]interface{}
  30441. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30442. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30444. return
  30445. }
  30446. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30447. userJSONBytes, _ := json.Marshal(respJSON)
  30448. fmt.Println("log")
  30449. fmt.Println(string(userJSONBytes))
  30450. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30451. utils.ErrorLog("解析失败:%v", err)
  30452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30453. return
  30454. }
  30455. } else if miConfig.MdtrtareaAdmvs == "420200" {
  30456. bytesData, _ := json.Marshal(data)
  30457. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  30458. resp, _ := client.Do(req)
  30459. defer resp.Body.Close()
  30460. body, ioErr := ioutil.ReadAll(resp.Body)
  30461. if ioErr != nil {
  30462. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30464. return
  30465. }
  30466. var respJSON map[string]interface{}
  30467. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30468. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30470. return
  30471. }
  30472. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30473. userJSONBytes, _ := json.Marshal(respJSON)
  30474. fmt.Println("log")
  30475. fmt.Println(string(userJSONBytes))
  30476. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30477. utils.ErrorLog("解析失败:%v", err)
  30478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30479. return
  30480. }
  30481. } else if miConfig.MdtrtareaAdmvs == "420902" {
  30482. bytesData, _ := json.Marshal(data)
  30483. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  30484. resp, _ := client.Do(req)
  30485. defer resp.Body.Close()
  30486. body, ioErr := ioutil.ReadAll(resp.Body)
  30487. if ioErr != nil {
  30488. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30490. return
  30491. }
  30492. var respJSON map[string]interface{}
  30493. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30494. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30496. return
  30497. }
  30498. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30499. userJSONBytes, _ := json.Marshal(respJSON)
  30500. fmt.Println("log")
  30501. fmt.Println(string(userJSONBytes))
  30502. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30503. utils.ErrorLog("解析失败:%v", err)
  30504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30505. return
  30506. }
  30507. } else if miConfig.MdtrtareaAdmvs == "421182" {
  30508. bytesData, _ := json.Marshal(data)
  30509. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  30510. resp, _ := client.Do(req)
  30511. defer resp.Body.Close()
  30512. body, ioErr := ioutil.ReadAll(resp.Body)
  30513. if ioErr != nil {
  30514. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30516. return
  30517. }
  30518. var respJSON map[string]interface{}
  30519. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30520. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30522. return
  30523. }
  30524. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30525. userJSONBytes, _ := json.Marshal(respJSON)
  30526. fmt.Println("log")
  30527. fmt.Println(string(userJSONBytes))
  30528. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30529. utils.ErrorLog("解析失败:%v", err)
  30530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30531. return
  30532. }
  30533. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  30534. var result3101 Result3101
  30535. //result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30536. result3101.Infcode = "0"
  30537. if result3101.Infcode == "0" {
  30538. if len(result3101.Output.Result) > 0 {
  30539. var errMsgs []string
  30540. for _, item := range result3101.Output.Result {
  30541. errMsgs = append(errMsgs, item.VolaCont)
  30542. }
  30543. c.ServeSuccessJSON(map[string]interface{}{
  30544. "failed_code": -10,
  30545. "msg": errMsgs,
  30546. })
  30547. return
  30548. } else {
  30549. if miConfig.MdtrtareaAdmvs == "320921" {
  30550. data["doctor_id"] = doctor_info.DoctorNumber
  30551. } else {
  30552. data["doctor_id"] = doctor_info.DoctorNumber
  30553. }
  30554. bytesData, _ := json.Marshal(data)
  30555. var req *http.Request
  30556. if miConfig.MdtrtareaAdmvs == "320830" {
  30557. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/2204", bytes.NewReader(bytesData))
  30558. } else if miConfig.MdtrtareaAdmvs == "320921" {
  30559. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30560. } else {
  30561. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  30562. }
  30563. resp, _ := client.Do(req)
  30564. defer resp.Body.Close()
  30565. body, ioErr := ioutil.ReadAll(resp.Body)
  30566. if ioErr != nil {
  30567. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30569. return
  30570. }
  30571. var respJSON map[string]interface{}
  30572. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30573. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30575. return
  30576. }
  30577. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30578. userJSONBytes, _ := json.Marshal(respJSON)
  30579. fmt.Println("log")
  30580. fmt.Println(string(userJSONBytes))
  30581. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  30582. utils.ErrorLog("解析失败:%v", err)
  30583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30584. return
  30585. }
  30586. res.InfRefmsgid = resFour10265.InfRefmsgid
  30587. res.Output = resFour10265.Output
  30588. res.ErrMsg = resFour10265.ErrMsg
  30589. res.Cainfo = resFour10265.Cainfo
  30590. res.WarnMsg = resFour10265.WarnMsg
  30591. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  30592. res.Infcode = infocode
  30593. }
  30594. }
  30595. } else if miConfig.MdtrtareaAdmvs == "150499" {
  30596. var pagesize int = 5
  30597. var start int = 1
  30598. var stop int
  30599. var pagecount int
  30600. var curpage int
  30601. data["doctor_id"] = doctor_info.DoctorNumber
  30602. var res2 ResultFour
  30603. //var result res.
  30604. //总页数,向上取整,注意除之前要先转换类型为float64
  30605. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  30606. for curpage = 1; curpage <= pagecount; curpage++ {
  30607. if curpage == 1 {
  30608. start = 1
  30609. } else {
  30610. start = (curpage-1)*pagesize + 1
  30611. }
  30612. stop = curpage * pagesize
  30613. if stop > len(prescriptions) {
  30614. stop = len(prescriptions)
  30615. }
  30616. //var requestLog string
  30617. data["pre"] = prescriptions[start-1 : stop]
  30618. fmt.Println(data["pre"])
  30619. bytesData, _ := json.Marshal(data)
  30620. var req *http.Request
  30621. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  30622. resp, _ := client.Do(req)
  30623. defer resp.Body.Close()
  30624. body, ioErr := ioutil.ReadAll(resp.Body)
  30625. if ioErr != nil {
  30626. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30628. return
  30629. }
  30630. var respJSON map[string]interface{}
  30631. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30632. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30634. return
  30635. }
  30636. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30637. userJSONBytes, _ := json.Marshal(respJSON)
  30638. fmt.Println("log")
  30639. fmt.Println(string(userJSONBytes))
  30640. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  30641. utils.ErrorLog("解析失败:%v", err)
  30642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30643. return
  30644. }
  30645. res.InfRefmsgid = resFour10265.InfRefmsgid
  30646. res.Output = resFour10265.Output
  30647. res.ErrMsg = resFour10265.ErrMsg
  30648. res.Cainfo = resFour10265.Cainfo
  30649. res.WarnMsg = resFour10265.WarnMsg
  30650. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  30651. res.Infcode = infocode
  30652. if infocode == 0 {
  30653. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  30654. } else {
  30655. isSuccess = false
  30656. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  30657. res.Infcode = -1
  30658. res.ErrMsg = resFour10265.ErrMsg
  30659. errlog := &models.HisOrderError{
  30660. UserOrgId: adminUser.CurrentOrgId,
  30661. Ctime: time.Now().Unix(),
  30662. Mtime: time.Now().Unix(),
  30663. Number: chrg_bchno,
  30664. ErrMsg: "",
  30665. Status: 1,
  30666. PatientId: id,
  30667. RecordTime: recordDateTime,
  30668. Stage: 4,
  30669. }
  30670. service.CreateErrMsgLog(errlog)
  30671. }
  30672. }
  30673. if isSuccess {
  30674. res.Infcode = 0
  30675. res.Output.Result = res2.Output.Result
  30676. } else {
  30677. order := &models.HisOrder{
  30678. UserOrgId: adminUser.CurrentOrgId,
  30679. HisPatientId: his.ID,
  30680. PatientId: his.PatientId,
  30681. SettleAccountsDate: recordDateTime,
  30682. Ctime: time.Now().Unix(),
  30683. Mtime: time.Now().Unix(),
  30684. MdtrtId: his.Number,
  30685. PsnNo: his.PsnNo,
  30686. MedType: strconv.FormatInt(reg_type, 10),
  30687. Status: 1,
  30688. Number: chrg_bchno,
  30689. Infcode: res.Infcode,
  30690. WarnMsg: res.WarnMsg,
  30691. Cainfo: res.Cainfo,
  30692. ErrMsg: res.ErrMsg,
  30693. RespondTime: res.RefmsgTime,
  30694. InfRefmsgid: res.InfRefmsgid,
  30695. OrderStatus: 1,
  30696. IsMedicineInsurance: 1,
  30697. SettleType: settle_accounts_type,
  30698. SettleStartTime: start_time,
  30699. SettleEndTime: end_time,
  30700. Creator: roles.AdminUserId,
  30701. Modify: roles.AdminUserId,
  30702. PType: 2,
  30703. Diagnosis: diagnosis_id,
  30704. }
  30705. err = service.CreateOrder(order)
  30706. if err != nil {
  30707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  30708. return
  30709. }
  30710. c.ServeSuccessJSON(map[string]interface{}{
  30711. "failed_code": -10,
  30712. "msg": res2.ErrMsg,
  30713. })
  30714. return
  30715. }
  30716. } else if miConfig.MdtrtareaAdmvs == "350500" {
  30717. 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)
  30718. var dat map[string]interface{}
  30719. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30720. fmt.Println(dat)
  30721. } else {
  30722. fmt.Println(err)
  30723. }
  30724. saveLog(result, request_log, "2204", "上传费用明细")
  30725. userJSONBytes, _ := json.Marshal(dat)
  30726. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30727. utils.ErrorLog("解析失败:%v", err)
  30728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30729. return
  30730. }
  30731. } else if miConfig.MdtrtareaAdmvs == "360302" {
  30732. 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, "", "")
  30733. var dat map[string]interface{}
  30734. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30735. fmt.Println(dat)
  30736. } else {
  30737. fmt.Println(err)
  30738. }
  30739. saveLog(result, request_log, "2204", "上传费用明细")
  30740. userJSONBytes, _ := json.Marshal(dat)
  30741. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30742. utils.ErrorLog("解析失败:%v", err)
  30743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30744. return
  30745. }
  30746. } else if miConfig.MdtrtareaAdmvs == "361025" {
  30747. 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, "", "")
  30748. var dat map[string]interface{}
  30749. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30750. fmt.Println(dat)
  30751. } else {
  30752. fmt.Println(err)
  30753. }
  30754. saveLog(result, request_log, "2204", "上传费用明细")
  30755. userJSONBytes, _ := json.Marshal(dat)
  30756. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30757. utils.ErrorLog("解析失败:%v", err)
  30758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30759. return
  30760. }
  30761. } else if miConfig.MdtrtareaAdmvs == "360100" {
  30762. 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, "", "")
  30763. var dat map[string]interface{}
  30764. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30765. fmt.Println(dat)
  30766. } else {
  30767. fmt.Println(err)
  30768. }
  30769. saveLog(result, request_log, "2204", "上传费用明细")
  30770. userJSONBytes, _ := json.Marshal(dat)
  30771. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30772. utils.ErrorLog("解析失败:%v", err)
  30773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30774. return
  30775. }
  30776. } else if miConfig.MdtrtareaAdmvs == "341203" {
  30777. bytesData, _ := json.Marshal(data)
  30778. var req *http.Request
  30779. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  30780. resp, _ := client.Do(req)
  30781. defer resp.Body.Close()
  30782. body, ioErr := ioutil.ReadAll(resp.Body)
  30783. if ioErr != nil {
  30784. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30786. return
  30787. }
  30788. var respJSON map[string]interface{}
  30789. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30790. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30792. return
  30793. }
  30794. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30795. if status == "0" {
  30796. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30797. c.ServeSuccessJSON(map[string]interface{}{
  30798. "failed_code": -10,
  30799. "msg": err_msg,
  30800. })
  30801. return
  30802. }
  30803. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30804. userJSONBytes, _ := json.Marshal(respJSON)
  30805. fmt.Println("log")
  30806. fmt.Println(string(userJSONBytes))
  30807. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30808. utils.ErrorLog("解析失败:%v", err)
  30809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30810. return
  30811. }
  30812. } else if miConfig.MdtrtareaAdmvs == "340699" {
  30813. bytesData, _ := json.Marshal(data)
  30814. var req *http.Request
  30815. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  30816. resp, _ := client.Do(req)
  30817. defer resp.Body.Close()
  30818. body, ioErr := ioutil.ReadAll(resp.Body)
  30819. if ioErr != nil {
  30820. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30822. return
  30823. }
  30824. var respJSON map[string]interface{}
  30825. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30826. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30828. return
  30829. }
  30830. status := respJSON["data"].(map[string]interface{})["status"].(string)
  30831. if status == "0" {
  30832. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  30833. c.ServeSuccessJSON(map[string]interface{}{
  30834. "failed_code": -10,
  30835. "msg": err_msg,
  30836. })
  30837. return
  30838. }
  30839. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30840. userJSONBytes, _ := json.Marshal(respJSON)
  30841. fmt.Println("log")
  30842. fmt.Println(string(userJSONBytes))
  30843. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30844. utils.ErrorLog("解析失败:%v", err)
  30845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30846. return
  30847. }
  30848. } else if miConfig.MdtrtareaAdmvs == "430800" {
  30849. 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, "", "")
  30850. var dat map[string]interface{}
  30851. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30852. fmt.Println(dat)
  30853. } else {
  30854. fmt.Println(err)
  30855. }
  30856. saveLog(result, request_log, "2204", "上传费用明细")
  30857. userJSONBytes, _ := json.Marshal(dat)
  30858. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30859. utils.ErrorLog("解析失败:%v", err)
  30860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30861. return
  30862. }
  30863. } else if miConfig.MdtrtareaAdmvs == "441799" {
  30864. bytesData, _ := json.Marshal(data)
  30865. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  30866. resp, _ := client.Do(req)
  30867. defer resp.Body.Close()
  30868. body, ioErr := ioutil.ReadAll(resp.Body)
  30869. if ioErr != nil {
  30870. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30872. return
  30873. }
  30874. var respJSON map[string]interface{}
  30875. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30876. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30878. return
  30879. }
  30880. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30881. userJSONBytes, _ := json.Marshal(respJSON)
  30882. fmt.Println("log")
  30883. fmt.Println(string(userJSONBytes))
  30884. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30885. utils.ErrorLog("解析失败:%v", err)
  30886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30887. return
  30888. }
  30889. } else {
  30890. if miConfig.MdtrtareaAdmvs == "441202" {
  30891. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30892. if result3101.Infcode == 0 {
  30893. if len(result3101.Output.Result) > 0 {
  30894. var errMsgs []string
  30895. for _, item := range result3101.Output.Result {
  30896. errMsgs = append(errMsgs, item.VolaCont)
  30897. }
  30898. c.ServeSuccessJSON(map[string]interface{}{
  30899. "failed_code": -10,
  30900. "msg": errMsgs,
  30901. })
  30902. return
  30903. } else {
  30904. 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)
  30905. var dat map[string]interface{}
  30906. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30907. fmt.Println(dat)
  30908. } else {
  30909. fmt.Println(err)
  30910. }
  30911. saveLog(result, request_log, "2204", "上传费用明细")
  30912. userJSONBytes, _ := json.Marshal(dat)
  30913. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30914. utils.ErrorLog("解析失败:%v", err)
  30915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30916. return
  30917. }
  30918. }
  30919. } else {
  30920. c.ServeSuccessJSON(map[string]interface{}{
  30921. "failed_code": -10,
  30922. "msg": result3101.ErrMsg,
  30923. })
  30924. return
  30925. }
  30926. } else if miConfig.MdtrtareaAdmvs == "440205" {
  30927. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30928. if result3101.Infcode == 0 {
  30929. if len(result3101.Output.Result) > 0 {
  30930. var errMsgs []string
  30931. for _, item := range result3101.Output.Result {
  30932. errMsgs = append(errMsgs, item.VolaCont)
  30933. }
  30934. c.ServeSuccessJSON(map[string]interface{}{
  30935. "failed_code": -10,
  30936. "msg": errMsgs,
  30937. })
  30938. return
  30939. } else {
  30940. 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)
  30941. var dat map[string]interface{}
  30942. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30943. fmt.Println(dat)
  30944. } else {
  30945. fmt.Println(err)
  30946. }
  30947. saveLog(result, request_log, "2204", "上传费用明细")
  30948. userJSONBytes, _ := json.Marshal(dat)
  30949. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30950. utils.ErrorLog("解析失败:%v", err)
  30951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30952. return
  30953. }
  30954. }
  30955. } else {
  30956. c.ServeSuccessJSON(map[string]interface{}{
  30957. "failed_code": -10,
  30958. "msg": result3101.ErrMsg,
  30959. })
  30960. return
  30961. }
  30962. } else {
  30963. if miConfig.Code == "H15049901371" {
  30964. 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)
  30965. var dat map[string]interface{}
  30966. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30967. fmt.Println(dat)
  30968. } else {
  30969. fmt.Println(err)
  30970. }
  30971. saveLog(result, request_log, "2204", "上传费用明细")
  30972. userJSONBytes, _ := json.Marshal(dat)
  30973. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  30974. utils.ErrorLog("解析失败:%v", err)
  30975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30976. return
  30977. }
  30978. res.InfRefmsgid = resFour10265.InfRefmsgid
  30979. res.Output = resFour10265.Output
  30980. res.ErrMsg = resFour10265.ErrMsg
  30981. res.Cainfo = resFour10265.Cainfo
  30982. res.WarnMsg = resFour10265.WarnMsg
  30983. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  30984. res.Infcode = infocode
  30985. } else {
  30986. if miConfig.Code == "H44030903432" || miConfig.Code == "H44030501364" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" || miConfig.Code == "H44090200998" {
  30987. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  30988. if result3101.Infcode == 0 {
  30989. if len(result3101.Output.Result) > 0 {
  30990. c.ServeSuccessJSON(map[string]interface{}{
  30991. "failed_code": -10,
  30992. "failed_type": 100,
  30993. "warm_type": 1,
  30994. "msg": result3101,
  30995. })
  30996. return
  30997. } else {
  30998. 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)
  30999. var dat map[string]interface{}
  31000. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31001. fmt.Println(dat)
  31002. } else {
  31003. fmt.Println(err)
  31004. }
  31005. saveLog(result, request_log, "2204", "上传费用明细")
  31006. userJSONBytes, _ := json.Marshal(dat)
  31007. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31008. utils.ErrorLog("解析失败:%v", err)
  31009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31010. return
  31011. }
  31012. }
  31013. } else {
  31014. c.ServeSuccessJSON(map[string]interface{}{
  31015. "failed_code": -10,
  31016. "msg": result3101.ErrMsg,
  31017. })
  31018. return
  31019. }
  31020. } else {
  31021. 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)
  31022. var dat map[string]interface{}
  31023. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31024. fmt.Println(dat)
  31025. } else {
  31026. fmt.Println(err)
  31027. }
  31028. saveLog(result, request_log, "2204", "上传费用明细")
  31029. userJSONBytes, _ := json.Marshal(dat)
  31030. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31031. utils.ErrorLog("解析失败:%v", err)
  31032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31033. return
  31034. }
  31035. }
  31036. }
  31037. }
  31038. }
  31039. var total_two float64
  31040. if res.Infcode == -1 {
  31041. errlog := &models.HisOrderError{
  31042. UserOrgId: adminUser.CurrentOrgId,
  31043. Ctime: time.Now().Unix(),
  31044. Mtime: time.Now().Unix(),
  31045. Number: chrg_bchno,
  31046. ErrMsg: res.ErrMsg,
  31047. Status: 1,
  31048. PatientId: id,
  31049. RecordTime: recordDateTime,
  31050. Stage: 4,
  31051. }
  31052. service.CreateErrMsgLog(errlog)
  31053. c.ServeSuccessJSON(map[string]interface{}{
  31054. "failed_code": -10,
  31055. "msg": res.ErrMsg,
  31056. })
  31057. return
  31058. }
  31059. if res.Infcode == 0 {
  31060. order := &models.HisOrder{
  31061. UserOrgId: adminUser.CurrentOrgId,
  31062. HisPatientId: his.ID,
  31063. PatientId: his.PatientId,
  31064. SettleAccountsDate: recordDateTime,
  31065. Ctime: time.Now().Unix(),
  31066. Mtime: time.Now().Unix(),
  31067. MdtrtId: his.Number,
  31068. PsnNo: his.PsnNo,
  31069. MedType: strconv.FormatInt(reg_type, 10),
  31070. Status: 1,
  31071. Number: chrg_bchno,
  31072. Infcode: res.Infcode,
  31073. WarnMsg: res.WarnMsg,
  31074. Cainfo: res.Cainfo,
  31075. ErrMsg: res.ErrMsg,
  31076. RespondTime: res.RefmsgTime,
  31077. InfRefmsgid: res.InfRefmsgid,
  31078. OrderStatus: 1,
  31079. IsMedicineInsurance: 1,
  31080. SettleType: settle_accounts_type,
  31081. SettleStartTime: start_time,
  31082. SettleEndTime: end_time,
  31083. Creator: roles.AdminUserId,
  31084. Modify: roles.AdminUserId,
  31085. PType: 2,
  31086. Diagnosis: diagnosis_id,
  31087. }
  31088. err = service.CreateOrder(order)
  31089. if err != nil {
  31090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  31091. return
  31092. }
  31093. for _, item := range res.Output.Result {
  31094. temp := strings.Split(item.FeedetlSn, "-")
  31095. var advice_id int64 = 0
  31096. var project_id int64 = 0
  31097. var types int64 = 0
  31098. id, _ := strconv.ParseInt(temp[2], 10, 64)
  31099. types, _ = strconv.ParseInt(temp[1], 10, 64)
  31100. if temp[1] == "1" {
  31101. advice_id = id
  31102. project_id = 0
  31103. } else if temp[1] == "2" {
  31104. advice_id = 0
  31105. project_id = id
  31106. }
  31107. total_two = total_two + item.DetItemFeeSumamt
  31108. info := &models.HisOrderInfo{
  31109. OrderNumber: order.Number,
  31110. FeedetlSn: item.FeedetlSn,
  31111. UploadDate: time.Now().Unix(),
  31112. AdviceId: advice_id,
  31113. DetItemFeeSumamt: item.DetItemFeeSumamt,
  31114. Cnt: item.Cnt,
  31115. Pric: float64(item.Pric),
  31116. PatientId: his.PatientId,
  31117. PricUplmtAmt: item.PricUplmtAmt,
  31118. SelfpayProp: item.SelfpayProp,
  31119. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  31120. OverlmtAmt: item.OverlmtAmt,
  31121. PreselfpayAmt: item.PreselfpayAmt,
  31122. BasMednFlag: item.BasMednFlag,
  31123. MedChrgitmType: item.MedChrgitmType,
  31124. HiNegoDrugFlag: item.HiNegoDrugFlag,
  31125. Status: 1,
  31126. Memo: item.Memo,
  31127. Mtime: time.Now().Unix(),
  31128. InscpScpAmt: item.InscpScpAmt,
  31129. DrtReimFlag: item.DrtReimFlag,
  31130. Ctime: time.Now().Unix(),
  31131. ListSpItemFlag: item.ListSpItemFlag,
  31132. ChldMedcFlag: item.ChldMedcFlag,
  31133. LmtUsedFlag: item.LmtUsedFlag,
  31134. ChrgitmLv: item.ChrgitmLv,
  31135. UserOrgId: adminUser.CurrentOrgId,
  31136. HisPatientId: his.ID,
  31137. OrderId: order.ID,
  31138. ProjectId: project_id,
  31139. Type: types,
  31140. }
  31141. service.CreateOrderInfo(info)
  31142. }
  31143. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  31144. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  31145. var total float64
  31146. for _, item := range prescriptions {
  31147. if item.Type == 1 { //药品
  31148. for _, subItem := range item.HisDoctorAdviceInfo {
  31149. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  31150. total_one := price * subItem.PrescribingNumber
  31151. fmt.Println("subItem")
  31152. fmt.Println(subItem.Price)
  31153. fmt.Println("price")
  31154. fmt.Println(price)
  31155. fmt.Println("total_one")
  31156. fmt.Println(total_one)
  31157. total = total + total_one
  31158. fmt.Println(total)
  31159. }
  31160. }
  31161. if item.Type == 2 { //项目
  31162. for _, subItem := range item.HisPrescriptionProject {
  31163. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  31164. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  31165. total_one := price * cnt
  31166. total = total + total_one
  31167. }
  31168. }
  31169. }
  31170. allTotal := fmt.Sprintf("%.2f", total)
  31171. if res.Infcode == 0 {
  31172. var rf []*ResultFive
  31173. json.Unmarshal([]byte(his.Iinfo), &rf)
  31174. chrg_bchno := chrg_bchno
  31175. cert_no := his.Certno
  31176. var insutypes []string
  31177. var insutype string
  31178. var is390 int = 0
  31179. var is310 int = 0
  31180. for _, item := range rf {
  31181. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  31182. insutypes = append(insutypes, item.Insutype)
  31183. }
  31184. }
  31185. if len(insutypes) == 1 {
  31186. insutype = insutypes[0]
  31187. } else {
  31188. for _, i := range insutypes {
  31189. if i == "390" {
  31190. is390 = 1
  31191. }
  31192. if i == "310" {
  31193. is310 = 1
  31194. }
  31195. }
  31196. }
  31197. if is390 == 1 {
  31198. insutype = "390"
  31199. }
  31200. if is310 == 1 {
  31201. insutype = "310"
  31202. }
  31203. if len(insutypes) == 0 {
  31204. insutype = "390"
  31205. }
  31206. if len(insutypes) == 2 {
  31207. insutype = strconv.FormatInt(his.SocialType, 10)
  31208. }
  31209. //insutype = "390"
  31210. if his.IdCardType == 1 {
  31211. cert_no = his.MedicalInsuranceNumber
  31212. } else {
  31213. cert_no = his.Certno
  31214. }
  31215. var res ResultSeven
  31216. var ahres ResultSevenAH
  31217. var resSeven10265 ResultSeven10265
  31218. var resSeven10265Two ResultSeven10265Two
  31219. var resSeven10633Three ResultSeven10633Three
  31220. var gzresSeven10265Two GZResultSeven10265Two
  31221. if miConfig.MdtrtareaAdmvs == "421300" {
  31222. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  31223. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31224. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31225. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31226. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31227. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31228. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31229. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31230. resp, requestErr := http.Get(api)
  31231. if requestErr != nil {
  31232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31233. return
  31234. }
  31235. body, ioErr := ioutil.ReadAll(resp.Body)
  31236. if ioErr != nil {
  31237. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31239. return
  31240. }
  31241. var respJSON map[string]interface{}
  31242. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31243. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31245. return
  31246. }
  31247. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31248. result, _ := json.Marshal(respJSON)
  31249. fmt.Println("log")
  31250. fmt.Println(string(result))
  31251. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31252. utils.ErrorLog("解析失败:%v", err)
  31253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31254. return
  31255. }
  31256. } else if miConfig.MdtrtareaAdmvs == "420200" {
  31257. if reg_type == 11 && his.Insutype == "390" {
  31258. reg_type = 110104
  31259. }
  31260. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31261. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31262. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31263. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31264. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31265. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31266. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31267. resp, requestErr := http.Get(api)
  31268. if requestErr != nil {
  31269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31270. return
  31271. }
  31272. body, ioErr := ioutil.ReadAll(resp.Body)
  31273. if ioErr != nil {
  31274. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31276. return
  31277. }
  31278. var respJSON map[string]interface{}
  31279. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31280. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31282. return
  31283. }
  31284. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31285. result, _ := json.Marshal(respJSON)
  31286. fmt.Println("log")
  31287. fmt.Println(string(result))
  31288. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31289. utils.ErrorLog("解析失败:%v", err)
  31290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31291. return
  31292. }
  31293. } else if miConfig.MdtrtareaAdmvs == "420902" {
  31294. if reg_type == 11 && his.Insutype == "390" {
  31295. reg_type = 110104
  31296. }
  31297. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31298. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31299. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31300. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31301. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31302. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31303. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31304. resp, requestErr := http.Get(api)
  31305. if requestErr != nil {
  31306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31307. return
  31308. }
  31309. body, ioErr := ioutil.ReadAll(resp.Body)
  31310. if ioErr != nil {
  31311. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31313. return
  31314. }
  31315. var respJSON map[string]interface{}
  31316. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31317. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31319. return
  31320. }
  31321. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31322. result, _ := json.Marshal(respJSON)
  31323. fmt.Println("log")
  31324. fmt.Println(string(result))
  31325. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31326. utils.ErrorLog("解析失败:%v", err)
  31327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31328. return
  31329. }
  31330. } else if miConfig.MdtrtareaAdmvs == "421182" {
  31331. if reg_type == 11 && his.Insutype == "390" {
  31332. reg_type = 110104
  31333. }
  31334. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31335. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31336. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31337. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31338. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31339. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31340. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  31341. resp, requestErr := http.Get(api)
  31342. if requestErr != nil {
  31343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31344. return
  31345. }
  31346. body, ioErr := ioutil.ReadAll(resp.Body)
  31347. if ioErr != nil {
  31348. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31350. return
  31351. }
  31352. var respJSON map[string]interface{}
  31353. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31354. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31356. return
  31357. }
  31358. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31359. result, _ := json.Marshal(respJSON)
  31360. fmt.Println("log")
  31361. fmt.Println(string(result))
  31362. if err := json.Unmarshal([]byte(result), &res); err != nil {
  31363. utils.ErrorLog("解析失败:%v", err)
  31364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31365. return
  31366. }
  31367. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  31368. //result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  31369. var result3101 Result3101
  31370. //utils.ErrorLog("解析失败:%v", result3101)
  31371. result3101.Infcode = "0"
  31372. if result3101.Infcode == "0" {
  31373. if len(result3101.Output.Result) > 0 {
  31374. var errMsgs []string
  31375. for _, item := range result3101.Output.Result {
  31376. errMsgs = append(errMsgs, item.VolaCont)
  31377. }
  31378. c.ServeSuccessJSON(map[string]interface{}{
  31379. "failed_code": -10,
  31380. "msg": errMsgs,
  31381. })
  31382. return
  31383. } else {
  31384. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31385. if his.IdCardType != 4 {
  31386. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  31387. bas := strings.Split(psn_info.CardInfo, "|")
  31388. if his.IdCardType == 1 {
  31389. cert_no = bas[2]
  31390. } else {
  31391. cert_no = bas[1]
  31392. }
  31393. } else {
  31394. cert_no = his.Certno
  31395. }
  31396. //江苏地区国家医保医疗类别
  31397. //职工透析:医疗类别选特殊情况门诊9933
  31398. //居民血透门慢: 医疗类别选门诊慢病1402
  31399. //var med_type string
  31400. //if his.Insutype == "310" {
  31401. // if reg_type == 14 {
  31402. // med_type = "9933"
  31403. // } else if reg_type == 11 {
  31404. // med_type = "11"
  31405. //
  31406. // }
  31407. //} else if his.Insutype == "390" {
  31408. // if reg_type == 14 {
  31409. // med_type = "1402"
  31410. // } else if reg_type == 11 {
  31411. // med_type = "11"
  31412. // }
  31413. //}
  31414. var api string
  31415. if miConfig.MdtrtareaAdmvs == "320830" {
  31416. api = miConfig.AppSecret + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31417. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31418. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31419. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31420. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31421. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31422. "&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
  31423. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31424. } else if miConfig.MdtrtareaAdmvs == "320921" {
  31425. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31426. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31427. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31428. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31429. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31430. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31431. "&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
  31432. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31433. } else {
  31434. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  31435. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31436. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  31437. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31438. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31439. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  31440. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31441. "&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
  31442. }
  31443. resp, requestErr := http.Get(api)
  31444. if requestErr != nil {
  31445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31446. return
  31447. }
  31448. body, ioErr := ioutil.ReadAll(resp.Body)
  31449. if ioErr != nil {
  31450. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31452. return
  31453. }
  31454. var respJSON map[string]interface{}
  31455. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31456. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31458. return
  31459. }
  31460. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31461. result, _ := json.Marshal(respJSON)
  31462. fmt.Println("log")
  31463. fmt.Println(string(result))
  31464. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  31465. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  31466. utils.ErrorLog("解析失败:%v", err)
  31467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31468. return
  31469. }
  31470. res.InfRefmsgid = resSeven10265.InfRefmsgid
  31471. res.Output = resSeven10265.Output
  31472. res.ErrMsg = resSeven10265.ErrMsg
  31473. res.Cainfo = resSeven10265.Cainfo
  31474. res.WarnMsg = resSeven10265.WarnMsg
  31475. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  31476. res.Infcode = infocode
  31477. } else {
  31478. if miConfig.MdtrtareaAdmvs == "320830" {
  31479. if strings.HasPrefix(his.InsuplcAdmdvs[0:3], "320") && !strings.HasPrefix(his.InsuplcAdmdvs[0:4], "3208") {
  31480. if err := json.Unmarshal([]byte(result), &resSeven10633Three); err != nil {
  31481. utils.ErrorLog("解析失败:%v", err)
  31482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31483. return
  31484. }
  31485. res.InfRefmsgid = resSeven10633Three.InfRefmsgid
  31486. AcctMulaidPay, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.AcctMulaidPay, 64)
  31487. res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  31488. res.Output.Setlinfo.AcctPay = resSeven10633Three.Output.Setlinfo.AcctPay
  31489. res.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31490. res.Output.Setlinfo.ActPayDedc = resSeven10633Three.Output.Setlinfo.ActPayDedc
  31491. res.Output.Setlinfo.Age = resSeven10633Three.Output.Setlinfo.Age
  31492. res.Output.Setlinfo.Balc = resSeven10633Three.Output.Setlinfo.Balc
  31493. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31494. res.Output.Setlinfo.Certno = resSeven10633Three.Output.Setlinfo.Certno
  31495. res.Output.Setlinfo.ClrOptins = resSeven10633Three.Output.Setlinfo.ClrOptins
  31496. res.Output.Setlinfo.ClrType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31497. res.Output.Setlinfo.ClrWay = resSeven10633Three.Output.Setlinfo.ClrOptins
  31498. res.Output.Setlinfo.CvlservFlag = resSeven10633Three.Output.Setlinfo.ClrOptins
  31499. res.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31500. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10633Three.Output.Setlinfo.FulamtOwnpayAmt
  31501. res.Output.Setlinfo.FundPaySumamt = resSeven10633Three.Output.Setlinfo.FundPaySumamt
  31502. res.Output.Setlinfo.Gend = resSeven10633Three.Output.Setlinfo.Gend
  31503. res.Output.Setlinfo.HifesPay = resSeven10633Three.Output.Setlinfo.HifesPay
  31504. res.Output.Setlinfo.HifmiPay = resSeven10633Three.Output.Setlinfo.HifmiPay
  31505. res.Output.Setlinfo.HifpPay = resSeven10633Three.Output.Setlinfo.HifpPay
  31506. HospPartAmt, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.HospPartAmt, 64)
  31507. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  31508. res.Output.Setlinfo.InscpScpAmt = resSeven10633Three.Output.Setlinfo.InscpScpAmt
  31509. res.Output.Setlinfo.Insutype = resSeven10633Three.Output.Setlinfo.Insutype
  31510. res.Output.Setlinfo.MafPay = resSeven10633Three.Output.Setlinfo.MafPay
  31511. res.Output.Setlinfo.MdtrtCertType = resSeven10633Three.Output.Setlinfo.MdtrtCertType
  31512. res.Output.Setlinfo.HifobPay = resSeven10633Three.Output.Setlinfo.HifobPay
  31513. res.Output.Setlinfo.MdtrtID = resSeven10633Three.Output.Setlinfo.MdtrtID
  31514. res.Output.Setlinfo.MedType = resSeven10633Three.Output.Setlinfo.MedType
  31515. res.Output.Setlinfo.MedfeeSumamt = resSeven10633Three.Output.Setlinfo.MedfeeSumamt
  31516. res.Output.Setlinfo.MedinsSetlID = resSeven10633Three.Output.Setlinfo.MedinsSetlID
  31517. res.Output.Setlinfo.Naty = resSeven10633Three.Output.Setlinfo.Naty
  31518. res.Output.Setlinfo.OthPay = resSeven10633Three.Output.Setlinfo.OthPay
  31519. res.Output.Setlinfo.OverlmtSelfpay = resSeven10633Three.Output.Setlinfo.OverlmtSelfpay
  31520. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.PoolPropSelfpay, 64)
  31521. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  31522. res.Output.Setlinfo.PreselfpayAmt = resSeven10633Three.Output.Setlinfo.PreselfpayAmt
  31523. res.Output.Setlinfo.PsnCashPay = resSeven10633Three.Output.Setlinfo.PsnCashPay
  31524. res.Output.Setlinfo.PsnCertType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31525. res.Output.Setlinfo.PsnName = resSeven10633Three.Output.Setlinfo.PsnName
  31526. res.Output.Setlinfo.PsnNo = resSeven10633Three.Output.Setlinfo.PsnNo
  31527. res.Output.Setlinfo.PsnPartAmt = resSeven10633Three.Output.Setlinfo.PsnPartAmt
  31528. res.Output.Setlinfo.PsnType = resSeven10633Three.Output.Setlinfo.PsnType
  31529. res.Output.Setlinfo.SetlID = resSeven10633Three.Output.Setlinfo.SetlID
  31530. res.Output.Setlinfo.SetlTime = resSeven10633Three.Output.Setlinfo.SetlTime
  31531. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31532. res.ErrMsg = resSeven10633Three.ErrMsg
  31533. res.Cainfo = resSeven10633Three.Cainfo
  31534. res.WarnMsg = resSeven10633Three.WarnMsg
  31535. infocode, _ := strconv.ParseInt(resSeven10633Three.Infcode, 10, 64)
  31536. res.Infcode = infocode
  31537. } else {
  31538. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  31539. utils.ErrorLog("解析失败:%v", err)
  31540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31541. return
  31542. }
  31543. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  31544. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  31545. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  31546. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  31547. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  31548. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  31549. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  31550. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  31551. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31552. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  31553. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  31554. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  31555. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  31556. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  31557. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  31558. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  31559. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  31560. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  31561. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  31562. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  31563. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  31564. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  31565. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  31566. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  31567. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  31568. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  31569. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  31570. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  31571. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  31572. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  31573. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  31574. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  31575. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  31576. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  31577. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  31578. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  31579. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  31580. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  31581. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  31582. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  31583. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  31584. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  31585. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31586. res.ErrMsg = resSeven10265Two.ErrMsg
  31587. res.Cainfo = resSeven10265Two.Cainfo
  31588. res.WarnMsg = resSeven10265Two.WarnMsg
  31589. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  31590. res.Infcode = infocode
  31591. }
  31592. } else {
  31593. if strings.HasPrefix(his.InsuplcAdmdvs[0:3], "320") && !strings.HasPrefix(his.InsuplcAdmdvs[0:4], "3209") {
  31594. if err := json.Unmarshal([]byte(result), &resSeven10633Three); err != nil {
  31595. utils.ErrorLog("解析失败:%v", err)
  31596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31597. return
  31598. }
  31599. res.InfRefmsgid = resSeven10633Three.InfRefmsgid
  31600. AcctMulaidPay, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.AcctMulaidPay, 64)
  31601. res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  31602. res.Output.Setlinfo.AcctPay = resSeven10633Three.Output.Setlinfo.AcctPay
  31603. res.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31604. res.Output.Setlinfo.ActPayDedc = resSeven10633Three.Output.Setlinfo.ActPayDedc
  31605. res.Output.Setlinfo.Age = resSeven10633Three.Output.Setlinfo.Age
  31606. res.Output.Setlinfo.Balc = resSeven10633Three.Output.Setlinfo.Balc
  31607. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31608. res.Output.Setlinfo.Certno = resSeven10633Three.Output.Setlinfo.Certno
  31609. res.Output.Setlinfo.ClrOptins = resSeven10633Three.Output.Setlinfo.ClrOptins
  31610. res.Output.Setlinfo.ClrType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31611. res.Output.Setlinfo.ClrWay = resSeven10633Three.Output.Setlinfo.ClrOptins
  31612. res.Output.Setlinfo.CvlservFlag = resSeven10633Three.Output.Setlinfo.ClrOptins
  31613. res.Output.Setlinfo.CvlservPay = resSeven10633Three.Output.Setlinfo.CvlservPay
  31614. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10633Three.Output.Setlinfo.FulamtOwnpayAmt
  31615. res.Output.Setlinfo.FundPaySumamt = resSeven10633Three.Output.Setlinfo.FundPaySumamt
  31616. res.Output.Setlinfo.Gend = resSeven10633Three.Output.Setlinfo.Gend
  31617. res.Output.Setlinfo.HifesPay = resSeven10633Three.Output.Setlinfo.HifesPay
  31618. res.Output.Setlinfo.HifmiPay = resSeven10633Three.Output.Setlinfo.HifmiPay
  31619. res.Output.Setlinfo.HifpPay = resSeven10633Three.Output.Setlinfo.HifpPay
  31620. HospPartAmt, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.HospPartAmt, 64)
  31621. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  31622. res.Output.Setlinfo.InscpScpAmt = resSeven10633Three.Output.Setlinfo.InscpScpAmt
  31623. res.Output.Setlinfo.Insutype = resSeven10633Three.Output.Setlinfo.Insutype
  31624. res.Output.Setlinfo.MafPay = resSeven10633Three.Output.Setlinfo.MafPay
  31625. res.Output.Setlinfo.MdtrtCertType = resSeven10633Three.Output.Setlinfo.MdtrtCertType
  31626. res.Output.Setlinfo.HifobPay = resSeven10633Three.Output.Setlinfo.HifobPay
  31627. res.Output.Setlinfo.MdtrtID = resSeven10633Three.Output.Setlinfo.MdtrtID
  31628. res.Output.Setlinfo.MedType = resSeven10633Three.Output.Setlinfo.MedType
  31629. res.Output.Setlinfo.MedfeeSumamt = resSeven10633Three.Output.Setlinfo.MedfeeSumamt
  31630. res.Output.Setlinfo.MedinsSetlID = resSeven10633Three.Output.Setlinfo.MedinsSetlID
  31631. res.Output.Setlinfo.Naty = resSeven10633Three.Output.Setlinfo.Naty
  31632. res.Output.Setlinfo.OthPay = resSeven10633Three.Output.Setlinfo.OthPay
  31633. res.Output.Setlinfo.OverlmtSelfpay = resSeven10633Three.Output.Setlinfo.OverlmtSelfpay
  31634. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10633Three.Output.Setlinfo.PoolPropSelfpay, 64)
  31635. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  31636. res.Output.Setlinfo.PreselfpayAmt = resSeven10633Three.Output.Setlinfo.PreselfpayAmt
  31637. res.Output.Setlinfo.PsnCashPay = resSeven10633Three.Output.Setlinfo.PsnCashPay
  31638. res.Output.Setlinfo.PsnCertType = resSeven10633Three.Output.Setlinfo.ClrOptins
  31639. res.Output.Setlinfo.PsnName = resSeven10633Three.Output.Setlinfo.PsnName
  31640. res.Output.Setlinfo.PsnNo = resSeven10633Three.Output.Setlinfo.PsnNo
  31641. res.Output.Setlinfo.PsnPartAmt = resSeven10633Three.Output.Setlinfo.PsnPartAmt
  31642. res.Output.Setlinfo.PsnType = resSeven10633Three.Output.Setlinfo.PsnType
  31643. res.Output.Setlinfo.SetlID = resSeven10633Three.Output.Setlinfo.SetlID
  31644. res.Output.Setlinfo.SetlTime = resSeven10633Three.Output.Setlinfo.SetlTime
  31645. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31646. res.ErrMsg = resSeven10633Three.ErrMsg
  31647. res.Cainfo = resSeven10633Three.Cainfo
  31648. res.WarnMsg = resSeven10633Three.WarnMsg
  31649. infocode, _ := strconv.ParseInt(resSeven10633Three.Infcode, 10, 64)
  31650. res.Infcode = infocode
  31651. } else {
  31652. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  31653. utils.ErrorLog("解析失败:%v", err)
  31654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31655. return
  31656. }
  31657. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  31658. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  31659. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  31660. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  31661. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  31662. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  31663. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  31664. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  31665. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  31666. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  31667. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  31668. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  31669. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  31670. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  31671. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  31672. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  31673. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  31674. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  31675. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  31676. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  31677. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  31678. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  31679. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  31680. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  31681. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  31682. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  31683. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  31684. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  31685. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  31686. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  31687. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  31688. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  31689. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  31690. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  31691. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  31692. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  31693. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  31694. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  31695. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  31696. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  31697. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  31698. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  31699. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  31700. res.ErrMsg = resSeven10265Two.ErrMsg
  31701. res.Cainfo = resSeven10265Two.Cainfo
  31702. res.WarnMsg = resSeven10265Two.WarnMsg
  31703. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  31704. res.Infcode = infocode
  31705. }
  31706. }
  31707. }
  31708. }
  31709. }
  31710. } else if miConfig.MdtrtareaAdmvs == "150499" {
  31711. psn_info, _ := service.GetPsnByPatientId(id)
  31712. var verify_number string
  31713. if psn_info.IdCardType == 4 {
  31714. verify_number = psn_info.VerifyNumber
  31715. } else if psn_info.IdCardType == 1 {
  31716. bas := strings.Split(psn_info.CardInfo, "|")
  31717. cardNumber := bas[2]
  31718. verify_number = cardNumber
  31719. } else {
  31720. psn_info.IdCardType = 2
  31721. verify_number = psn_info.Certno
  31722. }
  31723. var api string
  31724. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  31725. his.Number + "&chrg_bchno=" + new_chrg_bchno + "&org_name=" + miConfig.OrgName +
  31726. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  31727. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  31728. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  31729. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  31730. "&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
  31731. resp, requestErr := http.Get(api)
  31732. if requestErr != nil {
  31733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31734. return
  31735. }
  31736. body, ioErr := ioutil.ReadAll(resp.Body)
  31737. if ioErr != nil {
  31738. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31740. return
  31741. }
  31742. var respJSON map[string]interface{}
  31743. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  31744. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31746. return
  31747. }
  31748. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31749. result, _ := json.Marshal(respJSON)
  31750. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  31751. utils.ErrorLog("解析失败:%v", err)
  31752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31753. return
  31754. }
  31755. res.InfRefmsgid = resSeven10265.InfRefmsgid
  31756. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  31757. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  31758. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  31759. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  31760. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  31761. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  31762. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  31763. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  31764. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  31765. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  31766. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  31767. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  31768. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  31769. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  31770. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  31771. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  31772. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  31773. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  31774. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  31775. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  31776. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  31777. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  31778. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  31779. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  31780. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  31781. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  31782. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  31783. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  31784. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  31785. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  31786. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  31787. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  31788. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  31789. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  31790. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  31791. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  31792. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  31793. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  31794. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  31795. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  31796. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  31797. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  31798. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  31799. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  31800. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  31801. res.ErrMsg = resSeven10265.ErrMsg
  31802. res.Cainfo = resSeven10265.Cainfo
  31803. res.WarnMsg = resSeven10265.WarnMsg
  31804. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  31805. res.Infcode = infocode
  31806. } else if miConfig.MdtrtareaAdmvs == "350500" {
  31807. acct_used_flag := "1"
  31808. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  31809. var result string
  31810. var request_log string
  31811. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  31812. 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)
  31813. } else {
  31814. 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)
  31815. }
  31816. var dat map[string]interface{}
  31817. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31818. fmt.Println(dat)
  31819. } else {
  31820. fmt.Println(err)
  31821. }
  31822. saveLog(result, request_log, "2206", "预结算")
  31823. userJSONBytes, _ := json.Marshal(dat)
  31824. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31825. utils.ErrorLog("解析失败:%v", err)
  31826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31827. return
  31828. }
  31829. } else if miConfig.MdtrtareaAdmvs == "360302" {
  31830. var result string
  31831. var request_log string
  31832. if his.IdCardType == 2 {
  31833. insutype = strconv.FormatInt(his.SocialType, 10)
  31834. 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, "")
  31835. } else if his.IdCardType == 1 {
  31836. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31837. bas := strings.Split(psn_info.CardInfo, "|")
  31838. basNumber := bas[2]
  31839. card_sn := bas[3]
  31840. var rf []*ResultFive
  31841. json.Unmarshal([]byte(his.Iinfo), &rf)
  31842. var psn_type string
  31843. for _, item := range rf {
  31844. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31845. psn_type = item.PsnType
  31846. }
  31847. }
  31848. insutype = strconv.FormatInt(his.SocialType, 10)
  31849. 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)
  31850. } else {
  31851. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31852. //bas := strings.Split(psn_info.CardInfo, "|")
  31853. //basNumber := bas[2]
  31854. //card_sn := bas[3]
  31855. var rf []*ResultFive
  31856. json.Unmarshal([]byte(his.Iinfo), &rf)
  31857. var psn_type string
  31858. for _, item := range rf {
  31859. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31860. psn_type = item.PsnType
  31861. }
  31862. }
  31863. insutype = strconv.FormatInt(his.SocialType, 10)
  31864. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31865. 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)
  31866. }
  31867. var dat map[string]interface{}
  31868. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31869. fmt.Println(dat)
  31870. } else {
  31871. fmt.Println(err)
  31872. }
  31873. saveLog(result, request_log, "2206", "预结算")
  31874. userJSONBytes, _ := json.Marshal(dat)
  31875. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31876. utils.ErrorLog("解析失败:%v", err)
  31877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31878. return
  31879. }
  31880. } else if miConfig.MdtrtareaAdmvs == "361025" {
  31881. var result string
  31882. var request_log string
  31883. if his.IdCardType == 2 {
  31884. insutype = strconv.FormatInt(his.SocialType, 10)
  31885. 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, "")
  31886. } else if his.IdCardType == 1 {
  31887. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31888. bas := strings.Split(psn_info.CardInfo, "|")
  31889. basNumber := bas[0]
  31890. card_sn := ""
  31891. var rf []*ResultFive
  31892. json.Unmarshal([]byte(his.Iinfo), &rf)
  31893. var psn_type string
  31894. for _, item := range rf {
  31895. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31896. psn_type = item.PsnType
  31897. }
  31898. }
  31899. insutype = strconv.FormatInt(his.SocialType, 10)
  31900. 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)
  31901. } else {
  31902. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31903. //bas := strings.Split(psn_info.CardInfo, "|")
  31904. //basNumber := bas[2]
  31905. //card_sn := bas[3]
  31906. var rf []*ResultFive
  31907. json.Unmarshal([]byte(his.Iinfo), &rf)
  31908. var psn_type string
  31909. for _, item := range rf {
  31910. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31911. psn_type = item.PsnType
  31912. }
  31913. }
  31914. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31915. 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)
  31916. }
  31917. var dat map[string]interface{}
  31918. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31919. fmt.Println(dat)
  31920. } else {
  31921. fmt.Println(err)
  31922. }
  31923. saveLog(result, request_log, "2206", "预结算")
  31924. userJSONBytes, _ := json.Marshal(dat)
  31925. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31926. utils.ErrorLog("解析失败:%v", err)
  31927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31928. return
  31929. }
  31930. } else if miConfig.MdtrtareaAdmvs == "360100" {
  31931. var result string
  31932. var request_log string
  31933. if his.IdCardType == 2 {
  31934. insutype = strconv.FormatInt(his.SocialType, 10)
  31935. 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, "")
  31936. } else if his.IdCardType == 1 {
  31937. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31938. bas := strings.Split(psn_info.CardInfo, "|")
  31939. basNumber := bas[0]
  31940. card_sn := ""
  31941. var rf []*ResultFive
  31942. json.Unmarshal([]byte(his.Iinfo), &rf)
  31943. var psn_type string
  31944. for _, item := range rf {
  31945. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31946. psn_type = item.PsnType
  31947. }
  31948. }
  31949. insutype = strconv.FormatInt(his.SocialType, 10)
  31950. 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)
  31951. } else {
  31952. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31953. //bas := strings.Split(psn_info.CardInfo, "|")
  31954. //basNumber := bas[2]
  31955. //card_sn := bas[3]
  31956. var rf []*ResultFive
  31957. json.Unmarshal([]byte(his.Iinfo), &rf)
  31958. var psn_type string
  31959. for _, item := range rf {
  31960. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  31961. psn_type = item.PsnType
  31962. }
  31963. }
  31964. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31965. 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)
  31966. }
  31967. var dat map[string]interface{}
  31968. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  31969. fmt.Println(dat)
  31970. } else {
  31971. fmt.Println(err)
  31972. }
  31973. saveLog(result, request_log, "2206", "预结算")
  31974. userJSONBytes, _ := json.Marshal(dat)
  31975. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31976. utils.ErrorLog("解析失败:%v", err)
  31977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31978. return
  31979. }
  31980. } else if miConfig.MdtrtareaAdmvs == "341203" {
  31981. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  31982. if his.IdCardType == 4 {
  31983. psn_info.VerifyNumber = psn_info.VerifyNumber
  31984. cert_no = psn_info.VerifyNumber
  31985. } else if his.IdCardType == 2 {
  31986. cert_no = psn_info.Certno
  31987. psn_info.VerifyNumber = psn_info.Certno
  31988. } else {
  31989. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  31990. bas := strings.Split(psn_info.CardInfo, "|")
  31991. if his.IdCardType == 1 {
  31992. cert_no = bas[2]
  31993. } else {
  31994. cert_no = bas[1]
  31995. }
  31996. }
  31997. var api string
  31998. var med_type string
  31999. if his.Insutype == "390" {
  32000. if reg_type == 992102 {
  32001. med_type = "992102"
  32002. }
  32003. if reg_type == 140104 {
  32004. med_type = "140104"
  32005. }
  32006. if reg_type == 140201 {
  32007. med_type = "140201"
  32008. }
  32009. if reg_type == 14 {
  32010. med_type = "140104"
  32011. }
  32012. if reg_type == 1104 {
  32013. med_type = "1104"
  32014. }
  32015. } else if his.Insutype == "310" {
  32016. if reg_type == 1104 {
  32017. med_type = "1104"
  32018. }
  32019. if reg_type == 992102 {
  32020. med_type = "992102"
  32021. }
  32022. if reg_type == 140104 {
  32023. med_type = "140104"
  32024. }
  32025. if reg_type == 140201 {
  32026. med_type = "140201"
  32027. }
  32028. if reg_type == 14 {
  32029. med_type = "140104"
  32030. }
  32031. }
  32032. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  32033. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  32034. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32035. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32036. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  32037. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  32038. "&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
  32039. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32040. resp, requestErr := http.Get(api)
  32041. if requestErr != nil {
  32042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32043. return
  32044. }
  32045. body, ioErr := ioutil.ReadAll(resp.Body)
  32046. if ioErr != nil {
  32047. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32049. return
  32050. }
  32051. var respJSON map[string]interface{}
  32052. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32053. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32055. return
  32056. }
  32057. status := respJSON["data"].(map[string]interface{})["status"].(string)
  32058. if status == "0" {
  32059. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  32060. c.ServeSuccessJSON(map[string]interface{}{
  32061. "failed_code": -10,
  32062. "msg": err_msg,
  32063. })
  32064. return
  32065. }
  32066. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32067. result, _ := json.Marshal(respJSON)
  32068. fmt.Println("log")
  32069. fmt.Println(string(result))
  32070. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  32071. utils.ErrorLog("解析失败:%v", err)
  32072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32073. return
  32074. }
  32075. res.InfRefmsgid = ahres.InfRefmsgid
  32076. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  32077. // 创建对应的Time类型
  32078. t := time.UnixMilli(timestamp)
  32079. // 格式化成指定的日期字符串
  32080. str := t.Format("2006-01-02 15:04:05")
  32081. res.Output.Setlinfo.SetlTime = str
  32082. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  32083. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  32084. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32085. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  32086. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  32087. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  32088. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32089. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  32090. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  32091. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  32092. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  32093. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  32094. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32095. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  32096. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  32097. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  32098. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  32099. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  32100. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  32101. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32102. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  32103. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  32104. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  32105. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  32106. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  32107. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  32108. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  32109. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  32110. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  32111. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  32112. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  32113. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  32114. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  32115. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  32116. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  32117. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  32118. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  32119. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  32120. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  32121. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  32122. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  32123. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  32124. //res.Output.Setldetail = ahres.Output.Setldetail
  32125. res.ErrMsg = ahres.ErrMsg
  32126. res.Cainfo = ahres.Cainfo
  32127. res.WarnMsg = ahres.WarnMsg
  32128. res.Infcode = ahres.Infcode
  32129. } else if miConfig.MdtrtareaAdmvs == "340699" {
  32130. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32131. if his.IdCardType == 4 {
  32132. psn_info.VerifyNumber = psn_info.VerifyNumber
  32133. cert_no = psn_info.Certno
  32134. } else if his.IdCardType == 2 {
  32135. cert_no = psn_info.Certno
  32136. psn_info.VerifyNumber = psn_info.Certno
  32137. } else {
  32138. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  32139. bas := strings.Split(psn_info.CardInfo, "|")
  32140. if his.IdCardType == 1 {
  32141. cert_no = bas[2]
  32142. } else {
  32143. cert_no = bas[1]
  32144. }
  32145. }
  32146. var api string
  32147. var med_type string
  32148. if his.Insutype == "390" {
  32149. if reg_type == 992102 {
  32150. med_type = "992102"
  32151. }
  32152. if reg_type == 140104 {
  32153. med_type = "140104"
  32154. }
  32155. if reg_type == 140201 {
  32156. med_type = "140201"
  32157. }
  32158. if reg_type == 14 {
  32159. med_type = "14"
  32160. }
  32161. } else if his.Insutype == "310" {
  32162. if reg_type == 992102 {
  32163. med_type = "992102"
  32164. }
  32165. if reg_type == 140104 {
  32166. med_type = "140104"
  32167. }
  32168. if reg_type == 140201 {
  32169. med_type = "140201"
  32170. }
  32171. if reg_type == 14 {
  32172. med_type = "14"
  32173. }
  32174. }
  32175. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  32176. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  32177. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32178. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32179. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  32180. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  32181. "&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
  32182. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32183. resp, requestErr := http.Get(api)
  32184. if requestErr != nil {
  32185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32186. return
  32187. }
  32188. body, ioErr := ioutil.ReadAll(resp.Body)
  32189. if ioErr != nil {
  32190. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32192. return
  32193. }
  32194. var respJSON map[string]interface{}
  32195. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32196. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32198. return
  32199. }
  32200. status := respJSON["data"].(map[string]interface{})["status"].(string)
  32201. if status == "0" {
  32202. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  32203. c.ServeSuccessJSON(map[string]interface{}{
  32204. "failed_code": -10,
  32205. "msg": err_msg,
  32206. })
  32207. return
  32208. }
  32209. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32210. result, _ := json.Marshal(respJSON)
  32211. fmt.Println("log")
  32212. fmt.Println(string(result))
  32213. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  32214. utils.ErrorLog("解析失败:%v", err)
  32215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32216. return
  32217. }
  32218. res.InfRefmsgid = ahres.InfRefmsgid
  32219. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  32220. // 创建对应的Time类型
  32221. t := time.UnixMilli(timestamp)
  32222. // 格式化成指定的日期字符串
  32223. str := t.Format("2006-01-02 15:04:05")
  32224. res.Output.Setlinfo.SetlTime = str
  32225. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  32226. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  32227. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32228. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  32229. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  32230. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  32231. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32232. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  32233. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  32234. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  32235. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  32236. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  32237. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  32238. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  32239. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  32240. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  32241. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  32242. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  32243. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  32244. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32245. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  32246. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  32247. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  32248. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  32249. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  32250. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  32251. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  32252. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  32253. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  32254. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  32255. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  32256. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  32257. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  32258. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  32259. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  32260. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  32261. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  32262. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  32263. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  32264. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  32265. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  32266. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  32267. //res.Output.Setldetail = ahres.Output.Setldetail
  32268. res.ErrMsg = ahres.ErrMsg
  32269. res.Cainfo = ahres.Cainfo
  32270. res.WarnMsg = ahres.WarnMsg
  32271. res.Infcode = ahres.Infcode
  32272. } else if miConfig.MdtrtareaAdmvs == "430800" {
  32273. var result string
  32274. var request_log string
  32275. if his.IdCardType == 2 {
  32276. 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")
  32277. } else if his.IdCardType == 1 {
  32278. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32279. bas := strings.Split(psn_info.CardInfo, "|")
  32280. basNumber := bas[2]
  32281. card_sn := bas[3]
  32282. 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")
  32283. } else {
  32284. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32285. 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")
  32286. }
  32287. var dat map[string]interface{}
  32288. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32289. fmt.Println(dat)
  32290. } else {
  32291. fmt.Println(err)
  32292. }
  32293. saveLog(result, request_log, "2206", "预结算")
  32294. userJSONBytes, _ := json.Marshal(dat)
  32295. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32296. utils.ErrorLog("解析失败:%v", err)
  32297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32298. return
  32299. }
  32300. } else if miConfig.MdtrtareaAdmvs == "441799" {
  32301. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  32302. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  32303. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  32304. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  32305. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  32306. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  32307. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  32308. resp, requestErr := http.Get(api)
  32309. if requestErr != nil {
  32310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32311. return
  32312. }
  32313. body, ioErr := ioutil.ReadAll(resp.Body)
  32314. if ioErr != nil {
  32315. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  32316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32317. return
  32318. }
  32319. var respJSON map[string]interface{}
  32320. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  32321. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32323. return
  32324. }
  32325. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32326. result, _ := json.Marshal(respJSON)
  32327. fmt.Println("log")
  32328. fmt.Println(string(result))
  32329. if err := json.Unmarshal([]byte(result), &res); err != nil {
  32330. utils.ErrorLog("解析失败:%v", err)
  32331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32332. return
  32333. }
  32334. } else {
  32335. if miConfig.MdtrtareaAdmvs == "441202" {
  32336. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  32337. if result3101.Infcode == 0 {
  32338. if len(result3101.Output.Result) > 0 {
  32339. c.ServeSuccessJSON(map[string]interface{}{
  32340. "failed_code": -10,
  32341. "failed_type": 100,
  32342. "msg": result3101.Output.Result,
  32343. })
  32344. return
  32345. } else {
  32346. var result string
  32347. var request_log string
  32348. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32349. allTotal = fmt.Sprintf("%.2f", total_two)
  32350. if his.IdCardType == 4 {
  32351. 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)
  32352. } else {
  32353. 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)
  32354. }
  32355. var dat map[string]interface{}
  32356. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32357. fmt.Println(dat)
  32358. } else {
  32359. fmt.Println(err)
  32360. }
  32361. saveLog(result, request_log, "2206", "预结算")
  32362. //userJSONBytes, _ := json.Marshal(dat)
  32363. //
  32364. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32365. // utils.ErrorLog("解析失败:%v", err)
  32366. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32367. // return
  32368. //}
  32369. userJSONBytes, _ := json.Marshal(dat)
  32370. if miConfig.Code == "H15049901371" {
  32371. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  32372. utils.ErrorLog("解析失败:%v", err)
  32373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32374. return
  32375. }
  32376. res.InfRefmsgid = resSeven10265.InfRefmsgid
  32377. res.Output = resSeven10265.Output
  32378. res.ErrMsg = resSeven10265.ErrMsg
  32379. res.Cainfo = resSeven10265.Cainfo
  32380. res.WarnMsg = resSeven10265.WarnMsg
  32381. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32382. res.Infcode = infocode
  32383. } else {
  32384. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32385. utils.ErrorLog("解析失败:%v", err)
  32386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32387. return
  32388. }
  32389. }
  32390. }
  32391. } else {
  32392. c.ServeSuccessJSON(map[string]interface{}{
  32393. "failed_code": -10,
  32394. "msg": result3101.ErrMsg,
  32395. })
  32396. return
  32397. }
  32398. } else if miConfig.MdtrtareaAdmvs == "440205" {
  32399. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  32400. if result3101.Infcode == 0 {
  32401. if len(result3101.Output.Result) > 0 {
  32402. var errMsgs []string
  32403. for _, item := range result3101.Output.Result {
  32404. errMsgs = append(errMsgs, item.VolaCont)
  32405. }
  32406. c.ServeSuccessJSON(map[string]interface{}{
  32407. "failed_code": -10,
  32408. "msg": errMsgs,
  32409. })
  32410. return
  32411. } else {
  32412. var result string
  32413. var request_log string
  32414. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32415. allTotal = fmt.Sprintf("%.2f", total_two)
  32416. if his.IdCardType == 4 {
  32417. 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)
  32418. } else {
  32419. 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)
  32420. }
  32421. var dat map[string]interface{}
  32422. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32423. fmt.Println(dat)
  32424. } else {
  32425. fmt.Println(err)
  32426. }
  32427. saveLog(result, request_log, "2206", "预结算")
  32428. //userJSONBytes, _ := json.Marshal(dat)
  32429. //
  32430. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32431. // utils.ErrorLog("解析失败:%v", err)
  32432. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32433. // return
  32434. //}
  32435. userJSONBytes, _ := json.Marshal(dat)
  32436. if miConfig.Code == "H15049901371" {
  32437. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  32438. utils.ErrorLog("解析失败:%v", err)
  32439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32440. return
  32441. }
  32442. res.InfRefmsgid = resSeven10265.InfRefmsgid
  32443. res.Output = resSeven10265.Output
  32444. res.ErrMsg = resSeven10265.ErrMsg
  32445. res.Cainfo = resSeven10265.Cainfo
  32446. res.WarnMsg = resSeven10265.WarnMsg
  32447. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32448. res.Infcode = infocode
  32449. } else {
  32450. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32451. utils.ErrorLog("解析失败:%v", err)
  32452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32453. return
  32454. }
  32455. }
  32456. }
  32457. } else {
  32458. c.ServeSuccessJSON(map[string]interface{}{
  32459. "failed_code": -10,
  32460. "msg": result3101.ErrMsg,
  32461. })
  32462. return
  32463. }
  32464. } else {
  32465. var result string
  32466. var request_log string
  32467. var dat map[string]interface{}
  32468. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32469. allTotal = fmt.Sprintf("%.2f", total_two)
  32470. if miConfig.Code == "H44030501364" || miConfig.Code == "H44030903432" || miConfig.Code == "H44030500255" || miConfig.Code == "H44082500483" || miConfig.Code == "H44030702287" || miConfig.Code == "H44030304882" || miConfig.Code == "H44090200998" {
  32471. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  32472. if result3101.Infcode == 0 {
  32473. if len(result3101.Output.Result) > 0 {
  32474. c.ServeSuccessJSON(map[string]interface{}{
  32475. "failed_code": -10,
  32476. "failed_type": 100,
  32477. "warm_type": 2,
  32478. "msg": result3101,
  32479. })
  32480. return
  32481. } else {
  32482. var result string
  32483. var request_log string
  32484. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  32485. allTotal = fmt.Sprintf("%.2f", total_two)
  32486. if his.IdCardType == 4 {
  32487. 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)
  32488. } else {
  32489. if his.IdCardType == 2 {
  32490. cert_no = psn_info.Certno
  32491. psn_info.VerifyNumber = psn_info.Certno
  32492. } else {
  32493. bas := strings.Split(psn_info.CardInfo, "|")
  32494. cert_no = bas[2]
  32495. }
  32496. 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)
  32497. }
  32498. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32499. fmt.Println(dat)
  32500. } else {
  32501. fmt.Println(err)
  32502. }
  32503. saveLog(result, request_log, "2206", "预结算")
  32504. }
  32505. } else {
  32506. c.ServeSuccessJSON(map[string]interface{}{
  32507. "failed_code": -10,
  32508. "msg": result3101.ErrMsg,
  32509. })
  32510. return
  32511. }
  32512. } else {
  32513. if his.IdCardType == 4 {
  32514. 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)
  32515. } else {
  32516. if his.IdCardType == 2 {
  32517. cert_no = psn_info.Certno
  32518. psn_info.VerifyNumber = psn_info.Certno
  32519. } else {
  32520. bas := strings.Split(psn_info.CardInfo, "|")
  32521. cert_no = bas[2]
  32522. }
  32523. 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)
  32524. }
  32525. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  32526. fmt.Println(dat)
  32527. } else {
  32528. fmt.Println(err)
  32529. }
  32530. saveLog(result, request_log, "2206", "预结算")
  32531. }
  32532. //userJSONBytes, _ := json.Marshal(dat)
  32533. //
  32534. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32535. // utils.ErrorLog("解析失败:%v", err)
  32536. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32537. // return
  32538. //}
  32539. userJSONBytes, _ := json.Marshal(dat)
  32540. if miConfig.Code == "H15049901371" {
  32541. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  32542. utils.ErrorLog("解析失败:%v", err)
  32543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32544. return
  32545. }
  32546. res.InfRefmsgid = resSeven10265.InfRefmsgid
  32547. res.Output = resSeven10265.Output
  32548. res.ErrMsg = resSeven10265.ErrMsg
  32549. res.Cainfo = resSeven10265.Cainfo
  32550. res.WarnMsg = resSeven10265.WarnMsg
  32551. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  32552. res.Infcode = infocode
  32553. } else {
  32554. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  32555. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  32556. utils.ErrorLog("解析失败:%v", err)
  32557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32558. return
  32559. }
  32560. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  32561. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  32562. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  32563. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  32564. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  32565. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  32566. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  32567. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  32568. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  32569. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32570. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32571. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32572. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32573. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  32574. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  32575. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  32576. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  32577. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  32578. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  32579. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  32580. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  32581. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  32582. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  32583. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  32584. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  32585. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  32586. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  32587. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  32588. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  32589. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  32590. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  32591. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  32592. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  32593. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  32594. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  32595. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  32596. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  32597. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  32598. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  32599. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  32600. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  32601. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  32602. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  32603. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  32604. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  32605. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  32606. res.ErrMsg = gzresSeven10265Two.ErrMsg
  32607. res.Cainfo = gzresSeven10265Two.Cainfo
  32608. res.WarnMsg = gzresSeven10265Two.WarnMsg
  32609. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  32610. //res.Infcode = infocode
  32611. } else {
  32612. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  32613. utils.ErrorLog("解析失败:%v", err)
  32614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32615. return
  32616. }
  32617. }
  32618. }
  32619. }
  32620. }
  32621. utils.ErrorLog("解析失败:%v", res.Infcode)
  32622. if res.Infcode == -1 {
  32623. errlog := &models.HisOrderError{
  32624. UserOrgId: adminUser.CurrentOrgId,
  32625. Ctime: time.Now().Unix(),
  32626. Mtime: time.Now().Unix(),
  32627. Number: chrg_bchno,
  32628. ErrMsg: res.ErrMsg,
  32629. Status: 1,
  32630. PatientId: id,
  32631. RecordTime: recordDateTime,
  32632. Stage: 20,
  32633. }
  32634. service.CreateErrMsgLog(errlog)
  32635. c.ServeSuccessJSON(map[string]interface{}{
  32636. "failed_code": -10,
  32637. "msg": res.ErrMsg,
  32638. })
  32639. return
  32640. }
  32641. if res.Infcode != 0 {
  32642. errlog := &models.HisOrderError{
  32643. UserOrgId: adminUser.CurrentOrgId,
  32644. Ctime: time.Now().Unix(),
  32645. Mtime: time.Now().Unix(),
  32646. Number: chrg_bchno,
  32647. ErrMsg: res.ErrMsg,
  32648. Status: 1,
  32649. PatientId: id,
  32650. RecordTime: recordDateTime,
  32651. Stage: 20,
  32652. }
  32653. service.CreateErrMsgLog(errlog)
  32654. c.ServeSuccessJSON(map[string]interface{}{
  32655. "failed_code": -10,
  32656. "msg": res.ErrMsg,
  32657. })
  32658. return
  32659. } else {
  32660. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  32661. order.OrderStatus = 1
  32662. order.IsPre = 1
  32663. order.Status = 1
  32664. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  32665. order.SetlId = res.Output.Setlinfo.SetlID
  32666. order.PsnNo = res.Output.Setlinfo.PsnNo
  32667. order.PsnName = res.Output.Setlinfo.PsnName
  32668. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  32669. order.Certno = res.Output.Setlinfo.Certno
  32670. order.Gend = res.Output.Setlinfo.Gend
  32671. order.Naty = res.Output.Setlinfo.Naty
  32672. order.Age = res.Output.Setlinfo.Age
  32673. order.Insutype = res.Output.Setlinfo.Insutype
  32674. order.PsnType = res.Output.Setlinfo.PsnType
  32675. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  32676. order.SetlTime = res.Output.Setlinfo.SetlTime
  32677. order.AcctUsedFlag = acct_used_flag
  32678. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  32679. if res.Output.Setlinfo.MedType == "140101" {
  32680. order.MedType = "14"
  32681. } else {
  32682. if res.Output.Setlinfo.MedType == "110104" {
  32683. order.MedType = "11"
  32684. } else {
  32685. order.MedType = res.Output.Setlinfo.MedType
  32686. }
  32687. }
  32688. if res.Output.Setlinfo.MedType == "992102" {
  32689. order.MedType = "992102"
  32690. }
  32691. if res.Output.Setlinfo.MedType == "140104" {
  32692. order.MedType = "140104"
  32693. }
  32694. if res.Output.Setlinfo.MedType == "1104" {
  32695. order.MedType = "1104"
  32696. }
  32697. if res.Output.Setlinfo.MedType == "140201" {
  32698. order.MedType = "140201"
  32699. }
  32700. if res.Output.Setlinfo.MedType == "14" {
  32701. order.MedType = "14"
  32702. }
  32703. if reg_type == 1112 {
  32704. order.MedType = "1112"
  32705. }
  32706. if reg_type == 1111 {
  32707. order.MedType = "1111"
  32708. }
  32709. order.ClrType = res.Output.Setlinfo.ClrType
  32710. if adminUser.CurrentOrgId == 10480 {
  32711. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  32712. order.ClrType = "11"
  32713. } else {
  32714. order.ClrType = "9903"
  32715. }
  32716. }
  32717. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  32718. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  32719. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  32720. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  32721. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  32722. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  32723. order.HifpPay = res.Output.Setlinfo.HifpPay
  32724. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  32725. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  32726. order.HifesPay = res.Output.Setlinfo.HifesPay
  32727. order.HifobPay = res.Output.Setlinfo.HifobPay
  32728. order.MafPay = res.Output.Setlinfo.MafPay
  32729. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  32730. order.OthPay = res.Output.Setlinfo.OthPay
  32731. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  32732. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  32733. order.AcctPay = res.Output.Setlinfo.AcctPay
  32734. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  32735. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  32736. order.Balc = res.Output.Setlinfo.Balc
  32737. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  32738. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  32739. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  32740. order.ClrWay = res.Output.Setlinfo.ClrWay
  32741. order.Creator = order.Creator
  32742. order.Modify = roles.AdminUserId
  32743. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  32744. //detailStr := string(setlDetail)
  32745. //order.SetlDetail = detailStr
  32746. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  32747. err = service.UpDateOrder(order)
  32748. if err == nil {
  32749. c.ServeSuccessJSON(map[string]interface{}{
  32750. "msg": "预结算成功",
  32751. })
  32752. } else {
  32753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  32754. return
  32755. }
  32756. }
  32757. } else {
  32758. adminUser := c.GetAdminUserInfo()
  32759. errlog := &models.HisOrderError{
  32760. UserOrgId: adminUser.CurrentOrgId,
  32761. Ctime: time.Now().Unix(),
  32762. Mtime: time.Now().Unix(),
  32763. ErrMsg: res.ErrMsg,
  32764. Status: 1,
  32765. PatientId: id,
  32766. RecordTime: recordDateTime,
  32767. Stage: 4,
  32768. }
  32769. service.CreateErrMsgLog(errlog)
  32770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  32771. return
  32772. }
  32773. } else {
  32774. if miConfig.MdtrtareaAdmvs == "150499" {
  32775. order := &models.HisOrder{
  32776. UserOrgId: adminUser.CurrentOrgId,
  32777. HisPatientId: his.ID,
  32778. PatientId: his.PatientId,
  32779. SettleAccountsDate: recordDateTime,
  32780. Ctime: time.Now().Unix(),
  32781. Mtime: time.Now().Unix(),
  32782. MdtrtId: his.Number,
  32783. PsnNo: his.PsnNo,
  32784. MedType: strconv.FormatInt(reg_type, 10),
  32785. Status: 1,
  32786. Number: chrg_bchno,
  32787. Infcode: res.Infcode,
  32788. WarnMsg: res.WarnMsg,
  32789. Cainfo: res.Cainfo,
  32790. ErrMsg: res.ErrMsg,
  32791. RespondTime: res.RefmsgTime,
  32792. InfRefmsgid: res.InfRefmsgid,
  32793. OrderStatus: 1,
  32794. IsMedicineInsurance: 1,
  32795. SettleType: settle_accounts_type,
  32796. SettleStartTime: start_time,
  32797. SettleEndTime: end_time,
  32798. Creator: roles.AdminUserId,
  32799. Modify: roles.AdminUserId,
  32800. PType: 2,
  32801. Diagnosis: diagnosis_id,
  32802. }
  32803. err = service.CreateOrder(order)
  32804. if err != nil {
  32805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  32806. return
  32807. }
  32808. }
  32809. adminUser := c.GetAdminUserInfo()
  32810. errlog := &models.HisOrderError{
  32811. UserOrgId: adminUser.CurrentOrgId,
  32812. Ctime: time.Now().Unix(),
  32813. Mtime: time.Now().Unix(),
  32814. ErrMsg: res.ErrMsg,
  32815. Status: 1,
  32816. PatientId: id,
  32817. RecordTime: recordDateTime,
  32818. Stage: 4,
  32819. }
  32820. service.CreateErrMsgLog(errlog)
  32821. c.ServeSuccessJSON(map[string]interface{}{
  32822. "failed_code": -10,
  32823. "msg": res.ErrMsg,
  32824. })
  32825. return
  32826. }
  32827. }
  32828. }
  32829. }
  32830. // 退款
  32831. func (c *HisApiController) Refund() {
  32832. order_id, _ := c.GetInt64("order_id")
  32833. admin_user_id, _ := c.GetInt64("admin_user_id")
  32834. adminUser := c.GetAdminUserInfo()
  32835. var order models.HisOrder
  32836. order, _ = service.GetHisOrderByID(order_id)
  32837. fapiao, _ := service.GetFaPiaoHisOrderByID(order_id)
  32838. if fapiao.ID > 0 {
  32839. c.ServeSuccessJSON(map[string]interface{}{
  32840. "failed_code": -10,
  32841. "msg": "该结算已经开具发票无法退费,请先红冲发票",
  32842. })
  32843. return
  32844. }
  32845. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  32846. if order.ID == 0 {
  32847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32848. return
  32849. }
  32850. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  32851. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  32852. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  32853. if config.IsOpen == 1 { //对接了医保,走医保流程
  32854. var res ResultSixteen
  32855. var ahres ResultSevenAH
  32856. var resSixteen10265 ResultSixteen10265
  32857. var resSixteen10265Two ResultSixteen10265Two
  32858. var gz ResultgzSixteen10265Two
  32859. var src_resquest string
  32860. var result string
  32861. if miConfig.MdtrtareaAdmvs == "421300" {
  32862. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  32863. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32864. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32865. resp3, requestErr3 := http.Get(api3)
  32866. if requestErr3 != nil {
  32867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32868. return
  32869. }
  32870. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32871. if ioErr3 != nil {
  32872. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32874. return
  32875. }
  32876. var respJSON3 map[string]interface{}
  32877. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32878. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32880. return
  32881. }
  32882. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32883. userJSONBytes3, _ := json.Marshal(respJSON3)
  32884. fmt.Println("log")
  32885. fmt.Println(string(userJSONBytes3))
  32886. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32887. utils.ErrorLog("解析失败:%v", err)
  32888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32889. return
  32890. }
  32891. } else if miConfig.MdtrtareaAdmvs == "420200" {
  32892. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  32893. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32894. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32895. resp3, requestErr3 := http.Get(api3)
  32896. if requestErr3 != nil {
  32897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32898. return
  32899. }
  32900. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32901. if ioErr3 != nil {
  32902. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32904. return
  32905. }
  32906. var respJSON3 map[string]interface{}
  32907. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32908. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32910. return
  32911. }
  32912. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32913. userJSONBytes3, _ := json.Marshal(respJSON3)
  32914. fmt.Println("log")
  32915. fmt.Println(string(userJSONBytes3))
  32916. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32917. utils.ErrorLog("解析失败:%v", err)
  32918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32919. return
  32920. }
  32921. } else if miConfig.MdtrtareaAdmvs == "420902" {
  32922. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  32923. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32924. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32925. resp3, requestErr3 := http.Get(api3)
  32926. if requestErr3 != nil {
  32927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32928. return
  32929. }
  32930. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32931. if ioErr3 != nil {
  32932. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32934. return
  32935. }
  32936. var respJSON3 map[string]interface{}
  32937. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32938. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32940. return
  32941. }
  32942. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32943. userJSONBytes3, _ := json.Marshal(respJSON3)
  32944. fmt.Println("log")
  32945. fmt.Println(string(userJSONBytes3))
  32946. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32947. utils.ErrorLog("解析失败:%v", err)
  32948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32949. return
  32950. }
  32951. } else if miConfig.MdtrtareaAdmvs == "421182" {
  32952. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  32953. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32954. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  32955. resp3, requestErr3 := http.Get(api3)
  32956. if requestErr3 != nil {
  32957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32958. return
  32959. }
  32960. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  32961. if ioErr3 != nil {
  32962. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  32963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32964. return
  32965. }
  32966. var respJSON3 map[string]interface{}
  32967. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  32968. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  32969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32970. return
  32971. }
  32972. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  32973. userJSONBytes3, _ := json.Marshal(respJSON3)
  32974. fmt.Println("log")
  32975. fmt.Println(string(userJSONBytes3))
  32976. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  32977. utils.ErrorLog("解析失败:%v", err)
  32978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  32979. return
  32980. }
  32981. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  32982. var api3 string
  32983. if miConfig.MdtrtareaAdmvs == "320830" {
  32984. api3 = miConfig.AppSecret + "jsyb/2208?psn_no=" + order.PsnNo +
  32985. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32986. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32987. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32988. } else if miConfig.MdtrtareaAdmvs == "320921" {
  32989. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  32990. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32991. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32992. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32993. } else {
  32994. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  32995. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  32996. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  32997. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  32998. }
  32999. resp3, requestErr3 := http.Get(api3)
  33000. if requestErr3 != nil {
  33001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33002. return
  33003. }
  33004. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33005. if ioErr3 != nil {
  33006. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33008. return
  33009. }
  33010. var respJSON3 map[string]interface{}
  33011. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33012. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33014. return
  33015. }
  33016. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33017. userJSONBytes3, _ := json.Marshal(respJSON3)
  33018. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  33019. utils.ErrorLog("解析失败:%v", err)
  33020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33021. return
  33022. }
  33023. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  33024. res.Output = resSixteen10265.Output
  33025. res.ErrMsg = resSixteen10265.ErrMsg
  33026. res.Cainfo = resSixteen10265.Cainfo
  33027. res.WarnMsg = resSixteen10265.WarnMsg
  33028. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  33029. res.Infcode = infocode
  33030. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33031. var api3 string
  33032. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  33033. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33034. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33035. resp3, requestErr3 := http.Get(api3)
  33036. if requestErr3 != nil {
  33037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33038. return
  33039. }
  33040. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33041. if ioErr3 != nil {
  33042. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33044. return
  33045. }
  33046. var respJSON3 map[string]interface{}
  33047. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33048. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33050. return
  33051. }
  33052. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33053. userJSONBytes3, _ := json.Marshal(respJSON3)
  33054. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  33055. utils.ErrorLog("解析失败:%v", err)
  33056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33057. return
  33058. }
  33059. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  33060. res.Output = resSixteen10265.Output
  33061. res.ErrMsg = resSixteen10265.ErrMsg
  33062. res.Cainfo = resSixteen10265.Cainfo
  33063. res.WarnMsg = resSixteen10265.WarnMsg
  33064. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  33065. res.Infcode = infocode
  33066. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33067. 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)
  33068. var dat map[string]interface{}
  33069. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33070. fmt.Println(dat)
  33071. } else {
  33072. fmt.Println(err)
  33073. }
  33074. saveLog(result, src_resquest, "2208", "退费")
  33075. userJSONBytes, _ := json.Marshal(dat)
  33076. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33077. utils.ErrorLog("解析失败:%v", err)
  33078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33079. return
  33080. }
  33081. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33082. 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, "")
  33083. var dat map[string]interface{}
  33084. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33085. fmt.Println(dat)
  33086. } else {
  33087. fmt.Println(err)
  33088. }
  33089. saveLog(result, src_resquest, "2208", "退费")
  33090. userJSONBytes, _ := json.Marshal(dat)
  33091. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33092. utils.ErrorLog("解析失败:%v", err)
  33093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33094. return
  33095. }
  33096. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33097. 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, "")
  33098. var dat map[string]interface{}
  33099. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33100. fmt.Println(dat)
  33101. } else {
  33102. fmt.Println(err)
  33103. }
  33104. saveLog(result, src_resquest, "2208", "退费")
  33105. userJSONBytes, _ := json.Marshal(dat)
  33106. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33107. utils.ErrorLog("解析失败:%v", err)
  33108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33109. return
  33110. }
  33111. } else if miConfig.MdtrtareaAdmvs == "360100" {
  33112. 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, "")
  33113. var dat map[string]interface{}
  33114. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33115. fmt.Println(dat)
  33116. } else {
  33117. fmt.Println(err)
  33118. }
  33119. saveLog(result, src_resquest, "2208", "退费")
  33120. userJSONBytes, _ := json.Marshal(dat)
  33121. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33122. utils.ErrorLog("解析失败:%v", err)
  33123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33124. return
  33125. }
  33126. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33127. var api3 string
  33128. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  33129. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33130. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33131. resp3, requestErr3 := http.Get(api3)
  33132. if requestErr3 != nil {
  33133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33134. return
  33135. }
  33136. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33137. if ioErr3 != nil {
  33138. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33140. return
  33141. }
  33142. var respJSON3 map[string]interface{}
  33143. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33144. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33146. return
  33147. }
  33148. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33149. if status == "0" {
  33150. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33151. c.ServeSuccessJSON(map[string]interface{}{
  33152. "failed_code": -10,
  33153. "msg": err_msg,
  33154. })
  33155. return
  33156. }
  33157. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33158. userJSONBytes3, _ := json.Marshal(respJSON3)
  33159. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33160. // utils.ErrorLog("解析失败:%v", err)
  33161. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33162. // return
  33163. //}
  33164. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  33165. utils.ErrorLog("解析失败:%v", err)
  33166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33167. return
  33168. }
  33169. res.InfRefmsgid = ahres.InfRefmsgid
  33170. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  33171. // 创建对应的Time类型
  33172. t := time.UnixMilli(timestamp)
  33173. // 格式化成指定的日期字符串
  33174. str := t.Format("2006-01-02 15:04:05")
  33175. res.Output.Setlinfo.SetlTime = str
  33176. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  33177. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  33178. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33179. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  33180. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  33181. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  33182. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  33183. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  33184. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  33185. //
  33186. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  33187. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  33188. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  33189. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33190. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  33191. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  33192. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  33193. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  33194. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  33195. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  33196. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  33197. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  33198. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  33199. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  33200. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  33201. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  33202. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  33203. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  33204. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  33205. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  33206. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  33207. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  33208. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  33209. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  33210. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  33211. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  33212. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  33213. //res.Output.Setldetail = ahres.Output.Setldetail
  33214. res.ErrMsg = ahres.ErrMsg
  33215. res.Cainfo = ahres.Cainfo
  33216. res.WarnMsg = ahres.WarnMsg
  33217. res.Infcode = ahres.Infcode
  33218. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33219. var api3 string
  33220. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  33221. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33222. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33223. resp3, requestErr3 := http.Get(api3)
  33224. if requestErr3 != nil {
  33225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33226. return
  33227. }
  33228. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33229. if ioErr3 != nil {
  33230. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33232. return
  33233. }
  33234. var respJSON3 map[string]interface{}
  33235. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33236. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33238. return
  33239. }
  33240. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33241. if status == "0" {
  33242. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33243. c.ServeSuccessJSON(map[string]interface{}{
  33244. "failed_code": -10,
  33245. "msg": err_msg,
  33246. })
  33247. return
  33248. }
  33249. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33250. userJSONBytes3, _ := json.Marshal(respJSON3)
  33251. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33252. // utils.ErrorLog("解析失败:%v", err)
  33253. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33254. // return
  33255. //}
  33256. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  33257. utils.ErrorLog("解析失败:%v", err)
  33258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33259. return
  33260. }
  33261. res.InfRefmsgid = ahres.InfRefmsgid
  33262. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  33263. // 创建对应的Time类型
  33264. t := time.UnixMilli(timestamp)
  33265. // 格式化成指定的日期字符串
  33266. str := t.Format("2006-01-02 15:04:05")
  33267. res.Output.Setlinfo.SetlTime = str
  33268. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  33269. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  33270. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33271. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  33272. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  33273. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  33274. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  33275. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  33276. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  33277. //
  33278. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  33279. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  33280. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  33281. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  33282. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  33283. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  33284. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  33285. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  33286. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  33287. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  33288. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  33289. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  33290. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  33291. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  33292. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  33293. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  33294. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  33295. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  33296. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  33297. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  33298. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  33299. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  33300. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  33301. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  33302. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  33303. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  33304. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  33305. //res.Output.Setldetail = ahres.Output.Setldetail
  33306. res.ErrMsg = ahres.ErrMsg
  33307. res.Cainfo = ahres.Cainfo
  33308. res.WarnMsg = ahres.WarnMsg
  33309. res.Infcode = ahres.Infcode
  33310. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33311. 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, "")
  33312. var dat map[string]interface{}
  33313. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33314. fmt.Println(dat)
  33315. } else {
  33316. fmt.Println(err)
  33317. }
  33318. saveLog(result, src_resquest, "2208", "退费")
  33319. userJSONBytes, _ := json.Marshal(dat)
  33320. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33321. utils.ErrorLog("解析失败:%v", err)
  33322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33323. return
  33324. }
  33325. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33326. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  33327. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33328. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33329. resp3, requestErr3 := http.Get(api3)
  33330. if requestErr3 != nil {
  33331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33332. return
  33333. }
  33334. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33335. if ioErr3 != nil {
  33336. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33338. return
  33339. }
  33340. var respJSON3 map[string]interface{}
  33341. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33342. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33344. return
  33345. }
  33346. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33347. userJSONBytes3, _ := json.Marshal(respJSON3)
  33348. fmt.Println("log")
  33349. fmt.Println(string(userJSONBytes3))
  33350. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  33351. utils.ErrorLog("解析失败:%v", err)
  33352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33353. return
  33354. }
  33355. } else {
  33356. if miConfig.Code == "H15049901371" {
  33357. 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)
  33358. var dat map[string]interface{}
  33359. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33360. fmt.Println(dat)
  33361. } else {
  33362. fmt.Println(err)
  33363. }
  33364. saveLog(result, src_resquest, "2208", "退费")
  33365. if strings.Contains(result, "Post") {
  33366. res.Infcode = -1
  33367. res.ErrMsg = result
  33368. }
  33369. userJSONBytes, _ := json.Marshal(dat)
  33370. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  33371. utils.ErrorLog("解析失败:%v", err)
  33372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33373. return
  33374. }
  33375. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  33376. res.Output = resSixteen10265.Output
  33377. res.ErrMsg = resSixteen10265.ErrMsg
  33378. res.Cainfo = resSixteen10265.Cainfo
  33379. res.WarnMsg = resSixteen10265.WarnMsg
  33380. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  33381. res.Infcode = infocode
  33382. } else {
  33383. 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)
  33384. var dat map[string]interface{}
  33385. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  33386. fmt.Println(dat)
  33387. } else {
  33388. fmt.Println(err)
  33389. }
  33390. saveLog(result, src_resquest, "2208", "退费")
  33391. userJSONBytes, _ := json.Marshal(dat)
  33392. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  33393. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  33394. utils.ErrorLog("解析失败:%v", err)
  33395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33396. return
  33397. }
  33398. res.Infcode = gz.Infcode
  33399. } else {
  33400. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  33401. utils.ErrorLog("解析失败:%v", err)
  33402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33403. return
  33404. }
  33405. }
  33406. if strings.Contains(result, "Post") {
  33407. res.Infcode = -1
  33408. res.ErrMsg = result
  33409. }
  33410. }
  33411. }
  33412. if res.Infcode == -1 {
  33413. c.ServeSuccessJSON(map[string]interface{}{
  33414. "failed_code": -10,
  33415. "msg": res.ErrMsg,
  33416. })
  33417. return
  33418. }
  33419. if res.Infcode != -1 {
  33420. var res2 ResultSix
  33421. var resSix10265 ResultSix10265
  33422. if miConfig.MdtrtareaAdmvs == "421300" {
  33423. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  33424. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33425. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33426. resp3, requestErr3 := http.Get(api3)
  33427. if requestErr3 != nil {
  33428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33429. return
  33430. }
  33431. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33432. if ioErr3 != nil {
  33433. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33435. return
  33436. }
  33437. var respJSON3 map[string]interface{}
  33438. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33439. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33441. return
  33442. }
  33443. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33444. userJSONBytes3, _ := json.Marshal(respJSON3)
  33445. fmt.Println("log")
  33446. fmt.Println(string(userJSONBytes3))
  33447. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33448. utils.ErrorLog("解析失败:%v", err)
  33449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33450. return
  33451. }
  33452. } else if miConfig.MdtrtareaAdmvs == "420200" {
  33453. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  33454. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33455. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33456. resp3, requestErr3 := http.Get(api3)
  33457. if requestErr3 != nil {
  33458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33459. return
  33460. }
  33461. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33462. if ioErr3 != nil {
  33463. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33465. return
  33466. }
  33467. var respJSON3 map[string]interface{}
  33468. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33469. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33471. return
  33472. }
  33473. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33474. userJSONBytes3, _ := json.Marshal(respJSON3)
  33475. fmt.Println("log")
  33476. fmt.Println(string(userJSONBytes3))
  33477. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33478. utils.ErrorLog("解析失败:%v", err)
  33479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33480. return
  33481. }
  33482. } else if miConfig.MdtrtareaAdmvs == "420902" {
  33483. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  33484. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33485. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33486. resp3, requestErr3 := http.Get(api3)
  33487. if requestErr3 != nil {
  33488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33489. return
  33490. }
  33491. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33492. if ioErr3 != nil {
  33493. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33495. return
  33496. }
  33497. var respJSON3 map[string]interface{}
  33498. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33499. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33501. return
  33502. }
  33503. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33504. userJSONBytes3, _ := json.Marshal(respJSON3)
  33505. fmt.Println("log")
  33506. fmt.Println(string(userJSONBytes3))
  33507. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33508. utils.ErrorLog("解析失败:%v", err)
  33509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33510. return
  33511. }
  33512. } else if miConfig.MdtrtareaAdmvs == "421182" {
  33513. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  33514. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33515. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33516. resp3, requestErr3 := http.Get(api3)
  33517. if requestErr3 != nil {
  33518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33519. return
  33520. }
  33521. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33522. if ioErr3 != nil {
  33523. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33525. return
  33526. }
  33527. var respJSON3 map[string]interface{}
  33528. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33529. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33531. return
  33532. }
  33533. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33534. userJSONBytes3, _ := json.Marshal(respJSON3)
  33535. fmt.Println("log")
  33536. fmt.Println(string(userJSONBytes3))
  33537. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33538. utils.ErrorLog("解析失败:%v", err)
  33539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33540. return
  33541. }
  33542. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  33543. var api3 string
  33544. if miConfig.MdtrtareaAdmvs == "320830" {
  33545. api3 = miConfig.AppSecret + "jsyb/2205?psn_no=" + order.PsnNo +
  33546. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + "0000" + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33547. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33548. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33549. } else if miConfig.MdtrtareaAdmvs == "320921" {
  33550. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  33551. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33552. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33553. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33554. } else {
  33555. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  33556. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  33557. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33558. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33559. }
  33560. resp3, requestErr3 := http.Get(api3)
  33561. if requestErr3 != nil {
  33562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33563. return
  33564. }
  33565. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33566. if ioErr3 != nil {
  33567. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33569. return
  33570. }
  33571. var respJSON3 map[string]interface{}
  33572. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33573. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33575. return
  33576. }
  33577. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33578. userJSONBytes3, _ := json.Marshal(respJSON3)
  33579. fmt.Println("log")
  33580. fmt.Println(string(userJSONBytes3))
  33581. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33582. utils.ErrorLog("解析失败:%v", err)
  33583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33584. return
  33585. }
  33586. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33587. res2.Output = resSix10265.Output
  33588. res2.ErrMsg = resSix10265.ErrMsg
  33589. res2.Cainfo = resSix10265.Cainfo
  33590. res2.WarnMsg = resSix10265.WarnMsg
  33591. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33592. res2.Infcode = infocode
  33593. } else if miConfig.MdtrtareaAdmvs == "150499" {
  33594. var api3 string
  33595. new_chrg_bchno := order.Number
  33596. if adminUser.CurrentOrgId == 10265 {
  33597. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  33598. new_chrg_bchno = "0000"
  33599. }
  33600. }
  33601. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  33602. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33603. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33604. resp3, requestErr3 := http.Get(api3)
  33605. if requestErr3 != nil {
  33606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33607. return
  33608. }
  33609. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33610. if ioErr3 != nil {
  33611. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33613. return
  33614. }
  33615. var respJSON3 map[string]interface{}
  33616. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33617. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33619. return
  33620. }
  33621. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33622. userJSONBytes3, _ := json.Marshal(respJSON3)
  33623. fmt.Println("log")
  33624. fmt.Println(string(userJSONBytes3))
  33625. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  33626. utils.ErrorLog("解析失败:%v", err)
  33627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33628. return
  33629. }
  33630. res2.InfRefmsgid = resSix10265.InfRefmsgid
  33631. res2.Output = resSix10265.Output
  33632. res2.ErrMsg = resSix10265.ErrMsg
  33633. res2.Cainfo = resSix10265.Cainfo
  33634. res2.WarnMsg = resSix10265.WarnMsg
  33635. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  33636. res2.Infcode = infocode
  33637. } else if miConfig.MdtrtareaAdmvs == "350500" {
  33638. 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)
  33639. var dat map[string]interface{}
  33640. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33641. fmt.Println(dat)
  33642. } else {
  33643. fmt.Println(err)
  33644. }
  33645. saveLog(result2, src_request, "2205", "撤销明细")
  33646. userJSONBytes, _ := json.Marshal(dat)
  33647. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33648. utils.ErrorLog("解析失败:%v", err)
  33649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33650. return
  33651. }
  33652. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33653. 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, "")
  33654. var dat map[string]interface{}
  33655. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33656. fmt.Println(dat)
  33657. } else {
  33658. fmt.Println(err)
  33659. }
  33660. saveLog(result2, src_request, "2205", "撤销明细")
  33661. userJSONBytes, _ := json.Marshal(dat)
  33662. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33663. utils.ErrorLog("解析失败:%v", err)
  33664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33665. return
  33666. }
  33667. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33668. 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, "")
  33669. var dat map[string]interface{}
  33670. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33671. fmt.Println(dat)
  33672. } else {
  33673. fmt.Println(err)
  33674. }
  33675. saveLog(result2, src_request, "2205", "撤销明细")
  33676. userJSONBytes, _ := json.Marshal(dat)
  33677. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33678. utils.ErrorLog("解析失败:%v", err)
  33679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33680. return
  33681. }
  33682. } else if miConfig.MdtrtareaAdmvs == "360100" {
  33683. 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, "")
  33684. var dat map[string]interface{}
  33685. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33686. fmt.Println(dat)
  33687. } else {
  33688. fmt.Println(err)
  33689. }
  33690. saveLog(result2, src_request, "2205", "撤销明细")
  33691. userJSONBytes, _ := json.Marshal(dat)
  33692. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33693. utils.ErrorLog("解析失败:%v", err)
  33694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33695. return
  33696. }
  33697. } else if miConfig.MdtrtareaAdmvs == "341203" {
  33698. var api3 string
  33699. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  33700. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33701. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33702. resp3, requestErr3 := http.Get(api3)
  33703. if requestErr3 != nil {
  33704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33705. return
  33706. }
  33707. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33708. if ioErr3 != nil {
  33709. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33711. return
  33712. }
  33713. var respJSON3 map[string]interface{}
  33714. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33715. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33717. return
  33718. }
  33719. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33720. if status == "0" {
  33721. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33722. c.ServeSuccessJSON(map[string]interface{}{
  33723. "failed_code": -10,
  33724. "msg": err_msg,
  33725. })
  33726. return
  33727. }
  33728. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33729. userJSONBytes3, _ := json.Marshal(respJSON3)
  33730. fmt.Println("log")
  33731. fmt.Println(string(userJSONBytes3))
  33732. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33733. utils.ErrorLog("解析失败:%v", err)
  33734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33735. return
  33736. }
  33737. } else if miConfig.MdtrtareaAdmvs == "360302" {
  33738. 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, "")
  33739. var dat map[string]interface{}
  33740. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33741. fmt.Println(dat)
  33742. } else {
  33743. fmt.Println(err)
  33744. }
  33745. saveLog(result2, src_request, "2205", "撤销明细")
  33746. userJSONBytes, _ := json.Marshal(dat)
  33747. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33748. utils.ErrorLog("解析失败:%v", err)
  33749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33750. return
  33751. }
  33752. } else if miConfig.MdtrtareaAdmvs == "361025" {
  33753. 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, "")
  33754. var dat map[string]interface{}
  33755. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33756. fmt.Println(dat)
  33757. } else {
  33758. fmt.Println(err)
  33759. }
  33760. saveLog(result2, src_request, "2205", "撤销明细")
  33761. userJSONBytes, _ := json.Marshal(dat)
  33762. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33763. utils.ErrorLog("解析失败:%v", err)
  33764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33765. return
  33766. }
  33767. } else if miConfig.MdtrtareaAdmvs == "360100" {
  33768. 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, "")
  33769. var dat map[string]interface{}
  33770. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33771. fmt.Println(dat)
  33772. } else {
  33773. fmt.Println(err)
  33774. }
  33775. saveLog(result2, src_request, "2205", "撤销明细")
  33776. userJSONBytes, _ := json.Marshal(dat)
  33777. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33778. utils.ErrorLog("解析失败:%v", err)
  33779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33780. return
  33781. }
  33782. } else if miConfig.MdtrtareaAdmvs == "340699" {
  33783. var api3 string
  33784. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  33785. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33786. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  33787. resp3, requestErr3 := http.Get(api3)
  33788. if requestErr3 != nil {
  33789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33790. return
  33791. }
  33792. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33793. if ioErr3 != nil {
  33794. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33796. return
  33797. }
  33798. var respJSON3 map[string]interface{}
  33799. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33800. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33802. return
  33803. }
  33804. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  33805. if status == "0" {
  33806. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  33807. c.ServeSuccessJSON(map[string]interface{}{
  33808. "failed_code": -10,
  33809. "msg": err_msg,
  33810. })
  33811. return
  33812. }
  33813. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33814. userJSONBytes3, _ := json.Marshal(respJSON3)
  33815. fmt.Println("log")
  33816. fmt.Println(string(userJSONBytes3))
  33817. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33818. utils.ErrorLog("解析失败:%v", err)
  33819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33820. return
  33821. }
  33822. } else if miConfig.MdtrtareaAdmvs == "430800" {
  33823. 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, "")
  33824. var dat map[string]interface{}
  33825. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33826. fmt.Println(dat)
  33827. } else {
  33828. fmt.Println(err)
  33829. }
  33830. saveLog(result2, src_request, "2205", "撤销明细")
  33831. userJSONBytes, _ := json.Marshal(dat)
  33832. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33833. utils.ErrorLog("解析失败:%v", err)
  33834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33835. return
  33836. }
  33837. } else if miConfig.MdtrtareaAdmvs == "441799" {
  33838. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  33839. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33840. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33841. resp3, requestErr3 := http.Get(api3)
  33842. if requestErr3 != nil {
  33843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33844. return
  33845. }
  33846. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33847. if ioErr3 != nil {
  33848. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33850. return
  33851. }
  33852. var respJSON3 map[string]interface{}
  33853. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33854. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33856. return
  33857. }
  33858. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33859. userJSONBytes3, _ := json.Marshal(respJSON3)
  33860. fmt.Println("log")
  33861. fmt.Println(string(userJSONBytes3))
  33862. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33863. utils.ErrorLog("解析失败:%v", err)
  33864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33865. return
  33866. }
  33867. } else {
  33868. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  33869. res2.Infcode = 0
  33870. } else {
  33871. 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)
  33872. var dat map[string]interface{}
  33873. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  33874. fmt.Println(dat)
  33875. } else {
  33876. fmt.Println(err)
  33877. }
  33878. saveLog(result2, src_request, "2205", "撤销明细")
  33879. userJSONBytes, _ := json.Marshal(dat)
  33880. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  33881. utils.ErrorLog("解析失败:%v", err)
  33882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33883. return
  33884. }
  33885. }
  33886. }
  33887. if res2.Infcode == -1 {
  33888. c.ServeSuccessJSON(map[string]interface{}{
  33889. "failed_code": -10,
  33890. "msg": res2.ErrMsg,
  33891. })
  33892. return
  33893. }
  33894. if res2.Infcode == 0 {
  33895. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  33896. if err == nil {
  33897. //当押金不为零时产生退费记录
  33898. if order.Decimal != 0 {
  33899. tmp := strconv.FormatInt(order.ID, 10)
  33900. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  33901. if err != nil {
  33902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33903. return
  33904. }
  33905. }
  33906. c.ServeSuccessJSON(map[string]interface{}{
  33907. "msg": "退费成功",
  33908. })
  33909. } else {
  33910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33911. return
  33912. }
  33913. } else {
  33914. c.ServeSuccessJSON(map[string]interface{}{
  33915. "failed_code": -10,
  33916. "msg": res2.ErrMsg,
  33917. })
  33918. }
  33919. } else {
  33920. c.ServeSuccessJSON(map[string]interface{}{
  33921. "failed_code": -10,
  33922. "msg": res.ErrMsg,
  33923. })
  33924. }
  33925. }
  33926. }
  33927. func (c *HisApiController) RefundNumber() {
  33928. record_time := c.GetString("record_time")
  33929. //patient_id, _ := c.GetInt64("patient_id")
  33930. admin_user_id, _ := c.GetInt64("admin_user_id")
  33931. his_patient_id, _ := c.GetInt64("id")
  33932. timeLayout := "2006-01-02"
  33933. loc, _ := time.LoadLocation("Local")
  33934. adminUser := c.GetAdminUserInfo()
  33935. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  33936. fmt.Println(err)
  33937. if err != nil {
  33938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  33939. return
  33940. }
  33941. recordDateTime := theTime.Unix()
  33942. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  33943. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  33944. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  33945. //order, _ := service.GetHisOrderByID(order_id)
  33946. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  33947. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  33948. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  33949. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  33950. if count > 0 {
  33951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  33952. return
  33953. }
  33954. if config.IsOpen == 1 { //对接了医保,走医保流程
  33955. var res2 ResultSix
  33956. var res3 GZResultSix
  33957. var resSix10265 ResultSix10265
  33958. if miConfig.MdtrtareaAdmvs == "421300" {
  33959. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  33960. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33961. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33962. resp3, requestErr3 := http.Get(api3)
  33963. if requestErr3 != nil {
  33964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33965. return
  33966. }
  33967. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33968. if ioErr3 != nil {
  33969. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  33970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33971. return
  33972. }
  33973. var respJSON3 map[string]interface{}
  33974. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  33975. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  33976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33977. return
  33978. }
  33979. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  33980. userJSONBytes3, _ := json.Marshal(respJSON3)
  33981. fmt.Println("log")
  33982. fmt.Println(string(userJSONBytes3))
  33983. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  33984. utils.ErrorLog("解析失败:%v", err)
  33985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33986. return
  33987. }
  33988. } else if miConfig.MdtrtareaAdmvs == "420200" {
  33989. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  33990. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  33991. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  33992. resp3, requestErr3 := http.Get(api3)
  33993. if requestErr3 != nil {
  33994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  33995. return
  33996. }
  33997. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  33998. if ioErr3 != nil {
  33999. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34001. return
  34002. }
  34003. var respJSON3 map[string]interface{}
  34004. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34005. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34007. return
  34008. }
  34009. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34010. userJSONBytes3, _ := json.Marshal(respJSON3)
  34011. fmt.Println("log")
  34012. fmt.Println(string(userJSONBytes3))
  34013. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34014. utils.ErrorLog("解析失败:%v", err)
  34015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34016. return
  34017. }
  34018. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34019. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  34020. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34021. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34022. resp3, requestErr3 := http.Get(api3)
  34023. if requestErr3 != nil {
  34024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34025. return
  34026. }
  34027. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34028. if ioErr3 != nil {
  34029. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34031. return
  34032. }
  34033. var respJSON3 map[string]interface{}
  34034. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34035. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34037. return
  34038. }
  34039. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34040. userJSONBytes3, _ := json.Marshal(respJSON3)
  34041. fmt.Println("log")
  34042. fmt.Println(string(userJSONBytes3))
  34043. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34044. utils.ErrorLog("解析失败:%v", err)
  34045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34046. return
  34047. }
  34048. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34049. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  34050. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34051. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34052. resp3, requestErr3 := http.Get(api3)
  34053. if requestErr3 != nil {
  34054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34055. return
  34056. }
  34057. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34058. if ioErr3 != nil {
  34059. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34061. return
  34062. }
  34063. var respJSON3 map[string]interface{}
  34064. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34065. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34067. return
  34068. }
  34069. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34070. userJSONBytes3, _ := json.Marshal(respJSON3)
  34071. fmt.Println("log")
  34072. fmt.Println(string(userJSONBytes3))
  34073. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34074. utils.ErrorLog("解析失败:%v", err)
  34075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34076. return
  34077. }
  34078. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  34079. var api3 string
  34080. if miConfig.MdtrtareaAdmvs == "320830" {
  34081. api3 = miConfig.AppSecret + "jsyb/2202?psn_no=" + his.PsnNo +
  34082. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34083. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34084. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34085. } else if miConfig.MdtrtareaAdmvs == "320921" {
  34086. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  34087. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34088. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34089. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34090. } else {
  34091. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34092. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  34093. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34094. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34095. }
  34096. resp3, requestErr3 := http.Get(api3)
  34097. if requestErr3 != nil {
  34098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34099. return
  34100. }
  34101. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34102. if ioErr3 != nil {
  34103. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34105. return
  34106. }
  34107. var respJSON3 map[string]interface{}
  34108. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34109. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34111. return
  34112. }
  34113. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34114. userJSONBytes3, _ := json.Marshal(respJSON3)
  34115. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34116. utils.ErrorLog("解析失败:%v", err)
  34117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34118. return
  34119. }
  34120. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34121. res2.Output = resSix10265.Output
  34122. res2.ErrMsg = resSix10265.ErrMsg
  34123. res2.Cainfo = resSix10265.Cainfo
  34124. res2.WarnMsg = resSix10265.WarnMsg
  34125. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34126. res2.Infcode = infocode
  34127. } else if miConfig.MdtrtareaAdmvs == "150499" {
  34128. var api3 string
  34129. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  34130. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34131. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34132. resp3, requestErr3 := http.Get(api3)
  34133. if requestErr3 != nil {
  34134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34135. return
  34136. }
  34137. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34138. if ioErr3 != nil {
  34139. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34141. return
  34142. }
  34143. var respJSON3 map[string]interface{}
  34144. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34145. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34147. return
  34148. }
  34149. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34150. userJSONBytes3, _ := json.Marshal(respJSON3)
  34151. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34152. utils.ErrorLog("解析失败:%v", err)
  34153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34154. return
  34155. }
  34156. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34157. res2.Output = resSix10265.Output
  34158. res2.ErrMsg = resSix10265.ErrMsg
  34159. res2.Cainfo = resSix10265.Cainfo
  34160. res2.WarnMsg = resSix10265.WarnMsg
  34161. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34162. res2.Infcode = infocode
  34163. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34164. 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)
  34165. var dat map[string]interface{}
  34166. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34167. fmt.Println(dat)
  34168. } else {
  34169. fmt.Println(err)
  34170. }
  34171. saveLog(result, request, "2202", "退号")
  34172. userJSONBytes, _ := json.Marshal(dat)
  34173. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34174. utils.ErrorLog("解析失败:%v", err)
  34175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34176. return
  34177. }
  34178. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34179. 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, "")
  34180. var dat map[string]interface{}
  34181. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34182. fmt.Println(dat)
  34183. } else {
  34184. fmt.Println(err)
  34185. }
  34186. saveLog(result, request, "2202", "退号")
  34187. userJSONBytes, _ := json.Marshal(dat)
  34188. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34189. utils.ErrorLog("解析失败:%v", err)
  34190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34191. return
  34192. }
  34193. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34194. 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, "")
  34195. var dat map[string]interface{}
  34196. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34197. fmt.Println(dat)
  34198. } else {
  34199. fmt.Println(err)
  34200. }
  34201. saveLog(result, request, "2202", "退号")
  34202. userJSONBytes, _ := json.Marshal(dat)
  34203. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34204. utils.ErrorLog("解析失败:%v", err)
  34205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34206. return
  34207. }
  34208. } else if miConfig.MdtrtareaAdmvs == "360100" {
  34209. 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, "")
  34210. var dat map[string]interface{}
  34211. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34212. fmt.Println(dat)
  34213. } else {
  34214. fmt.Println(err)
  34215. }
  34216. saveLog(result, request, "2202", "退号")
  34217. userJSONBytes, _ := json.Marshal(dat)
  34218. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34219. utils.ErrorLog("解析失败:%v", err)
  34220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34221. return
  34222. }
  34223. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34224. var api3 string
  34225. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  34226. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34227. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34228. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34229. resp3, requestErr3 := http.Get(api3)
  34230. if requestErr3 != nil {
  34231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34232. return
  34233. }
  34234. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34235. if ioErr3 != nil {
  34236. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34238. return
  34239. }
  34240. var respJSON3 map[string]interface{}
  34241. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34242. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34244. return
  34245. }
  34246. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34247. if status == "0" {
  34248. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34249. c.ServeSuccessJSON(map[string]interface{}{
  34250. "failed_code": -10,
  34251. "msg": err_msg,
  34252. })
  34253. return
  34254. }
  34255. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34256. userJSONBytes3, _ := json.Marshal(respJSON3)
  34257. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34258. utils.ErrorLog("解析失败:%v", err)
  34259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34260. return
  34261. }
  34262. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  34263. } else if miConfig.MdtrtareaAdmvs == "340699" {
  34264. var api3 string
  34265. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  34266. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34267. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34268. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34269. resp3, requestErr3 := http.Get(api3)
  34270. if requestErr3 != nil {
  34271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34272. return
  34273. }
  34274. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34275. if ioErr3 != nil {
  34276. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34278. return
  34279. }
  34280. var respJSON3 map[string]interface{}
  34281. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34282. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34284. return
  34285. }
  34286. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34287. if status == "0" {
  34288. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34289. c.ServeSuccessJSON(map[string]interface{}{
  34290. "failed_code": -10,
  34291. "msg": err_msg,
  34292. })
  34293. return
  34294. }
  34295. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34296. userJSONBytes3, _ := json.Marshal(respJSON3)
  34297. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34298. utils.ErrorLog("解析失败:%v", err)
  34299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34300. return
  34301. }
  34302. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  34303. } else if miConfig.MdtrtareaAdmvs == "430800" {
  34304. 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, "")
  34305. var dat map[string]interface{}
  34306. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  34307. fmt.Println(dat)
  34308. } else {
  34309. fmt.Println(err)
  34310. }
  34311. saveLog(result, request, "2202", "退号")
  34312. userJSONBytes, _ := json.Marshal(dat)
  34313. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34314. utils.ErrorLog("解析失败:%v", err)
  34315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34316. return
  34317. }
  34318. } else if miConfig.MdtrtareaAdmvs == "441799" {
  34319. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  34320. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34321. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  34322. resp3, requestErr3 := http.Get(api3)
  34323. if requestErr3 != nil {
  34324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34325. return
  34326. }
  34327. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34328. if ioErr3 != nil {
  34329. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34331. return
  34332. }
  34333. var respJSON3 map[string]interface{}
  34334. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34335. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34337. return
  34338. }
  34339. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34340. userJSONBytes3, _ := json.Marshal(respJSON3)
  34341. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34342. utils.ErrorLog("解析失败:%v", err)
  34343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34344. return
  34345. }
  34346. } else {
  34347. var api3 string
  34348. if miConfig.Code == "H15049901371" {
  34349. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  34350. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34351. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34352. } else {
  34353. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  34354. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34355. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  34356. }
  34357. resp3, requestErr3 := http.Get(api3)
  34358. if requestErr3 != nil {
  34359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34360. return
  34361. }
  34362. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34363. if ioErr3 != nil {
  34364. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34366. return
  34367. }
  34368. var respJSON3 map[string]interface{}
  34369. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34370. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34372. return
  34373. }
  34374. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34375. userJSONBytes3, _ := json.Marshal(respJSON3)
  34376. if miConfig.Code == "H15049901371" {
  34377. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34378. utils.ErrorLog("解析失败:%v", err)
  34379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34380. return
  34381. }
  34382. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34383. res2.Output = resSix10265.Output
  34384. res2.ErrMsg = resSix10265.ErrMsg
  34385. res2.Cainfo = resSix10265.Cainfo
  34386. res2.WarnMsg = resSix10265.WarnMsg
  34387. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34388. res2.Infcode = infocode
  34389. } else {
  34390. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  34391. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  34392. utils.ErrorLog("解析失败:%v", err)
  34393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34394. return
  34395. }
  34396. res2.Infcode = res3.Infcode
  34397. } else {
  34398. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34399. utils.ErrorLog("解析失败:%v", err)
  34400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34401. return
  34402. }
  34403. }
  34404. }
  34405. }
  34406. if res2.Infcode == -1 {
  34407. c.ServeSuccessJSON(map[string]interface{}{
  34408. "failed_code": -10,
  34409. "msg": res2.ErrMsg,
  34410. })
  34411. return
  34412. }
  34413. if res2.Infcode == 0 {
  34414. if err == nil {
  34415. c.ServeSuccessJSON(map[string]interface{}{
  34416. "msg": "退号成功",
  34417. })
  34418. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  34419. //service.UpdataOrderStatusTen(his., recordDateTime, adminUser.CurrentOrgId)
  34420. } else {
  34421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34422. return
  34423. }
  34424. }
  34425. } else {
  34426. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  34427. //if err == nil {
  34428. // c.ServeSuccessJSON(map[string]interface{}{
  34429. // "msg": "退费成功",
  34430. // })
  34431. //} else {
  34432. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34433. // return
  34434. //}
  34435. }
  34436. }
  34437. func (c *HisApiController) RefundDetail() {
  34438. order_id, _ := c.GetInt64("order_id")
  34439. admin_user_id, _ := c.GetInt64("admin_user_id")
  34440. //his_patient_id, _ := c.GetInt64("his_patient_id")
  34441. number := c.GetString("number")
  34442. record_time := c.GetString("record_time")
  34443. patient_id, _ := c.GetInt64("patient_id")
  34444. //med_type, _ := c.GetInt64("med_type")
  34445. timeLayout := "2006-01-02"
  34446. loc, _ := time.LoadLocation("Local")
  34447. adminUser := c.GetAdminUserInfo()
  34448. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  34449. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  34450. fmt.Println(err)
  34451. if err != nil {
  34452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  34453. return
  34454. }
  34455. recordDateTime := theTime.Unix()
  34456. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  34457. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  34458. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  34459. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  34460. var order models.HisOrder
  34461. order, _ = service.GetHisOrderByID(order_id)
  34462. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  34463. if config.IsOpen == 1 { //对接了医保,走医保流程
  34464. var res2 ResultSix
  34465. if miConfig.MdtrtareaAdmvs == "421300" {
  34466. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  34467. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34468. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34469. resp3, requestErr3 := http.Get(api3)
  34470. if requestErr3 != nil {
  34471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34472. return
  34473. }
  34474. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34475. if ioErr3 != nil {
  34476. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34478. return
  34479. }
  34480. var respJSON3 map[string]interface{}
  34481. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34482. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34484. return
  34485. }
  34486. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34487. userJSONBytes3, _ := json.Marshal(respJSON3)
  34488. fmt.Println("log")
  34489. fmt.Println(string(userJSONBytes3))
  34490. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34491. utils.ErrorLog("解析失败:%v", err)
  34492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34493. return
  34494. }
  34495. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34496. if err == nil {
  34497. c.ServeSuccessJSON(map[string]interface{}{
  34498. "msg": "撤销明细成功",
  34499. })
  34500. return
  34501. } else {
  34502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34503. return
  34504. }
  34505. } else if miConfig.MdtrtareaAdmvs == "420200" {
  34506. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  34507. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34508. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34509. resp3, requestErr3 := http.Get(api3)
  34510. if requestErr3 != nil {
  34511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34512. return
  34513. }
  34514. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34515. if ioErr3 != nil {
  34516. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34518. return
  34519. }
  34520. var respJSON3 map[string]interface{}
  34521. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34522. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34524. return
  34525. }
  34526. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34527. userJSONBytes3, _ := json.Marshal(respJSON3)
  34528. fmt.Println("log")
  34529. fmt.Println(string(userJSONBytes3))
  34530. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34531. utils.ErrorLog("解析失败:%v", err)
  34532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34533. return
  34534. }
  34535. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34536. if err == nil {
  34537. c.ServeSuccessJSON(map[string]interface{}{
  34538. "msg": "撤销明细成功",
  34539. })
  34540. return
  34541. } else {
  34542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34543. return
  34544. }
  34545. } else if miConfig.MdtrtareaAdmvs == "420902" {
  34546. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  34547. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34548. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34549. resp3, requestErr3 := http.Get(api3)
  34550. if requestErr3 != nil {
  34551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34552. return
  34553. }
  34554. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34555. if ioErr3 != nil {
  34556. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34558. return
  34559. }
  34560. var respJSON3 map[string]interface{}
  34561. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34562. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34564. return
  34565. }
  34566. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34567. userJSONBytes3, _ := json.Marshal(respJSON3)
  34568. fmt.Println("log")
  34569. fmt.Println(string(userJSONBytes3))
  34570. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34571. utils.ErrorLog("解析失败:%v", err)
  34572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34573. return
  34574. }
  34575. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34576. if err == nil {
  34577. c.ServeSuccessJSON(map[string]interface{}{
  34578. "msg": "撤销明细成功",
  34579. })
  34580. return
  34581. } else {
  34582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34583. return
  34584. }
  34585. } else if miConfig.MdtrtareaAdmvs == "421182" {
  34586. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  34587. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34588. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  34589. resp3, requestErr3 := http.Get(api3)
  34590. if requestErr3 != nil {
  34591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34592. return
  34593. }
  34594. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34595. if ioErr3 != nil {
  34596. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34598. return
  34599. }
  34600. var respJSON3 map[string]interface{}
  34601. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34602. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34604. return
  34605. }
  34606. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34607. userJSONBytes3, _ := json.Marshal(respJSON3)
  34608. fmt.Println("log")
  34609. fmt.Println(string(userJSONBytes3))
  34610. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34611. utils.ErrorLog("解析失败:%v", err)
  34612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34613. return
  34614. }
  34615. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34616. if err == nil {
  34617. c.ServeSuccessJSON(map[string]interface{}{
  34618. "msg": "撤销明细成功",
  34619. })
  34620. return
  34621. } else {
  34622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34623. return
  34624. }
  34625. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  34626. var resSix10265 ResultSix10265
  34627. var api3 string
  34628. if miConfig.MdtrtareaAdmvs == "320830" {
  34629. api3 = miConfig.AppSecret + "jsyb/2205?psn_no=" + order.PsnNo +
  34630. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + "0000" + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34631. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34632. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34633. } else if miConfig.MdtrtareaAdmvs == "320921" {
  34634. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  34635. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34636. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34637. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34638. } else {
  34639. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34640. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  34641. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34642. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34643. }
  34644. resp3, requestErr3 := http.Get(api3)
  34645. utils.ErrorLog("接口: %v", requestErr3)
  34646. if requestErr3 != nil {
  34647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34648. return
  34649. }
  34650. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34651. if ioErr3 != nil {
  34652. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34654. return
  34655. }
  34656. var respJSON3 map[string]interface{}
  34657. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34658. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34660. return
  34661. }
  34662. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34663. userJSONBytes3, _ := json.Marshal(respJSON3)
  34664. fmt.Println("log")
  34665. fmt.Println(string(userJSONBytes3))
  34666. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34667. utils.ErrorLog("解析失败:%v", err)
  34668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34669. return
  34670. }
  34671. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34672. res2.Output = resSix10265.Output
  34673. res2.ErrMsg = resSix10265.ErrMsg
  34674. res2.Cainfo = resSix10265.Cainfo
  34675. res2.WarnMsg = resSix10265.WarnMsg
  34676. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34677. res2.Infcode = infocode
  34678. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34679. if err == nil {
  34680. c.ServeSuccessJSON(map[string]interface{}{
  34681. "msg": "撤销明细成功",
  34682. })
  34683. return
  34684. } else {
  34685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34686. return
  34687. }
  34688. } else if miConfig.MdtrtareaAdmvs == "341203" {
  34689. var api3 string
  34690. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  34691. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34692. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34693. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34694. resp3, requestErr3 := http.Get(api3)
  34695. utils.ErrorLog("接口: %v", requestErr3)
  34696. if requestErr3 != nil {
  34697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34698. return
  34699. }
  34700. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34701. if ioErr3 != nil {
  34702. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34704. return
  34705. }
  34706. var respJSON3 map[string]interface{}
  34707. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34708. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34710. return
  34711. }
  34712. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34713. if status == "0" {
  34714. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34715. c.ServeSuccessJSON(map[string]interface{}{
  34716. "failed_code": -10,
  34717. "msg": err_msg,
  34718. })
  34719. return
  34720. }
  34721. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34722. userJSONBytes3, _ := json.Marshal(respJSON3)
  34723. fmt.Println("log")
  34724. fmt.Println(string(userJSONBytes3))
  34725. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34726. utils.ErrorLog("解析失败:%v", err)
  34727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34728. return
  34729. }
  34730. fmt.Println(res2.Infcode)
  34731. if res2.Infcode == -1 {
  34732. c.ServeSuccessJSON(map[string]interface{}{
  34733. "failed_code": -10,
  34734. "msg": res2.ErrMsg,
  34735. })
  34736. return
  34737. }
  34738. if res2.Infcode == 0 {
  34739. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34740. if err == nil {
  34741. c.ServeSuccessJSON(map[string]interface{}{
  34742. "msg": "撤销明细成功",
  34743. })
  34744. return
  34745. } else {
  34746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34747. return
  34748. }
  34749. } else {
  34750. c.ServeSuccessJSON(map[string]interface{}{
  34751. "failed_code": -10,
  34752. "msg": res2.ErrMsg,
  34753. })
  34754. }
  34755. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34756. if err == nil {
  34757. c.ServeSuccessJSON(map[string]interface{}{
  34758. "msg": "撤销明细成功",
  34759. })
  34760. return
  34761. } else {
  34762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34763. return
  34764. }
  34765. } else if miConfig.MdtrtareaAdmvs == "340699" {
  34766. var api3 string
  34767. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  34768. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34769. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34770. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  34771. resp3, requestErr3 := http.Get(api3)
  34772. utils.ErrorLog("接口: %v", requestErr3)
  34773. if requestErr3 != nil {
  34774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34775. return
  34776. }
  34777. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34778. if ioErr3 != nil {
  34779. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34781. return
  34782. }
  34783. var respJSON3 map[string]interface{}
  34784. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34785. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34787. return
  34788. }
  34789. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  34790. if status == "0" {
  34791. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  34792. c.ServeSuccessJSON(map[string]interface{}{
  34793. "failed_code": -10,
  34794. "msg": err_msg,
  34795. })
  34796. return
  34797. }
  34798. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34799. userJSONBytes3, _ := json.Marshal(respJSON3)
  34800. fmt.Println("log")
  34801. fmt.Println(string(userJSONBytes3))
  34802. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  34803. utils.ErrorLog("解析失败:%v", err)
  34804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34805. return
  34806. }
  34807. fmt.Println(res2.Infcode)
  34808. if res2.Infcode == -1 {
  34809. c.ServeSuccessJSON(map[string]interface{}{
  34810. "failed_code": -10,
  34811. "msg": res2.ErrMsg,
  34812. })
  34813. return
  34814. }
  34815. if res2.Infcode == 0 {
  34816. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34817. if err == nil {
  34818. c.ServeSuccessJSON(map[string]interface{}{
  34819. "msg": "撤销明细成功",
  34820. })
  34821. return
  34822. } else {
  34823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34824. return
  34825. }
  34826. } else {
  34827. c.ServeSuccessJSON(map[string]interface{}{
  34828. "failed_code": -10,
  34829. "msg": res2.ErrMsg,
  34830. })
  34831. }
  34832. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34833. if err == nil {
  34834. c.ServeSuccessJSON(map[string]interface{}{
  34835. "msg": "撤销明细成功",
  34836. })
  34837. return
  34838. } else {
  34839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34840. return
  34841. }
  34842. } else if miConfig.MdtrtareaAdmvs == "150499" {
  34843. var resSix10265 ResultSix10265
  34844. new_chrg_bchno := order.Number
  34845. if adminUser.CurrentOrgId == 10265 {
  34846. if !strings.Contains(his.InsuplcAdmdvs, "1504") {
  34847. new_chrg_bchno = "0000"
  34848. }
  34849. }
  34850. var api3 string
  34851. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  34852. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + new_chrg_bchno + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  34853. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  34854. resp3, requestErr3 := http.Get(api3)
  34855. if requestErr3 != nil {
  34856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34857. return
  34858. }
  34859. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  34860. if ioErr3 != nil {
  34861. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  34862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34863. return
  34864. }
  34865. var respJSON3 map[string]interface{}
  34866. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  34867. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  34868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34869. return
  34870. }
  34871. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  34872. userJSONBytes3, _ := json.Marshal(respJSON3)
  34873. fmt.Println("log")
  34874. fmt.Println(string(userJSONBytes3))
  34875. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  34876. utils.ErrorLog("解析失败:%v", err)
  34877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34878. return
  34879. }
  34880. res2.InfRefmsgid = resSix10265.InfRefmsgid
  34881. res2.Output = resSix10265.Output
  34882. res2.ErrMsg = resSix10265.ErrMsg
  34883. res2.Cainfo = resSix10265.Cainfo
  34884. res2.WarnMsg = resSix10265.WarnMsg
  34885. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  34886. res2.Infcode = infocode
  34887. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34888. if err == nil {
  34889. c.ServeSuccessJSON(map[string]interface{}{
  34890. "msg": "撤销明细成功",
  34891. })
  34892. return
  34893. } else {
  34894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34895. return
  34896. }
  34897. } else if miConfig.MdtrtareaAdmvs == "350500" {
  34898. 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)
  34899. var dat map[string]interface{}
  34900. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34901. fmt.Println(dat)
  34902. } else {
  34903. fmt.Println(err)
  34904. }
  34905. saveLog(result2, src_request, "2205", "撤销明细")
  34906. userJSONBytes, _ := json.Marshal(dat)
  34907. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34908. utils.ErrorLog("解析失败:%v", err)
  34909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34910. return
  34911. }
  34912. if res2.Infcode == 0 {
  34913. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34914. if err == nil {
  34915. c.ServeSuccessJSON(map[string]interface{}{
  34916. "msg": "撤销明细成功",
  34917. })
  34918. return
  34919. } else {
  34920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34921. return
  34922. }
  34923. } else {
  34924. c.ServeSuccessJSON(map[string]interface{}{
  34925. "failed_code": -10,
  34926. "msg": res2.ErrMsg,
  34927. })
  34928. }
  34929. } else if miConfig.MdtrtareaAdmvs == "360302" {
  34930. result2, src_request := service.Jxyb2205(his.PsnNo, his.Number, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.AccessKey, "")
  34931. var dat map[string]interface{}
  34932. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34933. fmt.Println(dat)
  34934. } else {
  34935. fmt.Println(err)
  34936. }
  34937. saveLog(result2, src_request, "2205", "撤销明细")
  34938. userJSONBytes, _ := json.Marshal(dat)
  34939. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34940. utils.ErrorLog("解析失败:%v", err)
  34941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34942. return
  34943. }
  34944. if res2.Infcode == 0 {
  34945. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34946. if err == nil {
  34947. c.ServeSuccessJSON(map[string]interface{}{
  34948. "msg": "撤销明细成功",
  34949. })
  34950. return
  34951. } else {
  34952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34953. return
  34954. }
  34955. } else {
  34956. c.ServeSuccessJSON(map[string]interface{}{
  34957. "failed_code": -10,
  34958. "msg": res2.ErrMsg,
  34959. })
  34960. }
  34961. } else if miConfig.MdtrtareaAdmvs == "361025" {
  34962. 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, "")
  34963. var dat map[string]interface{}
  34964. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34965. fmt.Println(dat)
  34966. } else {
  34967. fmt.Println(err)
  34968. }
  34969. saveLog(result2, src_request, "2205", "撤销明细")
  34970. userJSONBytes, _ := json.Marshal(dat)
  34971. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  34972. utils.ErrorLog("解析失败:%v", err)
  34973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34974. return
  34975. }
  34976. if res2.Infcode == 0 {
  34977. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  34978. if err == nil {
  34979. c.ServeSuccessJSON(map[string]interface{}{
  34980. "msg": "撤销明细成功",
  34981. })
  34982. return
  34983. } else {
  34984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  34985. return
  34986. }
  34987. } else {
  34988. c.ServeSuccessJSON(map[string]interface{}{
  34989. "failed_code": -10,
  34990. "msg": res2.ErrMsg,
  34991. })
  34992. }
  34993. } else if miConfig.MdtrtareaAdmvs == "360100" {
  34994. 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, "")
  34995. var dat map[string]interface{}
  34996. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  34997. fmt.Println(dat)
  34998. } else {
  34999. fmt.Println(err)
  35000. }
  35001. saveLog(result2, src_request, "2205", "撤销明细")
  35002. userJSONBytes, _ := json.Marshal(dat)
  35003. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35004. utils.ErrorLog("解析失败:%v", err)
  35005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35006. return
  35007. }
  35008. if res2.Infcode == 0 {
  35009. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35010. if err == nil {
  35011. c.ServeSuccessJSON(map[string]interface{}{
  35012. "msg": "撤销明细成功",
  35013. })
  35014. return
  35015. } else {
  35016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35017. return
  35018. }
  35019. } else {
  35020. c.ServeSuccessJSON(map[string]interface{}{
  35021. "failed_code": -10,
  35022. "msg": res2.ErrMsg,
  35023. })
  35024. }
  35025. } else if miConfig.MdtrtareaAdmvs == "430800" {
  35026. 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, "")
  35027. var dat map[string]interface{}
  35028. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  35029. fmt.Println(dat)
  35030. } else {
  35031. fmt.Println(err)
  35032. }
  35033. saveLog(result2, src_request, "2205", "撤销明细")
  35034. userJSONBytes, _ := json.Marshal(dat)
  35035. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  35036. utils.ErrorLog("解析失败:%v", err)
  35037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35038. return
  35039. }
  35040. if res2.Infcode == 0 {
  35041. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35042. if err == nil {
  35043. c.ServeSuccessJSON(map[string]interface{}{
  35044. "msg": "撤销明细成功",
  35045. })
  35046. return
  35047. } else {
  35048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35049. return
  35050. }
  35051. } else {
  35052. c.ServeSuccessJSON(map[string]interface{}{
  35053. "failed_code": -10,
  35054. "msg": res2.ErrMsg,
  35055. })
  35056. }
  35057. } else if miConfig.MdtrtareaAdmvs == "441799" {
  35058. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  35059. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  35060. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  35061. resp2, requestErr2 := http.Get(api2)
  35062. if requestErr2 != nil {
  35063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35064. return
  35065. }
  35066. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  35067. if ioErr2 != nil {
  35068. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  35069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35070. return
  35071. }
  35072. var respJSON2 map[string]interface{}
  35073. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  35074. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35076. return
  35077. }
  35078. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35079. userJSONBytes3, _ := json.Marshal(respJSON2)
  35080. fmt.Println("log")
  35081. fmt.Println(string(userJSONBytes3))
  35082. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  35083. utils.ErrorLog("解析失败:%v", err)
  35084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35085. return
  35086. }
  35087. if res2.Infcode == 0 {
  35088. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35089. if err == nil {
  35090. c.ServeSuccessJSON(map[string]interface{}{
  35091. "msg": "撤销明细成功",
  35092. })
  35093. return
  35094. } else {
  35095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35096. return
  35097. }
  35098. } else {
  35099. c.ServeSuccessJSON(map[string]interface{}{
  35100. "failed_code": -10,
  35101. "msg": res2.ErrMsg,
  35102. })
  35103. }
  35104. } else {
  35105. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  35106. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  35107. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  35108. resp2, requestErr2 := http.Get(api2)
  35109. if requestErr2 != nil {
  35110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35111. return
  35112. }
  35113. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  35114. if ioErr2 != nil {
  35115. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  35116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35117. return
  35118. }
  35119. var respJSON2 map[string]interface{}
  35120. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  35121. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35123. return
  35124. }
  35125. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35126. userJSONBytes3, _ := json.Marshal(respJSON2)
  35127. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  35128. utils.ErrorLog("解析失败:%v", err)
  35129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35130. return
  35131. }
  35132. if res2.Infcode == -1 {
  35133. c.ServeSuccessJSON(map[string]interface{}{
  35134. "failed_code": -10,
  35135. "msg": res2.ErrMsg,
  35136. })
  35137. return
  35138. } else {
  35139. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35140. if err == nil {
  35141. c.ServeSuccessJSON(map[string]interface{}{
  35142. "msg": "撤销明细成功",
  35143. })
  35144. return
  35145. } else {
  35146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35147. return
  35148. }
  35149. }
  35150. }
  35151. } else {
  35152. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  35153. if err == nil {
  35154. c.ServeSuccessJSON(map[string]interface{}{
  35155. "msg": "退费成功",
  35156. })
  35157. } else {
  35158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35159. return
  35160. }
  35161. }
  35162. }
  35163. // 对账
  35164. func (c *HisApiController) GetCheckAccount() {
  35165. start_time := c.GetString("start_time")
  35166. end_time := c.GetString("end_time")
  35167. insutype := c.GetString("insutype")
  35168. clr_type := c.GetString("clr_type")
  35169. clr_org := c.GetString("clr_optins")
  35170. admin_user_id, _ := c.GetInt64("admin_user_id")
  35171. adminUser := c.GetAdminUserInfo()
  35172. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35173. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35174. if len(clr_org) == 0 {
  35175. clr_org = miConfig.InsuplcAdmdvs
  35176. }
  35177. timeLayout := "2006-01-02"
  35178. loc, _ := time.LoadLocation("Local")
  35179. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  35180. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  35181. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35182. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35183. fixmedins_setl_cnt := int64(len(orders))
  35184. var medfee_sumamt float64
  35185. var acct_pay float64
  35186. var fund_pay_sumamt float64
  35187. for _, item := range orders {
  35188. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35189. acct_pay = acct_pay + item.AcctPay
  35190. if miConfig.MdtrtareaAdmvs == "361025" || miConfig.MdtrtareaAdmvs == "360100" {
  35191. fund_pay_sumamt = fund_pay_sumamt + item.HifpPay + item.HifmiPay + item.MafPay + item.HifobPay + item.HifesPay
  35192. } else {
  35193. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35194. }
  35195. }
  35196. var user_name string
  35197. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  35198. if role.ID == 0 {
  35199. user_name = "xxx"
  35200. } else {
  35201. user_name = role.UserName
  35202. }
  35203. var res ResultEight
  35204. var res10188 ResultEightFor10188
  35205. if config.IsOpen == 1 {
  35206. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  35207. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  35208. "insutype=" + insutype +
  35209. "&clr_type=" + clr_type +
  35210. "&setl_optins=" + clr_org +
  35211. "&stmt_begndate=" + start_time +
  35212. "&stm_enddate=" + end_time +
  35213. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35214. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35215. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35216. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35217. "&fixmedins_code=" + miConfig.Code +
  35218. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35219. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35220. "&secret_key=" + miConfig.SecretKey +
  35221. "&org_name=" + miConfig.OrgName +
  35222. "&doctor=" + user_name +
  35223. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  35224. fmt.Println(api)
  35225. resp, requestErr := http.Get(api)
  35226. if requestErr != nil {
  35227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35228. return
  35229. }
  35230. body, ioErr := ioutil.ReadAll(resp.Body)
  35231. fmt.Println(body)
  35232. if ioErr != nil {
  35233. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35235. return
  35236. }
  35237. var respJSON map[string]interface{}
  35238. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35239. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35241. return
  35242. }
  35243. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35244. userJSONBytes, _ := json.Marshal(respJSON)
  35245. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35246. utils.ErrorLog("解析失败:%v", err)
  35247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35248. return
  35249. }
  35250. res.InfRefmsgid = res10188.InfRefmsgid
  35251. res.Output = res10188.Output
  35252. res.ErrMsg = res10188.ErrMsg
  35253. res.Cainfo = res10188.Cainfo
  35254. res.WarnMsg = res10188.WarnMsg
  35255. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  35256. res.Infcode = infocode
  35257. } else if miConfig.MdtrtareaAdmvs == "150499" {
  35258. if clr_type != "9903" {
  35259. clr_type = "99" // 就诊 ID(来自2201接口返回)
  35260. }
  35261. if clr_type == "9903" {
  35262. clr_type = "9910" // 就诊 ID(来自2201接口返回)
  35263. }
  35264. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  35265. "insutype=" + insutype +
  35266. "&clr_type=" + clr_type +
  35267. "&setl_optins=" + clr_org +
  35268. "&stmt_begndate=" + start_time +
  35269. "&stm_enddate=" + end_time +
  35270. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35271. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35272. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35273. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35274. "&fixmedins_code=" + miConfig.Code +
  35275. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35276. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35277. "&secret_key=" + miConfig.SecretKey +
  35278. "&org_name=" + miConfig.OrgName +
  35279. "&doctor=" + user_name
  35280. resp, requestErr := http.Get(api)
  35281. if requestErr != nil {
  35282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35283. return
  35284. }
  35285. body, ioErr := ioutil.ReadAll(resp.Body)
  35286. if ioErr != nil {
  35287. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35289. return
  35290. }
  35291. var respJSON map[string]interface{}
  35292. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35293. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35295. return
  35296. }
  35297. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35298. result, _ := json.Marshal(respJSON)
  35299. fmt.Println("log")
  35300. fmt.Println(string(result))
  35301. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  35302. utils.ErrorLog("解析失败:%v", err)
  35303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35304. return
  35305. }
  35306. res.InfRefmsgid = res10188.InfRefmsgid
  35307. res.Output = res10188.Output
  35308. res.ErrMsg = res10188.ErrMsg
  35309. res.Cainfo = res10188.Cainfo
  35310. res.WarnMsg = res10188.WarnMsg
  35311. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  35312. res.Infcode = infocode
  35313. } else if miConfig.MdtrtareaAdmvs == "350500" {
  35314. var baseParams models.BaseParams
  35315. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35316. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35317. baseParams.SecretKey = miConfig.SecretKey
  35318. baseParams.OrgName = miConfig.OrgName
  35319. baseParams.FixmedinsCode = miConfig.Code
  35320. baseParams.EncKey = miConfig.EncKey
  35321. baseParams.AppSecret = miConfig.AppSecret
  35322. baseParams.SignKey = miConfig.SignKey
  35323. baseParams.AppID = miConfig.Code
  35324. baseParams.Doctor = role.UserName
  35325. baseParams.RequestUrl = miConfig.Url
  35326. businessParams := models.BusinessParams{
  35327. Insutype: insutype,
  35328. ClrType: clr_type,
  35329. SetlOptins: clr_org,
  35330. StmtBegndate: start_time,
  35331. StmtEnddate: end_time,
  35332. MedfeeSumamt: medfee_sumamt,
  35333. FundPaySumamt: fund_pay_sumamt,
  35334. AcctPay: acct_pay,
  35335. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35336. }
  35337. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  35338. fmt.Println(requestLog)
  35339. fmt.Println(result)
  35340. fmt.Println(err_msg)
  35341. var dat map[string]interface{}
  35342. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35343. fmt.Println(dat)
  35344. } else {
  35345. fmt.Println(err)
  35346. }
  35347. userJSONBytes, _ := json.Marshal(dat)
  35348. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35349. utils.ErrorLog("解析失败:%v", err)
  35350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35351. return
  35352. }
  35353. } else if miConfig.MdtrtareaAdmvs == "430800" {
  35354. var baseParams models.BaseParams
  35355. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35356. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35357. baseParams.SecretKey = miConfig.SecretKey
  35358. baseParams.OrgName = miConfig.OrgName
  35359. baseParams.FixmedinsCode = miConfig.Code
  35360. baseParams.EncKey = miConfig.EncKey
  35361. baseParams.AppSecret = miConfig.AppSecret
  35362. baseParams.SignKey = miConfig.SignKey
  35363. baseParams.AppID = miConfig.Code
  35364. baseParams.Doctor = role.UserName
  35365. baseParams.RequestUrl = miConfig.Url
  35366. baseParams.AccessKey = miConfig.AccessKey
  35367. businessParams := models.BusinessParams{
  35368. Insutype: insutype,
  35369. ClrType: clr_type,
  35370. SetlOptins: "430822",
  35371. StmtBegndate: start_time,
  35372. StmtEnddate: end_time,
  35373. MedfeeSumamt: medfee_sumamt,
  35374. FundPaySumamt: fund_pay_sumamt,
  35375. AcctPay: acct_pay,
  35376. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35377. }
  35378. 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)
  35379. fmt.Println(requestLog)
  35380. fmt.Println(result)
  35381. var dat map[string]interface{}
  35382. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35383. fmt.Println(dat)
  35384. } else {
  35385. fmt.Println(err)
  35386. }
  35387. userJSONBytes, _ := json.Marshal(dat)
  35388. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35389. utils.ErrorLog("解析失败:%v", err)
  35390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35391. return
  35392. }
  35393. } else if miConfig.MdtrtareaAdmvs == "350500" {
  35394. var baseParams models.BaseParams
  35395. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35396. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35397. baseParams.SecretKey = miConfig.SecretKey
  35398. baseParams.OrgName = miConfig.OrgName
  35399. baseParams.FixmedinsCode = miConfig.Code
  35400. baseParams.EncKey = miConfig.EncKey
  35401. baseParams.AppSecret = miConfig.AppSecret
  35402. baseParams.SignKey = miConfig.SignKey
  35403. baseParams.AppID = miConfig.Code
  35404. baseParams.Doctor = role.UserName
  35405. baseParams.RequestUrl = miConfig.Url
  35406. businessParams := models.BusinessParams{
  35407. Insutype: insutype,
  35408. ClrType: clr_type,
  35409. SetlOptins: clr_org,
  35410. StmtBegndate: start_time,
  35411. StmtEnddate: end_time,
  35412. MedfeeSumamt: medfee_sumamt,
  35413. FundPaySumamt: fund_pay_sumamt,
  35414. AcctPay: acct_pay,
  35415. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35416. }
  35417. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  35418. fmt.Println(requestLog)
  35419. fmt.Println(result)
  35420. fmt.Println(err_msg)
  35421. var dat map[string]interface{}
  35422. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35423. fmt.Println(dat)
  35424. } else {
  35425. fmt.Println(err)
  35426. }
  35427. userJSONBytes, _ := json.Marshal(dat)
  35428. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35429. utils.ErrorLog("解析失败:%v", err)
  35430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35431. return
  35432. }
  35433. } else if miConfig.MdtrtareaAdmvs == "441799" {
  35434. if len(clr_type) == 0 {
  35435. clr_type = "11"
  35436. }
  35437. api := miConfig.Url + "gdyb/ten?" +
  35438. "insutype=" + insutype +
  35439. "&clr_type=" + clr_type +
  35440. "&setl_optins=" + clr_org +
  35441. "&stmt_begndate=" + start_time +
  35442. "&stm_enddate=" + end_time +
  35443. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35444. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35445. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35446. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  35447. "&fixmedins_code=" + miConfig.Code +
  35448. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35449. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35450. "&secret_key=" + miConfig.SecretKey +
  35451. "&org_name=" + miConfig.OrgName +
  35452. "&doctor=" + user_name
  35453. fmt.Println(api)
  35454. resp, requestErr := http.Get(api)
  35455. if requestErr != nil {
  35456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35457. return
  35458. }
  35459. body, ioErr := ioutil.ReadAll(resp.Body)
  35460. fmt.Println(body)
  35461. if ioErr != nil {
  35462. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35464. return
  35465. }
  35466. var respJSON map[string]interface{}
  35467. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35468. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35470. return
  35471. }
  35472. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35473. userJSONBytes, _ := json.Marshal(respJSON)
  35474. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35475. utils.ErrorLog("解析失败:%v", err)
  35476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35477. return
  35478. }
  35479. } else if miConfig.MdtrtareaAdmvs == "360302" {
  35480. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35481. //fixmedins_setl_cnt := int64(len(orders_two))
  35482. //var medfee_sumamt float64
  35483. //var acct_pay float64
  35484. //var fund_pay_sumamt float64
  35485. //for _, item := range orders_two {
  35486. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35487. // acct_pay = acct_pay + item.AcctPay
  35488. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35489. //}
  35490. var baseParams models.BaseParams
  35491. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35492. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35493. baseParams.SecretKey = miConfig.SecretKey
  35494. baseParams.OrgName = miConfig.OrgName
  35495. baseParams.FixmedinsCode = miConfig.Code
  35496. baseParams.EncKey = miConfig.EncKey
  35497. baseParams.AppSecret = miConfig.AppSecret
  35498. baseParams.SignKey = miConfig.SignKey
  35499. baseParams.AppID = miConfig.Code
  35500. baseParams.Doctor = role.UserName
  35501. baseParams.RequestUrl = miConfig.Url
  35502. if clr_type == "9903" {
  35503. clr_type = "9901"
  35504. }
  35505. businessParams := models.BusinessParams{
  35506. Insutype: insutype,
  35507. ClrType: clr_type,
  35508. SetlOptins: "360302",
  35509. StmtBegndate: start_time,
  35510. StmtEnddate: end_time,
  35511. MedfeeSumamt: 0,
  35512. FundPaySumamt: 0,
  35513. AcctPay: 0,
  35514. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35515. }
  35516. 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))
  35517. fmt.Println(requestLog)
  35518. fmt.Println(result)
  35519. var dat map[string]interface{}
  35520. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35521. fmt.Println(dat)
  35522. } else {
  35523. fmt.Println(err)
  35524. }
  35525. userJSONBytes, _ := json.Marshal(dat)
  35526. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35527. utils.ErrorLog("解析失败:%v", err)
  35528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35529. return
  35530. }
  35531. } else if miConfig.MdtrtareaAdmvs == "361025" {
  35532. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35533. //fixmedins_setl_cnt := int64(len(orders_two))
  35534. //var medfee_sumamt float64
  35535. //var acct_pay float64
  35536. //var fund_pay_sumamt float64
  35537. //for _, item := range orders_two {
  35538. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35539. // acct_pay = acct_pay + item.AcctPay
  35540. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35541. //}
  35542. var baseParams models.BaseParams
  35543. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35544. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35545. baseParams.SecretKey = miConfig.SecretKey
  35546. baseParams.OrgName = miConfig.OrgName
  35547. baseParams.FixmedinsCode = miConfig.Code
  35548. baseParams.EncKey = miConfig.EncKey
  35549. baseParams.AppSecret = miConfig.AppSecret
  35550. baseParams.SignKey = miConfig.SignKey
  35551. baseParams.AppID = miConfig.Code
  35552. baseParams.Doctor = role.UserName
  35553. baseParams.RequestUrl = miConfig.Url
  35554. if clr_type == "9903" {
  35555. clr_type = "9994"
  35556. }
  35557. businessParams := models.BusinessParams{
  35558. Insutype: insutype,
  35559. ClrType: clr_type,
  35560. SetlOptins: "361025",
  35561. StmtBegndate: start_time,
  35562. StmtEnddate: end_time,
  35563. MedfeeSumamt: 0,
  35564. FundPaySumamt: 0,
  35565. AcctPay: 0,
  35566. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35567. }
  35568. 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))
  35569. fmt.Println(requestLog)
  35570. fmt.Println(result)
  35571. var dat map[string]interface{}
  35572. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35573. fmt.Println(dat)
  35574. } else {
  35575. fmt.Println(err)
  35576. }
  35577. userJSONBytes, _ := json.Marshal(dat)
  35578. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35579. utils.ErrorLog("解析失败:%v", err)
  35580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35581. return
  35582. }
  35583. } else if miConfig.MdtrtareaAdmvs == "360100" {
  35584. //orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  35585. //fixmedins_setl_cnt := int64(len(orders_two))
  35586. //var medfee_sumamt float64
  35587. //var acct_pay float64
  35588. //var fund_pay_sumamt float64
  35589. //for _, item := range orders_two {
  35590. // medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35591. // acct_pay = acct_pay + item.AcctPay
  35592. // fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35593. //}
  35594. var baseParams models.BaseParams
  35595. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  35596. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  35597. baseParams.SecretKey = miConfig.SecretKey
  35598. baseParams.OrgName = miConfig.OrgName
  35599. baseParams.FixmedinsCode = miConfig.Code
  35600. baseParams.EncKey = miConfig.EncKey
  35601. baseParams.AppSecret = miConfig.AppSecret
  35602. baseParams.SignKey = miConfig.SignKey
  35603. baseParams.AppID = miConfig.Code
  35604. baseParams.Doctor = role.UserName
  35605. baseParams.RequestUrl = miConfig.Url
  35606. if clr_type == "9903" {
  35607. clr_type = "9994"
  35608. }
  35609. businessParams := models.BusinessParams{
  35610. Insutype: insutype,
  35611. ClrType: clr_type,
  35612. SetlOptins: "360100",
  35613. StmtBegndate: start_time,
  35614. StmtEnddate: end_time,
  35615. MedfeeSumamt: 0,
  35616. FundPaySumamt: 0,
  35617. AcctPay: 0,
  35618. FixmedinsSetlCnt: fixmedins_setl_cnt,
  35619. }
  35620. 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))
  35621. fmt.Println(requestLog)
  35622. fmt.Println(result)
  35623. var dat map[string]interface{}
  35624. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  35625. fmt.Println(dat)
  35626. } else {
  35627. fmt.Println(err)
  35628. }
  35629. userJSONBytes, _ := json.Marshal(dat)
  35630. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35631. utils.ErrorLog("解析失败:%v", err)
  35632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35633. return
  35634. }
  35635. } else if miConfig.MdtrtareaAdmvs == "341203" {
  35636. var api string
  35637. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  35638. "&clr_type=" + clr_type +
  35639. "&setl_optins=" + clr_org +
  35640. "&stmt_begndate=" + start_time +
  35641. "&stm_enddate=" + end_time +
  35642. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35643. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35644. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35645. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35646. "&fixmedins_code=" + miConfig.Code +
  35647. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35648. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35649. "&secret_key=" + miConfig.SecretKey +
  35650. "&org_name=" + miConfig.OrgName +
  35651. "&doctor=" + user_name + "&url=" + miConfig.Url
  35652. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35653. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35654. resp, requestErr := http.Get(api)
  35655. if requestErr != nil {
  35656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35657. return
  35658. }
  35659. body, ioErr := ioutil.ReadAll(resp.Body)
  35660. if ioErr != nil {
  35661. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35663. return
  35664. }
  35665. var respJSON map[string]interface{}
  35666. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35669. return
  35670. }
  35671. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35672. if status == "0" {
  35673. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35674. c.ServeSuccessJSON(map[string]interface{}{
  35675. "failed_code": -10,
  35676. "msg": err_msg,
  35677. })
  35678. return
  35679. }
  35680. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35681. userJSONBytes, _ := json.Marshal(respJSON)
  35682. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35683. utils.ErrorLog("解析失败:%v", err)
  35684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35685. return
  35686. }
  35687. } else if miConfig.MdtrtareaAdmvs == "340699" {
  35688. var api string
  35689. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  35690. "&clr_type=" + clr_type +
  35691. "&setl_optins=" + clr_org +
  35692. "&stmt_begndate=" + start_time +
  35693. "&stm_enddate=" + end_time +
  35694. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35695. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35696. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35697. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  35698. "&fixmedins_code=" + miConfig.Code +
  35699. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35700. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35701. "&secret_key=" + miConfig.SecretKey +
  35702. "&org_name=" + miConfig.OrgName +
  35703. "&doctor=" + user_name + "&url=" + miConfig.Url
  35704. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35705. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  35706. resp, requestErr := http.Get(api)
  35707. if requestErr != nil {
  35708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35709. return
  35710. }
  35711. body, ioErr := ioutil.ReadAll(resp.Body)
  35712. if ioErr != nil {
  35713. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35715. return
  35716. }
  35717. var respJSON map[string]interface{}
  35718. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35719. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35721. return
  35722. }
  35723. status := respJSON["data"].(map[string]interface{})["status"].(string)
  35724. if status == "0" {
  35725. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  35726. c.ServeSuccessJSON(map[string]interface{}{
  35727. "failed_code": -10,
  35728. "msg": err_msg,
  35729. })
  35730. return
  35731. }
  35732. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35733. userJSONBytes, _ := json.Marshal(respJSON)
  35734. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35735. utils.ErrorLog("解析失败:%v", err)
  35736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35737. return
  35738. }
  35739. } else {
  35740. if len(clr_type) == 0 {
  35741. clr_type = "11"
  35742. }
  35743. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  35744. "insutype=" + insutype +
  35745. "&clr_type=" + clr_type +
  35746. "&setl_optins=" + clr_org +
  35747. "&stmt_begndate=" + start_time +
  35748. "&stm_enddate=" + end_time +
  35749. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  35750. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  35751. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  35752. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  35753. "&fixmedins_code=" + miConfig.Code +
  35754. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35755. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35756. "&secret_key=" + miConfig.SecretKey +
  35757. "&org_name=" + miConfig.OrgName +
  35758. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  35759. fmt.Println(api)
  35760. resp, requestErr := http.Get(api)
  35761. if requestErr != nil {
  35762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35763. return
  35764. }
  35765. body, ioErr := ioutil.ReadAll(resp.Body)
  35766. fmt.Println(body)
  35767. if ioErr != nil {
  35768. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35770. return
  35771. }
  35772. var respJSON map[string]interface{}
  35773. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35774. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35776. return
  35777. }
  35778. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35779. userJSONBytes, _ := json.Marshal(respJSON)
  35780. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35781. utils.ErrorLog("解析失败:%v", err)
  35782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35783. return
  35784. }
  35785. }
  35786. if res.Infcode == 0 {
  35787. if res.Output.Stmtinfo.StmtRslt == "0" {
  35788. micc := &models.MedicalInsuranceCostCompare{
  35789. StartTime: startime.Unix(),
  35790. EndTime: endtime.Unix(),
  35791. Insutype: insutype,
  35792. CheckType: 1,
  35793. Num: fixmedins_setl_cnt,
  35794. Mtime: time.Now().Unix(),
  35795. Status: 1,
  35796. UserOrgId: adminUser.CurrentOrgId,
  35797. CostTotal: medfee_sumamt,
  35798. FuncTotal: fund_pay_sumamt,
  35799. PsnPay: acct_pay,
  35800. Creator: admin_user_id,
  35801. Ctime: time.Now().Unix(),
  35802. ClrType: clr_type,
  35803. }
  35804. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  35805. if err == nil {
  35806. c.ServeSuccessJSON(map[string]interface{}{
  35807. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  35808. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  35809. })
  35810. } else {
  35811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35812. }
  35813. } else {
  35814. c.ServeSuccessJSON(map[string]interface{}{
  35815. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  35816. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  35817. })
  35818. }
  35819. } else {
  35820. c.ServeSuccessJSON(map[string]interface{}{
  35821. "failed_code": -10,
  35822. "msg": res.ErrMsg,
  35823. })
  35824. }
  35825. }
  35826. }
  35827. func (c *HisApiController) Check310() {
  35828. adminUser := c.GetAdminUserInfo()
  35829. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35830. var user_name string
  35831. user_name = "高慧裕"
  35832. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  35833. "insutype=" + "310" +
  35834. "&clr_type=" + "" +
  35835. "&setl_optins=" + "441202" +
  35836. "&stmt_begndate=" + "2022-03-01" +
  35837. "&stm_enddate=" + "2022-03-31" +
  35838. "&medfee_sumamt=" + "194930.12" +
  35839. "&fund_pay_sumamt=" + "188741.46" +
  35840. "&acct_pay=" + "0" +
  35841. "&fixmedins_setl_cnt=" + "452" +
  35842. "&fixmedins_code=" + miConfig.Code +
  35843. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35844. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35845. "&secret_key=" + miConfig.SecretKey +
  35846. "&org_name=" + miConfig.OrgName +
  35847. "&doctor=" + user_name
  35848. fmt.Println(api)
  35849. resp, requestErr := http.Get(api)
  35850. if requestErr != nil {
  35851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35852. return
  35853. }
  35854. body, ioErr := ioutil.ReadAll(resp.Body)
  35855. fmt.Println(body)
  35856. if ioErr != nil {
  35857. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35859. return
  35860. }
  35861. var respJSON map[string]interface{}
  35862. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35863. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35865. return
  35866. }
  35867. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35868. userJSONBytes, _ := json.Marshal(respJSON)
  35869. var res ResultEight
  35870. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35871. utils.ErrorLog("解析失败:%v", err)
  35872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35873. return
  35874. }
  35875. }
  35876. func (c *HisApiController) Check390() {
  35877. adminUser := c.GetAdminUserInfo()
  35878. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35879. var user_name string
  35880. user_name = "高慧裕"
  35881. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  35882. "insutype=" + "390" +
  35883. "&clr_type=" + "" +
  35884. "&setl_optins=" + "441202" +
  35885. "&stmt_begndate=" + "2022-03-01" +
  35886. "&stm_enddate=" + "2022-03-31" +
  35887. "&medfee_sumamt=" + "1068448.89" +
  35888. "&fund_pay_sumamt=" + "1014677.62" +
  35889. "&acct_pay=" + "0" +
  35890. "&fixmedins_setl_cnt=" + "1950" +
  35891. "&fixmedins_code=" + miConfig.Code +
  35892. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  35893. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  35894. "&secret_key=" + miConfig.SecretKey +
  35895. "&org_name=" + miConfig.OrgName +
  35896. "&doctor=" + user_name
  35897. fmt.Println(api)
  35898. resp, requestErr := http.Get(api)
  35899. if requestErr != nil {
  35900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35901. return
  35902. }
  35903. body, ioErr := ioutil.ReadAll(resp.Body)
  35904. fmt.Println(body)
  35905. if ioErr != nil {
  35906. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  35907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35908. return
  35909. }
  35910. var respJSON map[string]interface{}
  35911. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  35912. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  35913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35914. return
  35915. }
  35916. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  35917. userJSONBytes, _ := json.Marshal(respJSON)
  35918. var res ResultEight
  35919. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  35920. utils.ErrorLog("解析失败:%v", err)
  35921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  35922. return
  35923. }
  35924. }
  35925. // 对账明细
  35926. func (c *HisApiController) GetCheckDetailAccount() {
  35927. start_time := c.GetString("start_time")
  35928. end_time := c.GetString("end_time")
  35929. admin_user_id, _ := c.GetInt64("admin_user_id")
  35930. adminUser := c.GetAdminUserInfo()
  35931. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  35932. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  35933. timeLayout := "2006-01-02"
  35934. loc, _ := time.LoadLocation("Local")
  35935. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  35936. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  35937. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  35938. rand.Seed(time.Now().UnixNano())
  35939. num := rand.Intn(30000)
  35940. Mkdir(miConfig.OrgName)
  35941. file := strconv.FormatInt(int64(num), 10)
  35942. file_name := file + ".txt"
  35943. zip_name := file + ".zip"
  35944. zip_path := miConfig.OrgName + "/" + zip_name
  35945. file_path := miConfig.OrgName + "/" + file_name
  35946. decimal.DivisionPrecision = 2
  35947. var medfee_sumamt float64
  35948. var psn_cash_pay float64
  35949. var fund_pay_sumamt float64
  35950. fixmedins_setl_cnt := int64(len(orders))
  35951. for _, item := range orders {
  35952. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  35953. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  35954. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  35955. }
  35956. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  35957. defer f.Close()
  35958. if err != nil {
  35959. fmt.Println(err.Error())
  35960. } else {
  35961. for _, item := range orders {
  35962. var refd_setl_flag string
  35963. if item.OrderStatus == 2 {
  35964. refd_setl_flag = "0"
  35965. var str string
  35966. str = item.SetlId + " " +
  35967. item.MdtrtId + " " +
  35968. item.PsnNo + " " +
  35969. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  35970. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  35971. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  35972. _, err = f.Write([]byte(str))
  35973. }
  35974. if item.OrderStatus == 3 {
  35975. var str string
  35976. str = item.SetlId + " " +
  35977. item.MdtrtId + " " +
  35978. item.PsnNo + " " +
  35979. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  35980. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  35981. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  35982. _, err = f.Write([]byte(str))
  35983. var str2 string
  35984. str2 = item.SetlId + " " +
  35985. item.MdtrtId + " " +
  35986. item.PsnNo + " " +
  35987. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  35988. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  35989. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  35990. _, err = f.Write([]byte(str2))
  35991. }
  35992. }
  35993. }
  35994. Zip(file_path, zip_path)
  35995. fmt.Println(ReadFile(zip_path))
  35996. fmt.Println(string(ReadFile(zip_path)))
  35997. if config.IsOpen == 1 {
  35998. var user_name string
  35999. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36000. if role.ID == 0 {
  36001. user_name = "管理员"
  36002. } else {
  36003. user_name = role.UserName
  36004. }
  36005. baseParams := models.BaseParams{
  36006. SecretKey: miConfig.SecretKey,
  36007. FixmedinsCode: miConfig.Code,
  36008. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36009. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36010. OrgName: miConfig.OrgName,
  36011. Doctor: user_name,
  36012. }
  36013. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  36014. var dat map[string]interface{}
  36015. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36016. fmt.Println(dat)
  36017. } else {
  36018. fmt.Println(err)
  36019. }
  36020. userJSONBytes, _ := json.Marshal(dat)
  36021. var res ResultNine
  36022. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36023. utils.ErrorLog("解析失败:%v", err)
  36024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36025. return
  36026. }
  36027. if res.Infcode == 0 {
  36028. fileNo := res.Output.FileQuryNo
  36029. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  36030. "file_qury_no=" + fileNo +
  36031. "&setl_optins=" + "定点医保中心" +
  36032. "&stmt_begndate=" + start_time +
  36033. "&stm_enddate=" + end_time +
  36034. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  36035. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  36036. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  36037. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  36038. "&fixmedins_code=" + miConfig.Code +
  36039. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  36040. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  36041. "&secret_key=" + miConfig.SecretKey +
  36042. "&org_name=" + miConfig.OrgName +
  36043. "&doctor=" + user_name
  36044. resp, requestErr := http.Get(api)
  36045. if requestErr != nil {
  36046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36047. return
  36048. }
  36049. body, ioErr := ioutil.ReadAll(resp.Body)
  36050. if ioErr != nil {
  36051. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36053. return
  36054. }
  36055. var respJSON map[string]interface{}
  36056. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36057. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36059. return
  36060. }
  36061. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36062. userJSONBytes, _ := json.Marshal(respJSON)
  36063. var res ResultTen
  36064. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36065. utils.ErrorLog("解析失败:%v", err)
  36066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36067. return
  36068. }
  36069. if res.Infcode == 0 {
  36070. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  36071. micc := &models.MedicalInsuranceCostCompare{
  36072. StartTime: startime.Unix(),
  36073. EndTime: endtime.Unix(),
  36074. Insutype: "0",
  36075. CheckType: 2,
  36076. Num: fixmedins_setl_cnt,
  36077. Mtime: time.Now().Unix(),
  36078. Status: 1,
  36079. UserOrgId: adminUser.CurrentOrgId,
  36080. CostTotal: medfee_sumamt,
  36081. FuncTotal: fund_pay_sumamt,
  36082. PsnPay: psn_cash_pay,
  36083. Creator: admin_user_id,
  36084. Ctime: time.Now().Unix(),
  36085. }
  36086. service.CreateMedicalInsuranceCostCompareRecord(micc)
  36087. c.ServeSuccessJSON(map[string]interface{}{
  36088. "msg": "明细对账成功",
  36089. })
  36090. }
  36091. } else {
  36092. }
  36093. }
  36094. }
  36095. type CustomOrderInfo struct {
  36096. Name string
  36097. Spec string
  36098. Unit string
  36099. Count float64
  36100. Price float64
  36101. Total float64
  36102. }
  36103. func (c *HisApiController) GetBatchSettleAccounts() {
  36104. admin_user_id, _ := c.GetInt64("admin_user_id")
  36105. order_ids := c.GetString("order_ids")
  36106. order_ids_arr := strings.Split(order_ids, ",")
  36107. data3 := []map[string]interface{}{}
  36108. for _, item := range order_ids_arr {
  36109. id, _ := strconv.ParseInt(item, 10, 64)
  36110. order_id := id
  36111. adminUser := c.GetAdminUserInfo()
  36112. order, _ := service.GetHisOrderByID(order_id)
  36113. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  36114. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  36115. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  36116. orderInfos = append(orderInfos, orderInfos_two...)
  36117. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  36118. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  36119. var diagnosis_ids []string
  36120. if his.ID > 0 {
  36121. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  36122. } else {
  36123. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  36124. }
  36125. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  36126. var dia_config []*models.HisXtDiagnoseConfig
  36127. var name string
  36128. for _, item := range diagnosis_ids {
  36129. id, _ := strconv.ParseInt(item, 10, 64)
  36130. diagnosisConfig, _ := service.FindDiagnoseById(id)
  36131. dia_config = append(dia_config, &diagnosisConfig)
  36132. if len(name) == 0 {
  36133. name = diagnosisConfig.ClassName
  36134. }
  36135. //} else {
  36136. // name = name + "," + diagnosisConfig.ClassName
  36137. //}
  36138. }
  36139. var bedCostTotal float64 = 0 //床位总费
  36140. var bedCostSelfTotal float64 = 0 //床位自费
  36141. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  36142. var bedSelfTotal float64 = 0 //床位部分项目自费
  36143. var bedInscpTotal float64 = 0 //床位部分项目自费
  36144. var operationCostTotal float64 = 0 //手术费
  36145. var operationCostSelfTotal float64 = 0 //手术费
  36146. var operationCostPartSelfTotal float64 = 0 //手术费
  36147. var operationSelfTotal float64 = 0 //床位部分项目自费
  36148. var operationInscpTotal float64 = 0 //床位部分项目自费
  36149. var otherCostTotal float64 = 0 //其他费用
  36150. var otherCostSelfTotal float64 = 0 //其他费用
  36151. var otherCostPartSelfTotal float64 = 0 //其他费用
  36152. var otherSelfTotal float64 = 0 //床位部分项目自费
  36153. var otherInscpTotal float64 = 0 //床位部分项目自费
  36154. var materialCostTotal float64 = 0 //材料费
  36155. var materialCostSelfTotal float64 = 0 //材料费
  36156. var materialCostPartSelfTotal float64 = 0 //材料费
  36157. var materialSelfTotal float64 = 0 //床位部分项目自费
  36158. var materialInscpTotal float64 = 0 //床位部分项目自费
  36159. var westernMedicineCostTotal float64 = 0 //西药费
  36160. var westernMedicineCostSelfTotal float64 = 0 //西药费
  36161. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  36162. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  36163. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  36164. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  36165. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  36166. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  36167. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  36168. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  36169. var checkCostTotal float64 = 0 //检查费
  36170. var checkCostSelfTotal float64 = 0 //检查费
  36171. var checkCostPartSelfTotal float64 = 0 //检查费
  36172. var checkSelfTotal float64 = 0 //床位部分项目自费
  36173. var checkInscpTotal float64 = 0 //床位部分项目自费
  36174. var laboratoryCostTotal float64 = 0 //化验费
  36175. var laboratoryCostSelfTotal float64 = 0 //化验费
  36176. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  36177. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  36178. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  36179. var treatCostTotal float64 = 0 //治疗费用
  36180. var treatCostSelfTotal float64 = 0 //治疗费用
  36181. var treatCostPartSelfTotal float64 = 0 //治疗费用
  36182. var treatSelfTotal float64 = 0 //床位部分项目自费
  36183. var treatInscpTotal float64 = 0 //床位部分项目自费
  36184. decimal.DivisionPrecision = 2
  36185. for _, item := range orderInfos {
  36186. if item.MedChrgitmType == "01" { //床位费
  36187. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36188. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36189. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36190. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36191. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36192. }
  36193. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  36194. if item.MedChrgitmType == "03" { //检查费
  36195. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36196. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36197. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36198. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36199. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36200. }
  36201. } else {
  36202. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  36203. fmt.Println("------------")
  36204. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36205. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36206. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36207. }
  36208. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  36209. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36210. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36211. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36212. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36213. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36214. }
  36215. }
  36216. if item.MedChrgitmType == "04" { //化验费
  36217. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36218. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36219. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36220. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36221. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36222. }
  36223. if item.MedChrgitmType == "05" { //治疗费
  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. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36228. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36229. }
  36230. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  36231. fmt.Println("------------")
  36232. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36233. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36234. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36235. }
  36236. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  36237. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36238. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36239. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36240. }
  36241. //if item.MedChrgitmType == "06" { //手术费
  36242. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36243. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36244. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36245. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36246. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36247. //
  36248. //}
  36249. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  36250. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36251. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36252. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36253. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36254. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36255. }
  36256. if item.MedChrgitmType == "09" { //西药费
  36257. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36258. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36259. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36260. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36261. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36262. }
  36263. if item.MedChrgitmType == "11" { //中成费
  36264. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36265. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36266. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36267. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36268. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36269. }
  36270. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  36271. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36272. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36273. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36274. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36275. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36276. }
  36277. }
  36278. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36279. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36280. var user_name string
  36281. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36282. if role.ID == 0 {
  36283. user_name = "管理员"
  36284. } else {
  36285. user_name = role.UserName
  36286. }
  36287. baseParams := models.BaseParams{
  36288. SecretKey: miConfig.SecretKey,
  36289. FixmedinsCode: miConfig.Code,
  36290. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36291. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36292. OrgName: miConfig.OrgName,
  36293. Doctor: user_name,
  36294. RequestUrl: miConfig.Url,
  36295. AccessKey: miConfig.AccessKey,
  36296. }
  36297. businessParams := models.BusinessParams{
  36298. PsnNo: order.PsnNo,
  36299. MdtrtId: order.MdtrtId,
  36300. SetlId: order.SetlId,
  36301. }
  36302. var res ResultEleven
  36303. var resEleven10265 ResultEleven10265
  36304. if config.IsOpen == 1 {
  36305. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36306. result := service.Gdyb5203(baseParams, businessParams)
  36307. service.Gdyb5204(baseParams, businessParams)
  36308. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  36309. var dat map[string]interface{}
  36310. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36311. fmt.Println(dat)
  36312. } else {
  36313. fmt.Println(err)
  36314. }
  36315. userJSONBytes, _ := json.Marshal(dat)
  36316. if miConfig.Code == "H15049901371" {
  36317. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  36318. utils.ErrorLog("解析失败:%v", err)
  36319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36320. return
  36321. }
  36322. res.InfRefmsgid = resEleven10265.InfRefmsgid
  36323. res.Output = resEleven10265.Output
  36324. res.ErrMsg = resEleven10265.ErrMsg
  36325. res.Cainfo = resEleven10265.Cainfo
  36326. res.WarnMsg = resEleven10265.WarnMsg
  36327. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  36328. res.Infcode = infocode
  36329. } else {
  36330. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36331. utils.ErrorLog("解析失败:%v", err)
  36332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36333. return
  36334. }
  36335. }
  36336. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36337. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  36338. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  36339. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  36340. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  36341. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36342. var doctor_name string
  36343. if roles.ID == 0 {
  36344. doctor_name = "管理员"
  36345. } else {
  36346. doctor_name = roles.UserName
  36347. }
  36348. yiliao_leibie := ""
  36349. switch order.MedType {
  36350. case "11":
  36351. yiliao_leibie = "普通门诊"
  36352. break
  36353. case "12":
  36354. yiliao_leibie = "门诊挂号"
  36355. break
  36356. case "13":
  36357. yiliao_leibie = "急诊"
  36358. break
  36359. case "14":
  36360. yiliao_leibie = "门诊特殊病"
  36361. break
  36362. case "15":
  36363. yiliao_leibie = "门诊统筹"
  36364. break
  36365. case "16":
  36366. yiliao_leibie = "门诊慢性病"
  36367. break
  36368. case "21":
  36369. yiliao_leibie = "普通住院"
  36370. break
  36371. }
  36372. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  36373. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  36374. if res.Infcode == 0 {
  36375. data2 := map[string]interface{}{
  36376. "diagnosis": name,
  36377. "order_infos": orderInfos,
  36378. "number": order.MdtrtId,
  36379. "date": order.SettleAccountsDate,
  36380. "charge_admin": charge_admin,
  36381. "printor_admin": printor_admin,
  36382. "info": res.Output.Setlinfo,
  36383. "order": order,
  36384. "bedCostTotal": bedCostTotal,
  36385. "bedCostSelfTotal": bedCostSelfTotal,
  36386. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  36387. "bedSelfTotal": bedSelfTotal,
  36388. "bedInscpTotal": bedInscpTotal,
  36389. "operationCostTotal": operationCostTotal,
  36390. "operationCostSelfTotal": operationCostSelfTotal,
  36391. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  36392. "operationSelfTotal": operationSelfTotal,
  36393. "operationInscpTotal": operationInscpTotal,
  36394. "otherCostTotal": otherCostTotal,
  36395. "otherCostSelfTotal": otherCostSelfTotal,
  36396. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  36397. "otherSelfTotal": otherSelfTotal,
  36398. "otherInscpTotal": otherInscpTotal,
  36399. "materialCostTotal": materialCostTotal,
  36400. "materialCostSelfTotal": materialCostSelfTotal,
  36401. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  36402. "materialSelfTotal": materialSelfTotal,
  36403. "materialInscpTotal": materialInscpTotal,
  36404. "westernMedicineCostTotal": westernMedicineCostTotal,
  36405. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  36406. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  36407. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  36408. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  36409. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  36410. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  36411. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  36412. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  36413. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  36414. "checkCostTotal": checkCostTotal,
  36415. "checkCostSelfTotal": checkCostSelfTotal,
  36416. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  36417. "checkSelfTotal": checkSelfTotal,
  36418. "checkInscpTotal": checkInscpTotal,
  36419. "laboratoryCostTotal": laboratoryCostTotal,
  36420. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  36421. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  36422. "laboratorySelfTotal": laboratorySelfTotal,
  36423. "laboratoryInscpTotal": laboratoryInscpTotal,
  36424. "treatCostTotal": treatCostTotal,
  36425. "treatCostSelfTotal": treatCostSelfTotal,
  36426. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  36427. "treatSelfTotal": treatSelfTotal,
  36428. "treatInscpTotal": treatInscpTotal,
  36429. "doctor_info": doctor_info,
  36430. "doctor_code": adminRole_two.DoctorCode,
  36431. "doctor_name": doctor_name,
  36432. "health_card_no": order.PsnNo,
  36433. "department": departments.Name,
  36434. "yiliao_leibie": yiliao_leibie,
  36435. "after_money": order.AccountPrice,
  36436. "patient": patient,
  36437. "org_name": miConfig.OrgName,
  36438. "org_code": miConfig.Code,
  36439. "order_number": order.Number,
  36440. "his_hospital": his_hospital,
  36441. "his": his,
  36442. "dia_config": dia_config,
  36443. "psn_cash_pay": order.PsnCashPay,
  36444. //"check_order_info": cus_slice,
  36445. }
  36446. data3 = append(data3, data2)
  36447. }
  36448. }
  36449. }
  36450. c.ServeSuccessJSON(map[string]interface{}{
  36451. "infos": data3,
  36452. })
  36453. }
  36454. func (c *HisApiController) GetSettleAccounts() {
  36455. //id, _ := c.GetInt64("id")
  36456. //record_time := c.GetString("record_time")
  36457. order_id, _ := c.GetInt64("order_id")
  36458. admin_user_id, _ := c.GetInt64("admin_user_id")
  36459. //timeLayout := "2006-01-02"
  36460. //loc, _ := time.LoadLocation("Local")
  36461. //
  36462. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  36463. //if err != nil {
  36464. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  36465. // return
  36466. //}Hbyb5203
  36467. //recordDateTime := theTime.Unix()
  36468. adminUser := c.GetAdminUserInfo()
  36469. order, _ := service.GetHisOrderByID(order_id)
  36470. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  36471. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  36472. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  36473. orderInfos = append(orderInfos, orderInfos_two...)
  36474. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  36475. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  36476. var diagnosis_ids []string
  36477. if his.ID > 0 {
  36478. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  36479. } else {
  36480. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  36481. }
  36482. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  36483. var dia_config []*models.HisXtDiagnoseConfig
  36484. var name string
  36485. for _, item := range diagnosis_ids {
  36486. id, _ := strconv.ParseInt(item, 10, 64)
  36487. diagnosisConfig, _ := service.FindDiagnoseById(id)
  36488. dia_config = append(dia_config, &diagnosisConfig)
  36489. if len(name) == 0 {
  36490. name = diagnosisConfig.ClassName
  36491. } else {
  36492. name = name + "," + diagnosisConfig.ClassName
  36493. }
  36494. }
  36495. if patient.UserOrgId == 10215 {
  36496. name = "慢性肾功能不全(血透治疗)"
  36497. }
  36498. var bedCostTotal float64 = 0 //床位总费
  36499. var bedCostSelfTotal float64 = 0 //床位自费
  36500. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  36501. var bedSelfTotal float64 = 0 //床位部分项目自费
  36502. var bedInscpTotal float64 = 0 //床位部分项目自费
  36503. var operationCostTotal float64 = 0 //手术费
  36504. var operationCostSelfTotal float64 = 0 //手术费
  36505. var operationCostPartSelfTotal float64 = 0 //手术费
  36506. var operationSelfTotal float64 = 0 //床位部分项目自费
  36507. var operationInscpTotal float64 = 0 //床位部分项目自费
  36508. var otherCostTotal float64 = 0 //其他费用
  36509. var otherCostSelfTotal float64 = 0 //其他费用
  36510. var otherCostPartSelfTotal float64 = 0 //其他费用
  36511. var otherSelfTotal float64 = 0 //床位部分项目自费
  36512. var otherInscpTotal float64 = 0 //床位部分项目自费
  36513. var materialCostTotal float64 = 0 //材料费
  36514. var materialCostSelfTotal float64 = 0 //材料费
  36515. var materialCostPartSelfTotal float64 = 0 //材料费
  36516. var materialSelfTotal float64 = 0 //床位部分项目自费
  36517. var materialInscpTotal float64 = 0 //床位部分项目自费
  36518. var westernMedicineCostTotal float64 = 0 //西药费
  36519. var westernMedicineCostSelfTotal float64 = 0 //西药费
  36520. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  36521. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  36522. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  36523. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  36524. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  36525. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  36526. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  36527. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  36528. var checkCostTotal float64 = 0 //检查费
  36529. var checkCostSelfTotal float64 = 0 //检查费
  36530. var checkCostPartSelfTotal float64 = 0 //检查费
  36531. var checkSelfTotal float64 = 0 //床位部分项目自费
  36532. var checkInscpTotal float64 = 0 //床位部分项目自费
  36533. var laboratoryCostTotal float64 = 0 //化验费
  36534. var laboratoryCostSelfTotal float64 = 0 //化验费
  36535. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  36536. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  36537. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  36538. var treatCostTotal float64 = 0 //治疗费用
  36539. var treatCostSelfTotal float64 = 0 //治疗费用
  36540. var treatCostPartSelfTotal float64 = 0 //治疗费用
  36541. var treatSelfTotal float64 = 0 //床位部分项目自费
  36542. var treatInscpTotal float64 = 0 //床位部分项目自费
  36543. var zcCostTotal float64 = 0 //治疗费用
  36544. var zcCostSelfTotal float64 = 0 //治疗费用
  36545. var zcCostPartSelfTotal float64 = 0 //治疗费用
  36546. var zcSelfTotal float64 = 0 //床位部分项目自费
  36547. var zcInscpTotal float64 = 0 //床位部分项目自费
  36548. var huliCostTotal float64 = 0 //治疗费用
  36549. var huliCostSelfTotal float64 = 0 //治疗费用
  36550. var huliCostPartSelfTotal float64 = 0 //治疗费用
  36551. var huliSelfTotal float64 = 0 //床位部分项目自费
  36552. var huliInscpTotal float64 = 0 //床位部分项目自费
  36553. decimal.DivisionPrecision = 2
  36554. for _, item := range orderInfos {
  36555. if item.MedChrgitmType == "01" { //床位费
  36556. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36557. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36558. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36559. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36560. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36561. }
  36562. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  36563. if item.MedChrgitmType == "03" { //检查费
  36564. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36565. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36566. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36567. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36568. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36569. }
  36570. } else {
  36571. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  36572. fmt.Println("------------")
  36573. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36574. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36575. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36576. }
  36577. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  36578. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36579. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36580. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36581. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36582. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36583. }
  36584. }
  36585. if item.MedChrgitmType == "04" { //化验费
  36586. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36587. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36588. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36589. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36590. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36591. }
  36592. if item.MedChrgitmType == "05" { //治疗费
  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. fmt.Println("------------")
  36601. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36602. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36603. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36604. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36605. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36606. }
  36607. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  36608. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36609. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36610. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36611. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36612. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36613. }
  36614. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  36615. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36616. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36617. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36618. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36619. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36620. }
  36621. if item.MedChrgitmType == "09" { //西药费
  36622. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36623. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36624. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36625. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36626. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36627. }
  36628. if item.MedChrgitmType == "11" { //中成费
  36629. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36630. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36631. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36632. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36633. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36634. }
  36635. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  36636. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36637. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36638. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36639. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36640. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36641. }
  36642. if item.MedChrgitmType == "02" { //其他费
  36643. zcCostTotal, _ = decimal.NewFromFloat(zcCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36644. zcCostSelfTotal, _ = decimal.NewFromFloat(zcCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36645. zcCostPartSelfTotal, _ = decimal.NewFromFloat(zcCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36646. zcSelfTotal, _ = decimal.NewFromFloat(zcSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36647. zcInscpTotal, _ = decimal.NewFromFloat(zcInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36648. }
  36649. if item.MedChrgitmType == "07" { //其他费
  36650. huliCostTotal, _ = decimal.NewFromFloat(huliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  36651. huliCostSelfTotal, _ = decimal.NewFromFloat(huliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  36652. huliCostPartSelfTotal, _ = decimal.NewFromFloat(huliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  36653. huliSelfTotal, _ = decimal.NewFromFloat(huliSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  36654. huliInscpTotal, _ = decimal.NewFromFloat(huliInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  36655. }
  36656. }
  36657. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  36658. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  36659. var user_name string
  36660. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  36661. if role.ID == 0 {
  36662. user_name = "管理员"
  36663. } else {
  36664. user_name = role.UserName
  36665. }
  36666. baseParams := models.BaseParams{
  36667. SecretKey: miConfig.SecretKey,
  36668. FixmedinsCode: miConfig.Code,
  36669. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  36670. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  36671. OrgName: miConfig.OrgName,
  36672. Doctor: user_name,
  36673. RequestUrl: miConfig.Url,
  36674. AccessKey: miConfig.AccessKey,
  36675. }
  36676. businessParams := models.BusinessParams{
  36677. PsnNo: order.PsnNo,
  36678. MdtrtId: order.MdtrtId,
  36679. SetlId: order.SetlId,
  36680. }
  36681. var res ResultEleven
  36682. var resah ResultElevenah
  36683. var resEleven10265 ResultEleven10265
  36684. if config.IsOpen == 1 {
  36685. if miConfig.MdtrtareaAdmvs == "421300" {
  36686. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36687. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36688. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36689. resp, requestErr := http.Get(api)
  36690. if requestErr != nil {
  36691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36692. return
  36693. }
  36694. body, ioErr := ioutil.ReadAll(resp.Body)
  36695. if ioErr != nil {
  36696. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36698. return
  36699. }
  36700. var respJSON map[string]interface{}
  36701. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36704. return
  36705. }
  36706. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36707. result, _ := json.Marshal(respJSON)
  36708. fmt.Println("log")
  36709. fmt.Println(string(result))
  36710. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36711. utils.ErrorLog("解析失败:%v", err)
  36712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36713. return
  36714. }
  36715. } else if miConfig.MdtrtareaAdmvs == "420200" {
  36716. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36717. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36718. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36719. resp, requestErr := http.Get(api)
  36720. if requestErr != nil {
  36721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36722. return
  36723. }
  36724. body, ioErr := ioutil.ReadAll(resp.Body)
  36725. if ioErr != nil {
  36726. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36728. return
  36729. }
  36730. var respJSON map[string]interface{}
  36731. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36732. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36734. return
  36735. }
  36736. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36737. result, _ := json.Marshal(respJSON)
  36738. fmt.Println("log")
  36739. fmt.Println(string(result))
  36740. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36741. utils.ErrorLog("解析失败:%v", err)
  36742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36743. return
  36744. }
  36745. } else if miConfig.MdtrtareaAdmvs == "420902" {
  36746. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36747. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36748. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  36749. resp, requestErr := http.Get(api)
  36750. if requestErr != nil {
  36751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36752. return
  36753. }
  36754. body, ioErr := ioutil.ReadAll(resp.Body)
  36755. if ioErr != nil {
  36756. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36758. return
  36759. }
  36760. var respJSON map[string]interface{}
  36761. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36762. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36764. return
  36765. }
  36766. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36767. result, _ := json.Marshal(respJSON)
  36768. fmt.Println("log")
  36769. fmt.Println(string(result))
  36770. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36771. utils.ErrorLog("解析失败:%v", err)
  36772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36773. return
  36774. }
  36775. } else if miConfig.MdtrtareaAdmvs == "421182" {
  36776. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36777. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36778. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  36779. resp, requestErr := http.Get(api)
  36780. if requestErr != nil {
  36781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36782. return
  36783. }
  36784. body, ioErr := ioutil.ReadAll(resp.Body)
  36785. if ioErr != nil {
  36786. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36788. return
  36789. }
  36790. var respJSON map[string]interface{}
  36791. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36792. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36794. return
  36795. }
  36796. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36797. result, _ := json.Marshal(respJSON)
  36798. fmt.Println("log")
  36799. fmt.Println(string(result))
  36800. if err := json.Unmarshal([]byte(result), &res); err != nil {
  36801. utils.ErrorLog("解析失败:%v", err)
  36802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36803. return
  36804. }
  36805. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  36806. var api string
  36807. if miConfig.MdtrtareaAdmvs == "320830" {
  36808. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36809. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36810. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  36811. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36812. } else if miConfig.MdtrtareaAdmvs == "320921" {
  36813. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36814. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36815. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  36816. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36817. } else {
  36818. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36819. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36820. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36821. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  36822. }
  36823. resp, requestErr := http.Get(api)
  36824. if requestErr != nil {
  36825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36826. return
  36827. }
  36828. body, ioErr := ioutil.ReadAll(resp.Body)
  36829. if ioErr != nil {
  36830. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36832. return
  36833. }
  36834. var respJSON map[string]interface{}
  36835. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36836. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36838. return
  36839. }
  36840. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36841. result, _ := json.Marshal(respJSON)
  36842. fmt.Println("log")
  36843. fmt.Println(string(result))
  36844. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  36845. utils.ErrorLog("解析失败:%v", err)
  36846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36847. return
  36848. }
  36849. res.InfRefmsgid = resEleven10265.InfRefmsgid
  36850. res.Output = resEleven10265.Output
  36851. res.ErrMsg = resEleven10265.ErrMsg
  36852. res.Cainfo = resEleven10265.Cainfo
  36853. res.WarnMsg = resEleven10265.WarnMsg
  36854. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  36855. res.Infcode = infocode
  36856. } else if miConfig.MdtrtareaAdmvs == "350500" {
  36857. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  36858. saveLog(result, requestLog, "5203", "结算单")
  36859. var dat map[string]interface{}
  36860. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36861. fmt.Println(dat)
  36862. } else {
  36863. fmt.Println(err)
  36864. }
  36865. userJSONBytes, _ := json.Marshal(dat)
  36866. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36867. utils.ErrorLog("解析失败:%v", err)
  36868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36869. return
  36870. }
  36871. } else if miConfig.MdtrtareaAdmvs == "360302" {
  36872. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36873. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  36874. saveLog(result, requestLog, "5203", "结算单")
  36875. var dat map[string]interface{}
  36876. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36877. fmt.Println(dat)
  36878. } else {
  36879. fmt.Println(err)
  36880. }
  36881. userJSONBytes, _ := json.Marshal(dat)
  36882. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36883. utils.ErrorLog("解析失败:%v", err)
  36884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36885. return
  36886. }
  36887. } else if miConfig.MdtrtareaAdmvs == "361025" {
  36888. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36889. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  36890. saveLog(result, requestLog, "5203", "结算单")
  36891. var dat map[string]interface{}
  36892. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36893. fmt.Println(dat)
  36894. } else {
  36895. fmt.Println(err)
  36896. }
  36897. userJSONBytes, _ := json.Marshal(dat)
  36898. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36899. utils.ErrorLog("解析失败:%v", err)
  36900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36901. return
  36902. }
  36903. } else if miConfig.MdtrtareaAdmvs == "360100" {
  36904. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  36905. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  36906. saveLog(result, requestLog, "5203", "结算单")
  36907. var dat map[string]interface{}
  36908. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  36909. fmt.Println(dat)
  36910. } else {
  36911. fmt.Println(err)
  36912. }
  36913. userJSONBytes, _ := json.Marshal(dat)
  36914. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  36915. utils.ErrorLog("解析失败:%v", err)
  36916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36917. return
  36918. }
  36919. } else if miConfig.MdtrtareaAdmvs == "341203" {
  36920. var api string
  36921. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  36922. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  36923. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  36924. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36925. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  36926. resp, requestErr := http.Get(api)
  36927. if requestErr != nil {
  36928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36929. return
  36930. }
  36931. body, ioErr := ioutil.ReadAll(resp.Body)
  36932. if ioErr != nil {
  36933. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  36934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36935. return
  36936. }
  36937. var respJSON map[string]interface{}
  36938. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  36939. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  36940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36941. return
  36942. }
  36943. status := respJSON["data"].(map[string]interface{})["status"].(string)
  36944. if status == "0" {
  36945. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  36946. c.ServeSuccessJSON(map[string]interface{}{
  36947. "failed_code": -10,
  36948. "msg": err_msg,
  36949. })
  36950. return
  36951. }
  36952. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  36953. result, _ := json.Marshal(respJSON)
  36954. fmt.Println("log")
  36955. fmt.Println(string(result))
  36956. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  36957. utils.ErrorLog("解析失败:%v", err)
  36958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36959. return
  36960. }
  36961. res.InfRefmsgid = resah.InfRefmsgid
  36962. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  36963. // 创建对应的Time类型
  36964. t := time.UnixMilli(timestamp)
  36965. // 格式化成指定的日期字符串
  36966. str := t.Format("2006-01-02 15:04:05")
  36967. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  36968. // 创建对应的Time类型
  36969. t3 := time.UnixMilli(timestamp2)
  36970. // 格式化成指定的日期字符串
  36971. str2 := t3.Format("2006-01-02 15:04:05")
  36972. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  36973. // 创建对应的Time类型
  36974. t4 := time.UnixMilli(timestamp3)
  36975. // 格式化成指定的日期字符串
  36976. str3 := t4.Format("2006-01-02 15:04:05")
  36977. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  36978. // 创建对应的Time类型
  36979. t5 := time.UnixMilli(timestamp4)
  36980. // 格式化成指定的日期字符串
  36981. str5 := t5.Format("2006-01-02 15:04:05")
  36982. res.Output.Setlinfo.Brdy = str2
  36983. res.Output.Setlinfo.SetlTime = str
  36984. res.Output.Setlinfo.Begndate = str3
  36985. res.Output.Setlinfo.Enddate = str5
  36986. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  36987. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  36988. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  36989. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  36990. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  36991. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  36992. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  36993. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  36994. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  36995. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  36996. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  36997. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  36998. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  36999. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  37000. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  37001. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  37002. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  37003. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  37004. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  37005. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  37006. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  37007. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  37008. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  37009. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  37010. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  37011. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  37012. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  37013. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  37014. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  37015. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  37016. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  37017. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  37018. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  37019. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  37020. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  37021. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  37022. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  37023. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  37024. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  37025. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  37026. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  37027. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  37028. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  37029. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  37030. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  37031. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  37032. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  37033. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  37034. //res.Output.Setldetail = resah.Output.Setldetail
  37035. res.ErrMsg = resah.ErrMsg
  37036. res.Cainfo = resah.Cainfo
  37037. res.WarnMsg = resah.WarnMsg
  37038. } else if miConfig.MdtrtareaAdmvs == "340699" {
  37039. var api string
  37040. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37041. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37042. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  37043. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37044. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  37045. resp, requestErr := http.Get(api)
  37046. if requestErr != nil {
  37047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37048. return
  37049. }
  37050. body, ioErr := ioutil.ReadAll(resp.Body)
  37051. if ioErr != nil {
  37052. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37054. return
  37055. }
  37056. var respJSON map[string]interface{}
  37057. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37058. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37060. return
  37061. }
  37062. status := respJSON["data"].(map[string]interface{})["status"].(string)
  37063. if status == "0" {
  37064. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  37065. c.ServeSuccessJSON(map[string]interface{}{
  37066. "failed_code": -10,
  37067. "msg": err_msg,
  37068. })
  37069. return
  37070. }
  37071. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37072. result, _ := json.Marshal(respJSON)
  37073. fmt.Println("log")
  37074. fmt.Println(string(result))
  37075. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  37076. utils.ErrorLog("解析失败:%v", err)
  37077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37078. return
  37079. }
  37080. res.InfRefmsgid = resah.InfRefmsgid
  37081. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  37082. // 创建对应的Time类型
  37083. t := time.UnixMilli(timestamp)
  37084. // 格式化成指定的日期字符串
  37085. str := t.Format("2006-01-02 15:04:05")
  37086. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  37087. // 创建对应的Time类型
  37088. t3 := time.UnixMilli(timestamp2)
  37089. // 格式化成指定的日期字符串
  37090. str2 := t3.Format("2006-01-02 15:04:05")
  37091. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  37092. // 创建对应的Time类型
  37093. t4 := time.UnixMilli(timestamp3)
  37094. // 格式化成指定的日期字符串
  37095. str3 := t4.Format("2006-01-02 15:04:05")
  37096. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  37097. // 创建对应的Time类型
  37098. t5 := time.UnixMilli(timestamp4)
  37099. // 格式化成指定的日期字符串
  37100. str5 := t5.Format("2006-01-02 15:04:05")
  37101. res.Output.Setlinfo.Brdy = str2
  37102. res.Output.Setlinfo.SetlTime = str
  37103. res.Output.Setlinfo.Begndate = str3
  37104. res.Output.Setlinfo.Enddate = str5
  37105. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  37106. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  37107. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  37108. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  37109. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  37110. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  37111. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  37112. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  37113. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  37114. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  37115. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  37116. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  37117. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  37118. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  37119. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  37120. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  37121. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  37122. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  37123. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  37124. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  37125. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  37126. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  37127. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  37128. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  37129. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  37130. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  37131. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  37132. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  37133. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  37134. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  37135. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  37136. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  37137. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  37138. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  37139. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  37140. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  37141. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  37142. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  37143. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  37144. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  37145. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  37146. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  37147. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  37148. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  37149. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  37150. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  37151. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  37152. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  37153. //res.Output.Setldetail = resah.Output.Setldetail
  37154. res.ErrMsg = resah.ErrMsg
  37155. res.Cainfo = resah.Cainfo
  37156. res.WarnMsg = resah.WarnMsg
  37157. } else if miConfig.MdtrtareaAdmvs == "430800" {
  37158. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  37159. saveLog(result, requestLog, "5203", "结算单")
  37160. var dat map[string]interface{}
  37161. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37162. fmt.Println(dat)
  37163. } else {
  37164. fmt.Println(err)
  37165. }
  37166. userJSONBytes, _ := json.Marshal(dat)
  37167. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37168. utils.ErrorLog("解析失败:%v", err)
  37169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37170. return
  37171. }
  37172. } else if miConfig.MdtrtareaAdmvs == "150499" {
  37173. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37174. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37175. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  37176. resp, requestErr := http.Get(api)
  37177. if requestErr != nil {
  37178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37179. return
  37180. }
  37181. body, ioErr := ioutil.ReadAll(resp.Body)
  37182. if ioErr != nil {
  37183. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37185. return
  37186. }
  37187. var respJSON map[string]interface{}
  37188. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37189. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37191. return
  37192. }
  37193. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37194. result, _ := json.Marshal(respJSON)
  37195. fmt.Println("log")
  37196. fmt.Println(string(result))
  37197. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  37198. utils.ErrorLog("解析失败:%v", err)
  37199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37200. return
  37201. }
  37202. res.InfRefmsgid = resEleven10265.InfRefmsgid
  37203. res.Output = resEleven10265.Output
  37204. res.ErrMsg = resEleven10265.ErrMsg
  37205. res.Cainfo = resEleven10265.Cainfo
  37206. res.WarnMsg = resEleven10265.WarnMsg
  37207. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  37208. res.Infcode = infocode
  37209. } else if miConfig.MdtrtareaAdmvs == "441799" {
  37210. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  37211. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  37212. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  37213. resp, requestErr := http.Get(api)
  37214. if requestErr != nil {
  37215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37216. return
  37217. }
  37218. body, ioErr := ioutil.ReadAll(resp.Body)
  37219. if ioErr != nil {
  37220. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37222. return
  37223. }
  37224. var respJSON map[string]interface{}
  37225. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37226. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37228. return
  37229. }
  37230. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37231. result, _ := json.Marshal(respJSON)
  37232. if err := json.Unmarshal([]byte(result), &res); err != nil {
  37233. utils.ErrorLog("解析失败:%v", err)
  37234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37235. return
  37236. }
  37237. } else if miConfig.MdtrtareaAdmvs == "450721" {
  37238. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  37239. //return
  37240. } else {
  37241. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  37242. if len(his.InsuplcAdmdvs) == 0 {
  37243. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  37244. } else {
  37245. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  37246. }
  37247. result := service.Gdyb5203(baseParams, businessParams)
  37248. //service.Gdyb5204(baseParams, businessParams)
  37249. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  37250. var dat map[string]interface{}
  37251. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37252. fmt.Println(dat)
  37253. } else {
  37254. fmt.Println(err)
  37255. }
  37256. userJSONBytes, _ := json.Marshal(dat)
  37257. if miConfig.Code == "H15049901371" {
  37258. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  37259. utils.ErrorLog("解析失败:%v", err)
  37260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37261. return
  37262. }
  37263. res.InfRefmsgid = resEleven10265.InfRefmsgid
  37264. res.Output = resEleven10265.Output
  37265. res.ErrMsg = resEleven10265.ErrMsg
  37266. res.Cainfo = resEleven10265.Cainfo
  37267. res.WarnMsg = resEleven10265.WarnMsg
  37268. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  37269. res.Infcode = infocode
  37270. } else {
  37271. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37272. utils.ErrorLog("解析失败:%v", err)
  37273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37274. return
  37275. }
  37276. }
  37277. }
  37278. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37279. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  37280. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  37281. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  37282. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  37283. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37284. var doctor_name string
  37285. if roles.ID == 0 {
  37286. doctor_name = "管理员"
  37287. } else {
  37288. doctor_name = roles.UserName
  37289. }
  37290. yiliao_leibie := ""
  37291. switch order.MedType {
  37292. case "11":
  37293. yiliao_leibie = "普通门诊"
  37294. break
  37295. case "12":
  37296. yiliao_leibie = "门诊挂号"
  37297. break
  37298. case "13":
  37299. yiliao_leibie = "急诊"
  37300. break
  37301. case "14":
  37302. yiliao_leibie = "门诊特殊病"
  37303. break
  37304. case "15":
  37305. yiliao_leibie = "门诊统筹"
  37306. break
  37307. case "16":
  37308. yiliao_leibie = "门诊慢性病"
  37309. break
  37310. case "21":
  37311. yiliao_leibie = "普通住院"
  37312. break
  37313. }
  37314. //var rf []CustomFundPay
  37315. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  37316. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  37317. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  37318. if res.Infcode == 0 {
  37319. 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 {
  37320. c.ServeSuccessJSON(map[string]interface{}{
  37321. "diagnosis": name,
  37322. "order_infos": orderInfos,
  37323. "number": order.MdtrtId,
  37324. "date": order.SettleAccountsDate,
  37325. "charge_admin": charge_admin,
  37326. "printor_admin": printor_admin,
  37327. "info": res.Output.Setlinfo,
  37328. "order": order,
  37329. "bedCostTotal": bedCostTotal,
  37330. "bedCostSelfTotal": bedCostSelfTotal,
  37331. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  37332. "bedSelfTotal": bedSelfTotal,
  37333. "bedInscpTotal": bedInscpTotal,
  37334. "operationCostTotal": operationCostTotal,
  37335. "operationCostSelfTotal": operationCostSelfTotal,
  37336. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  37337. "operationSelfTotal": operationSelfTotal,
  37338. "operationInscpTotal": operationInscpTotal,
  37339. "otherCostTotal": otherCostTotal,
  37340. "otherCostSelfTotal": otherCostSelfTotal,
  37341. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  37342. "otherSelfTotal": otherSelfTotal,
  37343. "otherInscpTotal": otherInscpTotal,
  37344. "materialCostTotal": materialCostTotal,
  37345. "materialCostSelfTotal": materialCostSelfTotal,
  37346. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  37347. "materialSelfTotal": materialSelfTotal,
  37348. "materialInscpTotal": materialInscpTotal,
  37349. "westernMedicineCostTotal": westernMedicineCostTotal,
  37350. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  37351. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  37352. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  37353. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  37354. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  37355. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  37356. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  37357. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  37358. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  37359. "checkCostTotal": checkCostTotal,
  37360. "checkCostSelfTotal": checkCostSelfTotal,
  37361. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  37362. "checkSelfTotal": checkSelfTotal,
  37363. "checkInscpTotal": checkInscpTotal,
  37364. "laboratoryCostTotal": laboratoryCostTotal,
  37365. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  37366. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  37367. "laboratorySelfTotal": laboratorySelfTotal,
  37368. "laboratoryInscpTotal": laboratoryInscpTotal,
  37369. "treatCostTotal": treatCostTotal,
  37370. "treatCostSelfTotal": treatCostSelfTotal,
  37371. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  37372. "treatSelfTotal": treatSelfTotal,
  37373. "treatInscpTotal": treatInscpTotal,
  37374. "doctor_info": doctor_info,
  37375. "doctor_code": adminRole_two.DoctorCode,
  37376. "doctor_name": doctor_name,
  37377. "health_card_no": order.PsnNo,
  37378. "department": departments.Name,
  37379. "yiliao_leibie": yiliao_leibie,
  37380. "after_money": order.AccountPrice,
  37381. "patient": patient,
  37382. "org_name": miConfig.OrgName,
  37383. "org_code": miConfig.Code,
  37384. "order_number": order.Number,
  37385. "his_hospital": his_hospital,
  37386. "his": his,
  37387. "dia_config": dia_config,
  37388. "psn_cash_pay": order.PsnCashPay,
  37389. "zcCostTotal": zcCostTotal,
  37390. "zcCostSelfTotal": zcCostSelfTotal,
  37391. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  37392. "zcSelfTotal": zcSelfTotal,
  37393. "zcInscpTotal": zcInscpTotal,
  37394. "huliCostTotal": huliCostTotal,
  37395. "huliCostSelfTotal": huliCostSelfTotal,
  37396. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  37397. "huliSelfTotal": huliSelfTotal,
  37398. "huliInscpTotal": huliInscpTotal,
  37399. //"funds": rf,
  37400. //"check_order_info": cus_slice,
  37401. })
  37402. } else {
  37403. c.ServeSuccessJSON(map[string]interface{}{
  37404. "diagnosis": name,
  37405. "order_infos": orderInfos,
  37406. "number": order.MdtrtId,
  37407. "date": order.SettleAccountsDate,
  37408. "charge_admin": charge_admin,
  37409. "printor_admin": printor_admin,
  37410. "info": order,
  37411. "order": order,
  37412. "bedCostTotal": bedCostTotal,
  37413. "bedCostSelfTotal": bedCostSelfTotal,
  37414. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  37415. "bedSelfTotal": bedSelfTotal,
  37416. "bedInscpTotal": bedInscpTotal,
  37417. "operationCostTotal": operationCostTotal,
  37418. "operationCostSelfTotal": operationCostSelfTotal,
  37419. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  37420. "operationSelfTotal": operationSelfTotal,
  37421. "operationInscpTotal": operationInscpTotal,
  37422. "otherCostTotal": otherCostTotal,
  37423. "otherCostSelfTotal": otherCostSelfTotal,
  37424. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  37425. "otherSelfTotal": otherSelfTotal,
  37426. "otherInscpTotal": otherInscpTotal,
  37427. "materialCostTotal": materialCostTotal,
  37428. "materialCostSelfTotal": materialCostSelfTotal,
  37429. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  37430. "materialSelfTotal": materialSelfTotal,
  37431. "materialInscpTotal": materialInscpTotal,
  37432. "westernMedicineCostTotal": westernMedicineCostTotal,
  37433. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  37434. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  37435. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  37436. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  37437. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  37438. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  37439. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  37440. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  37441. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  37442. "checkCostTotal": checkCostTotal,
  37443. "checkCostSelfTotal": checkCostSelfTotal,
  37444. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  37445. "checkSelfTotal": checkSelfTotal,
  37446. "checkInscpTotal": checkInscpTotal,
  37447. "laboratoryCostTotal": laboratoryCostTotal,
  37448. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  37449. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  37450. "laboratorySelfTotal": laboratorySelfTotal,
  37451. "laboratoryInscpTotal": laboratoryInscpTotal,
  37452. "treatCostTotal": treatCostTotal,
  37453. "treatCostSelfTotal": treatCostSelfTotal,
  37454. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  37455. "treatSelfTotal": treatSelfTotal,
  37456. "treatInscpTotal": treatInscpTotal,
  37457. "doctor_info": doctor_info,
  37458. "doctor_code": adminRole_two.DoctorCode,
  37459. "doctor_name": doctor_name,
  37460. "health_card_no": order.PsnNo,
  37461. "department": departments.Name,
  37462. "yiliao_leibie": yiliao_leibie,
  37463. "after_money": order.AccountPrice,
  37464. "patient": patient,
  37465. "org_name": miConfig.OrgName,
  37466. "org_code": miConfig.Code,
  37467. "order_number": order.Number,
  37468. "his_hospital": his_hospital,
  37469. "his": his,
  37470. "dia_config": dia_config,
  37471. "psn_cash_pay": order.PsnCashPay,
  37472. "zcCostTotal": zcCostTotal,
  37473. "zcCostSelfTotal": zcCostSelfTotal,
  37474. "zcCostPartSelfTotal": zcCostPartSelfTotal,
  37475. "zcSelfTotal": zcSelfTotal,
  37476. "zcInscpTotal": zcInscpTotal,
  37477. "huliCostTotal": huliCostTotal,
  37478. "huliCostSelfTotal": huliCostSelfTotal,
  37479. "huliCostPartSelfTotal": huliCostPartSelfTotal,
  37480. "huliSelfTotal": huliSelfTotal,
  37481. "huliInscpTotal": huliInscpTotal,
  37482. //"funds": rf,
  37483. //"check_order_info": cus_slice,
  37484. })
  37485. }
  37486. }
  37487. }
  37488. }
  37489. //func (c *HisApiController) CheckTreatment() {
  37490. // patient_id, _ := c.GetInt64("patient_id")
  37491. // id_card_no := c.GetString("id_card_no")
  37492. // insutype := c.GetString("insutype")
  37493. // med_type := c.GetString("med_type")
  37494. // admin_user_id, _ := c.GetInt64("admin_user_id")
  37495. //
  37496. // adminUser := c.GetAdminUserInfo()
  37497. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  37498. //
  37499. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37500. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37501. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37502. //
  37503. // if miConfig.MdtrtareaAdmvs == "421300" {
  37504. // var res ResultTwo
  37505. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  37506. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  37507. // "&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)
  37508. // resp, requestErr := http.Get(api)
  37509. // if requestErr != nil {
  37510. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37511. // return
  37512. // }
  37513. //
  37514. // body, ioErr := ioutil.ReadAll(resp.Body)
  37515. // if ioErr != nil {
  37516. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37517. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37518. // return
  37519. // }
  37520. // var respJSON map[string]interface{}
  37521. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37522. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37523. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37524. // return
  37525. // }
  37526. //
  37527. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37528. // result, _ := json.Marshal(respJSON)
  37529. //
  37530. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  37531. // utils.ErrorLog("解析失败:%v", err)
  37532. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37533. // return
  37534. // }
  37535. //
  37536. // if res.Infcode == 0 {
  37537. //
  37538. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  37539. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  37540. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  37541. // resp, requestErr := http.Get(api)
  37542. // if requestErr != nil {
  37543. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37544. // return
  37545. // }
  37546. //
  37547. // body, ioErr := ioutil.ReadAll(resp.Body)
  37548. // if ioErr != nil {
  37549. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37550. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37551. // return
  37552. // }
  37553. // var respJSON map[string]interface{}
  37554. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37555. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37556. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37557. // return
  37558. // }
  37559. // var res Result2001
  37560. //
  37561. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37562. // result2, _ := json.Marshal(respJSON)
  37563. //
  37564. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  37565. // utils.ErrorLog("解析失败:%v", err)
  37566. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37567. // return
  37568. // }
  37569. //
  37570. // if res.Infcode == 0 {
  37571. // c.ServeSuccessJSON(map[string]interface{}{
  37572. // "msg": res.Output.Trtinfo,
  37573. // })
  37574. // }
  37575. //
  37576. // } else {
  37577. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  37578. // return
  37579. // }
  37580. //
  37581. // } else {
  37582. //
  37583. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  37584. // var dat map[string]interface{}
  37585. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37586. // fmt.Println(dat)
  37587. // } else {
  37588. // fmt.Println(err)
  37589. // }
  37590. // userJSONBytes, _ := json.Marshal(dat)
  37591. // var res ResultTwo
  37592. // var res10265 ResultTwo10265
  37593. // if miConfig.Code == "H15049901371" {
  37594. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  37595. // utils.ErrorLog("解析失败:%v", err)
  37596. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37597. // return
  37598. // }
  37599. // res.ErrMsg = res10265.ErrMsg
  37600. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37601. // res.Infcode = infocode
  37602. // res.Output = res10265.Output
  37603. // res.InfRefmsgid = res10265.InfRefmsgid
  37604. // } else {
  37605. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37606. // utils.ErrorLog("解析失败:%v", err)
  37607. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37608. // return
  37609. // }
  37610. // }
  37611. //
  37612. // var user_name string
  37613. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  37614. // if role.ID == 0 {
  37615. // user_name = "xxx"
  37616. // } else {
  37617. // user_name = role.UserName
  37618. // }
  37619. //
  37620. // baseParams := models.BaseParams{
  37621. // SecretKey: miConfig.SecretKey,
  37622. // FixmedinsCode: miConfig.Code,
  37623. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  37624. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  37625. // OrgName: miConfig.OrgName,
  37626. // Doctor: user_name,
  37627. // }
  37628. //
  37629. // if config.IsOpen == 1 {
  37630. // if miConfig.Code == "H15049901371" {
  37631. // if med_type == "14" {
  37632. // if insutype == "390" {
  37633. // med_type = "9933"
  37634. // } else if insutype == "310" {
  37635. // med_type = "990502"
  37636. // }
  37637. // } else if med_type == "11" {
  37638. // med_type = "11"
  37639. // }
  37640. // }
  37641. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  37642. // var dat map[string]interface{}
  37643. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37644. // fmt.Println(dat)
  37645. // } else {
  37646. // fmt.Println(err)
  37647. // }
  37648. // var res Result2001
  37649. // var res10265 Result2001Org10265
  37650. // if miConfig.Code == "H15049901371" {
  37651. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  37652. // utils.ErrorLog("解析失败:%v", err)
  37653. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37654. // return
  37655. // }
  37656. // res.ErrMsg = res10265.ErrMsg
  37657. // res.Output = res10265.Output
  37658. // res.InfRefmsgid = res10265.InfRefmsgid
  37659. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  37660. // res.Infcode = infocode
  37661. // } else {
  37662. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  37663. // utils.ErrorLog("解析失败:%v", err)
  37664. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37665. // return
  37666. // }
  37667. // }
  37668. // if res.Infcode == 0 {
  37669. // c.ServeSuccessJSON(map[string]interface{}{
  37670. // "msg": res.Output.Trtinfo,
  37671. // })
  37672. // }
  37673. // }
  37674. // }
  37675. //}
  37676. //func (c *HisApiController) PutRecord() {
  37677. // id, _ := c.GetInt64("id")
  37678. // record_time := c.GetString("record_time")
  37679. // timeLayout := "2006-01-02"
  37680. // loc, _ := time.LoadLocation("Local")
  37681. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  37682. // if err != nil {
  37683. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  37684. // return
  37685. // }
  37686. // recordDateTime := theTime.Unix()
  37687. //
  37688. // adminInfo := c.GetAdminUserInfo()
  37689. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  37690. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  37691. //
  37692. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  37693. //
  37694. // fmt.Println(miConfig.SecretKey)
  37695. //
  37696. // if patient == nil {
  37697. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  37698. // return
  37699. // }
  37700. // if len(patient.IdCardNo) == 0 {
  37701. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  37702. // return
  37703. // }
  37704. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  37705. // if config.IsOpen == 1 {
  37706. // 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
  37707. // resp, requestErr := http.Get(api)
  37708. // if requestErr != nil {
  37709. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37710. // return
  37711. // }
  37712. // defer resp.Body.Close()
  37713. // body, ioErr := ioutil.ReadAll(resp.Body)
  37714. // if ioErr != nil {
  37715. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  37716. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37717. // return
  37718. // }
  37719. // var respJSON map[string]interface{}
  37720. //
  37721. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  37722. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37723. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37724. // return
  37725. // }
  37726. //
  37727. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37728. // userJSONBytes, _ := json.Marshal(userJSON)
  37729. // var res ResultTwo
  37730. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37731. // utils.ErrorLog("解析失败:%v", err)
  37732. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37733. // return
  37734. // }
  37735. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  37736. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  37737. // infoStr := string(Iinfos)
  37738. // idetinfoStr := string(Idetinfos)
  37739. //
  37740. // if res.Infcode == 0 {
  37741. // his := models.VMHisPatient{
  37742. // Status: 1,
  37743. // Ctime: time.Now().Unix(),
  37744. // Mtime: time.Now().Unix(),
  37745. // PsnNo: res.Output.Baseinfo.PsnNo,
  37746. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  37747. // Certno: res.Output.Baseinfo.Certno,
  37748. // PsnName: res.Output.Baseinfo.PsnName,
  37749. // Gend: res.Output.Baseinfo.Gend,
  37750. // Naty: res.Output.Baseinfo.Naty,
  37751. // Brdy: res.Output.Baseinfo.Brdy,
  37752. // Age: res.Output.Baseinfo.Age,
  37753. // Iinfo: infoStr,
  37754. // Idetinfo: idetinfoStr,
  37755. // PatientId: patient.ID,
  37756. // RecordDate: theTime.Unix(),
  37757. // UserOrgId: adminInfo.CurrentOrgId,
  37758. // AdminUserId: adminInfo.AdminUser.Id,
  37759. // IsReturn: 1,
  37760. // }
  37761. //
  37762. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  37763. // //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")
  37764. // //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")
  37765. //
  37766. // //var dat map[string]interface{}
  37767. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37768. // // fmt.Println(dat)
  37769. // //} else {
  37770. // // fmt.Println(err)
  37771. // //}
  37772. //
  37773. // var dat2 map[string]interface{}
  37774. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  37775. // fmt.Println(dat2)
  37776. // } else {
  37777. // fmt.Println(err)
  37778. // }
  37779. //
  37780. // } else {
  37781. // adminUser := c.GetAdminUserInfo()
  37782. // errlog := &models.HisOrderError{
  37783. // UserOrgId: adminUser.CurrentOrgId,
  37784. // Ctime: time.Now().Unix(),
  37785. // Mtime: time.Now().Unix(),
  37786. // ErrMsg: res.ErrMsg,
  37787. // Status: 1,
  37788. // PatientId: id,
  37789. // RecordTime: recordDateTime,
  37790. // Stage: 1,
  37791. // }
  37792. // service.CreateErrMsgLog(errlog)
  37793. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  37794. // return
  37795. // }
  37796. // }
  37797. //
  37798. //}
  37799. //func (c *HisApiController) GetUploadDiag() {
  37800. // id, _ := c.GetInt64("id")
  37801. // record_time := c.GetString("record_time")
  37802. //
  37803. // diagnosis_id, _ := c.GetInt64("diagnosis")
  37804. // sick_type, _ := c.GetInt64("sick_type")
  37805. // reg_type, _ := c.GetInt64("reg_type")
  37806. //
  37807. // timeLayout := "2006-01-02"
  37808. // loc, _ := time.LoadLocation("Local")
  37809. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  37810. // if err != nil {
  37811. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  37812. // return
  37813. // }
  37814. //
  37815. // var patientPrescription models.HisPrescriptionInfo
  37816. // recordDateTime := theTime.Unix()
  37817. // adminInfo := c.GetAdminUserInfo()
  37818. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  37819. //
  37820. // if patientPrescription.ID == 0 {
  37821. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  37822. // }
  37823. //
  37824. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  37825. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  37826. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  37827. // sickConfig, _ := service.FindSickById(sick_type)
  37828. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  37829. //
  37830. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  37831. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  37832. // "&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 +
  37833. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  37834. // resp2, requestErr2 := http.Get(api2)
  37835. // if requestErr2 != nil {
  37836. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37837. // return
  37838. // }
  37839. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  37840. // if ioErr2 != nil {
  37841. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  37842. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37843. // return
  37844. // }
  37845. // var respJSON2 map[string]interface{}
  37846. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  37847. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  37848. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37849. // return
  37850. // }
  37851. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  37852. // userJSONBytes2, _ := json.Marshal(respJSON2)
  37853. //
  37854. // var res2 ResultSix
  37855. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  37856. // utils.ErrorLog("解析失败:%v", err)
  37857. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37858. // return
  37859. // }
  37860. // if res2.Infcode != 0 {
  37861. // adminUser := c.GetAdminUserInfo()
  37862. // errlog := &models.HisOrderError{
  37863. // UserOrgId: adminUser.CurrentOrgId,
  37864. // Ctime: time.Now().Unix(),
  37865. // Mtime: time.Now().Unix(),
  37866. // ErrMsg: res2.ErrMsg,
  37867. // Status: 1,
  37868. // PatientId: id,
  37869. // RecordTime: recordDateTime,
  37870. // Stage: 3,
  37871. // }
  37872. // service.CreateErrMsgLog(errlog)
  37873. //
  37874. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  37875. // return
  37876. // }
  37877. //
  37878. // c.ServeSuccessJSON(map[string]interface{}{
  37879. // "msg": "上传成功",
  37880. // })
  37881. //
  37882. //}
  37883. type QueryResult struct {
  37884. ID int64
  37885. Name string
  37886. Code string
  37887. List_type_code string
  37888. }
  37889. func (c *HisApiController) GetCheckCode() {
  37890. ids_str := c.GetString("ids")
  37891. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  37892. ids_arr := strings.Split(ids_str, ",")
  37893. var queryResult []QueryResult
  37894. ids := make([]int64, 0)
  37895. for _, item := range ids_arr {
  37896. id, _ := strconv.ParseInt(item, 10, 64)
  37897. ids = append(ids, id)
  37898. }
  37899. if record_type == 1 {
  37900. drugs, _ := service.GetBatchDrugList(ids)
  37901. for _, item := range drugs {
  37902. result := QueryResult{
  37903. ID: item.ID,
  37904. Name: item.DrugName,
  37905. Code: item.MedicalInsuranceNumber,
  37906. List_type_code: "101",
  37907. }
  37908. queryResult = append(queryResult, result)
  37909. }
  37910. } else if record_type == 2 {
  37911. goods, _ := service.GetBatchGoodInformationList(ids)
  37912. fmt.Println(goods)
  37913. for _, item := range goods {
  37914. result := QueryResult{
  37915. ID: item.ID,
  37916. Name: item.GoodName,
  37917. Code: item.SocialSecurityDirectoryCode,
  37918. List_type_code: "301",
  37919. }
  37920. queryResult = append(queryResult, result)
  37921. }
  37922. } else if record_type == 3 {
  37923. projects, _ := service.GetBathchMyPorjecgList(ids)
  37924. for _, item := range projects {
  37925. result := QueryResult{
  37926. ID: item.ID,
  37927. Name: item.ProjectName,
  37928. Code: item.MedicalCode,
  37929. List_type_code: "201",
  37930. }
  37931. queryResult = append(queryResult, result)
  37932. }
  37933. }
  37934. admin_user_id, _ := c.GetInt64("admin_user_id")
  37935. adminUser := c.GetAdminUserInfo()
  37936. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  37937. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  37938. var user_name string
  37939. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  37940. if role.ID == 0 {
  37941. user_name = "管理员"
  37942. } else {
  37943. user_name = role.UserName
  37944. }
  37945. baseParams := models.BaseParams{
  37946. SecretKey: miConfig.SecretKey,
  37947. FixmedinsCode: miConfig.Code,
  37948. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  37949. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  37950. OrgName: miConfig.OrgName,
  37951. Doctor: user_name,
  37952. }
  37953. var result string
  37954. if miConfig.MdtrtareaAdmvs == "430800" {
  37955. for _, item := range queryResult {
  37956. if record_type == 1 {
  37957. 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)
  37958. } else if record_type == 2 {
  37959. fmt.Println(item.Code)
  37960. 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)
  37961. } else if record_type == 3 {
  37962. 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)
  37963. }
  37964. var dat map[string]interface{}
  37965. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  37966. fmt.Println(dat)
  37967. } else {
  37968. fmt.Println(err)
  37969. }
  37970. userJSONBytes, _ := json.Marshal(dat)
  37971. var res ResultSix
  37972. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  37973. utils.ErrorLog("解析失败:%v", err)
  37974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  37975. return
  37976. }
  37977. if res.Infcode == 0 {
  37978. if record_type == 1 {
  37979. service.UpdateBaseDrugById(item.ID)
  37980. } else if record_type == 2 {
  37981. service.UpdateGoodInformaitonByDetail(item.ID)
  37982. } else if record_type == 3 {
  37983. service.UpdateProjectById(item.ID)
  37984. }
  37985. c.ServeSuccessJSON(map[string]interface{}{
  37986. "failed_code": 0,
  37987. "msg": "目录对照成功",
  37988. })
  37989. } else {
  37990. c.ServeSuccessJSON(map[string]interface{}{
  37991. "failed_code": -10,
  37992. "msg": res.ErrMsg,
  37993. })
  37994. }
  37995. }
  37996. } else {
  37997. for _, item := range queryResult {
  37998. var result string
  37999. if record_type == 1 {
  38000. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  38001. } else if record_type == 2 {
  38002. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  38003. } else if record_type == 3 {
  38004. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  38005. }
  38006. var dat map[string]interface{}
  38007. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38008. fmt.Println(dat)
  38009. } else {
  38010. fmt.Println(err)
  38011. }
  38012. userJSONBytes, _ := json.Marshal(dat)
  38013. var res ResultSix
  38014. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38015. utils.ErrorLog("解析失败:%v", err)
  38016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38017. return
  38018. }
  38019. if res.Infcode == 0 {
  38020. if record_type == 1 {
  38021. service.UpdateBaseDrugById(item.ID)
  38022. } else if record_type == 2 {
  38023. service.UpdateGoodInformaitonByDetail(item.ID)
  38024. } else if record_type == 3 {
  38025. service.UpdateProjectById(item.ID)
  38026. }
  38027. c.ServeSuccessJSON(map[string]interface{}{
  38028. "failed_code": 0,
  38029. "msg": "目录对照成功",
  38030. })
  38031. } else {
  38032. c.ServeSuccessJSON(map[string]interface{}{
  38033. "failed_code": -10,
  38034. "msg": res.ErrMsg,
  38035. })
  38036. }
  38037. }
  38038. }
  38039. }
  38040. func (c *HisApiController) UnCheckCode() {
  38041. ids_str := c.GetString("ids")
  38042. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  38043. admin_user_id, _ := c.GetInt64("admin_user_id")
  38044. ids_arr := strings.Split(ids_str, ",")
  38045. var queryResult []QueryResult
  38046. ids := make([]int64, 0)
  38047. for _, item := range ids_arr {
  38048. id, _ := strconv.ParseInt(item, 10, 64)
  38049. ids = append(ids, id)
  38050. }
  38051. if record_type == 1 {
  38052. drugs, _ := service.GetBatchDrugList(ids)
  38053. for _, item := range drugs {
  38054. result := QueryResult{
  38055. ID: item.ID,
  38056. Name: item.DrugName,
  38057. Code: item.MedicalInsuranceNumber,
  38058. List_type_code: "101",
  38059. }
  38060. queryResult = append(queryResult, result)
  38061. }
  38062. } else if record_type == 2 {
  38063. goods, _ := service.GetBatchGoodInformationList(ids)
  38064. for _, item := range goods {
  38065. result := QueryResult{
  38066. ID: item.ID,
  38067. Name: item.GoodName,
  38068. Code: item.SocialSecurityDirectoryCode,
  38069. List_type_code: "301",
  38070. }
  38071. queryResult = append(queryResult, result)
  38072. }
  38073. } else if record_type == 3 {
  38074. projects, _ := service.GetBathchMyPorjecgList(ids)
  38075. for _, item := range projects {
  38076. result := QueryResult{
  38077. ID: item.ID,
  38078. Name: item.ProjectName,
  38079. Code: item.MedicalCode,
  38080. List_type_code: "201",
  38081. }
  38082. queryResult = append(queryResult, result)
  38083. }
  38084. }
  38085. adminUser := c.GetAdminUserInfo()
  38086. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38087. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38088. var user_name string
  38089. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38090. if role.ID == 0 {
  38091. user_name = "xxx"
  38092. } else {
  38093. user_name = role.UserName
  38094. }
  38095. baseParams := &models.BaseParams{
  38096. SecretKey: miConfig.SecretKey,
  38097. FixmedinsCode: miConfig.Code,
  38098. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  38099. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  38100. OrgName: miConfig.OrgName,
  38101. Doctor: user_name,
  38102. }
  38103. if config.IsOpen == 1 {
  38104. if miConfig.MdtrtareaAdmvs == "430800" {
  38105. for _, item := range queryResult {
  38106. var result string
  38107. if record_type == 1 {
  38108. 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)
  38109. } else if record_type == 2 {
  38110. fmt.Println(item.Code)
  38111. 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)
  38112. } else if record_type == 3 {
  38113. 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)
  38114. }
  38115. var dat map[string]interface{}
  38116. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38117. fmt.Println(dat)
  38118. } else {
  38119. fmt.Println(err)
  38120. }
  38121. userJSONBytes, _ := json.Marshal(dat)
  38122. var res ResultSix
  38123. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38124. utils.ErrorLog("解析失败:%v", err)
  38125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38126. return
  38127. }
  38128. if res.Infcode == 0 {
  38129. if record_type == 1 {
  38130. service.UpdateBaseDrugById(item.ID)
  38131. } else if record_type == 2 {
  38132. service.UpdateGoodInformaitonByDetail(item.ID)
  38133. } else if record_type == 3 {
  38134. service.UpdateProjectById(item.ID)
  38135. }
  38136. c.ServeSuccessJSON(map[string]interface{}{
  38137. "failed_code": 0,
  38138. "msg": "目录对照成功",
  38139. })
  38140. } else {
  38141. c.ServeSuccessJSON(map[string]interface{}{
  38142. "failed_code": -10,
  38143. "msg": res.ErrMsg,
  38144. })
  38145. }
  38146. }
  38147. } else {
  38148. for _, item := range queryResult {
  38149. var result string
  38150. if record_type == 1 {
  38151. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  38152. } else if record_type == 2 {
  38153. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  38154. } else if record_type == 3 {
  38155. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  38156. }
  38157. var dat2 map[string]interface{}
  38158. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  38159. fmt.Println(dat2)
  38160. } else {
  38161. fmt.Println(err)
  38162. }
  38163. userJSONBytes, _ := json.Marshal(dat2)
  38164. var res ResultSix
  38165. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38166. utils.ErrorLog("解析失败:%v", err)
  38167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38168. return
  38169. }
  38170. if res.Infcode == 0 {
  38171. if record_type == 1 {
  38172. service.UpdateDrugByIdDetail(item.ID)
  38173. } else if record_type == 2 {
  38174. service.UpdateGoodInfoById(item.ID)
  38175. } else if record_type == 3 {
  38176. service.UpdateMyProjectById(item.ID)
  38177. }
  38178. c.ServeSuccessJSON(map[string]interface{}{
  38179. "failed_code": 0,
  38180. "msg": "撤销目录对照成功",
  38181. })
  38182. } else {
  38183. c.ServeSuccessJSON(map[string]interface{}{
  38184. "failed_code": -10,
  38185. "msg": res.ErrMsg,
  38186. })
  38187. }
  38188. }
  38189. }
  38190. }
  38191. }
  38192. func (c *HisApiController) GetPatientInfo() {
  38193. id_card_no := c.GetString("id_card_no")
  38194. admin_user_id, _ := c.GetInt64("admin_user_id")
  38195. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  38196. if patient.ID == 0 {
  38197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  38198. return
  38199. }
  38200. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  38201. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  38202. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  38203. var res ResultTwo
  38204. var res10265 ResultTwo10265
  38205. if config.IsOpen == 1 {
  38206. if miConfig.MdtrtareaAdmvs == "150499" {
  38207. //请求内网数据
  38208. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  38209. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  38210. "&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
  38211. resp, requestErr := http.Get(api)
  38212. if requestErr != nil {
  38213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38214. return
  38215. }
  38216. body, ioErr := ioutil.ReadAll(resp.Body)
  38217. if ioErr != nil {
  38218. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38220. return
  38221. }
  38222. var respJSON map[string]interface{}
  38223. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38224. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38226. return
  38227. }
  38228. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38229. result_byte, _ := json.Marshal(respJSON)
  38230. result := string(result_byte)
  38231. var dat map[string]interface{}
  38232. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38233. fmt.Println(dat)
  38234. } else {
  38235. fmt.Println(err)
  38236. }
  38237. userJSONBytes, _ := json.Marshal(dat)
  38238. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  38239. utils.ErrorLog("解析失败:%v", err)
  38240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38241. return
  38242. }
  38243. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38244. res.Infcode = Infcode
  38245. res.ErrMsg = res10265.ErrMsg
  38246. res.Output = res10265.Output
  38247. res.InfRefmsgid = res10265.InfRefmsgid
  38248. res.RespondTime = res10265.RespondTime
  38249. res.WarnInfo = res10265.WarnInfo
  38250. } else {
  38251. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  38252. var dat map[string]interface{}
  38253. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38254. fmt.Println(dat)
  38255. } else {
  38256. fmt.Println(err)
  38257. }
  38258. userJSONBytes, _ := json.Marshal(dat)
  38259. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38260. utils.ErrorLog("解析失败:%v", err)
  38261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38262. return
  38263. }
  38264. }
  38265. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38266. // utils.ErrorLog("解析失败:%v", err)
  38267. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38268. // return
  38269. //}
  38270. for index, item := range res.Output.Iinfo {
  38271. if item.PsnInsuStas == "2" {
  38272. fmt.Println("--------")
  38273. res.Output.Iinfo[index].Insutype = "300"
  38274. res.Output.Iinfo[index].PsnInsuStas = "1"
  38275. }
  38276. }
  38277. fmt.Println(res.Output.Iinfo)
  38278. if res.Infcode != 0 {
  38279. c.ServeSuccessJSON(map[string]interface{}{
  38280. "failed_code": -10,
  38281. "msg": res.ErrMsg,
  38282. })
  38283. } else {
  38284. c.ServeSuccessJSON(map[string]interface{}{
  38285. "failed_code": 0,
  38286. "info": res,
  38287. })
  38288. }
  38289. }
  38290. }
  38291. func (c *HisApiController) PsnPutOnRecord() {
  38292. record_type, _ := c.GetInt64("type")
  38293. patient_id, _ := c.GetInt64("patient_id")
  38294. admin_user_id, _ := c.GetInt64("admin_user_id")
  38295. start_time := c.GetString("start_time")
  38296. end_time := c.GetString("end_time")
  38297. adminUser := c.GetAdminUserInfo()
  38298. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38299. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38300. var patients []*models.Patients
  38301. if record_type == 1 { //全部备案
  38302. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  38303. patients = append(patients, patient...)
  38304. } else { //单个备案
  38305. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  38306. patients = append(patients, patient)
  38307. }
  38308. var user_name string
  38309. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38310. if role.ID == 0 {
  38311. user_name = "xxx"
  38312. } else {
  38313. user_name = role.UserName
  38314. }
  38315. if config.IsOpen == 1 {
  38316. for _, item := range patients {
  38317. 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
  38318. resp, requestErr := http.Get(api)
  38319. if requestErr != nil {
  38320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38321. return
  38322. }
  38323. defer resp.Body.Close()
  38324. body, ioErr := ioutil.ReadAll(resp.Body)
  38325. if ioErr != nil {
  38326. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38328. return
  38329. }
  38330. var respJSON map[string]interface{}
  38331. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38332. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38334. return
  38335. }
  38336. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38337. userJSONBytes, _ := json.Marshal(userJSON)
  38338. var res ResultTwo
  38339. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38340. utils.ErrorLog("解析失败:%v", err)
  38341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38342. return
  38343. }
  38344. if res.Infcode == 0 {
  38345. 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)
  38346. var dat map[string]interface{}
  38347. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38348. fmt.Println(dat)
  38349. } else {
  38350. fmt.Println(err)
  38351. }
  38352. userJSONBytes, _ := json.Marshal(dat)
  38353. var res2 ResultThirteen
  38354. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  38355. utils.ErrorLog("解析失败:%v", err)
  38356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38357. return
  38358. }
  38359. if res2.Infcode == 0 {
  38360. psnResult := &models.GdybPsnRecord{
  38361. UserOrgId: adminUser.CurrentOrgId,
  38362. PatientId: item.ID,
  38363. PsnNo: res.Output.Baseinfo.PsnNo,
  38364. Ctime: time.Now().Unix(),
  38365. Mtime: time.Now().Unix(),
  38366. Status: 1,
  38367. IsCancel: 1,
  38368. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  38369. }
  38370. service.CreatePsnRecord(psnResult)
  38371. } else {
  38372. c.ServeSuccessJSON(map[string]interface{}{
  38373. "failed_code": -10,
  38374. "msg": res2.ErrMsg,
  38375. })
  38376. return
  38377. }
  38378. }
  38379. }
  38380. }
  38381. }
  38382. func (c *HisApiController) PsnUnPutOnRecord() {
  38383. id, _ := c.GetInt64("id")
  38384. //record_type, _ := c.GetInt64("type")
  38385. admin_user_id, _ := c.GetInt64("admin_user_id")
  38386. adminUser := c.GetAdminUserInfo()
  38387. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38388. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38389. var user_name string
  38390. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38391. if role.ID == 0 {
  38392. user_name = "xxx"
  38393. } else {
  38394. user_name = role.UserName
  38395. }
  38396. psn_record, _ := service.GetPsnRecordById(id)
  38397. if psn_record.ID == 0 {
  38398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  38399. return
  38400. }
  38401. if config.IsOpen == 1 {
  38402. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  38403. var dat map[string]interface{}
  38404. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38405. fmt.Println(dat)
  38406. } else {
  38407. fmt.Println(err)
  38408. }
  38409. userJSONBytes, _ := json.Marshal(dat)
  38410. var res ResultFourteen
  38411. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38412. utils.ErrorLog("解析失败:%v", err)
  38413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38414. return
  38415. }
  38416. if res.Infcode == 0 {
  38417. psn_record.IsCancel = 2
  38418. service.CreatePsnRecord(&psn_record)
  38419. } else {
  38420. c.ServeSuccessJSON(map[string]interface{}{
  38421. "failed_code": -10,
  38422. "msg": res.ErrMsg,
  38423. })
  38424. return
  38425. }
  38426. }
  38427. }
  38428. func (c *HisApiController) PsnPutNCDSOnRecord() {
  38429. patient_id, _ := c.GetInt64("patient_id")
  38430. insutype_two := c.GetString("insutype")
  38431. psn_no := c.GetString("psn_no")
  38432. doctor_id, _ := c.GetInt64("doctor_id")
  38433. sick_id, _ := c.GetInt64("sick_id")
  38434. department_id, _ := c.GetInt64("department_id")
  38435. start_time := c.GetString("start_time")
  38436. end_time := c.GetString("end_time")
  38437. check_time := c.GetString("check_time")
  38438. hospital_code := c.GetString("hospital_code")
  38439. hospital_name := c.GetString("hospital_name")
  38440. adminUser := c.GetAdminUserInfo()
  38441. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  38442. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38443. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38444. sick, _ := service.FindSickById(sick_id)
  38445. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  38446. if len(hospital_code) == 0 {
  38447. hospital_code = miConfig.Code
  38448. }
  38449. if len(hospital_name) == 0 {
  38450. hospital_name = miConfig.OrgName
  38451. }
  38452. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  38453. var res ResultTwo
  38454. var res10265 ResultTwo10265
  38455. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  38456. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  38457. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  38458. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  38459. "&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
  38460. resp, requestErr := http.Get(api)
  38461. if requestErr != nil {
  38462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38463. return
  38464. }
  38465. body, ioErr := ioutil.ReadAll(resp.Body)
  38466. if ioErr != nil {
  38467. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38469. return
  38470. }
  38471. var respJSON map[string]interface{}
  38472. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38473. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38475. return
  38476. }
  38477. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38478. result, _ := json.Marshal(respJSON)
  38479. fmt.Println("log")
  38480. fmt.Println(string(result))
  38481. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38482. utils.ErrorLog("解析失败:%v", err)
  38483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38484. return
  38485. }
  38486. res.ErrMsg = res10265.ErrMsg
  38487. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38488. res.Infcode = infocode
  38489. res.Output = res10265.Output
  38490. res.InfRefmsgid = res10265.InfRefmsgid
  38491. } else {
  38492. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  38493. if miConfig.Code == "H15049901371" {
  38494. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38495. utils.ErrorLog("解析失败:%v", err)
  38496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38497. return
  38498. }
  38499. res.ErrMsg = res10265.ErrMsg
  38500. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38501. res.Infcode = infocode
  38502. res.Output = res10265.Output
  38503. res.InfRefmsgid = res10265.InfRefmsgid
  38504. } else {
  38505. if err := json.Unmarshal([]byte(result), &res); err != nil {
  38506. utils.ErrorLog("解析失败:%v", err)
  38507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38508. return
  38509. }
  38510. }
  38511. }
  38512. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  38513. infoStr := string(Iinfos)
  38514. var rf []*ResultFive
  38515. json.Unmarshal([]byte(infoStr), &rf)
  38516. var insuplc_admdvs string
  38517. var insutype string
  38518. var is390 int = 0
  38519. var is310 int = 0
  38520. var insutypes []*ResultFive
  38521. for _, item := range rf {
  38522. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  38523. insutypes = append(insutypes, item)
  38524. }
  38525. }
  38526. if len(insutypes) == 1 {
  38527. insutype = insutypes[0].Insutype
  38528. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  38529. } else {
  38530. for _, i := range insutypes {
  38531. if i.Insutype == "390" {
  38532. is390 = 1
  38533. }
  38534. if i.Insutype == "310" {
  38535. is310 = 1
  38536. }
  38537. }
  38538. }
  38539. if is390 == 1 {
  38540. insutype = "390"
  38541. }
  38542. if is310 == 1 {
  38543. insutype = "310"
  38544. }
  38545. if len(insutypes) == 2 {
  38546. insutype = insutype_two
  38547. }
  38548. if len(insutypes) == 0 {
  38549. insutype = "310"
  38550. }
  38551. insutype = insutype_two
  38552. fmt.Println(insutype)
  38553. for _, item := range rf {
  38554. fmt.Println(item.Insutype)
  38555. fmt.Println(insutype)
  38556. if item.Insutype == insutype {
  38557. fmt.Println(item.Insutype)
  38558. fmt.Println(insutype)
  38559. insuplc_admdvs = item.InsuplcAdmdvs
  38560. }
  38561. }
  38562. fmt.Println(insuplc_admdvs)
  38563. var res2 ResultThirteen
  38564. var res10265_2 ResultThirteen10265
  38565. if config.IsOpen == 1 {
  38566. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  38567. } else {
  38568. if miConfig.MdtrtareaAdmvs == "150499" {
  38569. //
  38570. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  38571. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  38572. // "&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
  38573. //resp, requestErr := http.Get(api)
  38574. //if requestErr != nil {
  38575. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38576. // return
  38577. //}
  38578. //
  38579. //body, ioErr := ioutil.ReadAll(resp.Body)
  38580. //if ioErr != nil {
  38581. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  38582. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38583. // return
  38584. //}
  38585. //var respJSON map[string]interface{}
  38586. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  38587. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  38588. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38589. // return
  38590. //}
  38591. //
  38592. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  38593. //result, _ := json.Marshal(respJSON)
  38594. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  38595. // utils.ErrorLog("解析失败:%v", err)
  38596. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38597. // return
  38598. //}
  38599. //infocode = resThree.Infcode
  38600. //result, _ := json.Marshal(respJSON)
  38601. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  38602. // utils.ErrorLog("解析失败:%v", err)
  38603. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38604. // return
  38605. //}
  38606. //
  38607. //resThree.ErrMsg = resThree10265.ErrMsg
  38608. //
  38609. //resThree.Output = resThree10265.Output
  38610. //
  38611. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  38612. //
  38613. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  38614. //
  38615. } else {
  38616. 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)
  38617. var dat map[string]interface{}
  38618. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38619. fmt.Println(dat)
  38620. } else {
  38621. fmt.Println(err)
  38622. }
  38623. userJSONBytes, _ := json.Marshal(dat)
  38624. if miConfig.Code == "H15049901371" {
  38625. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  38626. utils.ErrorLog("解析失败:%v", err)
  38627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38628. return
  38629. }
  38630. res2.ErrMsg = res10265_2.ErrMsg
  38631. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  38632. res2.Infcode = infocode
  38633. res2.Output = res10265_2.Output
  38634. res2.InfRefmsgid = res10265_2.InfRefmsgid
  38635. } else {
  38636. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  38637. utils.ErrorLog("解析失败:%v", err)
  38638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38639. return
  38640. }
  38641. }
  38642. }
  38643. }
  38644. if res2.Infcode == 0 {
  38645. psnResult := &models.GdybPsnNcdsRecord{
  38646. UserOrgId: adminUser.CurrentOrgId,
  38647. PatientId: patient.ID,
  38648. PsnNo: psn_no,
  38649. DoctorId: doctor.AdminUserId,
  38650. DepartmentId: department_id,
  38651. SickType: sick_id,
  38652. Insutype: insutype,
  38653. Ctime: time.Now().Unix(),
  38654. Mtime: time.Now().Unix(),
  38655. Status: 1,
  38656. IsCancel: 1,
  38657. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  38658. }
  38659. service.CreatePsnNCDSRecord(psnResult)
  38660. c.ServeSuccessJSON(map[string]interface{}{
  38661. "failed_code": 0,
  38662. "msg": "备案成功",
  38663. "result": psnResult,
  38664. })
  38665. } else {
  38666. c.ServeSuccessJSON(map[string]interface{}{
  38667. "failed_code": -10,
  38668. "msg": res2.ErrMsg,
  38669. })
  38670. return
  38671. }
  38672. }
  38673. }
  38674. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  38675. id, _ := c.GetInt64("id")
  38676. admin_user_id, _ := c.GetInt64("admin_user_id")
  38677. adminUser := c.GetAdminUserInfo()
  38678. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38679. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  38680. //config, _ := service.Ge(adminUser.CurrentOrgId)
  38681. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  38682. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38683. //var user_name string
  38684. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38685. //if role.ID == 0 {
  38686. // user_name = "xxx"
  38687. //} else {
  38688. // user_name = role.UserName
  38689. //}
  38690. psn_record, _ := service.GetPsnNCDSRecordById(id)
  38691. if psn_record.ID == 0 {
  38692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  38693. return
  38694. }
  38695. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  38696. var res ResultTwo
  38697. var res10265 ResultTwo10265
  38698. if miConfig.Code == "H15049901371" {
  38699. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  38700. utils.ErrorLog("解析失败:%v", err)
  38701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38702. return
  38703. }
  38704. res.ErrMsg = res10265.ErrMsg
  38705. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38706. res.Infcode = infocode
  38707. res.Output = res10265.Output
  38708. res.InfRefmsgid = res10265.InfRefmsgid
  38709. } else {
  38710. if err := json.Unmarshal([]byte(result), &res); err != nil {
  38711. utils.ErrorLog("解析失败:%v", err)
  38712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38713. return
  38714. }
  38715. }
  38716. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  38717. infoStr := string(Iinfos)
  38718. var rf []*ResultFive
  38719. json.Unmarshal([]byte(infoStr), &rf)
  38720. var insuplc_admdvs string
  38721. var insutype string
  38722. var is390 int = 0
  38723. var is310 int = 0
  38724. var insutypes []*ResultFive
  38725. for _, item := range rf {
  38726. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  38727. insutypes = append(insutypes, item)
  38728. }
  38729. }
  38730. if len(insutypes) == 1 {
  38731. insutype = insutypes[0].Insutype
  38732. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  38733. } else {
  38734. for _, i := range insutypes {
  38735. if i.Insutype == "390" {
  38736. is390 = 1
  38737. }
  38738. if i.Insutype == "310" {
  38739. is310 = 1
  38740. }
  38741. }
  38742. }
  38743. if is390 == 1 {
  38744. insutype = "390"
  38745. }
  38746. if is310 == 1 {
  38747. insutype = "310"
  38748. }
  38749. if len(insutypes) == 0 {
  38750. insutype = "310"
  38751. }
  38752. insutype = psn_record.Insutype
  38753. for _, item := range rf {
  38754. if item.Insutype == insutype {
  38755. insuplc_admdvs = item.InsuplcAdmdvs
  38756. }
  38757. }
  38758. if config.IsOpen == 1 {
  38759. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  38760. var dat map[string]interface{}
  38761. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38762. fmt.Println(dat)
  38763. } else {
  38764. fmt.Println(err)
  38765. }
  38766. userJSONBytes, _ := json.Marshal(dat)
  38767. var res ResultFourteen
  38768. var res10265 ResultFourteen10265
  38769. if miConfig.Code == "H15049901371" {
  38770. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  38771. utils.ErrorLog("解析失败:%v", err)
  38772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38773. return
  38774. }
  38775. res.ErrMsg = res10265.ErrMsg
  38776. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  38777. res.Infcode = infocode
  38778. res.Output = res10265.Output
  38779. res.InfRefmsgid = res10265.InfRefmsgid
  38780. } else {
  38781. if err := json.Unmarshal([]byte(result), &res); err != nil {
  38782. utils.ErrorLog("解析失败:%v", err)
  38783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38784. return
  38785. }
  38786. }
  38787. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38788. // utils.ErrorLog("解析失败:%v", err)
  38789. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38790. // return
  38791. //}
  38792. if res.Infcode == 0 {
  38793. psn_record.IsCancel = 2
  38794. service.CreatePsnNCDSRecord(&psn_record)
  38795. c.ServeSuccessJSON(map[string]interface{}{
  38796. "failed_code": 0,
  38797. "msg": "撤销备案成功",
  38798. })
  38799. } else {
  38800. c.ServeSuccessJSON(map[string]interface{}{
  38801. "failed_code": -10,
  38802. "msg": res.ErrMsg,
  38803. })
  38804. return
  38805. }
  38806. }
  38807. }
  38808. func (c *HisApiController) TestTest() {
  38809. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  38810. fmt.Println(patient.Iinfo)
  38811. }
  38812. type CustomData struct {
  38813. MsgId string
  38814. PsnNo string
  38815. Info string
  38816. }
  38817. func (c *HisApiController) ReversalData() {
  38818. var customData []*CustomData
  38819. custom := &CustomData{
  38820. MsgId: "H44022900158202103301714472004",
  38821. PsnNo: "44020000001101329945",
  38822. Info: "2207",
  38823. }
  38824. customData = append(customData, custom)
  38825. custom1 := &CustomData{
  38826. MsgId: "H4402290015820210330172057803",
  38827. PsnNo: "44020000001101161813",
  38828. Info: "2207",
  38829. }
  38830. customData = append(customData, custom1)
  38831. custom2 := &CustomData{
  38832. MsgId: "H44022900158202103301705198813",
  38833. PsnNo: "44190000133097375417",
  38834. Info: "2207",
  38835. }
  38836. customData = append(customData, custom2)
  38837. custom3 := &CustomData{
  38838. MsgId: "H44022900158202103301715524756",
  38839. PsnNo: "44020000001100187221",
  38840. Info: "2207",
  38841. }
  38842. customData = append(customData, custom3)
  38843. custom4 := &CustomData{
  38844. MsgId: "H44022900158202103301730376224",
  38845. PsnNo: "44020000001101959155",
  38846. Info: "2207",
  38847. }
  38848. customData = append(customData, custom4)
  38849. custom5 := &CustomData{
  38850. MsgId: "H44022900158202103301748008725",
  38851. PsnNo: "44020000001104246641",
  38852. Info: "2207",
  38853. }
  38854. customData = append(customData, custom5)
  38855. custom6 := &CustomData{
  38856. MsgId: "H44022900158202103301718096755",
  38857. PsnNo: "44020000001102211860",
  38858. Info: "2207",
  38859. }
  38860. customData = append(customData, custom6)
  38861. custom7 := &CustomData{
  38862. MsgId: "H44022900158202103301736551640",
  38863. PsnNo: "44020000001102687718",
  38864. Info: "2207",
  38865. }
  38866. customData = append(customData, custom7)
  38867. custom8 := &CustomData{
  38868. MsgId: "H44022900158202103301743097676",
  38869. PsnNo: "44020000001102127785",
  38870. Info: "2207",
  38871. }
  38872. customData = append(customData, custom8)
  38873. custom9 := &CustomData{
  38874. MsgId: "H44022900158202103301712304203",
  38875. PsnNo: "44020000001101518097",
  38876. Info: "2207",
  38877. }
  38878. customData = append(customData, custom9)
  38879. custom10 := &CustomData{
  38880. MsgId: "H44022900158202103301738448785",
  38881. PsnNo: "44020000001100500813",
  38882. Info: "2207",
  38883. }
  38884. customData = append(customData, custom10)
  38885. custom11 := &CustomData{
  38886. MsgId: "H44022900158202103301732455843",
  38887. PsnNo: "44020000001102690557",
  38888. Info: "2207",
  38889. }
  38890. customData = append(customData, custom11)
  38891. custom12 := &CustomData{
  38892. MsgId: "H44022900158202103301745421708",
  38893. PsnNo: "44020000001102211928",
  38894. Info: "2207",
  38895. }
  38896. customData = append(customData, custom12)
  38897. custom1212 := &CustomData{
  38898. MsgId: "H440229001582021033017351627",
  38899. PsnNo: "44020000001102481733",
  38900. Info: "2207",
  38901. }
  38902. customData = append(customData, custom1212)
  38903. custom13 := &CustomData{
  38904. MsgId: "H44022900158202103301740327951",
  38905. PsnNo: "44020000001103174866",
  38906. Info: "2207",
  38907. }
  38908. customData = append(customData, custom13)
  38909. custom14 := &CustomData{
  38910. MsgId: "H4402290015820210330174922668",
  38911. PsnNo: "44020000001102927272",
  38912. Info: "2207",
  38913. }
  38914. customData = append(customData, custom14)
  38915. custom15 := &CustomData{
  38916. MsgId: "H44022900158202103301752362273",
  38917. PsnNo: "44020000001102942890",
  38918. Info: "2207",
  38919. }
  38920. customData = append(customData, custom15)
  38921. custom16 := &CustomData{
  38922. MsgId: "H44022900158202103301751082917",
  38923. PsnNo: "44020000001101662162",
  38924. Info: "2207",
  38925. }
  38926. customData = append(customData, custom16)
  38927. custom17 := &CustomData{
  38928. MsgId: "H44022900158202103301754147728",
  38929. PsnNo: "44020000000229014511",
  38930. Info: "2207",
  38931. }
  38932. customData = append(customData, custom17)
  38933. adminUser := c.GetAdminUserInfo()
  38934. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38935. for _, item := range customData {
  38936. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  38937. fmt.Println(result)
  38938. }
  38939. }
  38940. func (c *HisApiController) GetAllopatry() {
  38941. year := c.GetString("year")
  38942. month := c.GetString("month")
  38943. admin_user_id, _ := c.GetInt64("admin_user_id")
  38944. adminUser := c.GetAdminUserInfo()
  38945. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  38946. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  38947. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  38948. var dat map[string]interface{}
  38949. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  38950. fmt.Println(dat)
  38951. } else {
  38952. fmt.Println(err)
  38953. }
  38954. userJSONBytes, _ := json.Marshal(dat)
  38955. var res models.Result9001
  38956. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  38957. utils.ErrorLog("解析失败:%v", err)
  38958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38959. return
  38960. }
  38961. fmt.Println(res.Output.Signinoutb)
  38962. fmt.Println(res.Output.Signinoutb.SignNo)
  38963. fmt.Println(string(userJSONBytes))
  38964. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  38965. var dat3 map[string]interface{}
  38966. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  38967. fmt.Println(dat3)
  38968. } else {
  38969. fmt.Println(err)
  38970. }
  38971. userJSONBytes3, _ := json.Marshal(dat3)
  38972. var res3 models.Result3260
  38973. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  38974. utils.ErrorLog("解析失败:%v", err)
  38975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38976. return
  38977. }
  38978. var curpage int
  38979. var pagesize int = 100
  38980. var start int = 1
  38981. //var stop int
  38982. //pagecount := 10
  38983. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  38984. var res22 []models.Result3260
  38985. for curpage = 1; curpage <= pagecount; curpage++ {
  38986. if curpage == 1 {
  38987. start = 0
  38988. } else {
  38989. start = (curpage-1)*pagesize + 1
  38990. }
  38991. fmt.Println(start)
  38992. //stop = curpage * pagesize
  38993. //if stop > int(res3.Output.Totalrow) {
  38994. // stop =int(res3.Output.Totalrow)
  38995. //}
  38996. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  38997. var dat2 map[string]interface{}
  38998. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  38999. fmt.Println(dat)
  39000. } else {
  39001. fmt.Println(err)
  39002. }
  39003. userJSONBytes2, _ := json.Marshal(dat2)
  39004. var res2 models.Result3260
  39005. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  39006. utils.ErrorLog("解析失败:%v", err)
  39007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39008. return
  39009. }
  39010. if res2.Infcode == 0 {
  39011. res22 = append(res22, res2)
  39012. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  39013. //var dat2 map[string]interface{}
  39014. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  39015. // fmt.Println(dat)
  39016. //} else {
  39017. // fmt.Println(err)
  39018. //}
  39019. //c.ServeSuccessJSON(map[string]interface{}{
  39020. // "list": res2.Output.Data,
  39021. //})
  39022. //continue
  39023. }
  39024. }
  39025. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  39026. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  39027. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  39028. //var dat2 map[string]interface{}
  39029. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  39030. // fmt.Println(dat)
  39031. //} else {
  39032. // fmt.Println(err)
  39033. //}
  39034. //userJSONBytes2, _ := json.Marshal(dat2)
  39035. //var res2 models.Result3260
  39036. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  39037. // utils.ErrorLog("解析失败:%v", err)
  39038. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39039. // return
  39040. //}
  39041. //if res2.Infcode == 0 {
  39042. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  39043. // var dat2 map[string]interface{}
  39044. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  39045. // fmt.Println(dat)
  39046. // } else {
  39047. // fmt.Println(err)
  39048. // }
  39049. // c.ServeSuccessJSON(map[string]interface{}{
  39050. // "list": res2.Output.Data,
  39051. // })
  39052. //}
  39053. }
  39054. func (c *HisApiController) ComfirmAllopatry() {
  39055. year := c.GetString("year")
  39056. month := c.GetString("month")
  39057. admin_user_id, _ := c.GetInt64("admin_user_id")
  39058. adminUser := c.GetAdminUserInfo()
  39059. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39060. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39061. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  39062. var dat map[string]interface{}
  39063. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  39064. fmt.Println(dat)
  39065. } else {
  39066. fmt.Println(err)
  39067. }
  39068. userJSONBytes, _ := json.Marshal(dat)
  39069. var res models.Result9001
  39070. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39071. utils.ErrorLog("解析失败:%v", err)
  39072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39073. return
  39074. }
  39075. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  39076. var dat2 map[string]interface{}
  39077. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  39078. fmt.Println(dat)
  39079. } else {
  39080. fmt.Println(err)
  39081. }
  39082. userJSONBytes2, _ := json.Marshal(dat2)
  39083. var res2 models.Result3260
  39084. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  39085. utils.ErrorLog("解析失败:%v", err)
  39086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39087. return
  39088. }
  39089. //if res2.Infcode == 0 {
  39090. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  39091. // var dat map[string]interface{}
  39092. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  39093. // fmt.Println(dat)
  39094. // } else {
  39095. // fmt.Println(err)
  39096. // }
  39097. // userJSONBytes, _ := json.Marshal(dat)
  39098. // var res3 models.Result3261
  39099. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  39100. // utils.ErrorLog("解析失败:%v", err)
  39101. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39102. // return
  39103. // }
  39104. //
  39105. // if res3.Infcode == 0 {
  39106. // record := &models.HisYidiClearRecord{
  39107. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39108. // Ctime: time.Now().Unix(),
  39109. // Mtime: time.Now().Unix(),
  39110. // Status: 1,
  39111. // MsgId: msgId,
  39112. // }
  39113. // service.SaveClearRecord(record)
  39114. // c.ServeSuccessJSON(map[string]interface{}{
  39115. // "msg": "提取成功",
  39116. // })
  39117. // }
  39118. //}
  39119. }
  39120. func (c *HisApiController) RefundAllopatry() {
  39121. year := c.GetString("year")
  39122. month := c.GetString("month")
  39123. //id, _ := c.GetInt64("id")
  39124. admin_user_id, _ := c.GetInt64("admin_user_id")
  39125. adminUser := c.GetAdminUserInfo()
  39126. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39127. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39128. //record, _ := service.GetClearRecordById(id)
  39129. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  39130. var dat map[string]interface{}
  39131. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  39132. fmt.Println(dat)
  39133. } else {
  39134. fmt.Println(err)
  39135. }
  39136. userJSONBytes, _ := json.Marshal(dat)
  39137. var res models.Result9001
  39138. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39139. utils.ErrorLog("解析失败:%v", err)
  39140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39141. return
  39142. }
  39143. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  39144. var dat2 map[string]interface{}
  39145. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  39146. fmt.Println(dat)
  39147. } else {
  39148. fmt.Println(err)
  39149. }
  39150. userJSONBytes2, _ := json.Marshal(dat2)
  39151. var empty ResultFourteen
  39152. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  39153. utils.ErrorLog("解析失败:%v", err)
  39154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39155. return
  39156. }
  39157. if empty.Infcode == 0 {
  39158. c.ServeSuccessJSON(map[string]interface{}{
  39159. "msg": "撤销成功",
  39160. })
  39161. return
  39162. }
  39163. }
  39164. func (c *HisApiController) ReversalOtherData() {
  39165. var customData []*CustomData
  39166. custom := &CustomData{
  39167. MsgId: "H44022900158202103301714472004",
  39168. PsnNo: "44020000001101329945",
  39169. Info: "2208",
  39170. }
  39171. customData = append(customData, custom)
  39172. custom1 := &CustomData{
  39173. MsgId: "H4402290015820210330172057803",
  39174. PsnNo: "44020000001101161813",
  39175. Info: "2208",
  39176. }
  39177. customData = append(customData, custom1)
  39178. custom2 := &CustomData{
  39179. MsgId: "H44022900158202103301705198813",
  39180. PsnNo: "44190000133097375417",
  39181. Info: "2208",
  39182. }
  39183. customData = append(customData, custom2)
  39184. custom3 := &CustomData{
  39185. MsgId: "H44022900158202103301715524756",
  39186. PsnNo: "44020000001100187221",
  39187. Info: "2208",
  39188. }
  39189. customData = append(customData, custom3)
  39190. custom4 := &CustomData{
  39191. MsgId: "H44022900158202103301730376224",
  39192. PsnNo: "44020000001101959155",
  39193. Info: "2208",
  39194. }
  39195. customData = append(customData, custom4)
  39196. custom5 := &CustomData{
  39197. MsgId: "H44022900158202103301748008725",
  39198. PsnNo: "44020000001104246641",
  39199. Info: "2208",
  39200. }
  39201. customData = append(customData, custom5)
  39202. custom6 := &CustomData{
  39203. MsgId: "H44022900158202103301718096755",
  39204. PsnNo: "44020000001102211860",
  39205. Info: "2208",
  39206. }
  39207. customData = append(customData, custom6)
  39208. custom7 := &CustomData{
  39209. MsgId: "H44022900158202103301736551640",
  39210. PsnNo: "44020000001102687718",
  39211. Info: "2208",
  39212. }
  39213. customData = append(customData, custom7)
  39214. custom8 := &CustomData{
  39215. MsgId: "H44022900158202103301743097676",
  39216. PsnNo: "44020000001102127785",
  39217. Info: "2208",
  39218. }
  39219. customData = append(customData, custom8)
  39220. custom9 := &CustomData{
  39221. MsgId: "H44022900158202103301712304203",
  39222. PsnNo: "44020000001101518097",
  39223. Info: "2208",
  39224. }
  39225. customData = append(customData, custom9)
  39226. custom10 := &CustomData{
  39227. MsgId: "H44022900158202103301738448785",
  39228. PsnNo: "44020000001100500813",
  39229. Info: "2208",
  39230. }
  39231. customData = append(customData, custom10)
  39232. custom11 := &CustomData{
  39233. MsgId: "H44022900158202103301732455843",
  39234. PsnNo: "44020000001102690557",
  39235. Info: "2208",
  39236. }
  39237. customData = append(customData, custom11)
  39238. custom12 := &CustomData{
  39239. MsgId: "H44022900158202103301745421708",
  39240. PsnNo: "44020000001102211928",
  39241. Info: "2208",
  39242. }
  39243. customData = append(customData, custom12)
  39244. custom1212 := &CustomData{
  39245. MsgId: "H440229001582021033017351627",
  39246. PsnNo: "44020000001102481733",
  39247. Info: "2208",
  39248. }
  39249. customData = append(customData, custom1212)
  39250. custom13 := &CustomData{
  39251. MsgId: "H44022900158202103301740327951",
  39252. PsnNo: "44020000001103174866",
  39253. Info: "2208",
  39254. }
  39255. customData = append(customData, custom13)
  39256. custom14 := &CustomData{
  39257. MsgId: "H4402290015820210330174922668",
  39258. PsnNo: "44020000001102927272",
  39259. Info: "2208",
  39260. }
  39261. customData = append(customData, custom14)
  39262. custom15 := &CustomData{
  39263. MsgId: "H44022900158202103301752362273",
  39264. PsnNo: "44020000001102942890",
  39265. Info: "2208",
  39266. }
  39267. customData = append(customData, custom15)
  39268. custom16 := &CustomData{
  39269. MsgId: "H44022900158202103301751082917",
  39270. PsnNo: "44020000001101662162",
  39271. Info: "2208",
  39272. }
  39273. customData = append(customData, custom16)
  39274. custom17 := &CustomData{
  39275. MsgId: "H44022900158202103301754147728",
  39276. PsnNo: "44020000000229014511",
  39277. Info: "2208",
  39278. }
  39279. customData = append(customData, custom17)
  39280. adminUser := c.GetAdminUserInfo()
  39281. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39282. for _, item := range customData {
  39283. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  39284. fmt.Println(result)
  39285. }
  39286. }
  39287. func PathExists(path string) (bool, error) {
  39288. _, err := os.Stat(path)
  39289. if err == nil {
  39290. return true, nil
  39291. }
  39292. if os.IsNotExist(err) {
  39293. return false, nil
  39294. }
  39295. return false, err
  39296. }
  39297. // 创建文件夹
  39298. func Mkdir(dir string) {
  39299. // 创建文件夹
  39300. exist, err := PathExists(dir)
  39301. if err != nil {
  39302. fmt.Println(err.Error())
  39303. } else {
  39304. if exist {
  39305. fmt.Println(dir + "文件夹已存在!")
  39306. } else {
  39307. // 文件夹名称,权限
  39308. err := os.Mkdir(dir, os.ModePerm)
  39309. if err != nil {
  39310. fmt.Println(dir+"文件夹创建失败:", err.Error())
  39311. } else {
  39312. fmt.Println(dir + "文件夹创建成功!")
  39313. }
  39314. }
  39315. }
  39316. }
  39317. // 压缩文件
  39318. func Zip(srcFile string, destZip string) error {
  39319. zipfile, err := os.Create(destZip)
  39320. if err != nil {
  39321. return err
  39322. }
  39323. defer zipfile.Close()
  39324. archive := zip.NewWriter(zipfile)
  39325. defer archive.Close()
  39326. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  39327. if err != nil {
  39328. return err
  39329. }
  39330. header, err := zip.FileInfoHeader(info)
  39331. if err != nil {
  39332. return err
  39333. }
  39334. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  39335. // header.Name = path
  39336. if info.IsDir() {
  39337. header.Name += "/"
  39338. } else {
  39339. header.Method = zip.Deflate
  39340. }
  39341. writer, err := archive.CreateHeader(header)
  39342. if err != nil {
  39343. return err
  39344. }
  39345. if !info.IsDir() {
  39346. file, err := os.Open(path)
  39347. if err != nil {
  39348. return err
  39349. }
  39350. defer file.Close()
  39351. _, err = io.Copy(writer, file)
  39352. }
  39353. return err
  39354. })
  39355. return err
  39356. }
  39357. func ReadFile(filePath string) []byte {
  39358. f, err := os.Open(filePath)
  39359. if err != nil {
  39360. fmt.Println("read file fail", err)
  39361. return nil
  39362. }
  39363. defer f.Close()
  39364. fd, err := ioutil.ReadAll(f)
  39365. if err != nil {
  39366. fmt.Println("read to fd fail", err)
  39367. return nil
  39368. }
  39369. return fd
  39370. }
  39371. func saveLogq(result string, request string, infno string, desc string) {
  39372. dir := "日志"
  39373. utils.Mkdir(dir)
  39374. month := time.Unix(1557042972, 0).Format("1")
  39375. year := time.Now().Format("2006")
  39376. month = time.Now().Format("01")
  39377. day := time.Now().Format("02")
  39378. hour := time.Now().Format("15")
  39379. min := time.Now().Format("04")
  39380. sec := time.Now().Format("05")
  39381. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  39382. file := year + month + day + "_log"
  39383. file_name := file + ".txt"
  39384. file_path := "日志" + "/" + file_name
  39385. exist, _ := utils.PathExists(file_path)
  39386. if exist { //存在
  39387. fmt.Println("存在")
  39388. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  39389. if err != nil {
  39390. fmt.Println("read fail")
  39391. }
  39392. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  39393. n, _ := f.Seek(0, 2)
  39394. _, err = f.WriteAt([]byte(content), n)
  39395. } else { //不存在
  39396. fmt.Println("文件不存在,创建文件")
  39397. f, err := os.Create("日志" + "/" + file_name)
  39398. defer f.Close()
  39399. if err != nil {
  39400. } else {
  39401. _, err = f.Write([]byte("记录日志"))
  39402. }
  39403. }
  39404. }
  39405. func saveLog(result string, request string, infno string, desc string) {
  39406. org_id, _ := beego.AppConfig.Int64("org_id")
  39407. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39408. dir := miConfig.OrgName + "日志"
  39409. utils.Mkdir(dir)
  39410. month := time.Unix(1557042972, 0).Format("1")
  39411. year := time.Now().Format("2006")
  39412. month = time.Now().Format("01")
  39413. day := time.Now().Format("02")
  39414. hour := time.Now().Format("15")
  39415. min := time.Now().Format("04")
  39416. sec := time.Now().Format("05")
  39417. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  39418. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  39419. file_name := file + ".txt"
  39420. file_path := miConfig.OrgName + "日志" + "/" + file_name
  39421. exist, _ := utils.PathExists(file_path)
  39422. if exist { //存在
  39423. fmt.Println("存在")
  39424. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  39425. if err != nil {
  39426. fmt.Println("read fail")
  39427. }
  39428. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  39429. n, _ := f.Seek(0, 2)
  39430. _, err = f.WriteAt([]byte(content), n)
  39431. } else { //不存在
  39432. fmt.Println("文件不存在,创建文件")
  39433. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  39434. defer f.Close()
  39435. if err != nil {
  39436. } else {
  39437. _, err = f.Write([]byte("记录日志"))
  39438. }
  39439. }
  39440. }
  39441. type Charset string
  39442. const (
  39443. UTF8 = Charset("UTF-8")
  39444. GB18030 = Charset("GB18030")
  39445. )
  39446. func ConvertToString(src string, srcCode string, tagCode string) string {
  39447. srcCoder := mahonia.NewDecoder(srcCode)
  39448. srcResult := srcCoder.ConvertString(src)
  39449. tagCoder := mahonia.NewDecoder(tagCode)
  39450. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  39451. result := string(cdata)
  39452. return result
  39453. }
  39454. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  39455. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39456. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39457. var token string
  39458. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  39459. var api string
  39460. if miConfig.MdtrtareaAdmvs == "320830" {
  39461. api = miConfig.AppSecret + "jsyb/readcardcharge?" + "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. fmt.Println(api)
  39464. } else if miConfig.MdtrtareaAdmvs == "320921" {
  39465. 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 +
  39466. "&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
  39467. fmt.Println(api)
  39468. } else {
  39469. 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 +
  39470. "&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
  39471. }
  39472. resp, requestErr := http.Get(api)
  39473. if requestErr != nil {
  39474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39475. return ""
  39476. }
  39477. body, ioErr := ioutil.ReadAll(resp.Body)
  39478. if ioErr != nil {
  39479. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39481. return ""
  39482. }
  39483. var respJSON map[string]interface{}
  39484. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  39485. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39487. return ""
  39488. }
  39489. var status string
  39490. status = respJSON["data"].(map[string]interface{})["status"].(string)
  39491. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  39492. var res ResultTwo //1101结果
  39493. var res10265 ResultTwo10265 //1101结果
  39494. if status == "0" { //读卡成功
  39495. var card_info string //卡信息
  39496. var busi_card_info string
  39497. token = respJSON["data"].(map[string]interface{})["token"].(string)
  39498. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  39499. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  39500. fmt.Println(card_info)
  39501. fmt.Println(busi_card_info)
  39502. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  39503. result, _ := json.Marshal(respJSON)
  39504. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  39505. utils.ErrorLog("解析失败:%v", err)
  39506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39507. return ""
  39508. }
  39509. res.ErrMsg = res10265.ErrMsg
  39510. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  39511. res.Infcode = infocode
  39512. res.Output = res10265.Output
  39513. res.InfRefmsgid = res10265.InfRefmsgid
  39514. if res.Infcode == 0 {
  39515. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  39516. if err == gorm.ErrRecordNotFound {
  39517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  39518. return ""
  39519. } else if err != nil {
  39520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  39521. return ""
  39522. } else {
  39523. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39524. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  39525. infoStr := string(Iinfos)
  39526. idetinfoStr := string(Idetinfos)
  39527. psn := &models.HisPsn{
  39528. PsnNo: res.Output.Baseinfo.PsnNo,
  39529. PatientId: patient.ID,
  39530. Certno: res.Output.Baseinfo.Certno,
  39531. Gend: res.Output.Baseinfo.Gend,
  39532. Naty: res.Output.Baseinfo.Naty,
  39533. PsnCertType: res.Output.Baseinfo.PsnCertType,
  39534. PsnName: res.Output.Baseinfo.PsnName,
  39535. Idetinfo: idetinfoStr,
  39536. Insuinfo: infoStr,
  39537. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39538. CardInfo: card_info,
  39539. VerifyNumber: token,
  39540. }
  39541. service.CreateHisPsn(psn)
  39542. return token
  39543. }
  39544. }
  39545. } else {
  39546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39547. return ""
  39548. }
  39549. } else { //读卡失败
  39550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39551. return ""
  39552. }
  39553. return token
  39554. }
  39555. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  39556. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39557. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39558. var token string
  39559. var api string
  39560. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  39561. "&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
  39562. fmt.Println(api)
  39563. resp, requestErr := http.Get(api)
  39564. if requestErr != nil {
  39565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39566. return ""
  39567. }
  39568. body, ioErr := ioutil.ReadAll(resp.Body)
  39569. if ioErr != nil {
  39570. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39572. return ""
  39573. }
  39574. var respJSON map[string]interface{}
  39575. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  39576. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39578. return ""
  39579. }
  39580. var status string
  39581. status = respJSON["data"].(map[string]interface{})["status"].(string)
  39582. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  39583. var res ResultTwo //1101结果
  39584. if status == "1" { //读卡成功
  39585. var card_info string //卡信息
  39586. var busi_card_info string
  39587. token = respJSON["data"].(map[string]interface{})["token"].(string)
  39588. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  39589. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  39590. fmt.Println(card_info)
  39591. fmt.Println(busi_card_info)
  39592. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  39593. result, _ := json.Marshal(respJSON)
  39594. if err := json.Unmarshal([]byte(result), &res); err != nil {
  39595. utils.ErrorLog("解析失败:%v", err)
  39596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39597. return ""
  39598. }
  39599. if res.Infcode == 0 {
  39600. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  39601. if err == gorm.ErrRecordNotFound {
  39602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  39603. return ""
  39604. } else if err != nil {
  39605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  39606. return ""
  39607. } else {
  39608. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39609. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  39610. infoStr := string(Iinfos)
  39611. idetinfoStr := string(Idetinfos)
  39612. psn := &models.HisPsn{
  39613. PsnNo: res.Output.Baseinfo.PsnNo,
  39614. PatientId: patient.ID,
  39615. Certno: res.Output.Baseinfo.Certno,
  39616. Gend: res.Output.Baseinfo.Gend,
  39617. Naty: res.Output.Baseinfo.Naty,
  39618. PsnCertType: res.Output.Baseinfo.PsnCertType,
  39619. PsnName: res.Output.Baseinfo.PsnName,
  39620. Idetinfo: idetinfoStr,
  39621. Insuinfo: infoStr,
  39622. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39623. CardInfo: card_info,
  39624. VerifyNumber: token,
  39625. }
  39626. service.CreateHisPsn(psn)
  39627. return token
  39628. }
  39629. }
  39630. } else {
  39631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39632. return ""
  39633. }
  39634. return token
  39635. }
  39636. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  39637. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  39638. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  39639. var token string
  39640. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" || miConfig.MdtrtareaAdmvs == "320830" {
  39641. var api string
  39642. if miConfig.MdtrtareaAdmvs == "320830" {
  39643. api = miConfig.AppSecret + "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. fmt.Println(api)
  39646. } else if miConfig.MdtrtareaAdmvs == "320921" {
  39647. 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 +
  39648. "&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
  39649. fmt.Println(api)
  39650. } else {
  39651. 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 +
  39652. "&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
  39653. }
  39654. resp, requestErr := http.Get(api)
  39655. if requestErr != nil {
  39656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39657. return ""
  39658. }
  39659. body, ioErr := ioutil.ReadAll(resp.Body)
  39660. if ioErr != nil {
  39661. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39663. return ""
  39664. }
  39665. var respJSON map[string]interface{}
  39666. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  39667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39669. return ""
  39670. }
  39671. var status string
  39672. status = respJSON["data"].(map[string]interface{})["status"].(string)
  39673. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  39674. var res ResultTwo //1101结果
  39675. var res10265 ResultTwo10265 //1101结果
  39676. if status == "0" { //读卡成功
  39677. var card_info string //卡信息
  39678. var busi_card_info string
  39679. token = respJSON["data"].(map[string]interface{})["token"].(string)
  39680. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  39681. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  39682. fmt.Println(card_info)
  39683. fmt.Println(busi_card_info)
  39684. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  39685. result, _ := json.Marshal(respJSON)
  39686. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  39687. utils.ErrorLog("解析失败:%v", err)
  39688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39689. return ""
  39690. }
  39691. res.ErrMsg = res10265.ErrMsg
  39692. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  39693. res.Infcode = infocode
  39694. res.Output = res10265.Output
  39695. res.InfRefmsgid = res10265.InfRefmsgid
  39696. if res.Infcode == 0 {
  39697. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  39698. if err == gorm.ErrRecordNotFound {
  39699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  39700. return ""
  39701. } else if err != nil {
  39702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  39703. return ""
  39704. } else {
  39705. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  39706. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  39707. infoStr := string(Iinfos)
  39708. idetinfoStr := string(Idetinfos)
  39709. psn := &models.HisPsn{
  39710. PsnNo: res.Output.Baseinfo.PsnNo,
  39711. PatientId: patient.ID,
  39712. Certno: res.Output.Baseinfo.Certno,
  39713. Gend: res.Output.Baseinfo.Gend,
  39714. Naty: res.Output.Baseinfo.Naty,
  39715. PsnCertType: res.Output.Baseinfo.PsnCertType,
  39716. PsnName: res.Output.Baseinfo.PsnName,
  39717. Idetinfo: idetinfoStr,
  39718. Insuinfo: infoStr,
  39719. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  39720. CardInfo: card_info,
  39721. VerifyNumber: token,
  39722. }
  39723. service.CreateHisPsn(psn)
  39724. return token
  39725. }
  39726. }
  39727. } else {
  39728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39729. return ""
  39730. }
  39731. } else { //读卡失败
  39732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  39733. return ""
  39734. }
  39735. return token
  39736. }
  39737. func DeleteExtraSpaceTwo(s string) string {
  39738. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  39739. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  39740. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  39741. reg, _ := regexp.Compile(regstr) //编译正则表达式
  39742. s2 := make([]byte, len(s1)) //定义字符数组切片
  39743. copy(s2, s1) //将字符串复制到切片
  39744. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  39745. for len(spc_index) > 0 { //找到适配项
  39746. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  39747. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  39748. }
  39749. return string(s2)
  39750. }
  39751. func Remove0000(s string) string {
  39752. str := make([]rune, 0, len(s))
  39753. for _, v := range []rune(s) {
  39754. if v == 0 {
  39755. continue
  39756. }
  39757. str = append(str, v)
  39758. }
  39759. return string(str)
  39760. }
  39761. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  39762. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  39763. readCard := DllDef.MustFindProc("EcQuery")
  39764. pCardInfo := make([]byte, 8192)
  39765. pBusiCardInfo := make([]byte, 8192)
  39766. data := make(map[string]interface{})
  39767. //pData := make(map[string]interface{})
  39768. inputData := make(map[string]interface{})
  39769. inputData["orgId"] = code
  39770. inputData["businessType"] = "01101"
  39771. inputData["operatorId"] = operator_id
  39772. inputData["operatorName"] = operator_name
  39773. inputData["officeId"] = "001"
  39774. inputData["officeName"] = "血透室"
  39775. //
  39776. data["data"] = inputData
  39777. data["transType"] = "ec.query"
  39778. data["orgId"] = code
  39779. bytesData, _ := json.Marshal(data)
  39780. pCardInfo = bytesData
  39781. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  39782. fmt.Println(ret2)
  39783. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  39784. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  39785. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  39786. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  39787. if ret2 != 0 {
  39788. return "", ""
  39789. }
  39790. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  39791. }
  39792. func DeleteExtraSpace(s string) string {
  39793. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  39794. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  39795. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  39796. reg, _ := regexp.Compile(regstr) //编译正则表达式
  39797. s2 := make([]byte, len(s1)) //定义字符数组切片
  39798. copy(s2, s1) //将字符串复制到切片
  39799. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  39800. for len(spc_index) > 0 { //找到适配项
  39801. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  39802. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  39803. }
  39804. return string(s2)
  39805. }
  39806. // 对账
  39807. func (c *HisApiController) Post3202() {
  39808. start_time := c.GetString("start_time")
  39809. end_time := c.GetString("end_time")
  39810. //insutype := c.GetString("insutype")
  39811. clr_type := c.GetString("clr_type")
  39812. clr_org := c.GetString("clr_optins")
  39813. admin_user_id, _ := c.GetInt64("admin_user_id")
  39814. adminUser := c.GetAdminUserInfo()
  39815. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  39816. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  39817. if len(clr_org) == 0 {
  39818. clr_org = miConfig.MdtrtareaAdmvs
  39819. }
  39820. timeLayout := "2006-01-02"
  39821. loc, _ := time.LoadLocation("Local")
  39822. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  39823. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  39824. var orders []*models.HisOrder
  39825. if clr_org == "421300" {
  39826. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39827. } else if clr_org == "420902" {
  39828. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39829. } else {
  39830. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  39831. }
  39832. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  39833. //fixmedins_setl_cnt := int64(len(orders))
  39834. var medfee_sumamt float64
  39835. var acct_pay float64
  39836. var fund_pay_sumamt float64
  39837. for _, item := range orders {
  39838. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  39839. acct_pay = acct_pay + item.AcctPay
  39840. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  39841. }
  39842. //var medfee_sumamt_two float64
  39843. //var acct_pay_two float64
  39844. //var fund_pay_sumamt_two float64
  39845. //for _, item := range orders_two {
  39846. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  39847. // acct_pay_two = acct_pay_two + item.AcctPay
  39848. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  39849. //}
  39850. //var user_name string
  39851. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  39852. //if role.ID == 0 {
  39853. // user_name = "xxx"
  39854. //} else {
  39855. // user_name = role.UserName
  39856. //}
  39857. var res ResultSix
  39858. if config.IsOpen == 1 {
  39859. var bps []*models.BusinessParamsTwo
  39860. var bp models.BusinessParamsTwo
  39861. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  39862. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  39863. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  39864. bp.MedfeeSumamt = medfee_sumamt_str
  39865. bp.AcctPay = acct_pay_str
  39866. bp.FundPaySumamt = fund_pay_sumamt_str
  39867. bp.Insutype = ""
  39868. bp.StmtBegndate = start_time
  39869. bp.ClrType = clr_type
  39870. bp.SetlOptins = clr_org
  39871. bp.StmtEnddate = end_time
  39872. bps = append(bps, &bp)
  39873. data := make(map[string]interface{})
  39874. data["bps"] = bps
  39875. data["org_name"] = miConfig.OrgName
  39876. data["doctor"] = role.UserName
  39877. data["fixmedins_code"] = miConfig.Code
  39878. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39879. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  39880. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  39881. if miConfig.MdtrtareaAdmvs == "421300" {
  39882. client := &http.Client{}
  39883. bytesData, _ := json.Marshal(data)
  39884. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  39885. resp, _ := client.Do(req)
  39886. defer resp.Body.Close()
  39887. body, ioErr := ioutil.ReadAll(resp.Body)
  39888. if ioErr != nil {
  39889. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39891. return
  39892. }
  39893. var respJSON map[string]interface{}
  39894. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39895. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39897. return
  39898. }
  39899. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39900. userJSONBytes, _ := json.Marshal(respJSON)
  39901. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39902. utils.ErrorLog("解析失败:%v", err)
  39903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39904. return
  39905. }
  39906. }
  39907. if miConfig.MdtrtareaAdmvs == "420200" {
  39908. client := &http.Client{}
  39909. bytesData, _ := json.Marshal(data)
  39910. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  39911. resp, _ := client.Do(req)
  39912. defer resp.Body.Close()
  39913. body, ioErr := ioutil.ReadAll(resp.Body)
  39914. if ioErr != nil {
  39915. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39917. return
  39918. }
  39919. var respJSON map[string]interface{}
  39920. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39921. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39923. return
  39924. }
  39925. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39926. userJSONBytes, _ := json.Marshal(respJSON)
  39927. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39928. utils.ErrorLog("解析失败:%v", err)
  39929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39930. return
  39931. }
  39932. }
  39933. if miConfig.MdtrtareaAdmvs == "421182" {
  39934. client := &http.Client{}
  39935. bytesData, _ := json.Marshal(data)
  39936. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  39937. resp, _ := client.Do(req)
  39938. defer resp.Body.Close()
  39939. body, ioErr := ioutil.ReadAll(resp.Body)
  39940. if ioErr != nil {
  39941. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39943. return
  39944. }
  39945. var respJSON map[string]interface{}
  39946. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39947. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39949. return
  39950. }
  39951. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39952. userJSONBytes, _ := json.Marshal(respJSON)
  39953. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39954. utils.ErrorLog("解析失败:%v", err)
  39955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39956. return
  39957. }
  39958. }
  39959. if miConfig.MdtrtareaAdmvs == "420902" {
  39960. client := &http.Client{}
  39961. bytesData, _ := json.Marshal(data)
  39962. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  39963. resp, _ := client.Do(req)
  39964. defer resp.Body.Close()
  39965. body, ioErr := ioutil.ReadAll(resp.Body)
  39966. if ioErr != nil {
  39967. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  39968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39969. return
  39970. }
  39971. var respJSON map[string]interface{}
  39972. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  39973. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  39974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39975. return
  39976. }
  39977. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  39978. userJSONBytes, _ := json.Marshal(respJSON)
  39979. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  39980. utils.ErrorLog("解析失败:%v", err)
  39981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  39982. return
  39983. }
  39984. }
  39985. if res.Infcode == 0 {
  39986. c.ServeSuccessJSON(map[string]interface{}{
  39987. "msg": "发起成功",
  39988. })
  39989. } else {
  39990. c.ServeSuccessJSON(map[string]interface{}{
  39991. "failed_code": -10,
  39992. "msg": res.ErrMsg,
  39993. })
  39994. }
  39995. }
  39996. }
  39997. func (c *HisApiController) Post3204a() {
  39998. start_time := c.GetString("start_time")
  39999. end_time := c.GetString("end_time")
  40000. //insutype := c.GetString("insutype")
  40001. clr_type := c.GetString("clr_type")
  40002. clr_org := c.GetString("clr_optins")
  40003. admin_user_id, _ := c.GetInt64("admin_user_id")
  40004. adminUser := c.GetAdminUserInfo()
  40005. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40006. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40007. if len(clr_org) == 0 {
  40008. clr_org = miConfig.MdtrtareaAdmvs
  40009. }
  40010. timeLayout := "2006-01-02"
  40011. loc, _ := time.LoadLocation("Local")
  40012. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  40013. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  40014. var orders []*models.HisOrder
  40015. if clr_org == "421300" {
  40016. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40017. } else if clr_org == "420902" {
  40018. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40019. } else {
  40020. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40021. }
  40022. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  40023. //fixmedins_setl_cnt := int64(len(orders))
  40024. var medfee_sumamt float64
  40025. var acct_pay float64
  40026. var fund_pay_sumamt float64
  40027. for _, item := range orders {
  40028. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  40029. acct_pay = acct_pay + item.AcctPay
  40030. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  40031. }
  40032. //var medfee_sumamt_two float64
  40033. //var acct_pay_two float64
  40034. //var fund_pay_sumamt_two float64
  40035. //for _, item := range orders_two {
  40036. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  40037. // acct_pay_two = acct_pay_two + item.AcctPay
  40038. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  40039. //}
  40040. //var user_name string
  40041. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40042. //if role.ID == 0 {
  40043. // user_name = "xxx"
  40044. //} else {
  40045. // user_name = role.UserName
  40046. //}
  40047. var res ResultSix
  40048. if config.IsOpen == 1 {
  40049. var bps []*models.BusinessParamsTwo
  40050. var bp models.BusinessParamsTwo
  40051. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  40052. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  40053. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  40054. bp.MedfeeSumamt = medfee_sumamt_str
  40055. bp.AcctPay = acct_pay_str
  40056. bp.FundPaySumamt = fund_pay_sumamt_str
  40057. bp.Insutype = ""
  40058. bp.StmtBegndate = start_time
  40059. bp.ClrType = clr_type
  40060. bp.SetlOptins = clr_org
  40061. bp.StmtEnddate = end_time
  40062. bps = append(bps, &bp)
  40063. data := make(map[string]interface{})
  40064. data["bps"] = bps
  40065. data["org_name"] = miConfig.OrgName
  40066. data["doctor"] = role.UserName
  40067. data["fixmedins_code"] = miConfig.Code
  40068. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40069. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40070. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40071. if miConfig.MdtrtareaAdmvs == "421300" {
  40072. client := &http.Client{}
  40073. bytesData, _ := json.Marshal(data)
  40074. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  40075. resp, _ := client.Do(req)
  40076. defer resp.Body.Close()
  40077. body, ioErr := ioutil.ReadAll(resp.Body)
  40078. if ioErr != nil {
  40079. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40081. return
  40082. }
  40083. var respJSON map[string]interface{}
  40084. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40085. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40087. return
  40088. }
  40089. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40090. userJSONBytes, _ := json.Marshal(respJSON)
  40091. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40092. utils.ErrorLog("解析失败:%v", err)
  40093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40094. return
  40095. }
  40096. }
  40097. if miConfig.MdtrtareaAdmvs == "420200" {
  40098. client := &http.Client{}
  40099. bytesData, _ := json.Marshal(data)
  40100. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3204a", bytes.NewReader(bytesData))
  40101. resp, _ := client.Do(req)
  40102. defer resp.Body.Close()
  40103. body, ioErr := ioutil.ReadAll(resp.Body)
  40104. if ioErr != nil {
  40105. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40107. return
  40108. }
  40109. var respJSON map[string]interface{}
  40110. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40111. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40113. return
  40114. }
  40115. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40116. userJSONBytes, _ := json.Marshal(respJSON)
  40117. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40118. utils.ErrorLog("解析失败:%v", err)
  40119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40120. return
  40121. }
  40122. }
  40123. if miConfig.MdtrtareaAdmvs == "421182" {
  40124. client := &http.Client{}
  40125. bytesData, _ := json.Marshal(data)
  40126. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  40127. resp, _ := client.Do(req)
  40128. defer resp.Body.Close()
  40129. body, ioErr := ioutil.ReadAll(resp.Body)
  40130. if ioErr != nil {
  40131. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40133. return
  40134. }
  40135. var respJSON map[string]interface{}
  40136. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40137. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40139. return
  40140. }
  40141. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40142. userJSONBytes, _ := json.Marshal(respJSON)
  40143. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40144. utils.ErrorLog("解析失败:%v", err)
  40145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40146. return
  40147. }
  40148. }
  40149. if miConfig.MdtrtareaAdmvs == "420902" {
  40150. client := &http.Client{}
  40151. bytesData, _ := json.Marshal(data)
  40152. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204a", bytes.NewReader(bytesData))
  40153. resp, _ := client.Do(req)
  40154. defer resp.Body.Close()
  40155. body, ioErr := ioutil.ReadAll(resp.Body)
  40156. if ioErr != nil {
  40157. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40159. return
  40160. }
  40161. var respJSON map[string]interface{}
  40162. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40163. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40165. return
  40166. }
  40167. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40168. userJSONBytes, _ := json.Marshal(respJSON)
  40169. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40170. utils.ErrorLog("解析失败:%v", err)
  40171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40172. return
  40173. }
  40174. }
  40175. if res.Infcode == 0 {
  40176. c.ServeSuccessJSON(map[string]interface{}{
  40177. "msg": "撤销成功",
  40178. })
  40179. } else {
  40180. c.ServeSuccessJSON(map[string]interface{}{
  40181. "failed_code": -10,
  40182. "msg": res.ErrMsg,
  40183. })
  40184. }
  40185. }
  40186. }
  40187. func (c *HisApiController) Post3204() {
  40188. admin_user_id, _ := c.GetInt64("admin_user_id")
  40189. id := c.GetString("id")
  40190. adminUser := c.GetAdminUserInfo()
  40191. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40192. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40193. //clr_org := miConfig.MdtrtareaAdmvs
  40194. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40195. var res ResultSix
  40196. if config.IsOpen == 1 {
  40197. data := make(map[string]interface{})
  40198. data["id"] = id
  40199. data["org_name"] = miConfig.OrgName
  40200. data["doctor"] = role.UserName
  40201. data["fixmedins_code"] = miConfig.Code
  40202. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40203. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40204. client := &http.Client{}
  40205. bytesData, _ := json.Marshal(data)
  40206. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3204", bytes.NewReader(bytesData))
  40207. resp, _ := client.Do(req)
  40208. defer resp.Body.Close()
  40209. body, ioErr := ioutil.ReadAll(resp.Body)
  40210. if ioErr != nil {
  40211. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40213. return
  40214. }
  40215. var respJSON map[string]interface{}
  40216. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40217. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40219. return
  40220. }
  40221. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40222. userJSONBytes, _ := json.Marshal(respJSON)
  40223. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40224. utils.ErrorLog("解析失败:%v", err)
  40225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40226. return
  40227. }
  40228. if res.Infcode == 0 {
  40229. c.ServeSuccessJSON(map[string]interface{}{
  40230. "msg": "发起成功",
  40231. })
  40232. } else {
  40233. c.ServeSuccessJSON(map[string]interface{}{
  40234. "failed_code": -10,
  40235. "msg": res.ErrMsg,
  40236. })
  40237. }
  40238. }
  40239. }
  40240. func (c *HisApiController) Post8404() {
  40241. admin_user_id, _ := c.GetInt64("admin_user_id")
  40242. month := c.GetString("month")
  40243. adminUser := c.GetAdminUserInfo()
  40244. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40245. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40246. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40247. var res ResultSix
  40248. if config.IsOpen == 1 {
  40249. data := make(map[string]interface{})
  40250. data["month"] = month
  40251. data["org_name"] = miConfig.OrgName
  40252. data["doctor"] = role.UserName
  40253. data["fixmedins_code"] = miConfig.Code
  40254. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40255. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40256. client := &http.Client{}
  40257. bytesData, _ := json.Marshal(data)
  40258. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/8404", bytes.NewReader(bytesData))
  40259. resp, _ := client.Do(req)
  40260. defer resp.Body.Close()
  40261. body, ioErr := ioutil.ReadAll(resp.Body)
  40262. if ioErr != nil {
  40263. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40265. return
  40266. }
  40267. var respJSON map[string]interface{}
  40268. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40269. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40271. return
  40272. }
  40273. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40274. userJSONBytes, _ := json.Marshal(respJSON)
  40275. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40276. utils.ErrorLog("解析失败:%v", err)
  40277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40278. return
  40279. }
  40280. if res.Infcode == 0 {
  40281. c.ServeSuccessJSON(map[string]interface{}{
  40282. "msg": "查询成功",
  40283. })
  40284. } else {
  40285. c.ServeSuccessJSON(map[string]interface{}{
  40286. "failed_code": -10,
  40287. "msg": res.ErrMsg,
  40288. })
  40289. }
  40290. }
  40291. }
  40292. func (c *HisApiController) Post3202b() {
  40293. start_time := c.GetString("start_time")
  40294. end_time := c.GetString("end_time")
  40295. //insutype := c.GetString("insutype")
  40296. clr_type := c.GetString("clr_type")
  40297. clr_org := c.GetString("clr_optins")
  40298. admin_user_id, _ := c.GetInt64("admin_user_id")
  40299. adminUser := c.GetAdminUserInfo()
  40300. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40301. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40302. if len(clr_org) == 0 {
  40303. clr_org = miConfig.MdtrtareaAdmvs
  40304. }
  40305. timeLayout := "2006-01-02"
  40306. loc, _ := time.LoadLocation("Local")
  40307. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  40308. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  40309. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40310. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  40311. //fixmedins_setl_cnt := int64(len(orders))
  40312. var medfee_sumamt float64
  40313. var acct_pay float64
  40314. var fund_pay_sumamt float64
  40315. for _, item := range orders {
  40316. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  40317. acct_pay = acct_pay + item.AcctPay
  40318. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  40319. }
  40320. //var medfee_sumamt_two float64
  40321. //var acct_pay_two float64
  40322. //var fund_pay_sumamt_two float64
  40323. //for _, item := range orders_two {
  40324. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  40325. // acct_pay_two = acct_pay_two + item.AcctPay
  40326. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  40327. //}
  40328. //var user_name string
  40329. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40330. //if role.ID == 0 {
  40331. // user_name = "xxx"
  40332. //} else {
  40333. // user_name = role.UserName
  40334. //}
  40335. var res ResultSix
  40336. if config.IsOpen == 1 {
  40337. var bps []*models.BusinessParamsTwo
  40338. var bp models.BusinessParamsTwo
  40339. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  40340. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  40341. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  40342. bp.MedfeeSumamt = medfee_sumamt_str
  40343. bp.AcctPay = acct_pay_str
  40344. bp.FundPaySumamt = fund_pay_sumamt_str
  40345. bp.Insutype = "390"
  40346. bp.StmtBegndate = start_time
  40347. bp.ClrType = clr_type
  40348. bp.SetlOptins = clr_org
  40349. bp.StmtEnddate = end_time
  40350. bps = append(bps, &bp)
  40351. data := make(map[string]interface{})
  40352. data["bps"] = bps
  40353. data["org_name"] = miConfig.OrgName
  40354. data["doctor"] = role.UserName
  40355. data["fixmedins_code"] = miConfig.Code
  40356. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40357. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40358. if miConfig.MdtrtareaAdmvs == "421300" {
  40359. client := &http.Client{}
  40360. bytesData, _ := json.Marshal(data)
  40361. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  40362. resp, _ := client.Do(req)
  40363. defer resp.Body.Close()
  40364. body, ioErr := ioutil.ReadAll(resp.Body)
  40365. if ioErr != nil {
  40366. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40368. return
  40369. }
  40370. var respJSON map[string]interface{}
  40371. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40372. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40374. return
  40375. }
  40376. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40377. userJSONBytes, _ := json.Marshal(respJSON)
  40378. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40379. utils.ErrorLog("解析失败:%v", err)
  40380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40381. return
  40382. }
  40383. }
  40384. if miConfig.MdtrtareaAdmvs == "420200" {
  40385. client := &http.Client{}
  40386. bytesData, _ := json.Marshal(data)
  40387. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  40388. resp, _ := client.Do(req)
  40389. defer resp.Body.Close()
  40390. body, ioErr := ioutil.ReadAll(resp.Body)
  40391. if ioErr != nil {
  40392. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40394. return
  40395. }
  40396. var respJSON map[string]interface{}
  40397. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40398. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40400. return
  40401. }
  40402. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40403. userJSONBytes, _ := json.Marshal(respJSON)
  40404. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40405. utils.ErrorLog("解析失败:%v", err)
  40406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40407. return
  40408. }
  40409. }
  40410. if miConfig.MdtrtareaAdmvs == "421182" {
  40411. client := &http.Client{}
  40412. bytesData, _ := json.Marshal(data)
  40413. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  40414. resp, _ := client.Do(req)
  40415. defer resp.Body.Close()
  40416. body, ioErr := ioutil.ReadAll(resp.Body)
  40417. if ioErr != nil {
  40418. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40420. return
  40421. }
  40422. var respJSON map[string]interface{}
  40423. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40424. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40426. return
  40427. }
  40428. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40429. userJSONBytes, _ := json.Marshal(respJSON)
  40430. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40431. utils.ErrorLog("解析失败:%v", err)
  40432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40433. return
  40434. }
  40435. }
  40436. if res.Infcode == 0 {
  40437. c.ServeSuccessJSON(map[string]interface{}{
  40438. "msg": "发起成功",
  40439. })
  40440. } else {
  40441. c.ServeSuccessJSON(map[string]interface{}{
  40442. "failed_code": -10,
  40443. "msg": res.ErrMsg,
  40444. })
  40445. }
  40446. }
  40447. }
  40448. func (c *HisApiController) Post1608() {
  40449. start_time := c.GetString("start_time")
  40450. end_time := c.GetString("end_time")
  40451. admin_user_id, _ := c.GetInt64("admin_user_id")
  40452. adminUser := c.GetAdminUserInfo()
  40453. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40454. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40455. timeLayout := "2006-01-02"
  40456. loc, _ := time.LoadLocation("Local")
  40457. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  40458. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  40459. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  40460. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  40461. fixmedins_setl_cnt := int64(len(orders))
  40462. var medfee_sumamt float64
  40463. var func_smamt float64
  40464. for _, item := range orders {
  40465. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  40466. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  40467. }
  40468. times := strings.Split(start_time, "-")
  40469. time_tows := strings.Split(end_time, "-")
  40470. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40471. var res ResultSix
  40472. if config.IsOpen == 1 {
  40473. //var bps []*models.BusinessParamsTwo
  40474. //var bp models.BusinessParamsTwo
  40475. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  40476. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  40477. data := make(map[string]interface{})
  40478. data["org_name"] = miConfig.OrgName
  40479. data["doctor"] = role.UserName
  40480. data["func_smamt"] = func_smamt_str
  40481. data["fixmedins_code"] = miConfig.Code
  40482. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40483. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40484. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  40485. data["medfee_sumamt"] = medfee_sumamt_str
  40486. data["start_time"] = times[0] + times[1] + times[2]
  40487. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  40488. if miConfig.MdtrtareaAdmvs == "421300" {
  40489. client := &http.Client{}
  40490. bytesData, _ := json.Marshal(data)
  40491. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  40492. resp, _ := client.Do(req)
  40493. defer resp.Body.Close()
  40494. body, ioErr := ioutil.ReadAll(resp.Body)
  40495. if ioErr != nil {
  40496. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40498. return
  40499. }
  40500. var respJSON map[string]interface{}
  40501. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40502. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40504. return
  40505. }
  40506. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40507. userJSONBytes, _ := json.Marshal(respJSON)
  40508. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40509. utils.ErrorLog("解析失败:%v", err)
  40510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40511. return
  40512. }
  40513. }
  40514. if miConfig.MdtrtareaAdmvs == "420200" {
  40515. client := &http.Client{}
  40516. bytesData, _ := json.Marshal(data)
  40517. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  40518. resp, _ := client.Do(req)
  40519. defer resp.Body.Close()
  40520. body, ioErr := ioutil.ReadAll(resp.Body)
  40521. if ioErr != nil {
  40522. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40524. return
  40525. }
  40526. var respJSON map[string]interface{}
  40527. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40528. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40530. return
  40531. }
  40532. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40533. userJSONBytes, _ := json.Marshal(respJSON)
  40534. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40535. utils.ErrorLog("解析失败:%v", err)
  40536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40537. return
  40538. }
  40539. }
  40540. if miConfig.MdtrtareaAdmvs == "421182" {
  40541. client := &http.Client{}
  40542. bytesData, _ := json.Marshal(data)
  40543. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  40544. resp, _ := client.Do(req)
  40545. defer resp.Body.Close()
  40546. body, ioErr := ioutil.ReadAll(resp.Body)
  40547. if ioErr != nil {
  40548. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40550. return
  40551. }
  40552. var respJSON map[string]interface{}
  40553. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40554. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40556. return
  40557. }
  40558. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40559. userJSONBytes, _ := json.Marshal(respJSON)
  40560. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40561. utils.ErrorLog("解析失败:%v", err)
  40562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40563. return
  40564. }
  40565. }
  40566. if res.Infcode == 0 {
  40567. c.ServeSuccessJSON(map[string]interface{}{
  40568. "msg": "发起成功",
  40569. })
  40570. } else {
  40571. c.ServeSuccessJSON(map[string]interface{}{
  40572. "failed_code": -10,
  40573. "msg": res.ErrMsg,
  40574. })
  40575. }
  40576. }
  40577. }
  40578. // 5.11.1.1【5262】结算信息按时间段查询
  40579. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  40580. admin_user_id, _ := c.GetInt64("admin_user_id")
  40581. adminUser := c.GetAdminUserInfo()
  40582. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40583. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40584. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40585. var res Result5262
  40586. if config.IsOpen == 1 {
  40587. if miConfig.MdtrtareaAdmvs == "421300" {
  40588. data := make(map[string]interface{})
  40589. data["bps"] = bp
  40590. data["org_name"] = miConfig.OrgName
  40591. data["doctor"] = role.UserName
  40592. data["fixmedins_code"] = miConfig.Code
  40593. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40594. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40595. data["page"] = strconv.FormatInt(page, 10)
  40596. data["limit"] = strconv.FormatInt(limit, 10)
  40597. fmt.Println(data)
  40598. client := &http.Client{}
  40599. bytesData, _ := json.Marshal(data)
  40600. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  40601. resp, _ := client.Do(req)
  40602. defer resp.Body.Close()
  40603. body, ioErr := ioutil.ReadAll(resp.Body)
  40604. if ioErr != nil {
  40605. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40607. return
  40608. }
  40609. var respJSON map[string]interface{}
  40610. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40611. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40613. return
  40614. }
  40615. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40616. userJSONBytes, _ := json.Marshal(respJSON)
  40617. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40618. utils.ErrorLog("解析失败:%v", err)
  40619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40620. return
  40621. }
  40622. }
  40623. if miConfig.MdtrtareaAdmvs == "420200" {
  40624. data := make(map[string]interface{})
  40625. data["bps"] = bp
  40626. data["org_name"] = miConfig.OrgName
  40627. data["doctor"] = role.UserName
  40628. data["fixmedins_code"] = miConfig.Code
  40629. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40630. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40631. data["page"] = strconv.FormatInt(page, 10)
  40632. data["limit"] = strconv.FormatInt(limit, 10)
  40633. fmt.Println(data)
  40634. client := &http.Client{}
  40635. bytesData, _ := json.Marshal(data)
  40636. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  40637. resp, _ := client.Do(req)
  40638. defer resp.Body.Close()
  40639. body, ioErr := ioutil.ReadAll(resp.Body)
  40640. if ioErr != nil {
  40641. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40643. return
  40644. }
  40645. var respJSON map[string]interface{}
  40646. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40647. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40649. return
  40650. }
  40651. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40652. userJSONBytes, _ := json.Marshal(respJSON)
  40653. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40654. utils.ErrorLog("解析失败:%v", err)
  40655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40656. return
  40657. }
  40658. }
  40659. if miConfig.MdtrtareaAdmvs == "421182" {
  40660. data := make(map[string]interface{})
  40661. data["bps"] = bp
  40662. data["org_name"] = miConfig.OrgName
  40663. data["doctor"] = role.UserName
  40664. data["fixmedins_code"] = miConfig.Code
  40665. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40666. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40667. data["page"] = strconv.FormatInt(page, 10)
  40668. data["limit"] = strconv.FormatInt(limit, 10)
  40669. fmt.Println(data)
  40670. client := &http.Client{}
  40671. bytesData, _ := json.Marshal(data)
  40672. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  40673. resp, _ := client.Do(req)
  40674. defer resp.Body.Close()
  40675. body, ioErr := ioutil.ReadAll(resp.Body)
  40676. if ioErr != nil {
  40677. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40679. return
  40680. }
  40681. var respJSON map[string]interface{}
  40682. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40683. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40685. return
  40686. }
  40687. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40688. userJSONBytes, _ := json.Marshal(respJSON)
  40689. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40690. utils.ErrorLog("解析失败:%v", err)
  40691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40692. return
  40693. }
  40694. }
  40695. if miConfig.MdtrtareaAdmvs == "420902" {
  40696. data := make(map[string]interface{})
  40697. data["bps"] = bp
  40698. data["org_name"] = miConfig.OrgName
  40699. data["doctor"] = role.UserName
  40700. data["fixmedins_code"] = miConfig.Code
  40701. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40702. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40703. data["page"] = strconv.FormatInt(page, 10)
  40704. data["limit"] = strconv.FormatInt(limit, 10)
  40705. fmt.Println(data)
  40706. client := &http.Client{}
  40707. bytesData, _ := json.Marshal(data)
  40708. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  40709. resp, _ := client.Do(req)
  40710. defer resp.Body.Close()
  40711. body, ioErr := ioutil.ReadAll(resp.Body)
  40712. if ioErr != nil {
  40713. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40715. return
  40716. }
  40717. var respJSON map[string]interface{}
  40718. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40719. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40721. return
  40722. }
  40723. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40724. userJSONBytes, _ := json.Marshal(respJSON)
  40725. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40726. utils.ErrorLog("解析失败:%v", err)
  40727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40728. return
  40729. }
  40730. }
  40731. if res.Infcode == 0 {
  40732. c.ServeSuccessJSON(map[string]interface{}{
  40733. "order": res.Output.Result,
  40734. "total": res.Output.PageInfo.RecordCounts,
  40735. })
  40736. } else {
  40737. c.ServeSuccessJSON(map[string]interface{}{
  40738. "failed_code": -10,
  40739. "msg": res.ErrMsg,
  40740. })
  40741. }
  40742. }
  40743. }
  40744. // 5.11.1.2【5267】异地结算信息时间段查询
  40745. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  40746. admin_user_id, _ := c.GetInt64("admin_user_id")
  40747. adminUser := c.GetAdminUserInfo()
  40748. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  40749. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  40750. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  40751. var res Result5267
  40752. if config.IsOpen == 1 {
  40753. if miConfig.MdtrtareaAdmvs == "421300" {
  40754. data := make(map[string]interface{})
  40755. data["bps"] = bp
  40756. data["org_name"] = miConfig.OrgName
  40757. data["doctor"] = role.UserName
  40758. data["fixmedins_code"] = miConfig.Code
  40759. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40760. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40761. data["page"] = page
  40762. data["limit"] = limit
  40763. fmt.Println(data)
  40764. client := &http.Client{}
  40765. bytesData, _ := json.Marshal(data)
  40766. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  40767. resp, _ := client.Do(req)
  40768. defer resp.Body.Close()
  40769. body, ioErr := ioutil.ReadAll(resp.Body)
  40770. if ioErr != nil {
  40771. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40773. return
  40774. }
  40775. var respJSON map[string]interface{}
  40776. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40777. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40779. return
  40780. }
  40781. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40782. userJSONBytes, _ := json.Marshal(respJSON)
  40783. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40784. utils.ErrorLog("解析失败:%v", err)
  40785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40786. return
  40787. }
  40788. }
  40789. if miConfig.MdtrtareaAdmvs == "420200" {
  40790. data := make(map[string]interface{})
  40791. data["bps"] = bp
  40792. data["org_name"] = miConfig.OrgName
  40793. data["doctor"] = role.UserName
  40794. data["fixmedins_code"] = miConfig.Code
  40795. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40796. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40797. data["page"] = page
  40798. data["limit"] = limit
  40799. fmt.Println(data)
  40800. client := &http.Client{}
  40801. bytesData, _ := json.Marshal(data)
  40802. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  40803. resp, _ := client.Do(req)
  40804. defer resp.Body.Close()
  40805. body, ioErr := ioutil.ReadAll(resp.Body)
  40806. if ioErr != nil {
  40807. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40809. return
  40810. }
  40811. var respJSON map[string]interface{}
  40812. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40813. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40815. return
  40816. }
  40817. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40818. userJSONBytes, _ := json.Marshal(respJSON)
  40819. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40820. utils.ErrorLog("解析失败:%v", err)
  40821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40822. return
  40823. }
  40824. }
  40825. if miConfig.MdtrtareaAdmvs == "421182" {
  40826. data := make(map[string]interface{})
  40827. data["bps"] = bp
  40828. data["org_name"] = miConfig.OrgName
  40829. data["doctor"] = role.UserName
  40830. data["fixmedins_code"] = miConfig.Code
  40831. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  40832. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  40833. data["page"] = page
  40834. data["limit"] = limit
  40835. fmt.Println(data)
  40836. client := &http.Client{}
  40837. bytesData, _ := json.Marshal(data)
  40838. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  40839. resp, _ := client.Do(req)
  40840. defer resp.Body.Close()
  40841. body, ioErr := ioutil.ReadAll(resp.Body)
  40842. if ioErr != nil {
  40843. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40845. return
  40846. }
  40847. var respJSON map[string]interface{}
  40848. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40849. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40851. return
  40852. }
  40853. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  40854. userJSONBytes, _ := json.Marshal(respJSON)
  40855. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  40856. utils.ErrorLog("解析失败:%v", err)
  40857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40858. return
  40859. }
  40860. }
  40861. if res.Infcode == 0 {
  40862. c.ServeSuccessJSON(map[string]interface{}{
  40863. "order": res.Output.Result,
  40864. "total": res.Output.PageInfo.RecordCounts,
  40865. })
  40866. } else {
  40867. c.ServeSuccessJSON(map[string]interface{}{
  40868. "failed_code": -10,
  40869. "msg": res.ErrMsg,
  40870. })
  40871. }
  40872. }
  40873. }
  40874. func (c *HisApiController) Post3501() {
  40875. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  40876. data := make(map[string]interface{})
  40877. var struct3501s []models.Struct3501
  40878. var struct3501 models.Struct3501
  40879. struct3501.OrgName = miConfig.OrgName
  40880. struct3501.AccessKey = miConfig.AccessKey
  40881. struct3501.RequestUrl = miConfig.Url
  40882. struct3501.SecretKey = miConfig.SecretKey
  40883. struct3501.ManuDate = "2022-08-17"
  40884. struct3501.FixmedinsBchno = ""
  40885. struct3501.ManuLotnum = ""
  40886. struct3501.RxFlag = "0"
  40887. struct3501.ExpyEnd = "2022-08-17"
  40888. struct3501.Invdate = "2022-08-17"
  40889. struct3501.InvCnt = "20.25"
  40890. struct3501.Memo = ""
  40891. struct3501.MedListCodg = "XB01ABD056B002020200517"
  40892. struct3501.FixmedinsHilistId = miConfig.Code
  40893. struct3501.FixmedinsHilistName = miConfig.OrgName
  40894. struct3501s = append(struct3501s, struct3501)
  40895. data["struct_3501s"] = struct3501s
  40896. client := &http.Client{}
  40897. bytesData, _ := json.Marshal(data)
  40898. var req *http.Request
  40899. if miConfig.MdtrtareaAdmvs == "320830" {
  40900. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3501", bytes.NewReader(bytesData))
  40901. } else if miConfig.MdtrtareaAdmvs == "320921" {
  40902. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40903. } else {
  40904. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40905. }
  40906. resp, _ := client.Do(req)
  40907. defer resp.Body.Close()
  40908. body, ioErr := ioutil.ReadAll(resp.Body)
  40909. if ioErr != nil {
  40910. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40912. return
  40913. }
  40914. var respJSON map[string]interface{}
  40915. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40916. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40918. return
  40919. }
  40920. var res ResultSix
  40921. var resSix10265 ResultSix10265 //1101结果
  40922. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  40923. result, _ := json.Marshal(respJSON)
  40924. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  40925. utils.ErrorLog("解析失败:%v", err)
  40926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40927. return
  40928. }
  40929. res.InfRefmsgid = resSix10265.InfRefmsgid
  40930. res.Output = resSix10265.Output
  40931. res.ErrMsg = resSix10265.ErrMsg
  40932. res.Cainfo = resSix10265.Cainfo
  40933. res.WarnMsg = resSix10265.WarnMsg
  40934. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  40935. res.Infcode = infocode
  40936. if infocode == 0 {
  40937. c.ServeSuccessJSON(map[string]interface{}{
  40938. "msg": "上传成功",
  40939. })
  40940. return
  40941. } else {
  40942. c.ServeSuccessJSON(map[string]interface{}{
  40943. "failed_code": -10,
  40944. "msg": res.ErrMsg,
  40945. })
  40946. return
  40947. }
  40948. }
  40949. func (c *HisApiController) Post3502() {
  40950. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  40951. data := make(map[string]interface{})
  40952. var struct3502s []models.Struct3502
  40953. var struct3502 models.Struct3502
  40954. struct3502.OrgName = miConfig.OrgName
  40955. struct3502.AccessKey = miConfig.AccessKey
  40956. struct3502.RequestUrl = miConfig.Url
  40957. struct3502.SecretKey = miConfig.SecretKey
  40958. struct3502.ManuDate = "2022-08-15"
  40959. struct3502.FixmedinsBchno = ""
  40960. struct3502.ManuLotnum = ""
  40961. struct3502.RxFlag = "0"
  40962. struct3502.ExpyEnd = "2022-08-15"
  40963. struct3502.Invdate = "2022-08-15"
  40964. struct3502.InvCnt = "20.25"
  40965. struct3502.Memo = ""
  40966. struct3502.MedListCodg = "XB01ABD056B002020200517"
  40967. struct3502.FixmedinsHilistId = miConfig.Code
  40968. struct3502.FixmedinsHilistName = miConfig.OrgName
  40969. struct3502s = append(struct3502s, struct3502)
  40970. data["struct_3502s"] = struct3502s
  40971. client := &http.Client{}
  40972. bytesData, _ := json.Marshal(data)
  40973. var req *http.Request
  40974. if miConfig.MdtrtareaAdmvs == "320830" {
  40975. req, _ = http.NewRequest("POST", miConfig.AppSecret+"jsyb/3501", bytes.NewReader(bytesData))
  40976. } else if miConfig.MdtrtareaAdmvs == "320921" {
  40977. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40978. } else {
  40979. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  40980. }
  40981. resp, _ := client.Do(req)
  40982. defer resp.Body.Close()
  40983. body, ioErr := ioutil.ReadAll(resp.Body)
  40984. if ioErr != nil {
  40985. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  40986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40987. return
  40988. }
  40989. var respJSON map[string]interface{}
  40990. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  40991. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  40992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40993. return
  40994. }
  40995. var res ResultSix
  40996. var resSix10265 ResultSix10265 //1101结果
  40997. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  40998. result, _ := json.Marshal(respJSON)
  40999. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41000. utils.ErrorLog("解析失败:%v", err)
  41001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41002. return
  41003. }
  41004. res.InfRefmsgid = resSix10265.InfRefmsgid
  41005. res.Output = resSix10265.Output
  41006. res.ErrMsg = resSix10265.ErrMsg
  41007. res.Cainfo = resSix10265.Cainfo
  41008. res.WarnMsg = resSix10265.WarnMsg
  41009. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41010. res.Infcode = infocode
  41011. if infocode == 0 {
  41012. c.ServeSuccessJSON(map[string]interface{}{
  41013. "msg": "上传成功",
  41014. })
  41015. return
  41016. } else {
  41017. c.ServeSuccessJSON(map[string]interface{}{
  41018. "failed_code": -10,
  41019. "msg": res.ErrMsg,
  41020. })
  41021. return
  41022. }
  41023. }
  41024. func (c *HisApiController) Post3503() {
  41025. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41026. data := make(map[string]interface{})
  41027. var struct3501s []models.Struct3501
  41028. var struct3501 models.Struct3501
  41029. struct3501.OrgName = miConfig.OrgName
  41030. struct3501.AccessKey = miConfig.AccessKey
  41031. struct3501.RequestUrl = miConfig.Url
  41032. struct3501.SecretKey = miConfig.SecretKey
  41033. struct3501.ManuDate = "2022-08-15"
  41034. struct3501.FixmedinsBchno = ""
  41035. struct3501.ManuLotnum = ""
  41036. struct3501.RxFlag = "0"
  41037. struct3501.ExpyEnd = "2022-08-15"
  41038. struct3501.Invdate = "2022-08-15"
  41039. struct3501.InvCnt = "20.25"
  41040. struct3501.Memo = ""
  41041. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41042. struct3501.FixmedinsHilistId = miConfig.Code
  41043. struct3501.FixmedinsHilistName = miConfig.OrgName
  41044. struct3501s = append(struct3501s, struct3501)
  41045. data["struct_3501s"] = struct3501s
  41046. client := &http.Client{}
  41047. bytesData, _ := json.Marshal(data)
  41048. var req *http.Request
  41049. if miConfig.MdtrtareaAdmvs == "320921" {
  41050. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41051. } else {
  41052. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41053. }
  41054. resp, _ := client.Do(req)
  41055. defer resp.Body.Close()
  41056. body, ioErr := ioutil.ReadAll(resp.Body)
  41057. if ioErr != nil {
  41058. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41060. return
  41061. }
  41062. var respJSON map[string]interface{}
  41063. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41064. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41066. return
  41067. }
  41068. var res ResultSix
  41069. var resSix10265 ResultSix10265 //1101结果
  41070. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41071. result, _ := json.Marshal(respJSON)
  41072. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41073. utils.ErrorLog("解析失败:%v", err)
  41074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41075. return
  41076. }
  41077. res.InfRefmsgid = resSix10265.InfRefmsgid
  41078. res.Output = resSix10265.Output
  41079. res.ErrMsg = resSix10265.ErrMsg
  41080. res.Cainfo = resSix10265.Cainfo
  41081. res.WarnMsg = resSix10265.WarnMsg
  41082. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41083. res.Infcode = infocode
  41084. if infocode == 0 {
  41085. c.ServeSuccessJSON(map[string]interface{}{
  41086. "msg": "上传成功",
  41087. })
  41088. return
  41089. } else {
  41090. c.ServeSuccessJSON(map[string]interface{}{
  41091. "failed_code": -10,
  41092. "msg": res.ErrMsg,
  41093. })
  41094. return
  41095. }
  41096. }
  41097. func (c *HisApiController) Post3504() {
  41098. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41099. data := make(map[string]interface{})
  41100. var struct3501s []models.Struct3501
  41101. var struct3501 models.Struct3501
  41102. struct3501.OrgName = miConfig.OrgName
  41103. struct3501.AccessKey = miConfig.AccessKey
  41104. struct3501.RequestUrl = miConfig.Url
  41105. struct3501.SecretKey = miConfig.SecretKey
  41106. struct3501.ManuDate = "2022-08-15"
  41107. struct3501.FixmedinsBchno = ""
  41108. struct3501.ManuLotnum = ""
  41109. struct3501.RxFlag = "0"
  41110. struct3501.ExpyEnd = "2022-08-15"
  41111. struct3501.Invdate = "2022-08-15"
  41112. struct3501.InvCnt = "20.25"
  41113. struct3501.Memo = ""
  41114. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41115. struct3501.FixmedinsHilistId = miConfig.Code
  41116. struct3501.FixmedinsHilistName = miConfig.OrgName
  41117. struct3501s = append(struct3501s, struct3501)
  41118. data["struct_3501s"] = struct3501s
  41119. client := &http.Client{}
  41120. bytesData, _ := json.Marshal(data)
  41121. var req *http.Request
  41122. if miConfig.MdtrtareaAdmvs == "320921" {
  41123. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41124. } else {
  41125. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41126. }
  41127. resp, _ := client.Do(req)
  41128. defer resp.Body.Close()
  41129. body, ioErr := ioutil.ReadAll(resp.Body)
  41130. if ioErr != nil {
  41131. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41133. return
  41134. }
  41135. var respJSON map[string]interface{}
  41136. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41137. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41139. return
  41140. }
  41141. var res ResultSix
  41142. var resSix10265 ResultSix10265 //1101结果
  41143. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41144. result, _ := json.Marshal(respJSON)
  41145. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41146. utils.ErrorLog("解析失败:%v", err)
  41147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41148. return
  41149. }
  41150. res.InfRefmsgid = resSix10265.InfRefmsgid
  41151. res.Output = resSix10265.Output
  41152. res.ErrMsg = resSix10265.ErrMsg
  41153. res.Cainfo = resSix10265.Cainfo
  41154. res.WarnMsg = resSix10265.WarnMsg
  41155. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41156. res.Infcode = infocode
  41157. if infocode == 0 {
  41158. c.ServeSuccessJSON(map[string]interface{}{
  41159. "msg": "上传成功",
  41160. })
  41161. return
  41162. } else {
  41163. c.ServeSuccessJSON(map[string]interface{}{
  41164. "failed_code": -10,
  41165. "msg": res.ErrMsg,
  41166. })
  41167. return
  41168. }
  41169. }
  41170. func (c *HisApiController) Post3505() {
  41171. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41172. data := make(map[string]interface{})
  41173. var struct3501s []models.Struct3501
  41174. var struct3501 models.Struct3501
  41175. struct3501.OrgName = miConfig.OrgName
  41176. struct3501.AccessKey = miConfig.AccessKey
  41177. struct3501.RequestUrl = miConfig.Url
  41178. struct3501.SecretKey = miConfig.SecretKey
  41179. struct3501.ManuDate = "2022-08-15"
  41180. struct3501.FixmedinsBchno = ""
  41181. struct3501.ManuLotnum = ""
  41182. struct3501.RxFlag = "0"
  41183. struct3501.ExpyEnd = "2022-08-15"
  41184. struct3501.Invdate = "2022-08-15"
  41185. struct3501.InvCnt = "20.25"
  41186. struct3501.Memo = ""
  41187. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41188. struct3501.FixmedinsHilistId = miConfig.Code
  41189. struct3501.FixmedinsHilistName = miConfig.OrgName
  41190. struct3501s = append(struct3501s, struct3501)
  41191. data["struct_3501s"] = struct3501s
  41192. client := &http.Client{}
  41193. bytesData, _ := json.Marshal(data)
  41194. var req *http.Request
  41195. if miConfig.MdtrtareaAdmvs == "320921" {
  41196. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41197. } else {
  41198. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41199. }
  41200. resp, _ := client.Do(req)
  41201. defer resp.Body.Close()
  41202. body, ioErr := ioutil.ReadAll(resp.Body)
  41203. if ioErr != nil {
  41204. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41206. return
  41207. }
  41208. var respJSON map[string]interface{}
  41209. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41210. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41212. return
  41213. }
  41214. var res ResultSix
  41215. var resSix10265 ResultSix10265 //1101结果
  41216. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41217. result, _ := json.Marshal(respJSON)
  41218. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41219. utils.ErrorLog("解析失败:%v", err)
  41220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41221. return
  41222. }
  41223. res.InfRefmsgid = resSix10265.InfRefmsgid
  41224. res.Output = resSix10265.Output
  41225. res.ErrMsg = resSix10265.ErrMsg
  41226. res.Cainfo = resSix10265.Cainfo
  41227. res.WarnMsg = resSix10265.WarnMsg
  41228. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41229. res.Infcode = infocode
  41230. if infocode == 0 {
  41231. c.ServeSuccessJSON(map[string]interface{}{
  41232. "msg": "上传成功",
  41233. })
  41234. return
  41235. } else {
  41236. c.ServeSuccessJSON(map[string]interface{}{
  41237. "failed_code": -10,
  41238. "msg": res.ErrMsg,
  41239. })
  41240. return
  41241. }
  41242. }
  41243. func (c *HisApiController) Post3506() {
  41244. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41245. data := make(map[string]interface{})
  41246. var struct3501s []models.Struct3501
  41247. var struct3501 models.Struct3501
  41248. struct3501.OrgName = miConfig.OrgName
  41249. struct3501.AccessKey = miConfig.AccessKey
  41250. struct3501.RequestUrl = miConfig.Url
  41251. struct3501.SecretKey = miConfig.SecretKey
  41252. struct3501.ManuDate = "2022-08-15"
  41253. struct3501.FixmedinsBchno = ""
  41254. struct3501.ManuLotnum = ""
  41255. struct3501.RxFlag = "0"
  41256. struct3501.ExpyEnd = "2022-08-15"
  41257. struct3501.Invdate = "2022-08-15"
  41258. struct3501.InvCnt = "20.25"
  41259. struct3501.Memo = ""
  41260. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41261. struct3501.FixmedinsHilistId = miConfig.Code
  41262. struct3501.FixmedinsHilistName = miConfig.OrgName
  41263. struct3501s = append(struct3501s, struct3501)
  41264. data["struct_3501s"] = struct3501s
  41265. client := &http.Client{}
  41266. bytesData, _ := json.Marshal(data)
  41267. var req *http.Request
  41268. if miConfig.MdtrtareaAdmvs == "320921" {
  41269. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41270. } else {
  41271. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41272. }
  41273. resp, _ := client.Do(req)
  41274. defer resp.Body.Close()
  41275. body, ioErr := ioutil.ReadAll(resp.Body)
  41276. if ioErr != nil {
  41277. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41279. return
  41280. }
  41281. var respJSON map[string]interface{}
  41282. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41283. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41285. return
  41286. }
  41287. var res ResultSix
  41288. var resSix10265 ResultSix10265 //1101结果
  41289. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41290. result, _ := json.Marshal(respJSON)
  41291. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41292. utils.ErrorLog("解析失败:%v", err)
  41293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41294. return
  41295. }
  41296. res.InfRefmsgid = resSix10265.InfRefmsgid
  41297. res.Output = resSix10265.Output
  41298. res.ErrMsg = resSix10265.ErrMsg
  41299. res.Cainfo = resSix10265.Cainfo
  41300. res.WarnMsg = resSix10265.WarnMsg
  41301. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41302. res.Infcode = infocode
  41303. if infocode == 0 {
  41304. c.ServeSuccessJSON(map[string]interface{}{
  41305. "msg": "上传成功",
  41306. })
  41307. return
  41308. } else {
  41309. c.ServeSuccessJSON(map[string]interface{}{
  41310. "failed_code": -10,
  41311. "msg": res.ErrMsg,
  41312. })
  41313. return
  41314. }
  41315. }
  41316. func (c *HisApiController) Post3507() {
  41317. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  41318. data := make(map[string]interface{})
  41319. var struct3501s []models.Struct3501
  41320. var struct3501 models.Struct3501
  41321. struct3501.OrgName = miConfig.OrgName
  41322. struct3501.AccessKey = miConfig.AccessKey
  41323. struct3501.RequestUrl = miConfig.Url
  41324. struct3501.SecretKey = miConfig.SecretKey
  41325. struct3501.ManuDate = "2022-08-15"
  41326. struct3501.FixmedinsBchno = ""
  41327. struct3501.ManuLotnum = ""
  41328. struct3501.RxFlag = "0"
  41329. struct3501.ExpyEnd = "2022-08-15"
  41330. struct3501.Invdate = "2022-08-15"
  41331. struct3501.InvCnt = "20.25"
  41332. struct3501.Memo = ""
  41333. struct3501.MedListCodg = "XB01ABD056B002020200517"
  41334. //struct3501.FixmedinsHilistId = drug.BaseDrugLib.MedicalInsuranceNumber
  41335. //struct3501.FixmedinsHilistName =drug.BaseDrugLib.DrugName
  41336. struct3501s = append(struct3501s, struct3501)
  41337. data["struct_3501s"] = struct3501s
  41338. client := &http.Client{}
  41339. bytesData, _ := json.Marshal(data)
  41340. var req *http.Request
  41341. if miConfig.MdtrtareaAdmvs == "320921" {
  41342. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41343. } else {
  41344. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  41345. }
  41346. resp, _ := client.Do(req)
  41347. defer resp.Body.Close()
  41348. body, ioErr := ioutil.ReadAll(resp.Body)
  41349. if ioErr != nil {
  41350. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  41351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41352. return
  41353. }
  41354. var respJSON map[string]interface{}
  41355. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  41356. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  41357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41358. return
  41359. }
  41360. var res ResultSix
  41361. var resSix10265 ResultSix10265 //1101结果
  41362. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  41363. result, _ := json.Marshal(respJSON)
  41364. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  41365. utils.ErrorLog("解析失败:%v", err)
  41366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  41367. return
  41368. }
  41369. res.InfRefmsgid = resSix10265.InfRefmsgid
  41370. res.Output = resSix10265.Output
  41371. res.ErrMsg = resSix10265.ErrMsg
  41372. res.Cainfo = resSix10265.Cainfo
  41373. res.WarnMsg = resSix10265.WarnMsg
  41374. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  41375. res.Infcode = infocode
  41376. if infocode == 0 {
  41377. c.ServeSuccessJSON(map[string]interface{}{
  41378. "msg": "上传成功",
  41379. })
  41380. return
  41381. } else {
  41382. c.ServeSuccessJSON(map[string]interface{}{
  41383. "failed_code": -10,
  41384. "msg": res.ErrMsg,
  41385. })
  41386. return
  41387. }
  41388. }
  41389. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  41390. // WebSocket服务器地址
  41391. serverURL := "ws://127.0.0.1:8899"
  41392. // 解析WebSocket服务器地址
  41393. u, err := url.Parse(serverURL)
  41394. if err != nil {
  41395. }
  41396. // 建立WebSocket连接
  41397. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41398. if err != nil {
  41399. }
  41400. defer conn.Close()
  41401. input2 := make(map[string]interface{})
  41402. input := make(map[string]interface{})
  41403. inputData := make(map[string]interface{})
  41404. inputData["orgId"] = code
  41405. inputData["businessType"] = "01101"
  41406. inputData["operatorId"] = operator_id
  41407. inputData["operatorName"] = operator_name
  41408. inputData["officeId"] = "001"
  41409. inputData["officeName"] = "血透室"
  41410. inputData["deviceType"] = ""
  41411. input["data"] = inputData
  41412. input["orgId"] = code
  41413. input["transType"] = "ec.query"
  41414. //if md == ""
  41415. if md[:4] == "4403" {
  41416. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41417. } else if md[:4] == "4401" {
  41418. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41419. } else {
  41420. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41421. }
  41422. input2["indata"] = input
  41423. fmt.Println(input2)
  41424. bytesData, _ := json.Marshal(input2)
  41425. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41426. if err != nil {
  41427. fmt.Println(err)
  41428. }
  41429. // 接收消息
  41430. _, receivedMessage, err := conn.ReadMessage()
  41431. if err != nil {
  41432. fmt.Println(err)
  41433. }
  41434. return "", string(receivedMessage)
  41435. }
  41436. func GethnELeInfo(code string, operator_id string, operator_name string) (string, string) {
  41437. // WebSocket服务器地址
  41438. serverURL := "ws://127.0.0.1:8899"
  41439. // 解析WebSocket服务器地址
  41440. u, err := url.Parse(serverURL)
  41441. if err != nil {
  41442. }
  41443. // 建立WebSocket连接
  41444. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41445. if err != nil {
  41446. }
  41447. defer conn.Close()
  41448. input2 := make(map[string]interface{})
  41449. input := make(map[string]interface{})
  41450. inputData := make(map[string]interface{})
  41451. inputData["orgId"] = code
  41452. inputData["businessType"] = "01101"
  41453. inputData["operatorId"] = operator_id
  41454. inputData["operatorName"] = operator_name
  41455. inputData["officeId"] = "001"
  41456. inputData["officeName"] = "血透室"
  41457. inputData["deviceType"] = ""
  41458. input["data"] = inputData
  41459. input["orgId"] = code
  41460. input["transType"] = "ec.query"
  41461. //if md == ""
  41462. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  41463. input2["indata"] = input
  41464. fmt.Println(input2)
  41465. bytesData, _ := json.Marshal(input2)
  41466. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41467. if err != nil {
  41468. fmt.Println(err)
  41469. }
  41470. // 接收消息
  41471. _, receivedMessage, err := conn.ReadMessage()
  41472. if err != nil {
  41473. fmt.Println(err)
  41474. }
  41475. return "", string(receivedMessage)
  41476. }
  41477. func GethnELeInfotwo(code string, operator_id string, operator_name string) (string, string) {
  41478. // WebSocket服务器地址
  41479. serverURL := "ws://127.0.0.1:8899"
  41480. // 解析WebSocket服务器地址
  41481. u, err := url.Parse(serverURL)
  41482. if err != nil {
  41483. }
  41484. // 建立WebSocket连接
  41485. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41486. if err != nil {
  41487. }
  41488. defer conn.Close()
  41489. input2 := make(map[string]interface{})
  41490. input := make(map[string]interface{})
  41491. inputData := make(map[string]interface{})
  41492. inputData["orgId"] = code
  41493. inputData["businessType"] = "01301"
  41494. inputData["operatorId"] = operator_id
  41495. inputData["operatorName"] = operator_name
  41496. inputData["officeId"] = "001"
  41497. inputData["officeName"] = "血透室"
  41498. inputData["deviceType"] = ""
  41499. input["data"] = inputData
  41500. input["orgId"] = code
  41501. input["transType"] = "ec.query"
  41502. //if md == ""
  41503. input2["url"] = "https://dvs.hun.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"
  41504. input2["indata"] = input
  41505. fmt.Println(input2)
  41506. bytesData, _ := json.Marshal(input2)
  41507. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41508. if err != nil {
  41509. fmt.Println(err)
  41510. }
  41511. // 接收消息
  41512. _, receivedMessage, err := conn.ReadMessage()
  41513. if err != nil {
  41514. fmt.Println(err)
  41515. }
  41516. return "", string(receivedMessage)
  41517. }
  41518. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  41519. // WebSocket服务器地址
  41520. serverURL := "ws://127.0.0.1:8899"
  41521. // 解析WebSocket服务器地址
  41522. u, err := url.Parse(serverURL)
  41523. if err != nil {
  41524. }
  41525. // 建立WebSocket连接
  41526. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41527. if err != nil {
  41528. }
  41529. defer conn.Close()
  41530. input2 := make(map[string]interface{})
  41531. input := make(map[string]interface{})
  41532. inputData := make(map[string]interface{})
  41533. inputData["orgId"] = code
  41534. inputData["businessType"] = "01103"
  41535. inputData["operatorId"] = operator_id
  41536. inputData["operatorName"] = operator_name
  41537. inputData["officeId"] = "001"
  41538. inputData["officeName"] = "血透室"
  41539. inputData["deviceType"] = ""
  41540. input["data"] = inputData
  41541. input["orgId"] = code
  41542. input["transType"] = "ec.query"
  41543. //if md ==
  41544. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  41545. input2["indata"] = input
  41546. fmt.Println(input2)
  41547. bytesData, _ := json.Marshal(input2)
  41548. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41549. if err != nil {
  41550. fmt.Println(err)
  41551. }
  41552. // 接收消息
  41553. _, receivedMessage, err := conn.ReadMessage()
  41554. if err != nil {
  41555. fmt.Println(err)
  41556. }
  41557. return "", string(receivedMessage)
  41558. }
  41559. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  41560. // WebSocket服务器地址
  41561. serverURL := "ws://127.0.0.1:8899"
  41562. // 解析WebSocket服务器地址
  41563. u, err := url.Parse(serverURL)
  41564. if err != nil {
  41565. }
  41566. // 建立WebSocket连接
  41567. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41568. if err != nil {
  41569. }
  41570. defer conn.Close()
  41571. input2 := make(map[string]interface{})
  41572. input := make(map[string]interface{})
  41573. inputData := make(map[string]interface{})
  41574. inputData["orgId"] = code
  41575. inputData["businessType"] = "01101"
  41576. inputData["operatorId"] = operator_id
  41577. inputData["operatorName"] = operator_name
  41578. inputData["officeId"] = "001"
  41579. inputData["officeName"] = "血透室"
  41580. inputData["deviceType"] = ""
  41581. input["data"] = inputData
  41582. input["orgId"] = code
  41583. input["transType"] = "ec.query"
  41584. //if md == ""
  41585. if md[:4] == "4403" {
  41586. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41587. } else if md[:4] == "4401" {
  41588. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41589. } else {
  41590. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41591. }
  41592. input2["indata"] = input
  41593. fmt.Println(input2)
  41594. bytesData, _ := json.Marshal(input2)
  41595. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41596. if err != nil {
  41597. fmt.Println(err)
  41598. }
  41599. // 接收消息
  41600. _, receivedMessage, err := conn.ReadMessage()
  41601. if err != nil {
  41602. fmt.Println(err)
  41603. }
  41604. return "", string(receivedMessage)
  41605. }
  41606. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  41607. // WebSocket服务器地址
  41608. serverURL := "ws://127.0.0.1:8899"
  41609. // 解析WebSocket服务器地址
  41610. u, err := url.Parse(serverURL)
  41611. if err != nil {
  41612. }
  41613. // 建立WebSocket连接
  41614. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  41615. if err != nil {
  41616. }
  41617. defer conn.Close()
  41618. input2 := make(map[string]interface{})
  41619. input := make(map[string]interface{})
  41620. inputData := make(map[string]interface{})
  41621. inputData["orgId"] = code
  41622. inputData["businessType"] = "01301"
  41623. inputData["operatorId"] = operator_id
  41624. inputData["operatorName"] = operator_name
  41625. inputData["officeId"] = "001"
  41626. inputData["officeName"] = "血透室"
  41627. inputData["deviceType"] = ""
  41628. input["data"] = inputData
  41629. input["orgId"] = code
  41630. input["transType"] = "ec.query"
  41631. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  41632. input2["indata"] = input
  41633. bytesData, _ := json.Marshal(input2)
  41634. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  41635. if err != nil {
  41636. fmt.Println(err)
  41637. }
  41638. // 接收消息
  41639. _, receivedMessage, err := conn.ReadMessage()
  41640. if err != nil {
  41641. fmt.Println(err)
  41642. }
  41643. return "", string(receivedMessage)
  41644. }
  41645. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  41646. newArr = make([]string, 0)
  41647. for i := 0; i < len(arr); i++ {
  41648. repeat := false
  41649. for j := i + 1; j < len(arr); j++ {
  41650. if arr[i] == arr[j] {
  41651. repeat = true
  41652. break
  41653. }
  41654. }
  41655. if !repeat {
  41656. newArr = append(newArr, arr[i])
  41657. }
  41658. }
  41659. return
  41660. }
  41661. func getBirthdateAndAge(idNumber string) (string, int, error) {
  41662. if len(idNumber) != 18 {
  41663. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  41664. }
  41665. // 提取出生日期
  41666. year, err := strconv.Atoi(idNumber[6:10])
  41667. if err != nil {
  41668. return "", 0, err
  41669. }
  41670. month, err := strconv.Atoi(idNumber[10:12])
  41671. if err != nil {
  41672. return "", 0, err
  41673. }
  41674. day, err := strconv.Atoi(idNumber[12:14])
  41675. if err != nil {
  41676. return "", 0, err
  41677. }
  41678. // 格式化生日字符串
  41679. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  41680. birthdateFormatted := birthdate.Format("2006-01-02")
  41681. // 计算年龄
  41682. today := time.Now()
  41683. age := today.Year() - birthdate.Year()
  41684. if today.YearDay() < birthdate.YearDay() {
  41685. age--
  41686. }
  41687. return birthdateFormatted, age, nil
  41688. }
  41689. // 从身份证号码中提取出生年月日
  41690. func getBirthDateFromIDCard(idCard string) (string, error) {
  41691. // 身份证号码长度应为18位
  41692. if len(idCard) != 18 {
  41693. return "", fmt.Errorf("身份证号码长度应为18位")
  41694. }
  41695. // 提取出生日期部分 (YYYYMMDD)
  41696. birthDateStr := idCard[6:14]
  41697. // 解析出生日期
  41698. birthDate, err := time.Parse("20060102", birthDateStr)
  41699. if err != nil {
  41700. return "", fmt.Errorf("解析出生日期失败: %v", err)
  41701. }
  41702. // 格式化出生日期为 YYYY-MM-DD
  41703. formattedDate := birthDate.Format("2006-01-02")
  41704. return formattedDate, nil
  41705. }